summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/autoload.el
diff options
context:
space:
mode:
authorGlenn Morris <rgm@gnu.org>2014-06-30 14:26:34 -0400
committerGlenn Morris <rgm@gnu.org>2014-06-30 14:26:34 -0400
commit0224bf74b28fea8cc64e80390b0210e3909dd81b (patch)
treed8a4e409562bfbc95b5173a8261599639c39981b /lisp/emacs-lisp/autoload.el
parentc6ecf7f23d99a7c51a9372fefb261ddca89a1db2 (diff)
downloademacs-0224bf74b28fea8cc64e80390b0210e3909dd81b.tar.gz
emacs-0224bf74b28fea8cc64e80390b0210e3909dd81b.tar.bz2
emacs-0224bf74b28fea8cc64e80390b0210e3909dd81b.zip
Get rid of the AUTOGEN_VCS variable in lisp/Makefile
* lisp/emacs-lisp/autoload.el (autoload-ensure-writable): New variable. (autoload-ensure-default-file): Maybe make existing output writable. * lisp/Makefile.in (AUTOGEN_VCS): Remove. (autoloads): Use autoload-ensure-writable rather than AUTOGEN_VCS.
Diffstat (limited to 'lisp/emacs-lisp/autoload.el')
-rw-r--r--lisp/emacs-lisp/autoload.el21
1 files changed, 19 insertions, 2 deletions
diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el
index 361e8fa7c68..38956df66de 100644
--- a/lisp/emacs-lisp/autoload.el
+++ b/lisp/emacs-lisp/autoload.el
@@ -351,9 +351,26 @@ not be relied upon."
";;; " basename
" ends here\n")))
+(defvar autoload-ensure-writable nil
+ "Non-nil means `autoload-ensure-default-file' makes existing file writable.")
+;; Just in case someone tries to get you to overwrite a file that you
+;; don't want to.
+;;;###autoload
+(put 'autoload-ensure-writable 'risky-local-variable t)
+
(defun autoload-ensure-default-file (file)
- "Make sure that the autoload file FILE exists and if not create it."
- (unless (file-exists-p 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)