emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r109949: Use quit-window for quitting


From: Chong Yidong
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r109949: Use quit-window for quitting the *Local Variables* buffer.
Date: Sun, 09 Sep 2012 13:50:43 +0800
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 109949
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Sun 2012-09-09 13:50:43 +0800
message:
  Use quit-window for quitting the *Local Variables* buffer.
  
  * lisp/files.el (hack-local-variables-confirm): Use quit-window to kill
  the *Local Variables* buffer.
modified:
  lisp/ChangeLog
  lisp/files.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-09-08 23:32:25 +0000
+++ b/lisp/ChangeLog    2012-09-09 05:50:43 +0000
@@ -1,3 +1,8 @@
+2012-09-09  Chong Yidong  <address@hidden>
+
+       * files.el (hack-local-variables-confirm): Use quit-window to kill
+       the *Local Variables* buffer.
+
 2012-09-08  Dmitry Gutov  <address@hidden>
 
        * progmodes/ruby-mode.el (ruby-toggle-block): Guess the current block,

=== modified file 'lisp/files.el'
--- a/lisp/files.el     2012-09-07 10:53:29 +0000
+++ b/lisp/files.el     2012-09-09 05:50:43 +0000
@@ -2951,20 +2951,16 @@
 RISKY-VARS is the list of those that are marked as risky.
 If these settings come from directory-local variables, then
 DIR-NAME is the name of the associated directory.  Otherwise it is nil."
-  (if noninteractive
-      nil
-    (save-window-excursion
-      (let* ((name (or dir-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))
-            (exit-chars
-             (if offer-save '(?! ?y ?n ?\s ?\C-g) '(?y ?n ?\s ?\C-g)))
-            (buf (pop-to-buffer "*Local Variables*"))
-            prompt char)
-       (set (make-local-variable 'cursor-type) nil)
+  (unless noninteractive
+    (let ((name (cond (dir-name)
+                     (buffer-file-name
+                      (file-name-nondirectory buffer-file-name))
+                     ((concat "buffer " (buffer-name)))))
+         (offer-save (and (eq enable-local-variables t)
+                          unsafe-vars))
+         (buf (get-buffer-create "*Local Variables*")))
+      ;; Set up the contents of the *Local Variables* buffer.
+      (with-current-buffer buf
        (erase-buffer)
        (cond
         (unsafe-vars
@@ -2999,25 +2995,35 @@
          (let ((print-escape-newlines t))
            (prin1 (cdr elt) buf))
          (insert "\n"))
-       (setq prompt
-             (format "Please type %s%s: "
-                     (if offer-save "y, n, or !" "y or n")
-                     (if (< (line-number-at-pos) (window-body-height))
-                         ""
-                       (push ?\C-v exit-chars)
-                       ", or C-v to scroll")))
-       (goto-char (point-min))
-       (while (null char)
-         (setq char (read-char-choice prompt exit-chars t))
-         (when (eq char ?\C-v)
-           (condition-case nil
-               (scroll-up)
-             (error (goto-char (point-min))))
-           (setq char nil)))
-       (kill-buffer buf)
-       (when (and offer-save (= char ?!) unsafe-vars)
-         (customize-push-and-save 'safe-local-variable-values unsafe-vars))
-       (memq char '(?! ?\s ?y))))))
+       (set (make-local-variable 'cursor-type) nil)
+       (set-buffer-modified-p nil)
+       (goto-char (point-min)))
+
+      ;; Display the buffer and read a choice.
+      (save-window-excursion
+       (pop-to-buffer buf)
+       (let* ((exit-chars '(?y ?n ?\s ?\C-g ?\C-v))
+              (prompt (format "Please type %s%s: "
+                              (if offer-save "y, n, or !" "y or n")
+                              (if (< (line-number-at-pos (point-max))
+                                     (window-body-height))
+                                  ""
+                                (push ?\C-v exit-chars)
+                                ", or C-v to scroll")))
+              char)
+         (if offer-save (push ?! exit-chars))
+         (while (null char)
+           (setq char (read-char-choice prompt exit-chars t))
+           (when (eq char ?\C-v)
+             (condition-case nil
+                 (scroll-up)
+               (error (goto-char (point-min))
+                      (recenter 1)))
+             (setq char nil)))
+         (when (and offer-save (= char ?!) unsafe-vars)
+           (customize-push-and-save 'safe-local-variable-values unsafe-vars))
+         (prog1 (memq char '(?! ?\s ?y))
+           (quit-window t)))))))
 
 (defun hack-local-variables-prop-line (&optional mode-only)
   "Return local variables specified in the -*- line.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]