changeset 68907:b596dc11d441

* files.el (hack-local-variables-confirm): Allow scrolling if the file variable list is too long.
author Chong Yidong <cyd@stupidchicken.com>
date Wed, 15 Feb 2006 01:21:31 +0000
parents 53503f63cc05
children 7d7207d65934
files lisp/ChangeLog lisp/files.el
diffstat 2 files changed, 55 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Wed Feb 15 01:05:41 2006 +0000
+++ b/lisp/ChangeLog	Wed Feb 15 01:21:31 2006 +0000
@@ -1,3 +1,8 @@
+2006-02-14  Chong Yidong  <cyd@stupidchicken.com>
+
+	* files.el (hack-local-variables-confirm): Allow scrolling if the
+	file variable list is too long.
+
 2006-02-15  Nick Roberts  <nickrob@snap.net.nz>
 
 	* progmodes/gud.el (gdb): Improve doc string.
--- a/lisp/files.el	Wed Feb 15 01:05:41 2006 +0000
+++ b/lisp/files.el	Wed Feb 15 01:21:31 2006 +0000
@@ -2227,56 +2227,66 @@
 		  (concat "buffer " (buffer-name))))
 	  char)
       (save-window-excursion
-	(with-output-to-temp-buffer "*Local Variables*"
+	(let ((buf (get-buffer-create "*Local Variables*"))
+	      (prompt))
+	  (pop-to-buffer buf)
+	  (set (make-local-variable 'cursor-type) nil)
+	  (erase-buffer)
 	  (if unsafe-vars
-	      (progn (princ "The local variables list in ")
-		     (princ name)
-		     (princ "\ncontains values that may not be safe (*)")
-		     (if risky-vars
-			 (princ ", and variables that are risky (**).")
-		       (princ ".")))
+	      (insert "The local variables list in " name
+		      "\ncontains values that may not be safe (*)"
+		      (if risky-vars
+			  ", and variables that are risky (**)."
+			"."))
 	    (if risky-vars
-		(progn (princ "The local variables list in ")
-		       (princ name)
-		       (princ "\ncontains variables that are risky (**)."))
-	      (princ "A local variables list is specified in ")
-	      (princ name)
-	      (princ ".")))
-	  (princ "\n\nDo you want to apply it?  You can type
+		(insert "The local variables list in " name
+			"\ncontains variables that are risky (**).")
+	      (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.
 !  -- to apply the local variables list, and mark these values (*) as
       safe (in the future, they can be set automatically.)\n\n")
 	  (dolist (elt vars)
 	    (cond ((member elt unsafe-vars)
-		   (princ "  * "))
+		   (insert "  * "))
 		  ((member elt risky-vars)
-		   (princ " ** "))
+		   (insert " ** "))
 		  (t
-		   (princ "    ")))
-	    (princ (car elt))
-	    (princ " : ")
-	    (princ (cdr elt))
-	    (princ "\n")))
-	(message "Please type y, n, or !: ")
-	(let ((inhibit-quit t)
-	      (cursor-in-echo-area t))
-	  (while (or (not (numberp (setq char (read-event))))
-		     (not (memq (downcase char)
-				'(?! ?y ?n ?\s ?\C-g))))
-	    (message "Please type y, n, or !: "))
-	  (if (= char ?\C-g)
-	      (setq quit-flag nil)))
-	(setq char (downcase char))
-	(when (and (= char ?!) unsafe-vars)
-	  (dolist (elt unsafe-vars)
-	    (push elt safe-local-variable-values))
-	  (customize-save-variable
-	   'safe-local-variable-values
-	   safe-local-variable-values))
-	(or (= char ?!)
-	    (= char ?\s)
-	    (= char ?y))))))
+		   (insert "    ")))
+	    (princ (car elt) buf)
+	    (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: "))
+	  (let ((inhibit-quit t)
+		(cursor-in-echo-area t)
+		done)
+	    (while (not done)
+	      (message prompt)
+	      (setq char (read-event))
+	      (if (numberp char)
+		  (if (eq char ?\C-v)
+		      (condition-case nil
+			  (scroll-up)
+			(error (goto-char (point-min))))
+		    (setq done (memq (downcase char)
+				     '(?! ?y ?n ?\s ?\C-g))))))
+	    (if (= char ?\C-g)
+		(setq quit-flag nil)))
+	  (setq char (downcase char))
+	  (when (and (= char ?!) unsafe-vars)
+	    (dolist (elt unsafe-vars)
+	      (add-to-list 'safe-local-variable-values elt))
+	    (customize-save-variable
+	     'safe-local-variable-values
+	     safe-local-variable-values))
+	  (or (= char ?!)
+	      (= char ?\s)
+	      (= char ?y)))))))
 
 (defun hack-local-variables-prop-line (&optional mode-only)
   "Return local variables specified in the -*- line.