summaryrefslogtreecommitdiff
path: root/lisp/userlock.el
diff options
context:
space:
mode:
authorChong Yidong <cyd@gnu.org>2012-09-07 18:19:58 +0800
committerChong Yidong <cyd@gnu.org>2012-09-07 18:19:58 +0800
commit145823ecb2d55a7ea33d4a8482b5941f189d9418 (patch)
tree82ec282d551f50cefee561c3b5986293b4322699 /lisp/userlock.el
parent843f263443272e8c323909879d4cc498873e33bb (diff)
downloademacs-145823ecb2d55a7ea33d4a8482b5941f189d9418.tar.gz
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. Fixes: debbugs:12093
Diffstat (limited to 'lisp/userlock.el')
-rw-r--r--lisp/userlock.el48
1 files changed, 19 insertions, 29 deletions
diff --git a/lisp/userlock.el b/lisp/userlock.el
index 705d9588249..4c003e423aa 100644
--- a/lisp/userlock.el
+++ b/lisp/userlock.el
@@ -108,37 +108,27 @@ You can rewrite this to use any criterion you like to choose which one to do.
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 ()