changeset 59311:8a9e4a779eb8

(hack-local-variables): Fix last change.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sun, 02 Jan 2005 18:08:12 +0000
parents aca1aaa26a77
children 945a627eedd9
files lisp/ChangeLog lisp/files.el
diffstat 2 files changed, 84 insertions(+), 80 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Sun Jan 02 17:22:06 2005 +0000
+++ b/lisp/ChangeLog	Sun Jan 02 18:08:12 2005 +0000
@@ -1,3 +1,7 @@
+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.
--- a/lisp/files.el	Sun Jan 02 17:22:06 2005 +0000
+++ b/lisp/files.el	Sun Jan 02 18:08:12 2005 +0000
@@ -2202,86 +2202,86 @@
     (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))
-
-		(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)))))))
+      (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)
+
+	  (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))