diff options
| author | Chong Yidong | 2011-10-29 16:41:39 +0800 |
|---|---|---|
| committer | Chong Yidong | 2011-10-29 16:41:39 +0800 |
| commit | aa4de34102ce87590991e62680eeefe7efffcc79 (patch) | |
| tree | fb6e966dc727036d2ec7d14b5547dae76c0db127 | |
| parent | e1eb5385bb8c30e9a9ff3b04b0928664e3440e01 (diff) | |
| download | emacs-aa4de34102ce87590991e62680eeefe7efffcc79.tar.gz emacs-aa4de34102ce87590991e62680eeefe7efffcc79.zip | |
* lisp/subr.el (y-or-n-p): Add code for batch mode.
Fixes: debbugs:9818
| -rw-r--r-- | lisp/ChangeLog | 2 | ||||
| -rw-r--r-- | lisp/subr.el | 26 |
2 files changed, 22 insertions, 6 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7565548fe53..8309d3256bf 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,7 @@ | |||
| 1 | 2011-10-29 Chong Yidong <cyd@gnu.org> | 1 | 2011-10-29 Chong Yidong <cyd@gnu.org> |
| 2 | 2 | ||
| 3 | * subr.el (y-or-n-p): Add code for batch mode (Bug#9818). | ||
| 4 | |||
| 3 | * mouse.el (mouse-yank-primary): Push the mark (Bug#9894). | 5 | * mouse.el (mouse-yank-primary): Push the mark (Bug#9894). |
| 4 | 6 | ||
| 5 | * textmodes/flyspell.el (flyspell-word): Fix char offset for | 7 | * textmodes/flyspell.el (flyspell-word): Fix char offset for |
diff --git a/lisp/subr.el b/lisp/subr.el index f3cd4dabe20..50ea49bd8c9 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -2262,11 +2262,25 @@ is nil and `use-dialog-box' is non-nil." | |||
| 2262 | ;; where all the keys were unbound (i.e. it somehow got triggered | 2262 | ;; where all the keys were unbound (i.e. it somehow got triggered |
| 2263 | ;; within read-key, apparently). I had to kill it. | 2263 | ;; within read-key, apparently). I had to kill it. |
| 2264 | (let ((answer 'recenter)) | 2264 | (let ((answer 'recenter)) |
| 2265 | (if (and (display-popup-menus-p) | 2265 | (cond |
| 2266 | (listp last-nonmenu-event) | 2266 | (noninteractive |
| 2267 | use-dialog-box) | 2267 | (setq prompt (concat prompt |
| 2268 | (setq answer | 2268 | (if (eq ?\s (aref prompt (1- (length prompt)))) |
| 2269 | (x-popup-dialog t `(,prompt ("Yes" . act) ("No" . skip)))) | 2269 | "" " ") |
| 2270 | "(y or n) ")) | ||
| 2271 | (let ((temp-prompt prompt)) | ||
| 2272 | (while (not (memq answer '(act skip))) | ||
| 2273 | (let ((str (read-string temp-prompt))) | ||
| 2274 | (cond ((member str '("y" "Y")) (setq answer 'act)) | ||
| 2275 | ((member str '("n" "N")) (setq answer 'skip)) | ||
| 2276 | (t (setq temp-prompt (concat "Please answer y or n. " | ||
| 2277 | prompt)))))))) | ||
| 2278 | ((and (display-popup-menus-p) | ||
| 2279 | (listp last-nonmenu-event) | ||
| 2280 | use-dialog-box) | ||
| 2281 | (setq answer | ||
| 2282 | (x-popup-dialog t `(,prompt ("Yes" . act) ("No" . skip))))) | ||
| 2283 | (t | ||
| 2270 | (setq prompt (concat prompt | 2284 | (setq prompt (concat prompt |
| 2271 | (if (eq ?\s (aref prompt (1- (length prompt)))) | 2285 | (if (eq ?\s (aref prompt (1- (length prompt)))) |
| 2272 | "" " ") | 2286 | "" " ") |
| @@ -2288,7 +2302,7 @@ is nil and `use-dialog-box' is non-nil." | |||
| 2288 | ((memq answer '(exit-prefix quit)) (signal 'quit nil) t) | 2302 | ((memq answer '(exit-prefix quit)) (signal 'quit nil) t) |
| 2289 | (t t))) | 2303 | (t t))) |
| 2290 | (ding) | 2304 | (ding) |
| 2291 | (discard-input))) | 2305 | (discard-input)))) |
| 2292 | (let ((ret (eq answer 'act))) | 2306 | (let ((ret (eq answer 'act))) |
| 2293 | (unless noninteractive | 2307 | (unless noninteractive |
| 2294 | (message "%s %s" prompt (if ret "y" "n"))) | 2308 | (message "%s %s" prompt (if ret "y" "n"))) |