summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/autoload.el
diff options
context:
space:
mode:
authorKenichi Handa <handa@gnu.org>2014-07-02 00:34:58 +0900
committerKenichi Handa <handa@gnu.org>2014-07-02 00:34:58 +0900
commit763a11d0d0dcf543e89a22c98f55ea07c40ceefa (patch)
tree9ecaec1b8a509a799903926ecd961ab905a1b1bd /lisp/emacs-lisp/autoload.el
parent0782685d43f026b2366dbacbebc79021a9df50c6 (diff)
parenta519335cc3a00f3d4d8efac2c08d9b6b17c7fcf0 (diff)
downloademacs-763a11d0d0dcf543e89a22c98f55ea07c40ceefa.tar.gz
merge trunk
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)