diff options
| author | Phillip Lord | 2016-04-08 16:22:44 +0100 |
|---|---|---|
| committer | Phillip Lord | 2016-04-20 13:30:23 +0100 |
| commit | 16af826eac64c5a6e79724b79b04f5318afb273b (patch) | |
| tree | 00132c90f972c99b28e2c358b29bb2de8b6d81ad | |
| parent | 65150493f7e3f0768fccd6097c6dafc9ae18770b (diff) | |
| download | emacs-16af826eac64c5a6e79724b79b04f5318afb273b.tar.gz emacs-16af826eac64c5a6e79724b79b04f5318afb273b.zip | |
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)
| -rw-r--r-- | lisp/emacs-lisp/autoload.el | 42 |
1 files changed, 28 insertions, 14 deletions
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." | |||
| 251 | (enable-local-eval nil)) | 251 | (enable-local-eval nil)) |
| 252 | ;; We used to use `raw-text' to read this file, but this causes | 252 | ;; We used to use `raw-text' to read this file, but this causes |
| 253 | ;; problems when the file contains non-ASCII characters. | 253 | ;; problems when the file contains non-ASCII characters. |
| 254 | (let ((delay-mode-hooks t)) | 254 | (let* ((delay-mode-hooks t) |
| 255 | (find-file-noselect | 255 | (file (autoload-generated-file)) |
| 256 | (autoload-ensure-default-file (autoload-generated-file)))))) | 256 | (file-missing (not (file-exists-p file)))) |
| 257 | (when file-missing | ||
| 258 | (autoload-ensure-default-file file)) | ||
| 259 | (with-current-buffer | ||
| 260 | (find-file-noselect | ||
| 261 | (autoload-ensure-file-writeable | ||
| 262 | file)) | ||
| 263 | ;; block backups when the file has just been created, since | ||
| 264 | ;; the backups will just be the auto-generated headers. | ||
| 265 | ;; bug#23203 | ||
| 266 | (when file-missing | ||
| 267 | (setq buffer-backed-up t) | ||
| 268 | (save-buffer)) | ||
| 269 | (current-buffer))))) | ||
| 257 | 270 | ||
| 258 | (defun autoload-generated-file () | 271 | (defun autoload-generated-file () |
| 259 | (expand-file-name generated-autoload-file | 272 | (expand-file-name generated-autoload-file |
| @@ -374,21 +387,22 @@ not be relied upon." | |||
| 374 | ;;;###autoload | 387 | ;;;###autoload |
| 375 | (put 'autoload-ensure-writable 'risky-local-variable t) | 388 | (put 'autoload-ensure-writable 'risky-local-variable t) |
| 376 | 389 | ||
| 390 | (defun autoload-ensure-file-writeable (file) | ||
| 391 | ;; Probably pointless, but replaces the old AUTOGEN_VCS in lisp/Makefile, | ||
| 392 | ;; which was designed to handle CVSREAD=1 and equivalent. | ||
| 393 | (and autoload-ensure-writable | ||
| 394 | (let ((modes (file-modes file))) | ||
| 395 | (if (zerop (logand modes #o0200)) | ||
| 396 | ;; Ignore any errors here, and let subsequent attempts | ||
| 397 | ;; to write the file raise any real error. | ||
| 398 | (ignore-errors (set-file-modes file (logior modes #o0200)))))) | ||
| 399 | file) | ||
| 400 | |||
| 377 | (defun autoload-ensure-default-file (file) | 401 | (defun autoload-ensure-default-file (file) |
| 378 | "Make sure that the autoload file FILE exists, creating it if needed. | 402 | "Make sure that the autoload file FILE exists, creating it if needed. |
| 379 | If the file already exists and `autoload-ensure-writable' is non-nil, | 403 | If the file already exists and `autoload-ensure-writable' is non-nil, |
| 380 | make it writable." | 404 | make it writable." |
| 381 | (if (file-exists-p file) | 405 | (write-region (autoload-rubric file) nil file)) |
| 382 | ;; Probably pointless, but replaces the old AUTOGEN_VCS in lisp/Makefile, | ||
| 383 | ;; which was designed to handle CVSREAD=1 and equivalent. | ||
| 384 | (and autoload-ensure-writable | ||
| 385 | (let ((modes (file-modes file))) | ||
| 386 | (if (zerop (logand modes #o0200)) | ||
| 387 | ;; Ignore any errors here, and let subsequent attempts | ||
| 388 | ;; to write the file raise any real error. | ||
| 389 | (ignore-errors (set-file-modes file (logior modes #o0200)))))) | ||
| 390 | (write-region (autoload-rubric file) nil file)) | ||
| 391 | file) | ||
| 392 | 406 | ||
| 393 | (defun autoload-insert-section-header (outbuf autoloads load-name file time) | 407 | (defun autoload-insert-section-header (outbuf autoloads load-name file time) |
| 394 | "Insert the section-header line, | 408 | "Insert the section-header line, |