diff options
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/subr.el | 11 | ||||
| -rw-r--r-- | lisp/userlock.el | 48 |
3 files changed, 34 insertions, 32 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7aae8fd7854..d7004237adf 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,12 @@ | |||
| 1 | 2012-09-07 Chong Yidong <cyd@gnu.org> | 1 | 2012-09-07 Chong Yidong <cyd@gnu.org> |
| 2 | 2 | ||
| 3 | * subr.el (read-char-choice): Allow quitting via ESC ESC. | ||
| 4 | |||
| 5 | * userlock.el (ask-user-about-supersession-threat): Use | ||
| 6 | read-char-choice (Bug#12093). | ||
| 7 | |||
| 8 | 2012-09-07 Chong Yidong <cyd@gnu.org> | ||
| 9 | |||
| 3 | * subr.el (buffer-narrowed-p): New function. | 10 | * subr.el (buffer-narrowed-p): New function. |
| 4 | 11 | ||
| 5 | * ses.el (ses-widen): | 12 | * ses.el (ses-widen): |
diff --git a/lisp/subr.el b/lisp/subr.el index 621622e70eb..a3e0897e9fe 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -2237,7 +2237,8 @@ keyboard-quit events while waiting for a valid input." | |||
| 2237 | (error "Called `read-char-choice' without valid char choices")) | 2237 | (error "Called `read-char-choice' without valid char choices")) |
| 2238 | (let (char done show-help (helpbuf " *Char Help*")) | 2238 | (let (char done show-help (helpbuf " *Char Help*")) |
| 2239 | (let ((cursor-in-echo-area t) | 2239 | (let ((cursor-in-echo-area t) |
| 2240 | (executing-kbd-macro executing-kbd-macro)) | 2240 | (executing-kbd-macro executing-kbd-macro) |
| 2241 | (esc-flag nil)) | ||
| 2241 | (save-window-excursion ; in case we call help-form-show | 2242 | (save-window-excursion ; in case we call help-form-show |
| 2242 | (while (not done) | 2243 | (while (not done) |
| 2243 | (unless (get-text-property 0 'face prompt) | 2244 | (unless (get-text-property 0 'face prompt) |
| @@ -2261,8 +2262,12 @@ keyboard-quit events while waiting for a valid input." | |||
| 2261 | ;; there are no more events in the macro. Attempt to | 2262 | ;; there are no more events in the macro. Attempt to |
| 2262 | ;; get an event interactively. | 2263 | ;; get an event interactively. |
| 2263 | (setq executing-kbd-macro nil)) | 2264 | (setq executing-kbd-macro nil)) |
| 2264 | ((and (not inhibit-keyboard-quit) (eq char ?\C-g)) | 2265 | ((not inhibit-keyboard-quit) |
| 2265 | (keyboard-quit)))))) | 2266 | (cond |
| 2267 | ((and (null esc-flag) (eq char ?\e)) | ||
| 2268 | (setq esc-flag t)) | ||
| 2269 | ((memq char '(?\C-g ?\e)) | ||
| 2270 | (keyboard-quit)))))))) | ||
| 2266 | ;; Display the question with the answer. But without cursor-in-echo-area. | 2271 | ;; Display the question with the answer. But without cursor-in-echo-area. |
| 2267 | (message "%s%s" prompt (char-to-string char)) | 2272 | (message "%s%s" prompt (char-to-string char)) |
| 2268 | char)) | 2273 | char)) |
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. | |||
| 108 | The buffer in question is current when this function is called." | 108 | The buffer in question is current when this function is called." |
| 109 | (discard-input) | 109 | (discard-input) |
| 110 | (save-window-excursion | 110 | (save-window-excursion |
| 111 | (let (answer) | 111 | (let ((prompt |
| 112 | (format "%s changed on disk; \ | ||
| 113 | really edit the buffer? (y, n, r or C-h) " | ||
| 114 | (file-name-nondirectory fn))) | ||
| 115 | (choices '(?y ?n ?r ?? ?\C-h)) | ||
| 116 | answer) | ||
| 112 | (while (null answer) | 117 | (while (null answer) |
| 113 | (message "%s changed on disk; really edit the buffer? (y, n, r or C-h) " | 118 | (setq answer (read-char-choice prompt choices)) |
| 114 | (file-name-nondirectory fn)) | 119 | (cond ((memq answer '(?? ?\C-h)) |
| 115 | (let ((tem (downcase (let ((cursor-in-echo-area t)) | 120 | (ask-user-about-supersession-help) |
| 116 | (read-char-exclusive))))) | 121 | (setq answer nil)) |
| 117 | (setq answer | 122 | ((eq answer ?r) |
| 118 | (if (= tem help-char) | 123 | ;; Ask for confirmation if buffer modified |
| 119 | 'help | 124 | (revert-buffer nil (not (buffer-modified-p))) |
| 120 | (cdr (assoc tem '((?n . yield) | 125 | (signal 'file-supersession |
| 121 | (?\C-g . yield) | 126 | (list "File reverted" fn))) |
| 122 | (?y . proceed) | 127 | ((eq answer ?n) |
| 123 | (?r . revert) | 128 | (signal 'file-supersession |
| 124 | (?? . help)))))) | 129 | (list "File changed on disk" fn))))) |
| 125 | (cond ((null answer) | ||
| 126 | (beep) | ||
| 127 | (message "Please type y, n or r; or ? for help") | ||
| 128 | (sit-for 3)) | ||
| 129 | ((eq answer 'help) | ||
| 130 | (ask-user-about-supersession-help) | ||
| 131 | (setq answer nil)) | ||
| 132 | ((eq answer 'revert) | ||
| 133 | (revert-buffer nil (not (buffer-modified-p))) | ||
| 134 | ; ask confirmation if buffer modified | ||
| 135 | (signal 'file-supersession | ||
| 136 | (list "File reverted" fn))) | ||
| 137 | ((eq answer 'yield) | ||
| 138 | (signal 'file-supersession | ||
| 139 | (list "File changed on disk" fn)))))) | ||
| 140 | (message | 130 | (message |
| 141 | "File on disk now will become a backup file if you save these changes.") | 131 | "File on disk now will become a backup file if you save these changes.") |
| 142 | (setq buffer-backed-up nil)))) | 132 | (setq buffer-backed-up nil)))) |
| 143 | 133 | ||
| 144 | (defun ask-user-about-supersession-help () | 134 | (defun ask-user-about-supersession-help () |