aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorChong Yidong2006-02-17 15:33:22 +0000
committerChong Yidong2006-02-17 15:33:22 +0000
commitb9e1451a3d0381455c862b8baebcc0aa965daa1f (patch)
treefd45a27f4080ee6fe148d6dd4c09d334dea13348 /lisp
parent5bf3610f7cb85b7b88762e431d7715d968b0c710 (diff)
downloademacs-b9e1451a3d0381455c862b8baebcc0aa965daa1f.tar.gz
emacs-b9e1451a3d0381455c862b8baebcc0aa965daa1f.zip
* files.el: Rearrange functions and variables in the file local
variables section.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/files.el239
2 files changed, 128 insertions, 116 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 68b5f0af4f3..39ddc63fb78 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12006-02-17 Chong Yidong <cyd@stupidchicken.com>
2
3 * files.el: Rearrange functions and variables in the file local
4 variables section.
5
12006-02-17 Reiner Steib <Reiner.Steib@gmx.de> 62006-02-17 Reiner Steib <Reiner.Steib@gmx.de>
2 7
3 * files.el: Add truncate-lines, ispell-check-comments and 8 * files.el: Add truncate-lines, ispell-check-comments and
diff --git a/lisp/files.el b/lisp/files.el
index 464d9854e7f..945a2ef9855 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -2218,6 +2218,129 @@ Otherwise, return nil; point may be changed."
2218 (setq end (point)) 2218 (setq end (point))
2219 (goto-char beg) 2219 (goto-char beg)
2220 end)))) 2220 end))))
2221
2222;;; Handling file local variables
2223
2224(defvar ignored-local-variables
2225 '(ignored-local-variables safe-local-variable-values)
2226 "Variables to be ignored in a file's local variable spec.")
2227
2228(defvar hack-local-variables-hook nil
2229 "Normal hook run after processing a file's local variables specs.
2230Major modes can use this to examine user-specified local variables
2231in order to initialize other data structure based on them.")
2232
2233(defcustom safe-local-variable-values nil
2234 "List variable-value pairs that are considered safe.
2235Each element is a cons cell (VAR . VAL), where VAR is a variable
2236symbol and VAL is a value that is considered safe."
2237 :group 'find-file
2238 :type 'alist)
2239
2240(defcustom safe-local-eval-forms nil
2241 "*Expressions that are considered safe in an `eval:' local variable.
2242Add expressions to this list if you want Emacs to evaluate them, when
2243they appear in an `eval' local variable specification, without first
2244asking you for confirmation."
2245 :group 'find-file
2246 :version "22.1"
2247 :type '(repeat sexp))
2248
2249;; Risky local variables:
2250(mapc (lambda (var) (put var 'risky-local-variable t))
2251 '(after-load-alist
2252 auto-mode-alist
2253 buffer-auto-save-file-name
2254 buffer-file-name
2255 buffer-file-truename
2256 buffer-undo-list
2257 dabbrev-case-fold-search
2258 dabbrev-case-replace
2259 debugger
2260 default-text-properties
2261 display-time-string
2262 enable-local-eval
2263 eval
2264 exec-directory
2265 exec-path
2266 file-name-handler-alist
2267 font-lock-defaults
2268 format-alist
2269 frame-title-format
2270 global-mode-string
2271 header-line-format
2272 icon-title-format
2273 ignored-local-variables
2274 imenu--index-alist
2275 imenu-generic-expression
2276 inhibit-quit
2277 input-method-alist
2278 load-path
2279 max-lisp-eval-depth
2280 max-specpdl-size
2281 minor-mode-alist
2282 minor-mode-map-alist
2283 minor-mode-overriding-map-alist
2284 mode-line-buffer-identification
2285 mode-line-format
2286 mode-line-modes
2287 mode-line-modified
2288 mode-line-mule-info
2289 mode-line-position
2290 mode-line-process
2291 mode-name
2292 outline-level
2293 overriding-local-map
2294 overriding-terminal-local-map
2295 parse-time-rules
2296 process-environment
2297 rmail-output-file-alist
2298 save-some-buffers-action-alist
2299 special-display-buffer-names
2300 standard-input
2301 standard-output
2302 unread-command-events
2303 vc-mode))
2304
2305;; Safe local variables:
2306;;
2307;; For variables defined by minor modes, put the safety declarations
2308;; here, not in the file defining the minor mode (when Emacs visits a
2309;; file specifying that local variable, the minor mode file may not be
2310;; loaded yet). For variables defined by major modes, the safety
2311;; declarations can go into the major mode's file, since that will be
2312;; loaded before file variables are processed.
2313
2314(let ((string-or-null (lambda (a) (or (stringp a) (null a)))))
2315 (eval
2316 `(mapc (lambda (pair)
2317 (put (car pair) 'safe-local-variable (cdr pair)))
2318 '((byte-compile-dynamic . t)
2319 (c-basic-offset . integerp)
2320 (c-file-style . stringp)
2321 (c-indent-level . integerp)
2322 (comment-column . integerp)
2323 (compile-command . ,string-or-null)
2324 (fill-column . integerp)
2325 (fill-prefix . ,string-or-null)
2326 (indent-tabs-mode . t)
2327 (ispell-check-comments . (lambda (a)
2328 (memq a '(nil t exclusive))))
2329 (ispell-local-dictionary . ,string-or-null)
2330 (kept-new-versions . integerp)
2331 (no-byte-compile . t)
2332 (no-update-autoloads . t)
2333 (outline-regexp . ,string-or-null)
2334 (page-delimiter . ,string-or-null)
2335 (paragraph-start . ,string-or-null)
2336 (paragraph-separate . ,string-or-null)
2337 (sentence-end . ,string-or-null)
2338 (sentence-end-double-space . t)
2339 (tab-width . integerp)
2340 (truncate-lines . t)
2341 (version-control . t)))))
2342
2343(put 'c-set-style 'safe-local-eval-function t)
2221 2344
2222(defun hack-local-variables-confirm (vars unsafe-vars risky-vars) 2345(defun hack-local-variables-confirm (vars unsafe-vars risky-vars)
2223 (if noninteractive 2346 (if noninteractive
@@ -2346,18 +2469,6 @@ and VAL is the specified value."
2346 mode-specified 2469 mode-specified
2347 result)))) 2470 result))))
2348 2471
2349(defvar hack-local-variables-hook nil
2350 "Normal hook run after processing a file's local variables specs.
2351Major modes can use this to examine user-specified local variables
2352in order to initialize other data structure based on them.")
2353
2354(defcustom safe-local-variable-values nil
2355 "List variable-value pairs that are considered safe.
2356Each element is a cons cell (VAR . VAL), where VAR is a variable
2357symbol and VAL is a value that is considered safe."
2358 :group 'find-file
2359 :type 'alist)
2360
2361(defun hack-local-variables (&optional mode-only) 2472(defun hack-local-variables (&optional mode-only)
2362 "Parse and put into effect this buffer's local variables spec. 2473 "Parse and put into effect this buffer's local variables spec.
2363If MODE-ONLY is non-nil, all we do is check whether the major mode 2474If MODE-ONLY is non-nil, all we do is check whether the major mode
@@ -2479,98 +2590,6 @@ is specified, returning t if it is specified."
2479 (hack-one-local-variable (car elt) (cdr elt))))) 2590 (hack-one-local-variable (car elt) (cdr elt)))))
2480 (run-hooks 'hack-local-variables-hook)))))) 2591 (run-hooks 'hack-local-variables-hook))))))
2481 2592
2482(defvar ignored-local-variables
2483 '(ignored-local-variables safe-local-variable-values)
2484 "Variables to be ignored in a file's local variable spec.")
2485
2486;; Get confirmation before setting these variables as locals in a file.
2487(put 'debugger 'risky-local-variable t)
2488(put 'enable-local-eval 'risky-local-variable t)
2489(put 'ignored-local-variables 'risky-local-variable t)
2490(put 'ignored-local-variables 'safe-local-variable-values t)
2491(put 'eval 'risky-local-variable t)
2492(put 'file-name-handler-alist 'risky-local-variable t)
2493(put 'inhibit-quit 'risky-local-variable t)
2494(put 'minor-mode-alist 'risky-local-variable t)
2495(put 'minor-mode-map-alist 'risky-local-variable t)
2496(put 'minor-mode-overriding-map-alist 'risky-local-variable t)
2497(put 'overriding-local-map 'risky-local-variable t)
2498(put 'overriding-terminal-local-map 'risky-local-variable t)
2499(put 'auto-mode-alist 'risky-local-variable t)
2500(put 'after-load-alist 'risky-local-variable t)
2501(put 'buffer-file-name 'risky-local-variable t)
2502(put 'buffer-undo-list 'risky-local-variable t)
2503(put 'buffer-auto-save-file-name 'risky-local-variable t)
2504(put 'buffer-file-truename 'risky-local-variable t)
2505(put 'default-text-properties 'risky-local-variable t)
2506(put 'exec-path 'risky-local-variable t)
2507(put 'load-path 'risky-local-variable t)
2508(put 'exec-directory 'risky-local-variable t)
2509(put 'process-environment 'risky-local-variable t)
2510(put 'dabbrev-case-fold-search 'risky-local-variable t)
2511(put 'dabbrev-case-replace 'risky-local-variable t)
2512;; Don't wait for outline.el to be loaded, for the sake of outline-minor-mode.
2513(put 'outline-level 'risky-local-variable t)
2514(put 'rmail-output-file-alist 'risky-local-variable t)
2515(put 'font-lock-defaults 'risky-local-variable t)
2516(put 'special-display-buffer-names 'risky-local-variable t)
2517(put 'frame-title-format 'risky-local-variable t)
2518(put 'global-mode-string 'risky-local-variable t)
2519(put 'header-line-format 'risky-local-variable t)
2520(put 'icon-title-format 'risky-local-variable t)
2521(put 'input-method-alist 'risky-local-variable t)
2522(put 'format-alist 'risky-local-variable t)
2523(put 'vc-mode 'risky-local-variable t)
2524(put 'imenu-generic-expression 'risky-local-variable t)
2525(put 'imenu--index-alist 'risky-local-variable t)
2526(put 'standard-input 'risky-local-variable t)
2527(put 'standard-output 'risky-local-variable t)
2528(put 'unread-command-events 'risky-local-variable t)
2529(put 'max-lisp-eval-depth 'risky-local-variable t)
2530(put 'max-specpdl-size 'risky-local-variable t)
2531(put 'mode-line-format 'risky-local-variable t)
2532(put 'mode-line-modified 'risky-local-variable t)
2533(put 'mode-line-mule-info 'risky-local-variable t)
2534(put 'mode-line-buffer-identification 'risky-local-variable t)
2535(put 'mode-line-modes 'risky-local-variable t)
2536(put 'mode-line-position 'risky-local-variable t)
2537(put 'mode-line-process 'risky-local-variable t)
2538(put 'mode-name 'risky-local-variable t)
2539(put 'display-time-string 'risky-local-variable t)
2540(put 'parse-time-rules 'risky-local-variable t)
2541
2542;; Commonly-encountered local variables that are safe:
2543(let ((string-or-null (lambda (a) (or (stringp a) (null a)))))
2544 (eval
2545 `(mapc (lambda (pair)
2546 (put (car pair) 'safe-local-variable (cdr pair)))
2547 '((byte-compile-dynamic . t)
2548 (c-basic-offset . integerp)
2549 (c-file-style . stringp)
2550 (c-indent-level . integerp)
2551 (comment-column . integerp)
2552 (compile-command . ,string-or-null)
2553 (fill-column . integerp)
2554 (fill-prefix . ,string-or-null)
2555 (indent-tabs-mode . t)
2556 (ispell-check-comments . (lambda (a)
2557 (or (null a)
2558 (eq t a)
2559 (eq 'exclusive a))))
2560 (ispell-local-dictionary . ,string-or-null)
2561 (kept-new-versions . integerp)
2562 (no-byte-compile . t)
2563 (no-update-autoloads . t)
2564 (outline-regexp . ,string-or-null)
2565 (page-delimiter . ,string-or-null)
2566 (paragraph-start . ,string-or-null)
2567 (paragraph-separate . ,string-or-null)
2568 (sentence-end . ,string-or-null)
2569 (sentence-end-double-space . t)
2570 (tab-width . integerp)
2571 (truncate-lines . t)
2572 (version-control . t)))))
2573
2574(defun safe-local-variable-p (sym val) 2593(defun safe-local-variable-p (sym val)
2575 "Non-nil if SYM is safe as a file-local variable with value VAL. 2594 "Non-nil if SYM is safe as a file-local variable with value VAL.
2576It is safe if any of these conditions are met: 2595It is safe if any of these conditions are met:
@@ -2608,17 +2627,6 @@ It is dangerous if either of these conditions are met:
2608-[0-9]+$\\|font-lock-syntactic-keywords$\\|-frame-alist$\\|-mode-alist$\\|\ 2627-[0-9]+$\\|font-lock-syntactic-keywords$\\|-frame-alist$\\|-mode-alist$\\|\
2609-map$\\|-map-alist$" (symbol-name sym)))) 2628-map$\\|-map-alist$" (symbol-name sym))))
2610 2629
2611(defcustom safe-local-eval-forms nil
2612 "*Expressions that are considered \"safe\" in an `eval:' local variable.
2613Add expressions to this list if you want Emacs to evaluate them, when
2614they appear in an `eval' local variable specification, without first
2615asking you for confirmation."
2616 :group 'find-file
2617 :version "22.1"
2618 :type '(repeat sexp))
2619
2620(put 'c-set-style 'safe-local-eval-function t)
2621
2622(defun hack-one-local-variable-quotep (exp) 2630(defun hack-one-local-variable-quotep (exp)
2623 (and (consp exp) (eq (car exp) 'quote) (consp (cdr exp)))) 2631 (and (consp exp) (eq (car exp) 'quote) (consp (cdr exp))))
2624 2632
@@ -3636,7 +3644,6 @@ This requires the external program `diff' to be in your `exec-path'."
3636 (?d diff-buffer-with-file 3644 (?d diff-buffer-with-file
3637 "view changes in file")) 3645 "view changes in file"))
3638 "ACTION-ALIST argument used in call to `map-y-or-n-p'.") 3646 "ACTION-ALIST argument used in call to `map-y-or-n-p'.")
3639(put 'save-some-buffers-action-alist 'risky-local-variable t)
3640 3647
3641(defvar buffer-save-without-query nil 3648(defvar buffer-save-without-query nil
3642 "Non-nil means `save-some-buffers' should save this buffer without asking.") 3649 "Non-nil means `save-some-buffers' should save this buffer without asking.")