emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r106230: * lisp/subr.el (y-or-n-p): A


From: Chong Yidong
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r106230: * lisp/subr.el (y-or-n-p): Add code for batch mode.
Date: Sat, 29 Oct 2011 16:41:39 +0800
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 106230
fixes bug(s): http://debbugs.gnu.org/9818
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Sat 2011-10-29 16:41:39 +0800
message:
  * lisp/subr.el (y-or-n-p): Add code for batch mode.
modified:
  lisp/ChangeLog
  lisp/subr.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2011-10-29 06:09:02 +0000
+++ b/lisp/ChangeLog    2011-10-29 08:41:39 +0000
@@ -1,5 +1,7 @@
 2011-10-29  Chong Yidong  <address@hidden>
 
+       * subr.el (y-or-n-p): Add code for batch mode (Bug#9818).
+
        * mouse.el (mouse-yank-primary): Push the mark (Bug#9894).
 
        * textmodes/flyspell.el (flyspell-word): Fix char offset for

=== modified file 'lisp/subr.el'
--- a/lisp/subr.el      2011-10-27 03:01:40 +0000
+++ b/lisp/subr.el      2011-10-29 08:41:39 +0000
@@ -2262,11 +2262,25 @@
   ;; where all the keys were unbound (i.e. it somehow got triggered
   ;; within read-key, apparently).  I had to kill it.
   (let ((answer 'recenter))
-    (if (and (display-popup-menus-p)
-             (listp last-nonmenu-event)
-             use-dialog-box)
-        (setq answer
-              (x-popup-dialog t `(,prompt ("Yes" . act) ("No" . skip))))
+    (cond
+     (noninteractive
+      (setq prompt (concat prompt
+                           (if (eq ?\s (aref prompt (1- (length prompt))))
+                               "" " ")
+                           "(y or n) "))
+      (let ((temp-prompt prompt))
+       (while (not (memq answer '(act skip)))
+         (let ((str (read-string temp-prompt)))
+           (cond ((member str '("y" "Y")) (setq answer 'act))
+                 ((member str '("n" "N")) (setq answer 'skip))
+                 (t (setq temp-prompt (concat "Please answer y or n.  "
+                                              prompt))))))))
+     ((and (display-popup-menus-p)
+          (listp last-nonmenu-event)
+          use-dialog-box)
+      (setq answer
+           (x-popup-dialog t `(,prompt ("Yes" . act) ("No" . skip)))))
+     (t
       (setq prompt (concat prompt
                            (if (eq ?\s (aref prompt (1- (length prompt))))
                                "" " ")
@@ -2288,7 +2302,7 @@
              ((memq answer '(exit-prefix quit)) (signal 'quit nil) t)
              (t t)))
         (ding)
-        (discard-input)))
+        (discard-input))))
     (let ((ret (eq answer 'act)))
       (unless noninteractive
         (message "%s %s" prompt (if ret "y" "n")))


reply via email to

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