aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhillip Lord2016-04-08 16:22:44 +0100
committerPhillip Lord2016-04-12 12:45:33 +0100
commitc23c965bb9d0a4bcc1b6158833ff99aa20fd53e9 (patch)
treee4d70da471a811b43d13843948779e5eba539084
parent9344612d3cd164317170b6189ec43175757e4231 (diff)
downloademacs-c23c965bb9d0a4bcc1b6158833ff99aa20fd53e9.tar.gz
emacs-c23c965bb9d0a4bcc1b6158833ff99aa20fd53e9.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.el42
1 files changed, 28 insertions, 14 deletions
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."
234 (enable-local-eval nil)) 234 (enable-local-eval nil))
235 ;; We used to use `raw-text' to read this file, but this causes 235 ;; We used to use `raw-text' to read this file, but this causes
236 ;; problems when the file contains non-ASCII characters. 236 ;; problems when the file contains non-ASCII characters.
237 (let ((delay-mode-hooks t)) 237 (let* ((delay-mode-hooks t)
238 (find-file-noselect 238 (file (autoload-generated-file))
239 (autoload-ensure-default-file (autoload-generated-file)))))) 239 (file-missing (not (file-exists-p file))))
240 (when file-missing
241 (autoload-ensure-default-file file))
242 (with-current-buffer
243 (find-file-noselect
244 (autoload-ensure-file-writeable
245 file))
246 ;; block backups when the file has just been created, since
247 ;; the backups will just be the auto-generated headers.
248 ;; bug#23203
249 (when file-missing
250 (setq buffer-backed-up t)
251 (save-buffer))
252 (current-buffer)))))
240 253
241(defun autoload-generated-file () 254(defun autoload-generated-file ()
242 (expand-file-name generated-autoload-file 255 (expand-file-name generated-autoload-file
@@ -357,21 +370,22 @@ not be relied upon."
357;;;###autoload 370;;;###autoload
358(put 'autoload-ensure-writable 'risky-local-variable t) 371(put 'autoload-ensure-writable 'risky-local-variable t)
359 372
373(defun autoload-ensure-file-writeable (file)
374 ;; Probably pointless, but replaces the old AUTOGEN_VCS in lisp/Makefile,
375 ;; which was designed to handle CVSREAD=1 and equivalent.
376 (and autoload-ensure-writable
377 (let ((modes (file-modes file)))
378 (if (zerop (logand modes #o0200))
379 ;; Ignore any errors here, and let subsequent attempts
380 ;; to write the file raise any real error.
381 (ignore-errors (set-file-modes file (logior modes #o0200))))))
382 file)
383
360(defun autoload-ensure-default-file (file) 384(defun autoload-ensure-default-file (file)
361 "Make sure that the autoload file FILE exists, creating it if needed. 385 "Make sure that the autoload file FILE exists, creating it if needed.
362If the file already exists and `autoload-ensure-writable' is non-nil, 386If the file already exists and `autoload-ensure-writable' is non-nil,
363make it writable." 387make it writable."
364 (if (file-exists-p file) 388 (write-region (autoload-rubric file) nil file))
365 ;; Probably pointless, but replaces the old AUTOGEN_VCS in lisp/Makefile,
366 ;; which was designed to handle CVSREAD=1 and equivalent.
367 (and autoload-ensure-writable
368 (let ((modes (file-modes file)))
369 (if (zerop (logand modes #o0200))
370 ;; Ignore any errors here, and let subsequent attempts
371 ;; to write the file raise any real error.
372 (ignore-errors (set-file-modes file (logior modes #o0200))))))
373 (write-region (autoload-rubric file) nil file))
374 file)
375 389
376(defun autoload-insert-section-header (outbuf autoloads load-name file time) 390(defun autoload-insert-section-header (outbuf autoloads load-name file time)
377 "Insert the section-header line, 391 "Insert the section-header line,