/[emacs]/emacs/lisp/files.el
ViewVC logotype

Diff of /emacs/lisp/files.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.583.2.20 by miles, Thu Sep 16 00:14:58 2004 UTC revision 1.583.2.21 by miles, Wed Oct 6 05:21:52 2004 UTC
# Line 439  specified in a -*- line.") Line 439  specified in a -*- line.")
439    "*Control processing of the \"variable\" `eval' in a file's local variables.    "*Control processing of the \"variable\" `eval' in a file's local variables.
440  The value can be t, nil or something else.  The value can be t, nil or something else.
441  A value of t means obey `eval' variables;  A value of t means obey `eval' variables;
442  nil means ignore them; anything else means query.  nil means ignore them; anything else means query."
   
 The command \\[normal-mode] always obeys local-variables lists  
 and ignores this variable."  
443    :type '(choice (const :tag "Obey" t)    :type '(choice (const :tag "Obey" t)
444                   (const :tag "Ignore" nil)                   (const :tag "Ignore" nil)
445                   (other :tag "Query" other))                   (other :tag "Query" other))
# Line 2110  is specified, returning t if it is speci Line 2107  is specified, returning t if it is speci
2107                                                     buffer-file-name)                                                     buffer-file-name)
2108                                                  (concat "buffer "                                                  (concat "buffer "
2109                                                          (buffer-name))))))))))                                                          (buffer-name))))))))))
2110            (let ((continue t)            (let (prefix prefixlen suffix beg
                 prefix prefixlen suffix beg  
                 mode-specified  
2111                  (enable-local-eval enable-local-eval))                  (enable-local-eval enable-local-eval))
2112              ;; The prefix is what comes before "local variables:" in its line.              ;; The prefix is what comes before "local variables:" in its line.
2113              ;; The suffix is what comes after "local variables:" in its line.              ;; The suffix is what comes after "local variables:" in its line.
# Line 2129  is specified, returning t if it is speci Line 2124  is specified, returning t if it is speci
2124              (if prefix (setq prefixlen (length prefix)              (if prefix (setq prefixlen (length prefix)
2125                               prefix (regexp-quote prefix)))                               prefix (regexp-quote prefix)))
2126              (if suffix (setq suffix (concat (regexp-quote suffix) "$")))              (if suffix (setq suffix (concat (regexp-quote suffix) "$")))
2127              (while continue              (forward-line 1)
2128                ;; Look at next local variable spec.              (let ((startpos (point))
2129                (if selective-display (re-search-forward "[\n\C-m]")                    endpos
2130                  (forward-line 1))                    (thisbuf (current-buffer)))
2131                ;; Skip the prefix, if any.                (save-excursion
2132                (if prefix                  (if (not (re-search-forward
2133                    (if (looking-at prefix)                            (concat (or prefix "")
2134                        (forward-char prefixlen)                                    "[ \t]*End:[ \t]*"
2135                      (error "Local variables entry is missing the prefix")))                                    (or suffix ""))
2136                ;; Find the variable name; strip whitespace.                            nil t))
2137                (skip-chars-forward " \t")                      (error "Local variables list is not properly terminated"))
2138                (setq beg (point))                  (beginning-of-line)
2139                (skip-chars-forward "^:\n")                  (setq endpos (point)))
2140                (if (eolp) (error "Missing colon in local variables entry"))  
2141                (skip-chars-backward " \t")                (with-temp-buffer
2142                (let* ((str (buffer-substring beg (point)))                  (insert-buffer-substring thisbuf startpos endpos)
2143                       (var (read str))                  (goto-char (point-min))
2144                      val)                  (subst-char-in-region (point) (point-max)
2145                  ;; Setting variable named "end" means end of list.                                        ?\^m ?\n)
2146                  (if (string-equal (downcase str) "end")                  (while (not (eobp))
2147                      (setq continue nil)                    ;; Discard the prefix, if any.
2148                    ;; Otherwise read the variable value.                    (if prefix
2149                    (skip-chars-forward "^:")                        (if (looking-at prefix)
2150                    (forward-char 1)                            (delete-region (point) (match-end 0))
2151                    (setq val (read (current-buffer)))                          (error "Local variables entry is missing the prefix")))
2152                    (skip-chars-backward "\n")                    (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.
2163                    (skip-chars-forward " \t")                    (skip-chars-forward " \t")
2164                    (or (if suffix (looking-at suffix) (eolp))                    (setq beg (point))
2165                        (error "Local variables entry is terminated incorrectly"))                    (skip-chars-forward "^:\n")
2166                    (if mode-only                    (if (eolp) (error "Missing colon in local variables entry"))
2167                        (if (eq var 'mode)                    (skip-chars-backward " \t")
2168                            (setq mode-specified t))                    (let* ((str (buffer-substring beg (point)))
2169                      ;; Set the variable.  "Variables" mode and eval are funny.                           (var (read str))
2170                      (hack-one-local-variable var val))))))))                           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)))))))
2182      (unless mode-only      (unless mode-only
2183        (run-hooks 'hack-local-variables-hook))        (run-hooks 'hack-local-variables-hook))
2184      mode-specified))      mode-specified))
2185    
2186  (defvar ignored-local-variables  (defvar ignored-local-variables ()
   '(enable-local-eval)  
2187    "Variables to be ignored in a file's local variable spec.")    "Variables to be ignored in a file's local variable spec.")
2188    
2189  ;; Get confirmation before setting these variables as locals in a file.  ;; Get confirmation before setting these variables as locals in a file.
# Line 2234  is specified, returning t if it is speci Line 2249  is specified, returning t if it is speci
2249  If VAL is nil or omitted, the question is whether any value might be  If VAL is nil or omitted, the question is whether any value might be
2250  dangerous."  dangerous."
2251    (let ((safep (get sym 'safe-local-variable)))    (let ((safep (get sym 'safe-local-variable)))
2252      (or (memq sym ignored-local-variables)      (or (get sym 'risky-local-variable)
         (get sym 'risky-local-variable)  
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$"          (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$"
2254                             (symbol-name sym))                             (symbol-name sym))
2255               (not safep))               (not safep))
# Line 2309  is considered risky." Line 2323  is considered risky."
2323          ((eq var 'coding)          ((eq var 'coding)
2324           ;; We have already handled coding: tag in set-auto-coding.           ;; We have already handled coding: tag in set-auto-coding.
2325           nil)           nil)
2326            ((memq var ignored-local-variables)
2327             nil)
2328          ;; "Setting" eval means either eval it or do nothing.          ;; "Setting" eval means either eval it or do nothing.
2329          ;; Likewise for setting hook variables.          ;; Likewise for setting hook variables.
2330          ((risky-local-variable-p var val)          ((risky-local-variable-p var val)

Legend:
Removed from v.1.583.2.20  
changed lines
  Added in v.1.583.2.21

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26