changeset 69361:b15334da7435

* files.el (hack-local-variables-confirm): Don't prompt for ! if enable-local-variables is set to always query, or there is no savable variable.
author Chong Yidong <cyd@stupidchicken.com>
date Fri, 10 Mar 2006 23:22:30 +0000
parents e5e4303f8050
children 29fe34ec2296
files lisp/ChangeLog lisp/files.el
diffstat 2 files changed, 27 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Fri Mar 10 22:52:26 2006 +0000
+++ b/lisp/ChangeLog	Fri Mar 10 23:22:30 2006 +0000
@@ -1,3 +1,9 @@
+2006-03-10  Chong Yidong  <cyd@stupidchicken.com>
+
+	* files.el (hack-local-variables-confirm): Don't prompt for ! if
+	enable-local-variables is set to always query, or there is no
+	savable variable.
+
 2006-03-10  Bill Wohler  <wohler@newt.com>
 
 	* image.el (image-load-path-for-library): Merge at least three
--- a/lisp/files.el	Fri Mar 10 22:52:26 2006 +0000
+++ b/lisp/files.el	Fri Mar 10 23:22:30 2006 +0000
@@ -2349,6 +2349,7 @@
     (let ((name (if buffer-file-name
 		    (file-name-nondirectory buffer-file-name)
 		  (concat "buffer " (buffer-name))))
+	  (offer-save (and (eq enable-local-variables t) unsafe-vars))
 	  prompt char)
       (save-window-excursion
 	(let ((buf (get-buffer-create "*Local Variables*")))
@@ -2367,9 +2368,12 @@
 	      (insert "A local variables list is specified in " name ".")))
 	  (insert "\n\nDo you want to apply it?  You can type
 y  -- to apply the local variables list.
-n  -- to ignore the local variables list.
+n  -- to ignore the local variables list.")
+	  (if offer-save
+	      (insert "
 !  -- to apply the local variables list, and mark these values (*) as
       safe (in the future, they can be set automatically.)\n\n")
+	    (insert "\n\n"))
 	  (dolist (elt vars)
 	    (cond ((member elt unsafe-vars)
 		   (insert "  * "))
@@ -2381,12 +2385,17 @@
 	    (insert " : ")
 	    (princ (cdr elt) buf)
 	    (insert "\n"))
-	  (if (< (line-number-at-pos) (window-body-height))
-	      (setq prompt "Please type y, n, or !: ")
-	    (goto-char (point-min))
-	    (setq prompt "Please type y, n, or !, or C-v to scroll: "))
+	  (setq prompt
+		(format "Please type %s%s: "
+			(if offer-save "y, n, or !" "y or n")
+			(if (< (line-number-at-pos) (window-body-height))
+			    ""
+			  ", or C-v to scroll")))
+	  (goto-char (point-min))
 	  (let ((inhibit-quit t)
 		(cursor-in-echo-area t)
+		(exit-chars
+		 (if offer-save '(?! ?y ?n ?\s ?\C-g) '(?y ?n ?\s ?\C-g)))
 		done)
 	    (while (not done)
 	      (message prompt)
@@ -2396,21 +2405,21 @@
 		      (condition-case nil
 			  (scroll-up)
 			(error (goto-char (point-min))))
-		    (setq done (memq (downcase char)
-				     '(?! ?y ?n ?\s ?\C-g))))))
+		    (setq done (memq (downcase char) exit-chars)))))
 	    (if (= char ?\C-g)
 		(setq quit-flag nil)))
 	  (setq char (downcase char))
-	  (when (and (= char ?!) unsafe-vars)
+	  (when (and offer-save (= char ?!) unsafe-vars)
 	    (dolist (elt unsafe-vars)
 	      (add-to-list 'safe-local-variable-values elt))
 	    ;; When this is called from desktop-restore-file-buffer,
 	    ;; coding-system-for-read may be non-nil.  Reset it before
 	    ;; writing to .emacs.
-	    (let ((coding-system-for-read nil))
-	      (customize-save-variable
-	       'safe-local-variable-values
-	       safe-local-variable-values)))
+	    (if (or custom-file user-init-file)
+		(let ((coding-system-for-read nil))
+		  (customize-save-variable
+		   'safe-local-variable-values
+		   safe-local-variable-values))))
 	  (kill-buffer buf)
 	  (or (= char ?!)
 	      (= char ?\s)