emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r109925: Let ESC ESC quit in read-cha


From: Chong Yidong
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r109925: Let ESC ESC quit in read-char-choice, and use it in userlock.el.
Date: Fri, 07 Sep 2012 18:19:58 +0800
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 109925
fixes bug: http://debbugs.gnu.org/12093
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Fri 2012-09-07 18:19:58 +0800
message:
  Let ESC ESC quit in read-char-choice, and use it in userlock.el.
  
  * lisp/subr.el (read-char-choice): Allow quitting via ESC ESC.
  
  * lisp/userlock.el (ask-user-about-supersession-threat): Use
  read-char-choice.
modified:
  lisp/ChangeLog
  lisp/subr.el
  lisp/userlock.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-09-07 08:58:31 +0000
+++ b/lisp/ChangeLog    2012-09-07 10:19:58 +0000
@@ -1,5 +1,12 @@
 2012-09-07  Chong Yidong  <address@hidden>
 
+       * subr.el (read-char-choice): Allow quitting via ESC ESC.
+
+       * userlock.el (ask-user-about-supersession-threat): Use
+       read-char-choice (Bug#12093).
+
+2012-09-07  Chong Yidong  <address@hidden>
+
        * subr.el (buffer-narrowed-p): New function.
 
        * ses.el (ses-widen):

=== modified file 'lisp/subr.el'
--- a/lisp/subr.el      2012-09-07 08:58:31 +0000
+++ b/lisp/subr.el      2012-09-07 10:19:58 +0000
@@ -2237,7 +2237,8 @@
     (error "Called `read-char-choice' without valid char choices"))
   (let (char done show-help (helpbuf " *Char Help*"))
     (let ((cursor-in-echo-area t)
-          (executing-kbd-macro executing-kbd-macro))
+          (executing-kbd-macro executing-kbd-macro)
+         (esc-flag nil))
       (save-window-excursion         ; in case we call help-form-show
        (while (not done)
          (unless (get-text-property 0 'face prompt)
@@ -2261,8 +2262,12 @@
            ;; there are no more events in the macro.  Attempt to
            ;; get an event interactively.
            (setq executing-kbd-macro nil))
-          ((and (not inhibit-keyboard-quit) (eq char ?\C-g))
-           (keyboard-quit))))))
+          ((not inhibit-keyboard-quit)
+           (cond
+            ((and (null esc-flag) (eq char ?\e))
+             (setq esc-flag t))
+            ((memq char '(?\C-g ?\e))
+             (keyboard-quit))))))))
     ;; Display the question with the answer.  But without cursor-in-echo-area.
     (message "%s%s" prompt (char-to-string char))
     char))

=== modified file 'lisp/userlock.el'
--- a/lisp/userlock.el  2012-07-18 11:44:13 +0000
+++ b/lisp/userlock.el  2012-09-07 10:19:58 +0000
@@ -108,37 +108,27 @@
 The buffer in question is current when this function is called."
   (discard-input)
   (save-window-excursion
-    (let (answer)
+    (let ((prompt
+          (format "%s changed on disk; \
+really edit the buffer? (y, n, r or C-h) "
+                  (file-name-nondirectory fn)))
+         (choices '(?y ?n ?r ?? ?\C-h))
+         answer)
       (while (null answer)
-       (message "%s changed on disk; really edit the buffer? (y, n, r or C-h) "
-                (file-name-nondirectory fn))
-       (let ((tem (downcase (let ((cursor-in-echo-area t))
-                              (read-char-exclusive)))))
-         (setq answer
-               (if (= tem help-char)
-                   'help
-                 (cdr (assoc tem '((?n . yield)
-                                   (?\C-g . yield)
-                                   (?y . proceed)
-                                   (?r . revert)
-                                   (?? . help))))))
-         (cond ((null answer)
-                (beep)
-                (message "Please type y, n or r; or ? for help")
-                (sit-for 3))
-               ((eq answer 'help)
-                (ask-user-about-supersession-help)
-                (setq answer nil))
-               ((eq answer 'revert)
-                (revert-buffer nil (not (buffer-modified-p)))
-                                       ; ask confirmation if buffer modified
-                (signal 'file-supersession
-                        (list "File reverted" fn)))
-               ((eq answer 'yield)
-                (signal 'file-supersession
-                        (list "File changed on disk" fn))))))
+       (setq answer (read-char-choice prompt choices))
+       (cond ((memq answer '(?? ?\C-h))
+              (ask-user-about-supersession-help)
+              (setq answer nil))
+             ((eq answer ?r)
+              ;; Ask for confirmation if buffer modified
+              (revert-buffer nil (not (buffer-modified-p)))
+              (signal 'file-supersession
+                      (list "File reverted" fn)))
+             ((eq answer ?n)
+              (signal 'file-supersession
+                      (list "File changed on disk" fn)))))
       (message
-        "File on disk now will become a backup file if you save these 
changes.")
+       "File on disk now will become a backup file if you save these changes.")
       (setq buffer-backed-up nil))))
 
 (defun ask-user-about-supersession-help ()


reply via email to

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