From 4f85b47922a2e316ccd05be6be85842b2b5c03e3 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Wed, 30 Oct 2013 16:03:07 -0400 Subject: * lisp/emacs-lisp/autoload.el (autoload-generate-file-autoloads): `newline' does not respect `standard-output', so use `princ'. Otherwise you can get \n inserted in the wrong buffer, eg http://lists.gnu.org/archive/html/emacs-diffs/2013-10/msg00379.html --- lisp/emacs-lisp/autoload.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp/emacs-lisp/autoload.el') diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index e531bc0bdae..099f06d9135 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -553,7 +553,7 @@ Return non-nil if and only if FILE adds no autoloads to OUTFILE (princ `(push (purecopy ',(cons (intern package) version)) package--builtin-versions)) - (newline))))) + (princ "\n"))))) (goto-char (point-min)) (while (not (eobp)) -- cgit v1.2.1 From ca7dd4cd1761362289e877e8c20b412821f669c0 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Wed, 30 Oct 2013 16:27:35 -0400 Subject: * lisp/Makefile.in (autoloads): Do not use abs_lisp. This should stop recent weirdness, eg: http://lists.gnu.org/archive/html/emacs-diffs/2013-10/msg00381.html * lisp/emacs-lisp/autoload.el: Comment. --- lisp/emacs-lisp/autoload.el | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lisp/emacs-lisp/autoload.el') diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index 099f06d9135..f94f74a5652 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -528,6 +528,9 @@ Return non-nil if and only if FILE adds no autoloads to OUTFILE (if (stringp generated-autoload-load-name) generated-autoload-load-name (autoload-file-load-name absfile))) + ;; FIXME? Comparing file-names for equality with just equal + ;; is fragile, eg if one has an automounter prefix and one + ;; does not, but both refer to the same physical file. (when (and outfile (not (if (memq system-type '(ms-dos windows-nt)) -- cgit v1.2.1 From ba3189039adc8ec5eba5ed3e21d42019a4616b7c Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 1 Jan 2014 07:43:34 +0000 Subject: Update copyright year to 2014 by running admin/update-copyright. --- lisp/emacs-lisp/autoload.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp/emacs-lisp/autoload.el') diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index f94f74a5652..361e8fa7c68 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -1,6 +1,6 @@ ;; autoload.el --- maintain autoloads in loaddefs.el -*- lexical-binding: t -*- -;; Copyright (C) 1991-1997, 2001-2013 Free Software Foundation, Inc. +;; Copyright (C) 1991-1997, 2001-2014 Free Software Foundation, Inc. ;; Author: Roland McGrath ;; Keywords: maint -- cgit v1.2.1 From 0224bf74b28fea8cc64e80390b0210e3909dd81b Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Mon, 30 Jun 2014 14:26:34 -0400 Subject: Get rid of the AUTOGEN_VCS variable in lisp/Makefile * lisp/emacs-lisp/autoload.el (autoload-ensure-writable): New variable. (autoload-ensure-default-file): Maybe make existing output writable. * lisp/Makefile.in (AUTOGEN_VCS): Remove. (autoloads): Use autoload-ensure-writable rather than AUTOGEN_VCS. --- lisp/emacs-lisp/autoload.el | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'lisp/emacs-lisp/autoload.el') diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index 361e8fa7c68..38956df66de 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -351,9 +351,26 @@ not be relied upon." ";;; " basename " ends here\n"))) +(defvar autoload-ensure-writable nil + "Non-nil means `autoload-ensure-default-file' makes existing file writable.") +;; Just in case someone tries to get you to overwrite a file that you +;; don't want to. +;;;###autoload +(put 'autoload-ensure-writable 'risky-local-variable t) + (defun autoload-ensure-default-file (file) - "Make sure that the autoload file FILE exists and if not create it." - (unless (file-exists-p file) + "Make sure that the autoload file FILE exists, creating it if needed. +If the file already exists and `autoload-ensure-writable' is non-nil, +make it writable." + (if (file-exists-p file) + ;; Probably pointless, but replaces the old AUTOGEN_VCS in lisp/Makefile, + ;; which was designed to handle CVSREAD=1 and equivalent. + (and autoload-ensure-writable + (let ((modes (file-modes file))) + (if (zerop (logand modes #o0200)) + ;; Ignore any errors here, and let subsequent attempts + ;; to write the file raise any real error. + (ignore-errors (set-file-modes file (logior modes #o0200)))))) (write-region (autoload-rubric file) nil file)) file) -- cgit v1.2.1 From 6a278b64f7356613c4a7709ed699655fa7415260 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Tue, 4 Nov 2014 21:04:30 -0800 Subject: Merge from emacs-24; up to 117669 --- lisp/emacs-lisp/autoload.el | 42 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) (limited to 'lisp/emacs-lisp/autoload.el') diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index 38956df66de..c3aaa905afd 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -812,14 +812,40 @@ write its autoloads into the specified file instead." (setq files (delete file files))))) ;; Elements remaining in FILES have no existing autoload sections yet. (dolist (file files) - (cond - ((member (expand-file-name file) autoload-excludes) nil) - ;; Passing nil as second argument forces - ;; autoload-generate-file-autoloads to look for the right - ;; spot where to insert each autoloads section. - ((autoload-generate-file-autoloads file nil buffer-file-name) - (push file no-autoloads)))) - + (unless (member (expand-file-name file) autoload-excludes) + ;; Passing nil as second argument forces + ;; autoload-generate-file-autoloads to look for the right + ;; spot where to insert each autoloads section. + (let ((obuf + (autoload-generate-file-autoloads file nil buffer-file-name)) + ofile ofound oform opoint) + (when obuf + (push file no-autoloads) + ;; Did processing file update some other ofile? + (when (bufferp obuf) + (with-current-buffer obuf + (setq ofile (file-relative-name buffer-file-name))) + ;; Did we already scan ofile? + (and (member ofile done) + (not (member ofile no-autoloads)) + (save-excursion + (goto-char (point-min)) + (while + (and + (not ofound) + (search-forward + generate-autoload-section-header nil t)) + (setq opoint (point) + oform (autoload-read-section-header)) + (when (setq ofound + (string= ofile (nth 3 oform))) + (delete-region opoint (point)) + (autoload-insert-section-header + (current-buffer) + (nth 1 oform) + (nth 2 oform) + (nth 3 oform) + (nth 5 (file-attributes ofile)))))))))))) (when no-autoloads ;; Sort them for better readability. (setq no-autoloads (sort no-autoloads 'string<)) -- cgit v1.2.1 From ddce73d32fa3e62e022842e3bbdc0aa83bb358cc Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Tue, 4 Nov 2014 21:08:12 -0800 Subject: Revert previous accidental commit --- lisp/emacs-lisp/autoload.el | 42 ++++++++---------------------------------- 1 file changed, 8 insertions(+), 34 deletions(-) (limited to 'lisp/emacs-lisp/autoload.el') diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index c3aaa905afd..38956df66de 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -812,40 +812,14 @@ write its autoloads into the specified file instead." (setq files (delete file files))))) ;; Elements remaining in FILES have no existing autoload sections yet. (dolist (file files) - (unless (member (expand-file-name file) autoload-excludes) - ;; Passing nil as second argument forces - ;; autoload-generate-file-autoloads to look for the right - ;; spot where to insert each autoloads section. - (let ((obuf - (autoload-generate-file-autoloads file nil buffer-file-name)) - ofile ofound oform opoint) - (when obuf - (push file no-autoloads) - ;; Did processing file update some other ofile? - (when (bufferp obuf) - (with-current-buffer obuf - (setq ofile (file-relative-name buffer-file-name))) - ;; Did we already scan ofile? - (and (member ofile done) - (not (member ofile no-autoloads)) - (save-excursion - (goto-char (point-min)) - (while - (and - (not ofound) - (search-forward - generate-autoload-section-header nil t)) - (setq opoint (point) - oform (autoload-read-section-header)) - (when (setq ofound - (string= ofile (nth 3 oform))) - (delete-region opoint (point)) - (autoload-insert-section-header - (current-buffer) - (nth 1 oform) - (nth 2 oform) - (nth 3 oform) - (nth 5 (file-attributes ofile)))))))))))) + (cond + ((member (expand-file-name file) autoload-excludes) nil) + ;; Passing nil as second argument forces + ;; autoload-generate-file-autoloads to look for the right + ;; spot where to insert each autoloads section. + ((autoload-generate-file-autoloads file nil buffer-file-name) + (push file no-autoloads)))) + (when no-autoloads ;; Sort them for better readability. (setq no-autoloads (sort no-autoloads 'string<)) -- cgit v1.2.1 From f0e8c1eac226641ea8acab9e0f47ce3541803f0d Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 1 Dec 2014 09:45:15 -0500 Subject: New macro `define-inline'. * lisp/emacs-lisp/inline.el: New file. --- lisp/emacs-lisp/autoload.el | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'lisp/emacs-lisp/autoload.el') diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index 38956df66de..01f59704a39 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -120,7 +120,8 @@ expression, in which case we want to handle forms differently." ;; Look for an interactive spec. (interactive (pcase body ((or `((interactive . ,_) . ,_) - `(,_ (interactive . ,_) . ,_)) t)))) + `(,_ (interactive . ,_) . ,_)) + t)))) ;; Add the usage form at the end where describe-function-1 ;; can recover it. (when (listp args) (setq doc (help-add-fundoc-usage doc args))) @@ -140,11 +141,9 @@ expression, in which case we want to handle forms differently." ;; For complex cases, try again on the macro-expansion. ((and (memq car '(easy-mmode-define-global-mode define-global-minor-mode define-globalized-minor-mode defun defmacro - ;; FIXME: we'd want `defmacro*' here as well, so as - ;; to handle its `declare', but when autoload is run - ;; CL is not loaded so macroexpand doesn't know how - ;; to expand it! - easy-mmode-define-minor-mode define-minor-mode)) + easy-mmode-define-minor-mode define-minor-mode + define-inline cl-defun cl-defmacro)) + (macrop car) (setq expand (let ((load-file-name file)) (macroexpand form))) (memq (car expand) '(progn prog1 defalias))) (make-autoload expand file 'expansion)) ;Recurse on the expansion. -- cgit v1.2.1 From 7e09ef09a479731d01b1ca46e94ddadd73ac98e3 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 1 Jan 2015 14:26:41 -0800 Subject: Update copyright year to 2015 Run admin/update-copyright. --- lisp/emacs-lisp/autoload.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp/emacs-lisp/autoload.el') diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index 01f59704a39..e9d13b86c29 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -1,6 +1,6 @@ ;; autoload.el --- maintain autoloads in loaddefs.el -*- lexical-binding: t -*- -;; Copyright (C) 1991-1997, 2001-2014 Free Software Foundation, Inc. +;; Copyright (C) 1991-1997, 2001-2015 Free Software Foundation, Inc. ;; Author: Roland McGrath ;; Keywords: maint -- cgit v1.2.1 From cd2d58c1c81d608d6e1aefe1eb8a3d1f1cd60540 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 3 Jan 2015 18:28:35 -0800 Subject: Less 'make' chatter in batch mode * admin/unidata/unidata-gen.el (unidata-gen-files): * lisp/emacs-lisp/autoload.el (autoload-generate-file-autoloads): * lisp/emacs-lisp/bytecomp.el (byte-compile-file): * lisp/files.el (save-buffer, basic-save-buffer): * lisp/international/quail.el (quail-update-leim-list-file): Don't output messages like "Generating ..." in batch mode. --- lisp/emacs-lisp/autoload.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lisp/emacs-lisp/autoload.el') diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index e9d13b86c29..073d923a178 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -539,7 +539,7 @@ Return non-nil if and only if FILE adds no autoloads to OUTFILE (autoload-find-file file)) ;; Obey the no-update-autoloads file local variable. (unless no-update-autoloads - (message "Generating autoloads for %s..." file) + (or noninteractive (message "Generating autoloads for %s..." file)) (setq load-name (if (stringp generated-autoload-load-name) generated-autoload-load-name @@ -623,7 +623,8 @@ Return non-nil if and only if FILE adds no autoloads to OUTFILE (nth 5 (file-attributes relfile)))) (insert ";;; Generated autoloads from " relfile "\n"))) (insert generate-autoload-section-trailer)))) - (message "Generating autoloads for %s...done" file)) + (or noninteractive + (message "Generating autoloads for %s...done" file))) (or visited ;; We created this buffer, so we should kill it. (kill-buffer (current-buffer)))) -- cgit v1.2.1 From 3ba6b3a9c1e0565ee5f45f11a9c09702a24f8453 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sun, 12 Apr 2015 03:23:35 +0100 Subject: Speed up byte-compilation and autoload generation by avoiding mode-hooks This prevents emacs-lisp-mode-hook from being run everytime an autoload file is generated, which can account for a fraction of package installation time depending on the hooks the user has configured. * lisp/emacs-lisp/bytecomp.el (byte-compile-file): Use delay-mode-hooks. * lisp/emacs-lisp/autoload.el (autoload-find-file) (autoload-find-generated-file): Use delay-mode-hooks. --- lisp/emacs-lisp/autoload.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lisp/emacs-lisp/autoload.el') diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index 073d923a178..206d5bb4434 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -235,8 +235,9 @@ If a buffer is visiting the desired autoload file, return it." (enable-local-eval nil)) ;; We used to use `raw-text' to read this file, but this causes ;; problems when the file contains non-ASCII characters. - (find-file-noselect - (autoload-ensure-default-file (autoload-generated-file))))) + (let ((delay-mode-hooks t)) + (find-file-noselect + (autoload-ensure-default-file (autoload-generated-file)))))) (defun autoload-generated-file () (expand-file-name generated-autoload-file @@ -400,7 +401,7 @@ which lists the file name and which functions are in it, etc." (erase-buffer) (setq buffer-undo-list t buffer-read-only nil) - (emacs-lisp-mode) + (delay-mode-hooks (emacs-lisp-mode)) (setq default-directory (file-name-directory file)) (insert-file-contents file nil) (let ((enable-local-variables :safe) -- cgit v1.2.1 From 00ec2dd7af3d472fcd5098c74f2e6b8f759e007d Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 20 May 2015 08:23:09 -0700 Subject: Don't require help-fns when not needed * lisp/emacs-lisp/autoload.el, lisp/emacs-lisp/advice.el: * lisp/emacs-lisp/elint.el: Don't require help-fns at the top level. * lisp/emacs-lisp/advice.el (ad-arglist): * lisp/emacs-lisp/cl-macs.el (cl--transform-lambda): Don't require help-fns. (Bug#17001) --- lisp/emacs-lisp/autoload.el | 1 - 1 file changed, 1 deletion(-) (limited to 'lisp/emacs-lisp/autoload.el') diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index 206d5bb4434..a6fefebf3f5 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -32,7 +32,6 @@ (require 'lisp-mode) ;for `doc-string-elt' properties. (require 'lisp-mnt) -(require 'help-fns) ;for help-add-fundoc-usage. (eval-when-compile (require 'cl-lib)) (defvar generated-autoload-file nil -- cgit v1.2.1 From 5200c2baefbc855d36c07e2d6a9c1adeb693a542 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Tue, 30 Jun 2015 14:59:04 -0400 Subject: Improve reproducibility of generated loaddefs file. * lisp/emacs-lisp/autoload.el (autoload-generate-file-autoloads): Make the return value the modtime of the input file (if no autoloads). (update-directory-autoloads): In the "no autoloads" section, use "most recent modtime" rather than "current time". ; http://lists.gnu.org/archive/html/emacs-devel/2015-06/msg00688.html --- lisp/emacs-lisp/autoload.el | 281 +++++++++++++++++++++++--------------------- 1 file changed, 144 insertions(+), 137 deletions(-) (limited to 'lisp/emacs-lisp/autoload.el') diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index a6fefebf3f5..9d1abdddb2b 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -522,116 +522,119 @@ If OUTFILE is non-nil and FILE specifies a `generated-autoload-file' different from OUTFILE, then OUTBUF is ignored. Return non-nil if and only if FILE adds no autoloads to OUTFILE -\(or OUTBUF if OUTFILE is nil)." - (catch 'done - (let (load-name - (print-length nil) - (print-level nil) - (print-readably t) ; This does something in Lucid Emacs. - (float-output-format nil) - (visited (get-file-buffer file)) - (otherbuf nil) - (absfile (expand-file-name file)) - ;; nil until we found a cookie. - output-start) - (with-current-buffer (or visited - ;; It is faster to avoid visiting the file. - (autoload-find-file file)) - ;; Obey the no-update-autoloads file local variable. - (unless no-update-autoloads - (or noninteractive (message "Generating autoloads for %s..." file)) - (setq load-name - (if (stringp generated-autoload-load-name) - generated-autoload-load-name - (autoload-file-load-name absfile))) - ;; FIXME? Comparing file-names for equality with just equal - ;; is fragile, eg if one has an automounter prefix and one - ;; does not, but both refer to the same physical file. - (when (and outfile - (not - (if (memq system-type '(ms-dos windows-nt)) - (equal (downcase outfile) - (downcase (autoload-generated-file))) - (equal outfile (autoload-generated-file))))) - (setq otherbuf t)) - (save-excursion - (save-restriction - (widen) - (when autoload-builtin-package-versions - (let ((version (lm-header "version")) - package) - (and version - (setq version (ignore-errors (version-to-list version))) - (setq package (or (lm-header "package") - (file-name-sans-extension - (file-name-nondirectory file)))) - (setq output-start (autoload--setup-output - otherbuf outbuf absfile load-name)) - (let ((standard-output (marker-buffer output-start)) - (print-quoted t)) - (princ `(push (purecopy - ',(cons (intern package) version)) - package--builtin-versions)) - (princ "\n"))))) - - (goto-char (point-min)) - (while (not (eobp)) - (skip-chars-forward " \t\n\f") - (cond - ((looking-at (regexp-quote generate-autoload-cookie)) - ;; If not done yet, figure out where to insert this text. - (unless output-start - (setq output-start (autoload--setup-output - otherbuf outbuf absfile load-name))) - (autoload--print-cookie-text output-start load-name file)) - ((looking-at ";") - ;; Don't read the comment. - (forward-line 1)) - (t - (forward-sexp 1) - (forward-line 1)))))) - - (when output-start - (let ((secondary-autoloads-file-buf - (if otherbuf (current-buffer)))) - (with-current-buffer (marker-buffer output-start) - (save-excursion - ;; Insert the section-header line which lists the file name - ;; and which functions are in it, etc. - (goto-char output-start) - (let ((relfile (file-relative-name absfile))) - (autoload-insert-section-header - (marker-buffer output-start) - () load-name relfile - (if secondary-autoloads-file-buf - ;; MD5 checksums are much better because they do not - ;; change unless the file changes (so they'll be - ;; equal on two different systems and will change - ;; less often than time-stamps, thus leading to fewer - ;; unneeded changes causing spurious conflicts), but - ;; using time-stamps is a very useful optimization, - ;; so we use time-stamps for the main autoloads file - ;; (loaddefs.el) where we have special ways to - ;; circumvent the "random change problem", and MD5 - ;; checksum in secondary autoload files where we do - ;; not need the time-stamp optimization because it is - ;; already provided by the primary autoloads file. - (md5 secondary-autoloads-file-buf - ;; We'd really want to just use - ;; `emacs-internal' instead. - nil nil 'emacs-mule-unix) - (nth 5 (file-attributes relfile)))) - (insert ";;; Generated autoloads from " relfile "\n"))) - (insert generate-autoload-section-trailer)))) - (or noninteractive - (message "Generating autoloads for %s...done" file))) - (or visited - ;; We created this buffer, so we should kill it. - (kill-buffer (current-buffer)))) - (or (not output-start) - ;; If the entries were added to some other buffer, then the file - ;; doesn't add entries to OUTFILE. - otherbuf)))) +\(or OUTBUF if OUTFILE is nil). The actual return value is +FILE's modification time." + (let (load-name + (print-length nil) + (print-level nil) + (print-readably t) ; This does something in Lucid Emacs. + (float-output-format nil) + (visited (get-file-buffer file)) + (otherbuf nil) + (absfile (expand-file-name file)) + ;; nil until we found a cookie. + output-start) + (when + (catch 'done + (with-current-buffer (or visited + ;; It is faster to avoid visiting the file. + (autoload-find-file file)) + ;; Obey the no-update-autoloads file local variable. + (unless no-update-autoloads + (or noninteractive (message "Generating autoloads for %s..." file)) + (setq load-name + (if (stringp generated-autoload-load-name) + generated-autoload-load-name + (autoload-file-load-name absfile))) + ;; FIXME? Comparing file-names for equality with just equal + ;; is fragile, eg if one has an automounter prefix and one + ;; does not, but both refer to the same physical file. + (when (and outfile + (not + (if (memq system-type '(ms-dos windows-nt)) + (equal (downcase outfile) + (downcase (autoload-generated-file))) + (equal outfile (autoload-generated-file))))) + (setq otherbuf t)) + (save-excursion + (save-restriction + (widen) + (when autoload-builtin-package-versions + (let ((version (lm-header "version")) + package) + (and version + (setq version (ignore-errors (version-to-list version))) + (setq package (or (lm-header "package") + (file-name-sans-extension + (file-name-nondirectory file)))) + (setq output-start (autoload--setup-output + otherbuf outbuf absfile load-name)) + (let ((standard-output (marker-buffer output-start)) + (print-quoted t)) + (princ `(push (purecopy + ',(cons (intern package) version)) + package--builtin-versions)) + (princ "\n"))))) + + (goto-char (point-min)) + (while (not (eobp)) + (skip-chars-forward " \t\n\f") + (cond + ((looking-at (regexp-quote generate-autoload-cookie)) + ;; If not done yet, figure out where to insert this text. + (unless output-start + (setq output-start (autoload--setup-output + otherbuf outbuf absfile load-name))) + (autoload--print-cookie-text output-start load-name file)) + ((looking-at ";") + ;; Don't read the comment. + (forward-line 1)) + (t + (forward-sexp 1) + (forward-line 1)))))) + + (when output-start + (let ((secondary-autoloads-file-buf + (if otherbuf (current-buffer)))) + (with-current-buffer (marker-buffer output-start) + (save-excursion + ;; Insert the section-header line which lists the file name + ;; and which functions are in it, etc. + (goto-char output-start) + (let ((relfile (file-relative-name absfile))) + (autoload-insert-section-header + (marker-buffer output-start) + () load-name relfile + (if secondary-autoloads-file-buf + ;; MD5 checksums are much better because they do not + ;; change unless the file changes (so they'll be + ;; equal on two different systems and will change + ;; less often than time-stamps, thus leading to fewer + ;; unneeded changes causing spurious conflicts), but + ;; using time-stamps is a very useful optimization, + ;; so we use time-stamps for the main autoloads file + ;; (loaddefs.el) where we have special ways to + ;; circumvent the "random change problem", and MD5 + ;; checksum in secondary autoload files where we do + ;; not need the time-stamp optimization because it is + ;; already provided by the primary autoloads file. + (md5 secondary-autoloads-file-buf + ;; We'd really want to just use + ;; `emacs-internal' instead. + nil nil 'emacs-mule-unix) + (nth 5 (file-attributes relfile)))) + (insert ";;; Generated autoloads from " relfile "\n"))) + (insert generate-autoload-section-trailer)))) + (or noninteractive + (message "Generating autoloads for %s...done" file))) + (or visited + ;; We created this buffer, so we should kill it. + (kill-buffer (current-buffer)))) + (or (not output-start) + ;; If the entries were added to some other buffer, then the file + ;; doesn't add entries to OUTFILE. + otherbuf)) + (nth 5 (file-attributes absfile))))) (defun autoload-save-buffers () (while autoload-modified-buffers @@ -757,7 +760,7 @@ write its autoloads into the specified file instead." t files-re)) dirs))) (done ()) - (this-time (current-time)) + (last-time) ;; Files with no autoload cookies or whose autoloads go to other ;; files because of file-local autoload-generated-file settings. (no-autoloads nil) @@ -782,14 +785,14 @@ write its autoloads into the specified file instead." ;; There shouldn't be more than one such entry. ;; Remove the obsolete section. (autoload-remove-section (match-beginning 0)) - (let ((last-time (nth 4 form))) - (dolist (file file) - (let ((file-time (nth 5 (file-attributes file)))) - (when (and file-time - (not (time-less-p last-time file-time))) - ;; file unchanged - (push file no-autoloads) - (setq files (delete file files))))))) + (setq last-time (nth 4 form)) + (dolist (file file) + (let ((file-time (nth 5 (file-attributes file)))) + (when (and file-time + (not (time-less-p last-time file-time))) + ;; file unchanged + (push file no-autoloads) + (setq files (delete file files)))))) ((not (stringp file))) ((or (not (file-exists-p file)) ;; Remove duplicates as well, just in case. @@ -811,24 +814,28 @@ write its autoloads into the specified file instead." (push file done) (setq files (delete file files))))) ;; Elements remaining in FILES have no existing autoload sections yet. - (dolist (file files) - (cond - ((member (expand-file-name file) autoload-excludes) nil) - ;; Passing nil as second argument forces - ;; autoload-generate-file-autoloads to look for the right - ;; spot where to insert each autoloads section. - ((autoload-generate-file-autoloads file nil buffer-file-name) - (push file no-autoloads)))) - - (when no-autoloads - ;; Sort them for better readability. - (setq no-autoloads (sort no-autoloads 'string<)) - ;; Add the `no-autoloads' section. - (goto-char (point-max)) - (search-backward "\f" nil t) - (autoload-insert-section-header - (current-buffer) nil nil no-autoloads this-time) - (insert generate-autoload-section-trailer)) + (let ((no-autoloads-time (or last-time '(0 0 0 0))) file-time) + (dolist (file files) + (cond + ((member (expand-file-name file) autoload-excludes) nil) + ;; Passing nil as second argument forces + ;; autoload-generate-file-autoloads to look for the right + ;; spot where to insert each autoloads section. + ((setq file-time + (autoload-generate-file-autoloads file nil buffer-file-name)) + (push file no-autoloads) + (if (time-less-p no-autoloads-time file-time) + (setq no-autoloads-time file-time))))) + + (when no-autoloads + ;; Sort them for better readability. + (setq no-autoloads (sort no-autoloads 'string<)) + ;; Add the `no-autoloads' section. + (goto-char (point-max)) + (search-backward "\f" nil t) + (autoload-insert-section-header + (current-buffer) nil nil no-autoloads no-autoloads-time) + (insert generate-autoload-section-trailer))) (let ((version-control 'never)) (save-buffer)) -- cgit v1.2.1 From fed091f7c2513631d8c0570f444be9486d7563d1 Mon Sep 17 00:00:00 2001 From: Stephen Leake Date: Wed, 22 Jul 2015 04:29:38 -0500 Subject: add file name to autoload error messages. * lisp/emacs-lisp/autoload.el (autoload-save-buffers): add condition-case to add file name to error message. --- lisp/emacs-lisp/autoload.el | 235 +++++++++++++++++++++++--------------------- 1 file changed, 124 insertions(+), 111 deletions(-) (limited to 'lisp/emacs-lisp/autoload.el') diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index 9d1abdddb2b..12d0a94127f 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -524,117 +524,130 @@ different from OUTFILE, then OUTBUF is ignored. Return non-nil if and only if FILE adds no autoloads to OUTFILE \(or OUTBUF if OUTFILE is nil). The actual return value is FILE's modification time." - (let (load-name - (print-length nil) - (print-level nil) - (print-readably t) ; This does something in Lucid Emacs. - (float-output-format nil) - (visited (get-file-buffer file)) - (otherbuf nil) - (absfile (expand-file-name file)) - ;; nil until we found a cookie. - output-start) - (when - (catch 'done - (with-current-buffer (or visited - ;; It is faster to avoid visiting the file. - (autoload-find-file file)) - ;; Obey the no-update-autoloads file local variable. - (unless no-update-autoloads - (or noninteractive (message "Generating autoloads for %s..." file)) - (setq load-name - (if (stringp generated-autoload-load-name) - generated-autoload-load-name - (autoload-file-load-name absfile))) - ;; FIXME? Comparing file-names for equality with just equal - ;; is fragile, eg if one has an automounter prefix and one - ;; does not, but both refer to the same physical file. - (when (and outfile - (not - (if (memq system-type '(ms-dos windows-nt)) - (equal (downcase outfile) - (downcase (autoload-generated-file))) - (equal outfile (autoload-generated-file))))) - (setq otherbuf t)) - (save-excursion - (save-restriction - (widen) - (when autoload-builtin-package-versions - (let ((version (lm-header "version")) - package) - (and version - (setq version (ignore-errors (version-to-list version))) - (setq package (or (lm-header "package") - (file-name-sans-extension - (file-name-nondirectory file)))) - (setq output-start (autoload--setup-output - otherbuf outbuf absfile load-name)) - (let ((standard-output (marker-buffer output-start)) - (print-quoted t)) - (princ `(push (purecopy - ',(cons (intern package) version)) - package--builtin-versions)) - (princ "\n"))))) - - (goto-char (point-min)) - (while (not (eobp)) - (skip-chars-forward " \t\n\f") - (cond - ((looking-at (regexp-quote generate-autoload-cookie)) - ;; If not done yet, figure out where to insert this text. - (unless output-start - (setq output-start (autoload--setup-output - otherbuf outbuf absfile load-name))) - (autoload--print-cookie-text output-start load-name file)) - ((looking-at ";") - ;; Don't read the comment. - (forward-line 1)) - (t - (forward-sexp 1) - (forward-line 1)))))) - - (when output-start - (let ((secondary-autoloads-file-buf - (if otherbuf (current-buffer)))) - (with-current-buffer (marker-buffer output-start) - (save-excursion - ;; Insert the section-header line which lists the file name - ;; and which functions are in it, etc. - (goto-char output-start) - (let ((relfile (file-relative-name absfile))) - (autoload-insert-section-header - (marker-buffer output-start) - () load-name relfile - (if secondary-autoloads-file-buf - ;; MD5 checksums are much better because they do not - ;; change unless the file changes (so they'll be - ;; equal on two different systems and will change - ;; less often than time-stamps, thus leading to fewer - ;; unneeded changes causing spurious conflicts), but - ;; using time-stamps is a very useful optimization, - ;; so we use time-stamps for the main autoloads file - ;; (loaddefs.el) where we have special ways to - ;; circumvent the "random change problem", and MD5 - ;; checksum in secondary autoload files where we do - ;; not need the time-stamp optimization because it is - ;; already provided by the primary autoloads file. - (md5 secondary-autoloads-file-buf - ;; We'd really want to just use - ;; `emacs-internal' instead. - nil nil 'emacs-mule-unix) - (nth 5 (file-attributes relfile)))) - (insert ";;; Generated autoloads from " relfile "\n"))) - (insert generate-autoload-section-trailer)))) - (or noninteractive - (message "Generating autoloads for %s...done" file))) - (or visited - ;; We created this buffer, so we should kill it. - (kill-buffer (current-buffer)))) - (or (not output-start) - ;; If the entries were added to some other buffer, then the file - ;; doesn't add entries to OUTFILE. - otherbuf)) - (nth 5 (file-attributes absfile))))) + ;; Include the file name in any error messages + (condition-case err + (let (load-name + (print-length nil) + (print-level nil) + (print-readably t) ; This does something in Lucid Emacs. + (float-output-format nil) + (visited (get-file-buffer file)) + (otherbuf nil) + (absfile (expand-file-name file)) + ;; nil until we found a cookie. + output-start) + (when + (catch 'done + (with-current-buffer (or visited + ;; It is faster to avoid visiting the file. + (autoload-find-file file)) + ;; Obey the no-update-autoloads file local variable. + (unless no-update-autoloads + (or noninteractive (message "Generating autoloads for %s..." file)) + (setq load-name + (if (stringp generated-autoload-load-name) + generated-autoload-load-name + (autoload-file-load-name absfile))) + ;; FIXME? Comparing file-names for equality with just equal + ;; is fragile, eg if one has an automounter prefix and one + ;; does not, but both refer to the same physical file. + (when (and outfile + (not + (if (memq system-type '(ms-dos windows-nt)) + (equal (downcase outfile) + (downcase (autoload-generated-file))) + (equal outfile (autoload-generated-file))))) + (setq otherbuf t)) + (save-excursion + (save-restriction + (widen) + (when autoload-builtin-package-versions + (let ((version (lm-header "version")) + package) + (and version + (setq version (ignore-errors (version-to-list version))) + (setq package (or (lm-header "package") + (file-name-sans-extension + (file-name-nondirectory file)))) + (setq output-start (autoload--setup-output + otherbuf outbuf absfile load-name)) + (let ((standard-output (marker-buffer output-start)) + (print-quoted t)) + (princ `(push (purecopy + ',(cons (intern package) version)) + package--builtin-versions)) + (princ "\n"))))) + + (goto-char (point-min)) + (while (not (eobp)) + (skip-chars-forward " \t\n\f") + (cond + ((looking-at (regexp-quote generate-autoload-cookie)) + ;; If not done yet, figure out where to insert this text. + (unless output-start + (setq output-start (autoload--setup-output + otherbuf outbuf absfile load-name))) + (autoload--print-cookie-text output-start load-name file)) + ((looking-at ";") + ;; Don't read the comment. + (forward-line 1)) + (t + (forward-sexp 1) + (forward-line 1)))))) + + (when output-start + (let ((secondary-autoloads-file-buf + (if otherbuf (current-buffer)))) + (with-current-buffer (marker-buffer output-start) + (save-excursion + ;; Insert the section-header line which lists the file name + ;; and which functions are in it, etc. + (goto-char output-start) + (let ((relfile (file-relative-name absfile))) + (autoload-insert-section-header + (marker-buffer output-start) + () load-name relfile + (if secondary-autoloads-file-buf + ;; MD5 checksums are much better because they do not + ;; change unless the file changes (so they'll be + ;; equal on two different systems and will change + ;; less often than time-stamps, thus leading to fewer + ;; unneeded changes causing spurious conflicts), but + ;; using time-stamps is a very useful optimization, + ;; so we use time-stamps for the main autoloads file + ;; (loaddefs.el) where we have special ways to + ;; circumvent the "random change problem", and MD5 + ;; checksum in secondary autoload files where we do + ;; not need the time-stamp optimization because it is + ;; already provided by the primary autoloads file. + (md5 secondary-autoloads-file-buf + ;; We'd really want to just use + ;; `emacs-internal' instead. + nil nil 'emacs-mule-unix) + (nth 5 (file-attributes relfile)))) + (insert ";;; Generated autoloads from " relfile "\n"))) + (insert generate-autoload-section-trailer)))) + (or noninteractive + (message "Generating autoloads for %s...done" file))) + (or visited + ;; We created this buffer, so we should kill it. + (kill-buffer (current-buffer)))) + (or (not output-start) + ;; If the entries were added to some other buffer, then the file + ;; doesn't add entries to OUTFILE. + otherbuf)) + (nth 5 (file-attributes absfile)))) + (error + ;; Probably unbalanced parens in forward-sexp. In that case, the + ;; condition is scan-error, and the signal data includes point + ;; where the error was found; we'd like to convert that to + ;; line:col, but line-number-at-pos gets the wrong line in batch + ;; mode for some reason. + ;; + ;; At least this gets the file name in the error message; the + ;; developer can use goto-char to get to the error position. + (error "%s:0:0: error: %s: %s" file (car err) (cdr err))) + )) (defun autoload-save-buffers () (while autoload-modified-buffers -- cgit v1.2.1