diff options
| -rw-r--r-- | lisp/emacs-lisp/autoload.el | 39 |
1 files changed, 13 insertions, 26 deletions
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." | |||
| 255 | ;; Those properties are now set in lisp-mode.el. | 255 | ;; Those properties are now set in lisp-mode.el. |
| 256 | 256 | ||
| 257 | (defun autoload-find-generated-file () | 257 | (defun autoload-find-generated-file () |
| 258 | "Visit the autoload file for the current buffer, and return its buffer. | 258 | "Visit the autoload file for the current buffer, and return its buffer." |
| 259 | If a buffer is visiting the desired autoload file, return it." | ||
| 260 | (let ((enable-local-variables :safe) | 259 | (let ((enable-local-variables :safe) |
| 261 | (enable-local-eval nil)) | 260 | (enable-local-eval nil) |
| 261 | (delay-mode-hooks t) | ||
| 262 | (file (autoload-generated-file))) | ||
| 262 | ;; We used to use `raw-text' to read this file, but this causes | 263 | ;; We used to use `raw-text' to read this file, but this causes |
| 263 | ;; problems when the file contains non-ASCII characters. | 264 | ;; problems when the file contains non-ASCII characters. |
| 264 | (let* ((delay-mode-hooks t) | 265 | (with-current-buffer (find-file-noselect |
| 265 | (file (autoload-generated-file)) | 266 | (autoload-ensure-file-writeable file)) |
| 266 | (file-missing (not (file-exists-p file)))) | 267 | (if (zerop (buffer-size)) (insert (autoload-rubric file))) |
| 267 | (when file-missing | 268 | (current-buffer)))) |
| 268 | (autoload-ensure-default-file file)) | ||
| 269 | (with-current-buffer | ||
| 270 | (find-file-noselect | ||
| 271 | (autoload-ensure-file-writeable | ||
| 272 | file)) | ||
| 273 | ;; block backups when the file has just been created, since | ||
| 274 | ;; the backups will just be the auto-generated headers. | ||
| 275 | ;; bug#23203 | ||
| 276 | (when file-missing | ||
| 277 | (setq buffer-backed-up t) | ||
| 278 | (save-buffer)) | ||
| 279 | (current-buffer))))) | ||
| 280 | 269 | ||
| 281 | (defun autoload-generated-file () | 270 | (defun autoload-generated-file () |
| 271 | "Return `generated-autoload-file' as an absolute name. | ||
| 272 | If local to the current buffer, expand using the default directory; | ||
| 273 | otherwise, using `source-directory'/lisp." | ||
| 282 | (expand-file-name generated-autoload-file | 274 | (expand-file-name generated-autoload-file |
| 283 | ;; File-local settings of generated-autoload-file should | 275 | ;; File-local settings of generated-autoload-file should |
| 284 | ;; be interpreted relative to the file's location, | 276 | ;; be interpreted relative to the file's location, |
| @@ -391,7 +383,7 @@ not be relied upon." | |||
| 391 | " ends here\n"))) | 383 | " ends here\n"))) |
| 392 | 384 | ||
| 393 | (defvar autoload-ensure-writable nil | 385 | (defvar autoload-ensure-writable nil |
| 394 | "Non-nil means `autoload-ensure-default-file' makes existing file writable.") | 386 | "Non-nil means `autoload-find-generated-file' makes existing file writable.") |
| 395 | ;; Just in case someone tries to get you to overwrite a file that you | 387 | ;; Just in case someone tries to get you to overwrite a file that you |
| 396 | ;; don't want to. | 388 | ;; don't want to. |
| 397 | ;;;###autoload | 389 | ;;;###autoload |
| @@ -401,6 +393,7 @@ not be relied upon." | |||
| 401 | ;; Probably pointless, but replaces the old AUTOGEN_VCS in lisp/Makefile, | 393 | ;; Probably pointless, but replaces the old AUTOGEN_VCS in lisp/Makefile, |
| 402 | ;; which was designed to handle CVSREAD=1 and equivalent. | 394 | ;; which was designed to handle CVSREAD=1 and equivalent. |
| 403 | (and autoload-ensure-writable | 395 | (and autoload-ensure-writable |
| 396 | (file-exists-p file) | ||
| 404 | (let ((modes (file-modes file))) | 397 | (let ((modes (file-modes file))) |
| 405 | (if (zerop (logand modes #o0200)) | 398 | (if (zerop (logand modes #o0200)) |
| 406 | ;; Ignore any errors here, and let subsequent attempts | 399 | ;; Ignore any errors here, and let subsequent attempts |
| @@ -408,12 +401,6 @@ not be relied upon." | |||
| 408 | (ignore-errors (set-file-modes file (logior modes #o0200)))))) | 401 | (ignore-errors (set-file-modes file (logior modes #o0200)))))) |
| 409 | file) | 402 | file) |
| 410 | 403 | ||
| 411 | (defun autoload-ensure-default-file (file) | ||
| 412 | "Make sure that the autoload file FILE exists, creating it if needed. | ||
| 413 | If the file already exists and `autoload-ensure-writable' is non-nil, | ||
| 414 | make it writable." | ||
| 415 | (write-region (autoload-rubric file) nil file)) | ||
| 416 | |||
| 417 | (defun autoload-insert-section-header (outbuf autoloads load-name file time) | 404 | (defun autoload-insert-section-header (outbuf autoloads load-name file time) |
| 418 | "Insert the section-header line, | 405 | "Insert the section-header line, |
| 419 | which lists the file name and which functions are in it, etc." | 406 | which lists the file name and which functions are in it, etc." |