From c23c965bb9d0a4bcc1b6158833ff99aa20fd53e9 Mon Sep 17 00:00:00 2001 From: Phillip Lord Date: Fri, 8 Apr 2016 16:22:44 +0100 Subject: Prevent bootstrap autoload backup files * lisp/emacs-lisp/autoload (autoload-find-generated-file): Suppress backups in newly created file. (autoload-ensure-default-file): Function split into two. (autoload-ensure-file-writeable): New function from split. (Bug#23203) --- lisp/emacs-lisp/autoload.el | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) (limited to 'lisp/emacs-lisp/autoload.el') diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index e688d6be725..592d69d2eb9 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -234,9 +234,22 @@ 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. - (let ((delay-mode-hooks t)) - (find-file-noselect - (autoload-ensure-default-file (autoload-generated-file)))))) + (let* ((delay-mode-hooks t) + (file (autoload-generated-file)) + (file-missing (not (file-exists-p file)))) + (when file-missing + (autoload-ensure-default-file file)) + (with-current-buffer + (find-file-noselect + (autoload-ensure-file-writeable + file)) + ;; block backups when the file has just been created, since + ;; the backups will just be the auto-generated headers. + ;; bug#23203 + (when file-missing + (setq buffer-backed-up t) + (save-buffer)) + (current-buffer))))) (defun autoload-generated-file () (expand-file-name generated-autoload-file @@ -357,21 +370,22 @@ not be relied upon." ;;;###autoload (put 'autoload-ensure-writable 'risky-local-variable t) +(defun autoload-ensure-file-writeable (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)))))) + file) + (defun autoload-ensure-default-file (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) + (write-region (autoload-rubric file) nil file)) (defun autoload-insert-section-header (outbuf autoloads load-name file time) "Insert the section-header line, -- cgit v1.2.1 From 50455754b558d1689bbbb596e05631f2789b1350 Mon Sep 17 00:00:00 2001 From: Phillip Lord Date: Tue, 12 Apr 2016 18:00:50 +0100 Subject: Revert "Prevent bootstrap autoload backup files" This reverts commit c23c965bb9d0a4bcc1b6158833ff99aa20fd53e9. --- lisp/emacs-lisp/autoload.el | 42 ++++++++++++++---------------------------- 1 file changed, 14 insertions(+), 28 deletions(-) (limited to 'lisp/emacs-lisp/autoload.el') diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index 592d69d2eb9..e688d6be725 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -234,22 +234,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. - (let* ((delay-mode-hooks t) - (file (autoload-generated-file)) - (file-missing (not (file-exists-p file)))) - (when file-missing - (autoload-ensure-default-file file)) - (with-current-buffer - (find-file-noselect - (autoload-ensure-file-writeable - file)) - ;; block backups when the file has just been created, since - ;; the backups will just be the auto-generated headers. - ;; bug#23203 - (when file-missing - (setq buffer-backed-up t) - (save-buffer)) - (current-buffer))))) + (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 @@ -370,22 +357,21 @@ not be relied upon." ;;;###autoload (put 'autoload-ensure-writable 'risky-local-variable t) -(defun autoload-ensure-file-writeable (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)))))) - file) - (defun autoload-ensure-default-file (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." - (write-region (autoload-rubric file) nil file)) + (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) (defun autoload-insert-section-header (outbuf autoloads load-name file time) "Insert the section-header line, -- cgit v1.2.1 From 16af826eac64c5a6e79724b79b04f5318afb273b Mon Sep 17 00:00:00 2001 From: Phillip Lord Date: Fri, 8 Apr 2016 16:22:44 +0100 Subject: Prevent bootstrap autoload backup files * lisp/emacs-lisp/autoload (autoload-find-generated-file): Suppress backups in newly created file. (autoload-ensure-default-file): Function split into two. (autoload-ensure-file-writeable): New function from split. (Bug#23203) --- lisp/emacs-lisp/autoload.el | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) (limited to 'lisp/emacs-lisp/autoload.el') diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index 1b06fb6a51d..14e584df672 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -251,9 +251,22 @@ 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. - (let ((delay-mode-hooks t)) - (find-file-noselect - (autoload-ensure-default-file (autoload-generated-file)))))) + (let* ((delay-mode-hooks t) + (file (autoload-generated-file)) + (file-missing (not (file-exists-p file)))) + (when file-missing + (autoload-ensure-default-file file)) + (with-current-buffer + (find-file-noselect + (autoload-ensure-file-writeable + file)) + ;; block backups when the file has just been created, since + ;; the backups will just be the auto-generated headers. + ;; bug#23203 + (when file-missing + (setq buffer-backed-up t) + (save-buffer)) + (current-buffer))))) (defun autoload-generated-file () (expand-file-name generated-autoload-file @@ -374,21 +387,22 @@ not be relied upon." ;;;###autoload (put 'autoload-ensure-writable 'risky-local-variable t) +(defun autoload-ensure-file-writeable (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)))))) + file) + (defun autoload-ensure-default-file (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) + (write-region (autoload-rubric file) nil file)) (defun autoload-insert-section-header (outbuf autoloads load-name file time) "Insert the section-header line, -- cgit v1.2.1 From 5d1e62e32989399fd2a073cc8efc07f869a1b438 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Sat, 23 Apr 2016 17:59:06 -0700 Subject: When autoload-timestamps is nil, use a dummy timestamp rather than "t". * lisp/emacs-lisp/autoload.el (autoload--non-timestamp): New constant. (autoload-generate-file-autoloads, autoload-find-destination) (update-directory-autoloads): Use autoload--non-timestamp. --- lisp/emacs-lisp/autoload.el | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'lisp/emacs-lisp/autoload.el') diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index 14e584df672..1ab3de5f2fd 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -87,6 +87,12 @@ that text will be copied verbatim to `generated-autoload-file'.") (defconst generate-autoload-section-continuation ";;;;;; " "String to add on each continuation of the section header form.") +;; In some ways it would be nicer to use a value that is recognisably +;; not a time-value, eg t, but that can cause issues if an older Emacs +;; that does not expect non-time-values loads the file. +(defconst autoload--non-timestamp '(0 0 0 0) + "Value to insert when `autoload-timestamps' is nil.") + (defvar autoload-timestamps nil ; experimental, see bug#22213 "Non-nil means insert a timestamp for each input file into the output. We use these in incremental updates of the output file to decide @@ -657,7 +663,7 @@ FILE's modification time." nil nil 'emacs-mule-unix) (if autoload-timestamps (nth 5 (file-attributes relfile)) - t))) + autoload--non-timestamp))) (insert ";;; Generated autoloads from " relfile "\n"))) (insert generate-autoload-section-trailer)))) (or noninteractive @@ -755,11 +761,6 @@ removes any prior now out-of-date autoload entries." (if (and (or (null existing-buffer) (not (buffer-modified-p existing-buffer))) (cond - ;; last-time is the time-stamp (specifying - ;; the last time we looked at the file) and - ;; the file hasn't been changed since. - ((listp last-time) - (not (time-less-p last-time file-time))) ;; FIXME? Arguably we should throw a ;; user error, or some kind of warning, ;; if we were called from update-file-autoloads, @@ -768,8 +769,15 @@ removes any prior now out-of-date autoload entries." ;; file modtime in such a case, ;; if there are multiple input files ;; contributing to the output. - ((and output-time (eq t last-time)) + ((and output-time + (member last-time + (list t autoload--non-timestamp))) (not (time-less-p output-time file-time))) + ;; last-time is the time-stamp (specifying + ;; the last time we looked at the file) and + ;; the file hasn't been changed since. + ((listp last-time) + (not (time-less-p last-time file-time))) ;; last-time is an MD5 checksum instead. ((stringp last-time) (equal last-time @@ -854,7 +862,7 @@ write its autoloads into the specified file instead." ;; Remove the obsolete section. (autoload-remove-section (match-beginning 0)) (setq last-time (nth 4 form)) - (if (equal t last-time) + (if (member last-time (list t autoload--non-timestamp)) (setq last-time output-time)) (dolist (file file) (let ((file-time (nth 5 (file-attributes file)))) @@ -872,7 +880,9 @@ write its autoloads into the specified file instead." ;; Remove the obsolete section. (autoload-remove-section (match-beginning 0))) ((not (time-less-p (let ((oldtime (nth 4 form))) - (if (equal t oldtime) + (if (member oldtime + (list + t autoload--non-timestamp)) output-time oldtime)) (nth 5 (file-attributes file)))) @@ -909,7 +919,7 @@ write its autoloads into the specified file instead." (autoload-insert-section-header (current-buffer) nil nil no-autoloads (if autoload-timestamps no-autoloads-time - t)) + autoload--non-timestamp)) (insert generate-autoload-section-trailer))) (let ((version-control 'never)) -- cgit v1.2.1 From 935715a5cd5f77bedb00fbc860375924846f9e3b Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Mon, 25 Apr 2016 17:28:00 -0400 Subject: * lisp/emacs-lisp/autoload.el (update-directory-autoloads): Future-proof against non-time-values. ; Do not merge to master. --- lisp/emacs-lisp/autoload.el | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'lisp/emacs-lisp/autoload.el') diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index e688d6be725..eb6b746bd80 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -800,13 +800,14 @@ write its autoloads into the specified file instead." ;; Remove the obsolete section. (autoload-remove-section (match-beginning 0)) (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)))))) + (when (listp last-time) + (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. @@ -815,8 +816,9 @@ write its autoloads into the specified file instead." (member (expand-file-name file) autoload-excludes)) ;; Remove the obsolete section. (autoload-remove-section (match-beginning 0))) - ((not (time-less-p (nth 4 form) - (nth 5 (file-attributes file)))) + ((and (listp (nth 4 form)) + (not (time-less-p (nth 4 form) + (nth 5 (file-attributes file))))) ;; File hasn't changed. nil) (t -- cgit v1.2.1 From 743a32a153a8b77c379b33b204cf7ae30d9edd2b Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 1 May 2016 18:52:50 -0700 Subject: ; Spelling and quoting fixes --- 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 1ab3de5f2fd..aedee8c7636 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -87,7 +87,7 @@ that text will be copied verbatim to `generated-autoload-file'.") (defconst generate-autoload-section-continuation ";;;;;; " "String to add on each continuation of the section header form.") -;; In some ways it would be nicer to use a value that is recognisably +;; In some ways it would be nicer to use a value that is recognizably ;; not a time-value, eg t, but that can cause issues if an older Emacs ;; that does not expect non-time-values loads the file. (defconst autoload--non-timestamp '(0 0 0 0) -- cgit v1.2.1 From e971ce6de27f982720ef312637e1d40da80e8d1f Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Wed, 25 May 2016 22:58:18 -0400 Subject: Make autoloads populate a new definition-prefixes table * lisp/subr.el (definition-prefixes): New hash table. (register-definition-prefixes): New function. * lisp/emacs-lisp/autoload.el (autoload-compute-prefixes): New var. (autoload--split-prefixes-1, autoload--split-prefixes) (autoload--make-defs-autoload): New functions. (autoload-defs-autoload-max-size, autoload-popular-prefixes): New vars. (autoload-generate-file-autoloads): Obey autoload-compute-prefixes. (update-directory-autoloads): Don't touch loaddefs.el if the set of autoloads hasn't changed (i.e. if only the timestamp would change). * lisp/loadup.el: Purify definition-prefixes. * lisp/w32-fns.el: Keep name space clean. (w32-set-default-process-coding-system): Rename from set-default-process-coding-system. (w32-set-system-coding-system): Rename from set-w32-system-coding-system. --- lisp/emacs-lisp/autoload.el | 196 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 181 insertions(+), 15 deletions(-) (limited to 'lisp/emacs-lisp/autoload.el') diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index aedee8c7636..80f5c28f3ec 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -183,10 +183,12 @@ expression, in which case we want to handle forms differently." (args (pcase car ((or `defun `defmacro `defun* `defmacro* `cl-defun `cl-defmacro - `define-overloadable-function) (nth 2 form)) + `define-overloadable-function) + (nth 2 form)) (`define-skeleton '(&optional str arg)) ((or `define-generic-mode `define-derived-mode - `define-compilation-mode) nil) + `define-compilation-mode) + nil) (_ t))) (body (nthcdr (or (function-get car 'doc-string-elt) 3) form)) (doc (if (stringp (car body)) (pop body)))) @@ -202,7 +204,8 @@ expression, in which case we want to handle forms differently." define-global-minor-mode define-globalized-minor-mode easy-mmode-define-minor-mode - define-minor-mode)) t) + define-minor-mode)) + t) (eq (car-safe (car body)) 'interactive)) ,(if macrop ''macro nil)))) @@ -313,7 +316,7 @@ The variable `autoload-print-form-outbuf' specifies the buffer to put the output in." (cond ;; If the form is a sequence, recurse. - ((eq (car form) 'progn) (mapcar 'autoload-print-form (cdr form))) + ((eq (car form) 'progn) (mapcar #'autoload-print-form (cdr form))) ;; Symbols at the toplevel are meaningless. ((symbolp form) nil) (t @@ -413,6 +416,16 @@ make it writable." (defun autoload-insert-section-header (outbuf autoloads load-name file time) "Insert the section-header line, which lists the file name and which functions are in it, etc." + ;; (cl-assert ;Make sure we don't insert it in the middle of another section. + ;; (save-excursion + ;; (or (not (re-search-backward + ;; (concat "\\(" + ;; (regexp-quote generate-autoload-section-header) + ;; "\\)\\|\\(" + ;; (regexp-quote generate-autoload-section-trailer) + ;; "\\)") + ;; nil t)) + ;; (match-end 2)))) (insert generate-autoload-section-header) (prin1 `(autoloads ,autoloads ,load-name ,file ,time) outbuf) @@ -471,7 +484,7 @@ which lists the file name and which functions are in it, etc." ;; without checking its content. This makes it generate wrong load ;; names for cases like lisp/term which is not added to load-path. (setq dir (expand-file-name (pop names) dir))) - (t (setq name (mapconcat 'identity names "/"))))) + (t (setq name (mapconcat #'identity names "/"))))) (if (string-match "\\.elc?\\(\\.\\|\\'\\)" name) (substring name 0 (match-beginning 0)) name))) @@ -487,8 +500,93 @@ Return non-nil in the case where no autoloads were added at point." (let ((generated-autoload-file buffer-file-name)) (autoload-generate-file-autoloads file (current-buffer)))) -(defvar print-readably) - +(defun autoload--split-prefixes-1 (strs) + (let ((prefixes ())) + (dolist (str strs) + (string-match "\\`[^-:/_]*[-:/_]*" str) + (let* ((prefix (match-string 0 str)) + (tail (substring str (match-end 0))) + (cell (assoc prefix prefixes))) + (cond + ((null cell) (push (list prefix tail) prefixes)) + ((equal (cadr cell) tail) nil) + (t (setcdr cell (cons tail (cdr cell))))))) + prefixes)) + +(defun autoload--split-prefixes (prefixes) + (apply #'nconc + (mapcar (lambda (cell) + (let ((prefix (car cell))) + (mapcar (lambda (cell) + (cons (concat prefix (car cell)) (cdr cell))) + (autoload--split-prefixes-1 (cdr cell))))) + prefixes))) + +(defvar autoload-compute-prefixes t + "If non-nil, autoload will add code to register the prefixes used in a file. +Standard prefixes won't be registered anyway. I.e. if a file \"foo.el\" defines +variables or functions that use \"foo-\" as prefix, that will not be registered. +But all other prefixes will be included.") + +(defconst autoload-defs-autoload-max-size 5 + "Target length of the list of definition prefixes per file. +If set too small, the prefixes will be too generic (i.e. they'll use little +memory, we'll end up looking in too many files when we need a particular +prefix), and if set too large, they will be too specific (i.e. they will +cost more memory use).") + +(defvar autoload-popular-prefixes nil) + +(defun autoload--make-defs-autoload (defs file) + ;; Remove the defs that obey the rule that file foo.el (or + ;; foo-mode.el) uses "foo-" as prefix. + ;; FIXME: help--symbol-completion-table still doesn't know how to use + ;; the rule that file foo.el (or foo-mode.el) uses "foo-" as prefix. + ;;(let ((prefix + ;; (concat (substring file 0 (string-match "-mode\\'" file)) "-"))) + ;; (dolist (def (prog1 defs (setq defs nil))) + ;; (unless (string-prefix-p prefix def) + ;; (push def defs)))) + + ;; Then compute a small set of prefixes that cover all the + ;; remaining definitions. + (let ((prefixes (autoload--split-prefixes-1 defs)) + (again t)) + ;; (message "Initial prefixes %s : %S" file (mapcar #'car prefixes)) + (while again + (setq again nil) + (let ((newprefixes + (sort + (mapcar (lambda (cell) + (cons cell + (autoload--split-prefixes-1 (cdr cell)))) + prefixes) + (lambda (x y) (< (length (cdr x)) (length (cdr y))))))) + (setq prefixes nil) + (while newprefixes + (let ((x (pop newprefixes))) + (if (or (equal '("") (cdar x)) + (and (cddr x) + (not (member (caar x) + autoload-popular-prefixes)) + (> (+ (length prefixes) (length newprefixes) + (length (cdr x))) + autoload-defs-autoload-max-size))) + ;; Nothing to split or would split too deep. + (push (car x) prefixes) + ;; (message "Expand %S to %S" (caar x) (cdr x)) + (setq again t) + (setq prefixes + (nconc (mapcar (lambda (cell) + (cons (concat (caar x) + (car cell)) + (cdr cell))) + (cdr x)) + prefixes))))))) + ;; (message "Final prefixes %s : %S" file (mapcar #'car prefixes)) + (when prefixes + `(if (fboundp 'register-definition-prefixes) + (register-definition-prefixes ,file ',(mapcar #'car prefixes)))))) (defun autoload--setup-output (otherbuf outbuf absfile load-name) (let ((outbuf @@ -566,11 +664,11 @@ 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)) + (defs '()) ;; nil until we found a cookie. output-start) (when @@ -629,13 +727,73 @@ FILE's modification time." ;; Don't read the comment. (forward-line 1)) (t + ;; Avoid (defvar ) by requiring a trailing space. + ;; Also, ignore this prefix business + ;; for ;;;###tramp-autoload and friends. + (when (and (equal generate-autoload-cookie ";;;###autoload") + (looking-at "(\\(def[^ ]+\\) ['(]*\\([^' ()\"\n]+\\)[\n \t]") + (not (member + (match-string 1) + '("define-obsolete-function-alias" + "define-obsolete-variable-alias" + "define-category" "define-key" + "defgroup" "defface" "defadvice" + ;; Hmm... this is getting ugly: + "define-widget" + "defun-rcirc-command")))) + (push (match-string 2) defs)) (forward-sexp 1) (forward-line 1)))))) + (when (and autoload-compute-prefixes defs) + ;; This output needs to always go in the main loaddefs.el, + ;; regardless of generated-autoload-file. + ;; FIXME: the files that don't have autoload cookies but + ;; do have definitions end up listed twice in loaddefs.el: + ;; once for their register-definition-prefixes and once in + ;; the list of "files without any autoloads". + (let ((form (autoload--make-defs-autoload defs load-name))) + (cond + ((null form)) ;All defs obey the default rule, yay! + ((not otherbuf) + (unless output-start + (setq output-start (autoload--setup-output + nil outbuf absfile load-name))) + (let ((autoload-print-form-outbuf + (marker-buffer output-start))) + (autoload-print-form form))) + (t + (let* ((other-output-start + ;; To force the output to go to the main loaddefs.el + ;; rather than to generated-autoload-file, + ;; there are two cases: if outbuf is non-nil, + ;; then passing otherbuf=nil is enough, but if + ;; outbuf is nil, that won't cut it, so we + ;; locally bind generated-autoload-file. + (let ((generated-autoload-file + (default-value 'generated-autoload-file))) + (autoload--setup-output nil outbuf absfile load-name))) + (autoload-print-form-outbuf + (marker-buffer other-output-start))) + (autoload-print-form form) + (with-current-buffer (marker-buffer other-output-start) + (save-excursion + ;; Insert the section-header line which lists + ;; the file name and which functions are in it, etc. + (goto-char other-output-start) + (let ((relfile (file-relative-name absfile))) + (autoload-insert-section-header + (marker-buffer other-output-start) + "actual autoloads are elsewhere" load-name relfile + (nth 5 (file-attributes absfile))) + (insert ";;; Generated autoloads from " relfile "\n"))) + (insert generate-autoload-section-trailer))))))) + (when output-start (let ((secondary-autoloads-file-buf (if otherbuf (current-buffer)))) (with-current-buffer (marker-buffer output-start) + (cl-assert (> (point) output-start)) (save-excursion ;; Insert the section-header line which lists the file name ;; and which functions are in it, etc. @@ -827,12 +985,13 @@ write its autoloads into the specified file instead." (dolist (suf (get-load-suffixes)) (unless (string-match "\\.elc" suf) (push suf tmp))) (concat "^[^=.].*" (regexp-opt tmp t) "\\'"))) - (files (apply 'nconc + (files (apply #'nconc (mapcar (lambda (dir) (directory-files (expand-file-name dir) t files-re)) dirs))) - (done ()) + (done ()) ;Files processed; to remove duplicates. + (changed nil) ;Non-nil if some change occured. (last-time) ;; Files with no autoload cookies or whose autoloads go to other ;; files because of file-local autoload-generated-file settings. @@ -850,7 +1009,7 @@ write its autoloads into the specified file instead." (save-excursion ;; Canonicalize file names and remove the autoload file itself. (setq files (delete (file-relative-name buffer-file-name) - (mapcar 'file-relative-name files))) + (mapcar #'file-relative-name files))) (goto-char (point-min)) (while (search-forward generate-autoload-section-header nil t) @@ -878,6 +1037,7 @@ write its autoloads into the specified file instead." ;; If the file is actually excluded. (member (expand-file-name file) autoload-excludes)) ;; Remove the obsolete section. + (setq changed t) (autoload-remove-section (match-beginning 0))) ((not (time-less-p (let ((oldtime (nth 4 form))) (if (member oldtime @@ -889,6 +1049,7 @@ write its autoloads into the specified file instead." ;; File hasn't changed. nil) (t + (setq changed t) (autoload-remove-section (match-beginning 0)) (if (autoload-generate-file-autoloads ;; Passing `current-buffer' makes it insert at point. @@ -908,7 +1069,8 @@ write its autoloads into the specified file instead." (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))))) + (setq no-autoloads-time file-time))) + (t (setq changed t)))) (when no-autoloads ;; Sort them for better readability. @@ -922,8 +1084,12 @@ write its autoloads into the specified file instead." autoload--non-timestamp)) (insert generate-autoload-section-trailer))) - (let ((version-control 'never)) - (save-buffer)) + ;; Don't modify the file if its content has not been changed, so `make' + ;; dependencies don't trigger unnecessarily. + (when changed + (let ((version-control 'never)) + (save-buffer))) + ;; In case autoload entries were added to other files because of ;; file-local autoload-generated-file settings. (autoload-save-buffers)))) @@ -955,7 +1121,7 @@ should be non-nil)." (push (expand-file-name file) autoload-excludes))))))) (let ((args command-line-args-left)) (setq command-line-args-left nil) - (apply 'update-directory-autoloads args))) + (apply #'update-directory-autoloads args))) (provide 'autoload) -- cgit v1.2.1 From 84f431224cdc1ee65b4662f3eb55f4da46066e3e Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Fri, 27 May 2016 12:33:57 -0400 Subject: * lisp/subr.el (definition-prefixes): Expand docstring * lisp/emacs-lisp/autoload.el (autoload--split-prefixes): Remove unused function. --- lisp/emacs-lisp/autoload.el | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'lisp/emacs-lisp/autoload.el') diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index 80f5c28f3ec..11316f1d9d6 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -513,15 +513,6 @@ Return non-nil in the case where no autoloads were added at point." (t (setcdr cell (cons tail (cdr cell))))))) prefixes)) -(defun autoload--split-prefixes (prefixes) - (apply #'nconc - (mapcar (lambda (cell) - (let ((prefix (car cell))) - (mapcar (lambda (cell) - (cons (concat prefix (car cell)) (cdr cell))) - (autoload--split-prefixes-1 (cdr cell))))) - prefixes))) - (defvar autoload-compute-prefixes t "If non-nil, autoload will add code to register the prefixes used in a file. Standard prefixes won't be registered anyway. I.e. if a file \"foo.el\" defines @@ -538,6 +529,13 @@ cost more memory use).") (defvar autoload-popular-prefixes nil) (defun autoload--make-defs-autoload (defs file) + ;; FIXME: avoid redundant entries. E.g. opascal currently has + ;; "opascal-" "opascal--literal-start-re" "opascal--syntax-propertize" + ;; where only the first one should be kept. + ;; FIXME: Avoid keeping too-long-prefixes. E.g. ob-scheme currently has + ;; "org-babel-scheme-" "org-babel-default-header-args:scheme" + ;; "org-babel-expand-body:scheme" "org-babel-execute:scheme". + ;; Remove the defs that obey the rule that file foo.el (or ;; foo-mode.el) uses "foo-" as prefix. ;; FIXME: help--symbol-completion-table still doesn't know how to use -- cgit v1.2.1 From 0c26f14b7e200b39134ec70c77fab8c467cf3290 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 30 May 2016 23:22:49 -0400 Subject: * lisp/emacs-lisp/autoload.el: Use radix-tree. (autoload--make-defs-autoload): Rewrite. (autoload--split-prefixes-1): Remove. (autoload-def-prefixes-max-entries): Rename from autoload-defs-autoload-max-size. (autoload-popular-prefixes): Remove. (autoload-def-prefixes-max-length): New const. * lisp/emacs-lisp/radix-tree.el: New file. --- lisp/emacs-lisp/autoload.el | 86 +++++++++++++++++---------------------------- 1 file changed, 32 insertions(+), 54 deletions(-) (limited to 'lisp/emacs-lisp/autoload.el') diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index 11316f1d9d6..afd8e4ee03e 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -500,41 +500,26 @@ Return non-nil in the case where no autoloads were added at point." (let ((generated-autoload-file buffer-file-name)) (autoload-generate-file-autoloads file (current-buffer)))) -(defun autoload--split-prefixes-1 (strs) - (let ((prefixes ())) - (dolist (str strs) - (string-match "\\`[^-:/_]*[-:/_]*" str) - (let* ((prefix (match-string 0 str)) - (tail (substring str (match-end 0))) - (cell (assoc prefix prefixes))) - (cond - ((null cell) (push (list prefix tail) prefixes)) - ((equal (cadr cell) tail) nil) - (t (setcdr cell (cons tail (cdr cell))))))) - prefixes)) - (defvar autoload-compute-prefixes t "If non-nil, autoload will add code to register the prefixes used in a file. Standard prefixes won't be registered anyway. I.e. if a file \"foo.el\" defines variables or functions that use \"foo-\" as prefix, that will not be registered. But all other prefixes will be included.") -(defconst autoload-defs-autoload-max-size 5 +(defconst autoload-def-prefixes-max-entries 5 "Target length of the list of definition prefixes per file. If set too small, the prefixes will be too generic (i.e. they'll use little memory, we'll end up looking in too many files when we need a particular prefix), and if set too large, they will be too specific (i.e. they will cost more memory use).") -(defvar autoload-popular-prefixes nil) +(defconst autoload-def-prefixes-max-length 12 + "Target size of definition prefixes. +Don't try to split prefixes that are already longer than that.") + +(require 'radix-tree) (defun autoload--make-defs-autoload (defs file) - ;; FIXME: avoid redundant entries. E.g. opascal currently has - ;; "opascal-" "opascal--literal-start-re" "opascal--syntax-propertize" - ;; where only the first one should be kept. - ;; FIXME: Avoid keeping too-long-prefixes. E.g. ob-scheme currently has - ;; "org-babel-scheme-" "org-babel-default-header-args:scheme" - ;; "org-babel-expand-body:scheme" "org-babel-execute:scheme". ;; Remove the defs that obey the rule that file foo.el (or ;; foo-mode.el) uses "foo-" as prefix. @@ -548,39 +533,32 @@ cost more memory use).") ;; Then compute a small set of prefixes that cover all the ;; remaining definitions. - (let ((prefixes (autoload--split-prefixes-1 defs)) - (again t)) - ;; (message "Initial prefixes %s : %S" file (mapcar #'car prefixes)) - (while again - (setq again nil) - (let ((newprefixes - (sort - (mapcar (lambda (cell) - (cons cell - (autoload--split-prefixes-1 (cdr cell)))) - prefixes) - (lambda (x y) (< (length (cdr x)) (length (cdr y))))))) - (setq prefixes nil) - (while newprefixes - (let ((x (pop newprefixes))) - (if (or (equal '("") (cdar x)) - (and (cddr x) - (not (member (caar x) - autoload-popular-prefixes)) - (> (+ (length prefixes) (length newprefixes) - (length (cdr x))) - autoload-defs-autoload-max-size))) - ;; Nothing to split or would split too deep. - (push (car x) prefixes) - ;; (message "Expand %S to %S" (caar x) (cdr x)) - (setq again t) - (setq prefixes - (nconc (mapcar (lambda (cell) - (cons (concat (caar x) - (car cell)) - (cdr cell))) - (cdr x)) - prefixes))))))) + (let* ((tree (let ((tree radix-tree-empty)) + (dolist (def defs) + (setq tree (radix-tree-insert tree def t))) + tree)) + (prefixes (list (cons "" tree)))) + (while + (let ((newprefixes nil) + (changes nil)) + (dolist (pair prefixes) + (let ((prefix (car pair))) + (if (or (> (length prefix) autoload-def-prefixes-max-length) + (radix-tree-lookup (cdr pair) "")) + ;; No point splitting it any further. + (push pair newprefixes) + (setq changes t) + (radix-tree-iter-subtrees + (cdr pair) (lambda (sprefix subtree) + (push (cons (concat prefix sprefix) subtree) + newprefixes)))))) + (and changes + (or (and (null (cdr prefixes)) (equal "" (caar prefixes))) + (<= (length newprefixes) + autoload-def-prefixes-max-entries)) + (setq prefixes newprefixes) + (< (length prefixes) autoload-def-prefixes-max-entries)))) + ;; (message "Final prefixes %s : %S" file (mapcar #'car prefixes)) (when prefixes `(if (fboundp 'register-definition-prefixes) -- cgit v1.2.1 From 01030eed9395f5004e7d0721394697d1ca90cc2f Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 30 May 2016 23:19:54 -0700 Subject: ; Spelling fixes --- 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 afd8e4ee03e..424b8e31936 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -967,7 +967,7 @@ write its autoloads into the specified file instead." t files-re)) dirs))) (done ()) ;Files processed; to remove duplicates. - (changed nil) ;Non-nil if some change occured. + (changed nil) ;Non-nil if some change occurred. (last-time) ;; Files with no autoload cookies or whose autoloads go to other ;; files because of file-local autoload-generated-file settings. -- cgit v1.2.1 From 4428f5a97b942652e6894f22c4c251457a1edc8b Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Wed, 1 Jun 2016 14:54:40 -0400 Subject: * lisp/emacs-lisp/autoload.el (autoload--make-defs-autoload): Expand less --- lisp/emacs-lisp/autoload.el | 95 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 72 insertions(+), 23 deletions(-) (limited to 'lisp/emacs-lisp/autoload.el') diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index 424b8e31936..6473e31e56e 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -537,32 +537,79 @@ Don't try to split prefixes that are already longer than that.") (dolist (def defs) (setq tree (radix-tree-insert tree def t))) tree)) - (prefixes (list (cons "" tree)))) - (while - (let ((newprefixes nil) - (changes nil)) - (dolist (pair prefixes) - (let ((prefix (car pair))) - (if (or (> (length prefix) autoload-def-prefixes-max-length) - (radix-tree-lookup (cdr pair) "")) - ;; No point splitting it any further. - (push pair newprefixes) - (setq changes t) - (radix-tree-iter-subtrees - (cdr pair) (lambda (sprefix subtree) - (push (cons (concat prefix sprefix) subtree) - newprefixes)))))) - (and changes - (or (and (null (cdr prefixes)) (equal "" (caar prefixes))) - (<= (length newprefixes) - autoload-def-prefixes-max-entries)) - (setq prefixes newprefixes) - (< (length prefixes) autoload-def-prefixes-max-entries)))) + (prefixes nil)) + ;; Get the root prefixes, that we should include in any case. + (radix-tree-iter-subtrees + tree (lambda (prefix subtree) + (push (cons prefix subtree) prefixes))) + ;; In some cases, the root prefixes are too short, e.g. if you define + ;; "cc-helper" and "c-mode", you'll get "c" in the root prefixes. + (dolist (pair (prog1 prefixes (setq prefixes nil))) + (let ((s (car pair))) + (if (or (> (length s) 2) ;Long enough! + (string-match ".[[:punct:]]\\'" s) ;A real (tho short) prefix? + (radix-tree-lookup (cdr pair) "")) ;Nothing to expand! + (push pair prefixes) ;Keep it as is. + (radix-tree-iter-subtrees + (cdr pair) (lambda (prefix subtree) + (push (cons (concat s prefix) subtree) prefixes)))))) + ;; FIXME: The expansions done below are mostly pointless, such as + ;; for `yenc', where we replace "yenc-" with an exhaustive list (5 + ;; elements). + ;; (while + ;; (let ((newprefixes nil) + ;; (changes nil)) + ;; (dolist (pair prefixes) + ;; (let ((prefix (car pair))) + ;; (if (or (> (length prefix) autoload-def-prefixes-max-length) + ;; (radix-tree-lookup (cdr pair) "")) + ;; ;; No point splitting it any further. + ;; (push pair newprefixes) + ;; (setq changes t) + ;; (radix-tree-iter-subtrees + ;; (cdr pair) (lambda (sprefix subtree) + ;; (push (cons (concat prefix sprefix) subtree) + ;; newprefixes)))))) + ;; (and changes + ;; (<= (length newprefixes) + ;; autoload-def-prefixes-max-entries) + ;; (let ((new nil) + ;; (old nil)) + ;; (dolist (pair prefixes) + ;; (unless (memq pair newprefixes) ;Not old + ;; (push pair old))) + ;; (dolist (pair newprefixes) + ;; (unless (memq pair prefixes) ;Not new + ;; (push pair new))) + ;; (cl-assert new) + ;; (message "Expanding %S to %S" + ;; (mapcar #'car old) (mapcar #'car new)) + ;; t) + ;; (setq prefixes newprefixes) + ;; (< (length prefixes) autoload-def-prefixes-max-entries)))) ;; (message "Final prefixes %s : %S" file (mapcar #'car prefixes)) (when prefixes - `(if (fboundp 'register-definition-prefixes) - (register-definition-prefixes ,file ',(mapcar #'car prefixes)))))) + (let ((strings + (mapcar + (lambda (x) + (let ((prefix (car x))) + (if (or (> (length prefix) 2) ;Long enough! + (string-match ".[[:punct:]]\\'" prefix)) + prefix + ;; Some packages really don't follow the rules. + ;; Drop the most egregious cases such as the + ;; one-letter prefixes. + (let ((dropped ())) + (radix-tree-iter-mappings + (cdr x) (lambda (s _) + (push (concat prefix s) dropped))) + (message "Not registering prefix \"%s\" from %s. Affects: %S" + prefix file dropped) + nil)))) + prefixes))) + `(if (fboundp 'register-definition-prefixes) + (register-definition-prefixes ,file ',(delq nil strings))))))) (defun autoload--setup-output (otherbuf outbuf absfile load-name) (let ((outbuf @@ -714,8 +761,10 @@ FILE's modification time." "define-obsolete-variable-alias" "define-category" "define-key" "defgroup" "defface" "defadvice" + "def-edebug-spec" ;; Hmm... this is getting ugly: "define-widget" + "define-erc-response-handler" "defun-rcirc-command")))) (push (match-string 2) defs)) (forward-sexp 1) -- cgit v1.2.1 From 96bd07a3226700156fa7d5ec20e9bd6550c95057 Mon Sep 17 00:00:00 2001 From: Chris Feng Date: Wed, 13 Jul 2016 19:52:10 +0800 Subject: Include versioned preloaded libraries in `package--builtin-versions' * lisp/emacs-lisp/autoload.el (update-directory-autoloads): Do not exclude preloaded libraries or remove entries generated for them. (autoload-generate-file-autoloads): Do not generate autoload statements for preloaded libraries. --- lisp/emacs-lisp/autoload.el | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) (limited to 'lisp/emacs-lisp/autoload.el') diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index 6473e31e56e..fbb08fc3268 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -736,20 +736,22 @@ FILE's modification time." 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 + ;; Do not insert autoload entries for excluded files. + (unless (member absfile autoload-excludes) + (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 ;; Avoid (defvar ) by requiring a trailing space. ;; Also, ignore this prefix business ;; for ;;;###tramp-autoload and friends. @@ -767,8 +769,8 @@ FILE's modification time." "define-erc-response-handler" "defun-rcirc-command")))) (push (match-string 2) defs)) - (forward-sexp 1) - (forward-line 1)))))) + (forward-sexp 1) + (forward-line 1))))))) (when (and autoload-compute-prefixes defs) ;; This output needs to always go in the main loaddefs.el, @@ -1058,9 +1060,7 @@ write its autoloads into the specified file instead." ((not (stringp file))) ((or (not (file-exists-p file)) ;; Remove duplicates as well, just in case. - (member file done) - ;; If the file is actually excluded. - (member (expand-file-name file) autoload-excludes)) + (member file done)) ;; Remove the obsolete section. (setq changed t) (autoload-remove-section (match-beginning 0))) @@ -1086,7 +1086,6 @@ write its autoloads into the specified file instead." (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. -- cgit v1.2.1 From 573dde70a4bcd7ad972e25260374f5019c671df1 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Mon, 1 Aug 2016 16:31:57 -0400 Subject: * lisp/emacs-lisp/autoload.el (autoload-generate-file-autoloads): Respect autoload-timestamps for "actual autoloads are elsewhere" case. --- lisp/emacs-lisp/autoload.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lisp/emacs-lisp/autoload.el') diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index fbb08fc3268..aa58f7b27fa 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -812,7 +812,9 @@ FILE's modification time." (autoload-insert-section-header (marker-buffer other-output-start) "actual autoloads are elsewhere" load-name relfile - (nth 5 (file-attributes absfile))) + (if autoload-timestamps + (nth 5 (file-attributes absfile)) + autoload--non-timestamp)) (insert ";;; Generated autoloads from " relfile "\n"))) (insert generate-autoload-section-trailer))))))) -- cgit v1.2.1 From 5cc3c13d164e392218a4dbc277fdab8c757a91af Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Tue, 11 Oct 2016 15:52:14 -0400 Subject: If autoloads buffer is unchanged, mark it as such (bug#23692) * lisp/emacs-lisp/autoload.el (update-directory-autoloads): If autoloads buffer is unchanged, mark it as such (bug#23692). --- lisp/emacs-lisp/autoload.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lisp/emacs-lisp/autoload.el') diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index aa58f7b27fa..426601c81f7 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -1112,7 +1112,8 @@ write its autoloads into the specified file instead." ;; Don't modify the file if its content has not been changed, so `make' ;; dependencies don't trigger unnecessarily. - (when changed + (if (not changed) + (set-buffer-modified-p nil) (let ((version-control 'never)) (save-buffer))) -- cgit v1.2.1 From b2f32e4c9a06234019f07f448b53b76e62aebbba Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Wed, 19 Oct 2016 10:42:45 +0300 Subject: Don't scan compiled module files for autoloads * lisp/emacs-lisp/autoload.el (update-directory-autoloads): Ignore compiled module files. Make sure the extension really ends the file name. --- lisp/emacs-lisp/autoload.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lisp/emacs-lisp/autoload.el') diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index eb6b746bd80..d4b9479b752 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -766,7 +766,13 @@ write its autoloads into the specified file instead." (interactive "DUpdate autoloads from directory: ") (let* ((files-re (let ((tmp nil)) (dolist (suf (get-load-suffixes)) - (unless (string-match "\\.elc" suf) (push suf tmp))) + ;; We don't use module-file-suffix below because + ;; we don't want to depend on whether Emacs was + ;; built with or without modules support, nor + ;; what is the suffix for the underlying OS. + (unless (string-match "\\.\\(elc\\|\\so\\|dll\\)\\'" + suf) + (push suf tmp))) (concat "^[^=.].*" (regexp-opt tmp t) "\\'"))) (files (apply 'nconc (mapcar (lambda (dir) -- cgit v1.2.1 From 62f268414c1a04235b34befe3ad103cecec72382 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Wed, 19 Oct 2016 10:59:05 +0300 Subject: * lisp/emacs-lisp/autoload.el (update-directory-autoloads): Fix last change. --- lisp/emacs-lisp/autoload.el | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lisp/emacs-lisp/autoload.el') diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index d4b9479b752..883a38a4884 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -770,8 +770,7 @@ write its autoloads into the specified file instead." ;; we don't want to depend on whether Emacs was ;; built with or without modules support, nor ;; what is the suffix for the underlying OS. - (unless (string-match "\\.\\(elc\\|\\so\\|dll\\)\\'" - suf) + (unless (string-match "\\.\\(elc\\|\\so\\|dll\\)" suf) (push suf tmp))) (concat "^[^=.].*" (regexp-opt tmp t) "\\'"))) (files (apply 'nconc -- cgit v1.2.1