both at the file level and at the levels of the containing directories."
:type 'boolean
:group 'find-file)
+(put 'find-file-visit-truename 'safe-local-variable 'boolean)
(defcustom revert-without-query nil
"*Specify which files should be reverted without query.
(other :tag "Always" t))
:group 'backup
:group 'vc)
+(put 'version-control 'safe-local-variable
+ '(lambda (x) (or (booleanp x) (equal x 'never))))
(defcustom dired-kept-versions 2
"*When cleaning directory, number of versions to keep."
"*Number of oldest versions to keep when a new numbered backup is made."
:type 'integer
:group 'backup)
+(put 'kept-old-versions 'safe-local-variable 'integerp)
(defcustom kept-new-versions 2
"*Number of newest versions to keep when a new numbered backup is made.
Includes the new backup. Must be > 0"
:type 'integer
:group 'backup)
+(put 'kept-new-versions 'safe-local-variable 'integerp)
(defcustom require-final-newline nil
"*Whether to add a newline automatically at the end of the file.
(defcustom enable-local-variables t
"*Control use of local variables in files you visit.
-The value can be t, nil or something else.
+The value can be t, nil, :safe, or something else.
A value of t means file local variables specifications are obeyed
if all the specified variable values are safe; if any values are
not safe, Emacs queries you, once, whether to set them all.
+\(When you say yes to certain values, they are remembered as safe.)
+
+:safe means set the safe variables, and ignore the rest.
+:all means set all variables, whether safe or not.
+ (Don't set it permanently to :all.)
+nil means always ignore the file local variables.
-A value of nil means always ignore the file local variables.
Any other value means always query you once whether to set them all.
+\(When you say yes to certain values, they are remembered as safe, but
+this has no effect when `enable-local-variables' is \"something else\".)
This variable also controls use of major modes specified in
a -*- line.
The command \\[normal-mode], when used interactively,
always obeys file local variable specifications and the -*- line,
and ignores this variable."
- :type '(choice (const :tag "Obey" t)
+ :type '(choice (const :tag "Query Unsafe" t)
+ (const :tag "Safe Only" :safe)
+ (const :tag "Do all" :all)
(const :tag "Ignore" nil)
(other :tag "Query" other))
:group 'find-file)
This function is called automatically from `find-file'. In that case,
we may set up the file-specified mode and local variables,
-depending on the value of `enable-local-variables': if it is t, we do;
-if it is nil, we don't; otherwise, we query.
+depending on the value of `enable-local-variables'.
In addition, if `local-enable-local-variables' is nil, we do
not set local variables (though we do notice a mode specified with -*-.)
("\\.tar\\'" . tar-mode)
;; The list of archive file extensions should be in sync with
;; `auto-coding-alist' with `no-conversion' coding system.
- ("\\.\\(arc\\|zip\\|lzh\\|zoo\\|[jew]ar\\|xpi\\)\\'" . archive-mode)
- ("\\.\\(ARC\\|ZIP\\|LZH\\|ZOO\\|[JEW]AR\\|XPI\\)\\'" . archive-mode)
+ ("\\.\\(arc\\|zip\\|lzh\\|lha\\|zoo\\|[jew]ar\\|xpi\\)\\'" . archive-mode)
+ ("\\.\\(ARC\\|ZIP\\|LZH\\|LHA\\|ZOO\\|[JEW]AR\\|XPI\\)\\'" . archive-mode)
("\\.\\(sx[dmicw]\\|odt\\)\\'" . archive-mode) ; OpenOffice.org
;; Mailer puts message to be edited in
;; /tmp/Re.... or Message
default-text-properties
display-time-string
enable-local-eval
+ enable-local-variables
eval
exec-directory
exec-path
parse-time-rules
process-environment
rmail-output-file-alist
+ safe-local-variable-values
+ safe-local-eval-forms
save-some-buffers-action-alist
special-display-buffer-names
standard-input
;; Safe local variables:
;;
-;; For variables defined by minor modes, put the safety declarations
-;; here, not in the file defining the minor mode (when Emacs visits a
-;; file specifying that local variable, the minor mode file may not be
-;; loaded yet). For variables defined by major modes, the safety
-;; declarations can go into the major mode's file, since that will be
-;; loaded before file variables are processed.
-
-(let ((string-or-null (lambda (a) (or (stringp a) (null a)))))
- (eval
- `(mapc (lambda (pair)
- (put (car pair) 'safe-local-variable (cdr pair)))
- '((byte-compile-dynamic . t)
- (c-basic-offset . integerp)
- (c-file-style . stringp)
- (c-indent-level . integerp)
- (comment-column . integerp)
- (compile-command . ,string-or-null)
- (fill-column . integerp)
- (fill-prefix . ,string-or-null)
- (indent-tabs-mode . t)
- (ispell-check-comments . (lambda (a)
- (memq a '(nil t exclusive))))
- (ispell-local-dictionary . ,string-or-null)
- (kept-new-versions . integerp)
- (no-byte-compile . t)
- (no-update-autoloads . t)
- (outline-regexp . ,string-or-null)
- (page-delimiter . ,string-or-null)
- (paragraph-start . ,string-or-null)
- (paragraph-separate . ,string-or-null)
- (sentence-end . ,string-or-null)
- (sentence-end-double-space . t)
- (tab-width . integerp)
- (truncate-lines . t)
- (version-control . t)))))
+;; For variables defined by major modes, the safety declarations can go into
+;; the major mode's file, since that will be loaded before file variables are
+;; processed.
+;;
+;; For variables defined by minor modes, put the safety declarations in the
+;; file defining the minor mode after the defcustom/defvar using an autoload
+;; cookie, e.g.:
+;;
+;; ;;;###autoload(put 'variable 'safe-local-variable 'stringp)
+;;
+;; Otherwise, when Emacs visits a file specifying that local variable, the
+;; minor mode file may not be loaded yet.
+;;
+;; For variables defined in the C source code the declaration should go here:
+
+;; FIXME: Some variables should be moved according to the rules above.
+(mapc (lambda (pair)
+ (put (car pair) 'safe-local-variable (cdr pair)))
+ '((fill-column . integerp) ;; C source code
+ (indent-tabs-mode . booleanp) ;; C source code
+ (left-margin . integerp) ;; C source code
+ (no-update-autoloads . booleanp)
+ (tab-width . integerp) ;; C source code
+ (truncate-lines . booleanp))) ;; C source code
(put 'c-set-style 'safe-local-eval-function t)
n -- to ignore the local variables list.")
(if offer-save
(insert "
-! -- to apply the local variables list, and mark these values (*) as
- safe (in the future, they can be set automatically.)\n\n")
+! -- to apply the local variables list, and permanently mark these
+ values (*) as safe (in the future, they will be set automatically.)\n\n")
(insert "\n\n"))
(dolist (elt vars)
(cond ((member elt unsafe-vars)
""
", or C-v to scroll")))
(goto-char (point-min))
- (let ((inhibit-quit t)
- (cursor-in-echo-area t)
+ (let ((cursor-in-echo-area t)
(exit-chars
(if offer-save '(?! ?y ?n ?\s ?\C-g) '(?y ?n ?\s ?\C-g)))
done)
(condition-case nil
(scroll-up)
(error (goto-char (point-min))))
- (setq done (memq (downcase char) exit-chars)))))
- (if (= char ?\C-g)
- (setq quit-flag nil)))
+ (setq done (memq (downcase char) exit-chars))))))
(setq char (downcase char))
(when (and offer-save (= char ?!) unsafe-vars)
(dolist (elt unsafe-vars)
(and (risky-local-variable-p var val)
(push elt risky-vars))
(push elt unsafe-vars))))
- (if (or (and (eq enable-local-variables t)
- (null unsafe-vars)
- (null risky-vars))
- (hack-local-variables-confirm
- result unsafe-vars risky-vars))
+ (if (eq enable-local-variables :safe)
+ ;; If caller wants only the safe variables,
+ ;; install only them.
(dolist (elt result)
- (hack-one-local-variable (car elt) (cdr elt)))))
+ (unless (or (memq (car elt) unsafe-vars)
+ (memq (car elt) risky-vars))
+ (hack-one-local-variable (car elt) (cdr elt))))
+ ;; Query, except in the case where all are known safe
+ ;; if the user wants no quuery in that case.
+ (if (or (and (eq enable-local-variables t)
+ (null unsafe-vars)
+ (null risky-vars))
+ (eq enable-local-variables :all)
+ (hack-local-variables-confirm
+ result unsafe-vars risky-vars))
+ (dolist (elt result)
+ (hack-one-local-variable (car elt) (cdr elt))))))
(run-hooks 'hack-local-variables-hook))))))
(defun safe-local-variable-p (sym val)
* There is a matching entry (SYM . VAL) in the
`safe-local-variable-values' user option.
- * The `safe-local-variable' property of SYM is t.
-
* The `safe-local-variable' property of SYM is a function that
evaluates to a non-nil value with VAL as an argument."
(or (member (cons sym val) safe-local-variable-values)
(let ((safep (get sym 'safe-local-variable)))
- (or (eq safep t)
- (and (functionp safep)
- (funcall safep val))))))
+ (and (functionp safep) (funcall safep val)))))
(defun risky-local-variable-p (sym &optional ignored)
"Non-nil if SYM could be dangerous as a file-local variable.
(and (eq (car exp) 'put)
(hack-one-local-variable-quotep (nth 1 exp))
(hack-one-local-variable-quotep (nth 2 exp))
- (memq (nth 1 (nth 2 exp))
- '(lisp-indent-hook))
- ;; Only allow safe values of lisp-indent-hook;
- ;; not functions.
- (or (numberp (nth 3 exp))
- (equal (nth 3 exp) ''defun)))
+ (let ((prop (nth 1 (nth 2 exp))) (val (nth 3 exp)))
+ (cond ((eq prop 'lisp-indent-hook)
+ ;; Only allow safe values of lisp-indent-hook;
+ ;; not functions.
+ (or (numberp val) (equal val ''defun)))
+ ((eq prop 'edebug-form-spec)
+ ;; Only allow indirect form specs.
+ (edebug-basic-spec val)))))
;; Allow expressions that the user requested.
(member exp safe-local-eval-forms)
;; Certain functions can be allowed with safe arguments
time consuming operations.
For more information on how this variable is used by Auto Revert mode,
-see Info node `(emacs-xtra)Supporting additional buffers'.")
+see Info node `(emacs)Supporting additional buffers'.")
(defvar before-revert-hook nil
"Normal hook for `revert-buffer' to run before reverting.
(let ((inhibit-read-only t)
;; Keep the current buffer-file-coding-system.
(coding-system buffer-file-coding-system)
- ;; Auto-saved file shoule be read with special coding.
+ ;; Auto-saved file should be read with special coding.
(coding-system-for-read 'auto-save-coding))
(erase-buffer)
(insert-file-contents file-name nil)