aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2004-09-20 16:12:57 +0000
committerRichard M. Stallman2004-09-20 16:12:57 +0000
commite0b2a2d9afff14ce5babae84c50f24f1f0e89b02 (patch)
tree0a07d156bef202acecd983104f54357de911b360
parent1d1c5af904afe595cee12cd6c05e60694111cce5 (diff)
downloademacs-e0b2a2d9afff14ce5babae84c50f24f1f0e89b02.tar.gz
emacs-e0b2a2d9afff14ce5babae84c50f24f1f0e89b02.zip
(enable-local-eval): Doc fix.
(hack-local-variables): Copy the variables list to another buffer, strip prefixes and suffixes there, then read. (enable-local-eval): Doc fix. (ignored-local-variables): Initialize to nil. (risky-local-variable-p): Don't check ignored-local-variables here. (hack-one-local-variable): Ignore var if in ignored-local-variables.
-rw-r--r--lisp/files.el104
1 files changed, 60 insertions, 44 deletions
diff --git a/lisp/files.el b/lisp/files.el
index 2628ce2ee3d..994422fe710 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -439,10 +439,7 @@ specified in a -*- line.")
439 "*Control processing of the \"variable\" `eval' in a file's local variables. 439 "*Control processing of the \"variable\" `eval' in a file's local variables.
440The value can be t, nil or something else. 440The value can be t, nil or something else.
441A value of t means obey `eval' variables; 441A value of t means obey `eval' variables;
442nil means ignore them; anything else means query. 442nil means ignore them; anything else means query."
443
444The command \\[normal-mode] always obeys local-variables lists
445and ignores this variable."
446 :type '(choice (const :tag "Obey" t) 443 :type '(choice (const :tag "Obey" t)
447 (const :tag "Ignore" nil) 444 (const :tag "Ignore" nil)
448 (other :tag "Query" other)) 445 (other :tag "Query" other))
@@ -2110,9 +2107,7 @@ is specified, returning t if it is specified."
2110 buffer-file-name) 2107 buffer-file-name)
2111 (concat "buffer " 2108 (concat "buffer "
2112 (buffer-name)))))))))) 2109 (buffer-name))))))))))
2113 (let ((continue t) 2110 (let (prefix prefixlen suffix beg
2114 prefix prefixlen suffix beg
2115 mode-specified
2116 (enable-local-eval enable-local-eval)) 2111 (enable-local-eval enable-local-eval))
2117 ;; The prefix is what comes before "local variables:" in its line. 2112 ;; The prefix is what comes before "local variables:" in its line.
2118 ;; The suffix is what comes after "local variables:" in its line. 2113 ;; The suffix is what comes after "local variables:" in its line.
@@ -2129,46 +2124,66 @@ is specified, returning t if it is specified."
2129 (if prefix (setq prefixlen (length prefix) 2124 (if prefix (setq prefixlen (length prefix)
2130 prefix (regexp-quote prefix))) 2125 prefix (regexp-quote prefix)))
2131 (if suffix (setq suffix (concat (regexp-quote suffix) "$"))) 2126 (if suffix (setq suffix (concat (regexp-quote suffix) "$")))
2132 (while continue 2127 (forward-line 1)
2133 ;; Look at next local variable spec. 2128 (let ((startpos (point))
2134 (if selective-display (re-search-forward "[\n\C-m]") 2129 endpos
2135 (forward-line 1)) 2130 (thisbuf (current-buffer)))
2136 ;; Skip the prefix, if any. 2131 (save-excursion
2137 (if prefix 2132 (if (not (re-search-forward
2138 (if (looking-at prefix) 2133 (concat (or prefix "")
2139 (forward-char prefixlen) 2134 "[ \t]*End:[ \t]*"
2140 (error "Local variables entry is missing the prefix"))) 2135 (or suffix ""))
2141 ;; Find the variable name; strip whitespace. 2136 nil t))
2142 (skip-chars-forward " \t") 2137 (error "Local variables list is not properly terminated"))
2143 (setq beg (point)) 2138 (beginning-of-line)
2144 (skip-chars-forward "^:\n") 2139 (setq endpos (point)))
2145 (if (eolp) (error "Missing colon in local variables entry")) 2140
2146 (skip-chars-backward " \t") 2141 (with-temp-buffer
2147 (let* ((str (buffer-substring beg (point))) 2142 (insert-buffer-substring thisbuf startpos endpos)
2148 (var (read str)) 2143 (goto-char (point-min))
2149 val) 2144 (subst-char-in-region (point) (point-max)
2150 ;; Setting variable named "end" means end of list. 2145 ?\^m ?\n)
2151 (if (string-equal (downcase str) "end") 2146 (while (not (eobp))
2152 (setq continue nil) 2147 ;; Discard the prefix, if any.
2153 ;; Otherwise read the variable value. 2148 (if prefix
2154 (skip-chars-forward "^:") 2149 (if (looking-at prefix)
2155 (forward-char 1) 2150 (delete-region (point) (match-end 0))
2156 (setq val (read (current-buffer))) 2151 (error "Local variables entry is missing the prefix")))
2157 (skip-chars-backward "\n") 2152 (end-of-line)
2153 ;; Discard the suffix, if any.
2154 (if suffix
2155 (if (looking-back suffix)
2156 (delete-region (match-beginning 0) (point))
2157 (error "Local variables entry is missing the suffix")))
2158 (forward-line 1))
2159 (goto-char (point-min))
2160
2161 (while (not (eobp))
2162 ;; Find the variable name; strip whitespace.
2158 (skip-chars-forward " \t") 2163 (skip-chars-forward " \t")
2159 (or (if suffix (looking-at suffix) (eolp)) 2164 (setq beg (point))
2160 (error "Local variables entry is terminated incorrectly")) 2165 (skip-chars-forward "^:\n")
2161 (if mode-only 2166 (if (eolp) (error "Missing colon in local variables entry"))
2162 (if (eq var 'mode) 2167 (skip-chars-backward " \t")
2163 (setq mode-specified t)) 2168 (let* ((str (buffer-substring beg (point)))
2164 ;; Set the variable. "Variables" mode and eval are funny. 2169 (var (read str))
2165 (hack-one-local-variable var val)))))))) 2170 val)
2171 ;; Read the variable value.
2172 (skip-chars-forward "^:")
2173 (forward-char 1)
2174 (setq val (read (current-buffer)))
2175 (if mode-only
2176 (if (eq var 'mode)
2177 (setq mode-specified t))
2178 ;; Set the variable. "Variables" mode and eval are funny.
2179 (with-current-buffer thisbuf
2180 (hack-one-local-variable var val))))
2181 (forward-line 1)))))))
2166 (unless mode-only 2182 (unless mode-only
2167 (run-hooks 'hack-local-variables-hook)) 2183 (run-hooks 'hack-local-variables-hook))
2168 mode-specified)) 2184 mode-specified))
2169 2185
2170(defvar ignored-local-variables 2186(defvar ignored-local-variables ()
2171 '(enable-local-eval)
2172 "Variables to be ignored in a file's local variable spec.") 2187 "Variables to be ignored in a file's local variable spec.")
2173 2188
2174;; Get confirmation before setting these variables as locals in a file. 2189;; Get confirmation before setting these variables as locals in a file.
@@ -2234,8 +2249,7 @@ is specified, returning t if it is specified."
2234If VAL is nil or omitted, the question is whether any value might be 2249If VAL is nil or omitted, the question is whether any value might be
2235dangerous." 2250dangerous."
2236 (let ((safep (get sym 'safe-local-variable))) 2251 (let ((safep (get sym 'safe-local-variable)))
2237 (or (memq sym ignored-local-variables) 2252 (or (get sym 'risky-local-variable)
2238 (get sym 'risky-local-variable)
2239 (and (string-match "-hooks?$\\|-functions?$\\|-forms?$\\|-program$\\|-command$\\|-predicate$\\|font-lock-keywords$\\|font-lock-keywords-[0-9]+$\\|font-lock-syntactic-keywords$\\|-frame-alist$\\|-mode-alist$\\|-map$\\|-map-alist$" 2253 (and (string-match "-hooks?$\\|-functions?$\\|-forms?$\\|-program$\\|-command$\\|-predicate$\\|font-lock-keywords$\\|font-lock-keywords-[0-9]+$\\|font-lock-syntactic-keywords$\\|-frame-alist$\\|-mode-alist$\\|-map$\\|-map-alist$"
2240 (symbol-name sym)) 2254 (symbol-name sym))
2241 (not safep)) 2255 (not safep))
@@ -2309,6 +2323,8 @@ is considered risky."
2309 ((eq var 'coding) 2323 ((eq var 'coding)
2310 ;; We have already handled coding: tag in set-auto-coding. 2324 ;; We have already handled coding: tag in set-auto-coding.
2311 nil) 2325 nil)
2326 ((memq var ignored-local-variables)
2327 nil)
2312 ;; "Setting" eval means either eval it or do nothing. 2328 ;; "Setting" eval means either eval it or do nothing.
2313 ;; Likewise for setting hook variables. 2329 ;; Likewise for setting hook variables.
2314 ((risky-local-variable-p var val) 2330 ((risky-local-variable-p var val)