From 41a5b76f79e2ef12a089e94406159e2d0e1fad1f Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Wed, 19 Apr 2017 16:28:48 -0400 Subject: Stop cl-lib loading pcase at runtime The cause was an unexpanded pcase-defmacro in cl-loaddefs. * lisp/emacs-lisp/autoload.el (make-autoload): Treat pcase-defmacro like defmacro. --- 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 d1f3c359f37..90e6aec4e75 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -164,7 +164,8 @@ expression, in which case we want to handle forms differently." ((and (memq car '(easy-mmode-define-global-mode define-global-minor-mode define-globalized-minor-mode defun defmacro easy-mmode-define-minor-mode define-minor-mode - define-inline cl-defun cl-defmacro cl-defgeneric)) + define-inline cl-defun cl-defmacro cl-defgeneric + pcase-defmacro)) (macrop car) (setq expand (let ((load-file-name file)) (macroexpand form))) (memq (car expand) '(progn prog1 defalias))) -- cgit v1.2.3 From 4364a769b489c044c4e9eeac6cfbabcc844ab332 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Wed, 19 Apr 2017 23:01:43 -0400 Subject: Don't register "def" as an autoload prefix (Bug#26412) * lisp/emacs-lisp/autoload.el (autoload--make-defs-autoload): Don't accept "def" as a prefix. --- 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 90e6aec4e75..ca46f317677 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -547,7 +547,9 @@ Don't try to split prefixes that are already longer than that.") ;; "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! + (if (or (and (> (length s) 2) ; Long enough! + ;; But don't use "def" from deffoo-pkg-thing. + (not (string= "def" s))) (string-match ".[[:punct:]]\\'" s) ;A real (tho short) prefix? (radix-tree-lookup (cdr pair) "")) ;Nothing to expand! (push pair prefixes) ;Keep it as is. -- cgit v1.2.3 From a3b8618d79657af0d7fea9cb6fd914ccf0f67849 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Fri, 21 Apr 2017 12:14:59 -0400 Subject: Improve prefix handling for dash.el * lisp/emacs-lisp/autoload.el (autoload--make-defs-autoload): Don't drop dash's "-" prefixes. --- 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 ca46f317677..4d0554e6101 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -598,7 +598,8 @@ Don't try to split prefixes that are already longer than that.") (lambda (x) (let ((prefix (car x))) (if (or (> (length prefix) 2) ;Long enough! - (string-match ".[[:punct:]]\\'" prefix)) + (and (eq (length prefix) 2) + (string-match "[[:punct:]]" prefix))) prefix ;; Some packages really don't follow the rules. ;; Drop the most egregious cases such as the -- cgit v1.2.3 From 03d941982fbdf96260fc47d1cafbdda78c1d128e Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Sat, 6 May 2017 17:07:10 -0700 Subject: Write autoloads file once only * lisp/emacs-lisp/autoload.el (autoload-find-generated-file): Simplify. Don't bother about ensuring the output file exists. (autoload-generated-file): Add doc. (autoload-ensure-writable): Update doc. (autoload-ensure-file-writeable): Handle non-existing file. (autoload-ensure-default-file): Remove function. --- lisp/emacs-lisp/autoload.el | 39 +++++++++++++-------------------------- 1 file changed, 13 insertions(+), 26 deletions(-) (limited to 'lisp/emacs-lisp/autoload.el') diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index 4d0554e6101..9865b3198b2 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -255,30 +255,22 @@ expression, in which case we want to handle forms differently." ;; Those properties are now set in lisp-mode.el. (defun autoload-find-generated-file () - "Visit the autoload file for the current buffer, and return its buffer. -If a buffer is visiting the desired autoload file, return it." + "Visit the autoload file for the current buffer, and return its buffer." (let ((enable-local-variables :safe) - (enable-local-eval nil)) + (enable-local-eval nil) + (delay-mode-hooks t) + (file (autoload-generated-file))) ;; 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))))) + (with-current-buffer (find-file-noselect + (autoload-ensure-file-writeable file)) + (if (zerop (buffer-size)) (insert (autoload-rubric file))) + (current-buffer)))) (defun autoload-generated-file () + "Return `generated-autoload-file' as an absolute name. +If local to the current buffer, expand using the default directory; +otherwise, using `source-directory'/lisp." (expand-file-name generated-autoload-file ;; File-local settings of generated-autoload-file should ;; be interpreted relative to the file's location, @@ -391,7 +383,7 @@ not be relied upon." " ends here\n"))) (defvar autoload-ensure-writable nil - "Non-nil means `autoload-ensure-default-file' makes existing file writable.") + "Non-nil means `autoload-find-generated-file' makes existing file writable.") ;; Just in case someone tries to get you to overwrite a file that you ;; don't want to. ;;;###autoload @@ -401,6 +393,7 @@ not be relied upon." ;; Probably pointless, but replaces the old AUTOGEN_VCS in lisp/Makefile, ;; which was designed to handle CVSREAD=1 and equivalent. (and autoload-ensure-writable + (file-exists-p file) (let ((modes (file-modes file))) (if (zerop (logand modes #o0200)) ;; Ignore any errors here, and let subsequent attempts @@ -408,12 +401,6 @@ not be relied upon." (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)) - (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." -- cgit v1.2.3 From 7f3d63908cd05fb34347d942e435c2964cd8b249 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Sat, 6 May 2017 17:58:20 -0700 Subject: Write autoloads file atomically * lisp/emacs-lisp/autoload.el (autoload--save-buffer): New function, to save buffer atomically. (autoload-save-buffers, update-directory-autoloads): Use autoload--save-buffer. * lisp/Makefile.in ($(lisp)/loaddefs.el): No longer write to a temp file by hand. --- lisp/Makefile.in | 13 +------------ lisp/emacs-lisp/autoload.el | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 16 deletions(-) (limited to 'lisp/emacs-lisp/autoload.el') diff --git a/lisp/Makefile.in b/lisp/Makefile.in index cbbea78a00f..1da8814370a 100644 --- a/lisp/Makefile.in +++ b/lisp/Makefile.in @@ -203,28 +203,17 @@ $(lisp)/finder-inf.el: # batch-update-autoloads, which only updates the autoloads whose # sources have changed. -# Write to a temporary file in case we're doing a parallel build and a -# CANNOT_DUMP-mode Emacs needs to read loaddefs at startup. -# (FIXME: This seems like something that batch-update-autoloads should -# do internally, then it would Just Work for all loaddefs files.) -# We start by copying an existing loaddefs.el to loaddefs.tmp to avoid -# regenerating the entire file anew, which is slow; starting from an -# almost-correct content will enable the "only update where necessary" -# feature of batch-update-autoloads. - # Use expand-file-name rather than $abs_scrdir so that Emacs does not # get confused when it compares file-names for equality. autoloads .PHONY: $(lisp)/loaddefs.el $(lisp)/loaddefs.el: gen-lisp $(LOADDEFS) @echo Directories for loaddefs: ${SUBDIRS_ALMOST} - @if test -f $@ ; then cp $@ $(lisp)/loaddefs.tmp ; fi $(AM_V_GEN)$(emacs) -l autoload \ --eval '(setq autoload-ensure-writable t)' \ --eval '(setq autoload-builtin-package-versions t)' \ - --eval '(setq generated-autoload-file (expand-file-name (unmsys--file-name "$(lisp)/loaddefs.tmp")))' \ + --eval '(setq generated-autoload-file (expand-file-name (unmsys--file-name "$@")))' \ -f batch-update-autoloads ${SUBDIRS_ALMOST} - $(top_srcdir)/build-aux/move-if-change $(lisp)/loaddefs.tmp $@ # autoloads only runs when loaddefs.el is nonexistent, although it # generates a number of different files. Provide a force option to enable diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index 9865b3198b2..8ad5e6b823d 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -866,11 +866,26 @@ FILE's modification time." (error "%s:0:0: error: %s: %s" file (car err) (cdr err))) )) +;; For parallel builds, to stop another process reading a half-written file. +(defun autoload--save-buffer () + "Save current buffer to its file, atomically." + ;; Copied from byte-compile-file. + (let* ((version-control 'never) + (tempfile (make-temp-name buffer-file-name)) + (kill-emacs-hook + (cons (lambda () (ignore-errors (delete-file tempfile))) + kill-emacs-hook))) + (write-region (point-min) (point-max) tempfile nil 1) + (backup-buffer) + (rename-file tempfile buffer-file-name t) + (set-buffer-modified-p nil) + (set-visited-file-modtime) + (or noninteractive (message "Wrote %s" buffer-file-name)))) + (defun autoload-save-buffers () (while autoload-modified-buffers (with-current-buffer (pop autoload-modified-buffers) - (let ((version-control 'never)) - (save-buffer))))) + (autoload--save-buffer)))) ;; FIXME This command should be deprecated. ;; See http://debbugs.gnu.org/22213#41 @@ -1110,8 +1125,7 @@ write its autoloads into the specified file instead." ;; dependencies don't trigger unnecessarily. (if (not changed) (set-buffer-modified-p nil) - (let ((version-control 'never)) - (save-buffer))) + (autoload--save-buffer)) ;; In case autoload entries were added to other files because of ;; file-local autoload-generated-file settings. -- cgit v1.2.3 From d6d5020c2593a1e8ac2fe7ef4f217cfbcacfd32d Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Tue, 9 May 2017 13:03:04 -0400 Subject: Don't duplicate autoload code in package.el * lisp/emacs-lisp/autoload.el (autoload-rubric): Add a package option. * lisp/emacs-lisp/package.el (autoload-rubric): Declare. (package-autoload-ensure-default-file): Use autoload-rubric. --- lisp/emacs-lisp/autoload.el | 30 +++++++++++++++++++----------- lisp/emacs-lisp/package.el | 20 ++++---------------- 2 files changed, 23 insertions(+), 27 deletions(-) (limited to 'lisp/emacs-lisp/autoload.el') diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index 8ad5e6b823d..f6b09dcf31d 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -355,24 +355,32 @@ put the output in." (defun autoload-rubric (file &optional type feature) "Return a string giving the appropriate autoload rubric for FILE. TYPE (default \"autoloads\") is a string stating the type of -information contained in FILE. If FEATURE is non-nil, FILE -will provide a feature. FEATURE may be a string naming the -feature, otherwise it will be based on FILE's name. +information contained in FILE. TYPE \"package\" acts like the default, +but adds an extra line to the output to modify `load-path'. + +If FEATURE is non-nil, FILE will provide a feature. FEATURE may +be a string naming the feature, otherwise it will be based on +FILE's name. At present, a feature is in fact always provided, but this should not be relied upon." - (let ((basename (file-name-nondirectory file))) + (let ((basename (file-name-nondirectory file)) + (lp (if (equal type "package") (setq type "autoloads")))) (concat ";;; " basename " --- automatically extracted " (or type "autoloads") "\n" ";;\n" ";;; Code:\n\n" - " \n" - ;; This is used outside of autoload.el, eg cus-dep, finder. - "(provide '" - (if (stringp feature) - feature - (file-name-sans-extension basename)) - ")\n" + (if lp + ;; `load-path' should contain only directory names. + "(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path))))\n \n" + (concat + ;; This is used outside of autoload.el, eg cus-dep, finder. + " \n" + "(provide '" + (if (stringp feature) + feature + (file-name-sans-extension basename)) + ")\n")) ";; Local Variables:\n" ";; version-control: never\n" ";; no-byte-compile: t\n" diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 7ae7ffff1a7..c0ecb0447f3 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -905,25 +905,13 @@ untar into a directory named DIR; otherwise, signal an error." nil pkg-file nil 'silent)))) ;;;; Autoload -;; From Emacs 22, but changed so it adds to load-path. +(declare-function autoload-rubric "autoload" (file &optional type feature)) + (defun package-autoload-ensure-default-file (file) "Make sure that the autoload file FILE exists and if not create it." (unless (file-exists-p file) - (write-region - (concat ";;; " (file-name-nondirectory file) - " --- automatically extracted autoloads\n" - ";;\n" - ";;; Code:\n" - ;; `load-path' should contain only directory names - "(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path))))\n" - " \n;; Local Variables:\n" - ";; version-control: never\n" - ";; no-byte-compile: t\n" - ";; no-update-autoloads: t\n" - ";; End:\n" - ";;; " (file-name-nondirectory file) - " ends here\n") - nil file nil 'silent)) + (require 'autoload) + (write-region (autoload-rubric file "package" nil) nil file nil 'silent)) file) (defvar generated-autoload-file) -- cgit v1.2.3 From df4e105910a983f42e77828809ab50611b454905 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Wed, 17 May 2017 12:43:23 -0400 Subject: autoload-rubric no longer provides a feature by default * lisp/emacs-lisp/autoload.el (autoload-rubric): Stop providing a feature unless explicitly requested. (autoload-find-generated-file): Update autoload-rubric call. --- lisp/emacs-lisp/autoload.el | 24 ++++++++++-------------- 1 file changed, 10 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 f6b09dcf31d..8fe94013700 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -264,7 +264,7 @@ expression, in which case we want to handle forms differently." ;; problems when the file contains non-ASCII characters. (with-current-buffer (find-file-noselect (autoload-ensure-file-writeable file)) - (if (zerop (buffer-size)) (insert (autoload-rubric file))) + (if (zerop (buffer-size)) (insert (autoload-rubric file nil t))) (current-buffer)))) (defun autoload-generated-file () @@ -360,10 +360,7 @@ but adds an extra line to the output to modify `load-path'. If FEATURE is non-nil, FILE will provide a feature. FEATURE may be a string naming the feature, otherwise it will be based on -FILE's name. - -At present, a feature is in fact always provided, but this should -not be relied upon." +FILE's name." (let ((basename (file-name-nondirectory file)) (lp (if (equal type "package") (setq type "autoloads")))) (concat ";;; " basename @@ -372,15 +369,14 @@ not be relied upon." ";;; Code:\n\n" (if lp ;; `load-path' should contain only directory names. - "(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path))))\n \n" - (concat - ;; This is used outside of autoload.el, eg cus-dep, finder. - " \n" - "(provide '" - (if (stringp feature) - feature - (file-name-sans-extension basename)) - ")\n")) + "(add-to-list 'load-path (directory-file-name + (or (file-name-directory #$) (car load-path))))\n\n") + " \n" + ;; This is used outside of autoload.el, eg cus-dep, finder. + (if feature + (format "(provide '%s)\n" + (if (stringp feature) feature + (file-name-sans-extension basename)))) ";; Local Variables:\n" ";; version-control: never\n" ";; no-byte-compile: t\n" -- cgit v1.2.3