Commit 50292b6e authored by Stefan Monnier's avatar Stefan Monnier
Browse files

(hack-local-variables): Fix last change.

parent 731da695
2005-01-02 Stefan <monnier@iro.umontreal.ca>
* files.el (hack-local-variables): Fix last change.
2005-01-02 Jay Belanger <belanger@truman.edu>
 
* calc/calc-yank.el (calc-edit-top): New variable.
......
......@@ -2202,86 +2202,86 @@ is specified, returning t if it is specified."
(save-excursion
(goto-char (point-max))
(search-backward "\n\^L" (max (- (point-max) 3000) (point-min)) 'move)
(if (let ((case-fold-search t))
(and (search-forward "Local Variables:" nil t)
(or (eq enable-local-variables t)
mode-only
(and enable-local-variables
(save-window-excursion
(switch-to-buffer (current-buffer))
(save-excursion
(beginning-of-line)
(set-window-start (selected-window) (point)))
(y-or-n-p (format "Set local variables as specified at end of %s? "
(if buffer-file-name
(file-name-nondirectory
buffer-file-name)
(concat "buffer "
(buffer-name))))))))))
(skip-chars-forward " \t")
(let ((enable-local-eval enable-local-eval)
;; suffix is what comes after "local variables:" in its line.
(suffix
(concat
(regexp-quote (buffer-substring (point) (line-end-position)))
"$"))
;; prefix is what comes before "local variables:" in its line.
(prefix
(concat "^" (regexp-quote
(buffer-substring (line-beginning-position)
(match-beginning 0)))))
beg)
(forward-line 1)
(let ((startpos (point))
endpos
(thisbuf (current-buffer)))
(save-excursion
(if (not (re-search-forward
(concat prefix "[ \t]*End:[ \t]*" suffix)
nil t))
(error "Local variables list is not properly terminated"))
(beginning-of-line)
(setq endpos (point)))
(with-temp-buffer
(insert-buffer-substring thisbuf startpos endpos)
(goto-char (point-min))
(subst-char-in-region (point) (point-max) ?\^m ?\n)
(while (not (eobp))
;; Discard the prefix.
(if (looking-at prefix)
(delete-region (point) (match-end 0))
(error "Local variables entry is missing the prefix"))
(end-of-line)
;; Discard the suffix.
(if (looking-back suffix)
(delete-region (match-beginning 0) (point))
(error "Local variables entry is missing the suffix"))
(forward-line 1))
(goto-char (point-min))
(when (let ((case-fold-search t))
(and (search-forward "Local Variables:" nil t)
(or (eq enable-local-variables t)
mode-only
(and enable-local-variables
(save-window-excursion
(switch-to-buffer (current-buffer))
(save-excursion
(beginning-of-line)
(set-window-start (selected-window) (point)))
(y-or-n-p (format "Set local variables as specified at end of %s? "
(if buffer-file-name
(file-name-nondirectory
buffer-file-name)
(concat "buffer "
(buffer-name))))))))))
(skip-chars-forward " \t")
(let ((enable-local-eval enable-local-eval)
;; suffix is what comes after "local variables:" in its line.
(suffix
(concat
(regexp-quote (buffer-substring (point) (line-end-position)))
"$"))
;; prefix is what comes before "local variables:" in its line.
(prefix
(concat "^" (regexp-quote
(buffer-substring (line-beginning-position)
(match-beginning 0)))))
beg)
(while (not (eobp))
;; Find the variable name; strip whitespace.
(skip-chars-forward " \t")
(setq beg (point))
(skip-chars-forward "^:\n")
(if (eolp) (error "Missing colon in local variables entry"))
(skip-chars-backward " \t")
(let* ((str (buffer-substring beg (point)))
(var (read str))
val)
;; Read the variable value.
(skip-chars-forward "^:")
(forward-char 1)
(setq val (read (current-buffer)))
(if mode-only
(if (eq var 'mode)
(setq mode-specified t))
;; Set the variable. "Variables" mode and eval are funny.
(with-current-buffer thisbuf
(hack-one-local-variable var val))))
(forward-line 1)))))))
(forward-line 1)
(let ((startpos (point))
endpos
(thisbuf (current-buffer)))
(save-excursion
(if (not (re-search-forward
(concat prefix "[ \t]*End:[ \t]*" suffix)
nil t))
(error "Local variables list is not properly terminated"))
(beginning-of-line)
(setq endpos (point)))
(with-temp-buffer
(insert-buffer-substring thisbuf startpos endpos)
(goto-char (point-min))
(subst-char-in-region (point) (point-max) ?\^m ?\n)
(while (not (eobp))
;; Discard the prefix.
(if (looking-at prefix)
(delete-region (point) (match-end 0))
(error "Local variables entry is missing the prefix"))
(end-of-line)
;; Discard the suffix.
(if (looking-back suffix)
(delete-region (match-beginning 0) (point))
(error "Local variables entry is missing the suffix"))
(forward-line 1))
(goto-char (point-min))
(while (not (eobp))
;; Find the variable name; strip whitespace.
(skip-chars-forward " \t")
(setq beg (point))
(skip-chars-forward "^:\n")
(if (eolp) (error "Missing colon in local variables entry"))
(skip-chars-backward " \t")
(let* ((str (buffer-substring beg (point)))
(var (read str))
val)
;; Read the variable value.
(skip-chars-forward "^:")
(forward-char 1)
(setq val (read (current-buffer)))
(if mode-only
(if (eq var 'mode)
(setq mode-specified t))
;; Set the variable. "Variables" mode and eval are funny.
(with-current-buffer thisbuf
(hack-one-local-variable var val))))
(forward-line 1)))))))
(unless mode-only
(run-hooks 'hack-local-variables-hook))
mode-specified))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment