emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master b54a860: Improve and simplify 'map-y-or-n-p'


From: Eli Zaretskii
Subject: [Emacs-diffs] master b54a860: Improve and simplify 'map-y-or-n-p'
Date: Sat, 20 Jan 2018 07:25:02 -0500 (EST)

branch: master
commit b54a86000c9519b2826ed2bf7f4475763c9b43f6
Author: Basil L. Contovounesios <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Improve and simplify 'map-y-or-n-p'
    
    * lisp/emacs-lisp/map-ynp.el (map-y-or-n-p): Do not follow a
    definite article with an action verb in C-h help text.  Use
    'with-help-window' instead of 'with-output-to-temp-buffer'.
    Simplify string concatenation.  (Bug#30064)
---
 lisp/emacs-lisp/map-ynp.el | 38 +++++++++++++++++---------------------
 1 file changed, 17 insertions(+), 21 deletions(-)

diff --git a/lisp/emacs-lisp/map-ynp.el b/lisp/emacs-lisp/map-ynp.el
index 2a7edde..dd80524 100644
--- a/lisp/emacs-lisp/map-ynp.el
+++ b/lisp/emacs-lisp/map-ynp.el
@@ -191,34 +191,30 @@ Returns the number of actions taken."
                                  (funcall actor elt)
                                  (setq actions (1+ actions))))))
                         ((eq def 'help)
-                         (with-output-to-temp-buffer "*Help*"
+                          (with-help-window (help-buffer)
                            (princ
-                            (let ((object (if help (nth 0 help) "object"))
-                                  (objects (if help (nth 1 help) "objects"))
-                                  (action (if help (nth 2 help) "act on")))
+                             (let ((object  (or (nth 0 help) "object"))
+                                   (objects (or (nth 1 help) "objects"))
+                                   (action  (or (nth 2 help) "act on")))
                               (concat
-                               (format-message "\
+                                (format-message
+                                 "\
 Type SPC or `y' to %s the current %s;
 DEL or `n' to skip the current %s;
-RET or `q' to give up on the %s (skip all remaining %s);
+RET or `q' to skip the current and all remaining %s;
 C-g to quit (cancel the whole command);
 ! to %s all remaining %s;\n"
-                                       action object object action objects 
action
-                                       objects)
-                               (mapconcat (function
-                                           (lambda (elt)
-                                             (format "%s to %s"
-                                                     (single-key-description
-                                                      (nth 0 elt))
-                                                     (nth 2 elt))))
+                                 action object object objects action objects)
+                                (mapconcat (lambda (elt)
+                                             (format "%s to %s;\n"
+                                                     (single-key-description
+                                                      (nth 0 elt))
+                                                     (nth 2 elt)))
                                           action-alist
-                                          ";\n")
-                               (if action-alist ";\n")
-                               (format "or . (period) to %s \
-the current %s and exit."
-                                       action object))))
-                           (with-current-buffer standard-output
-                             (help-mode)))
+                                           "")
+                                (format
+                                 "or . (period) to %s the current %s and exit."
+                                 action object)))))
 
                          (funcall try-again))
                         ((and (symbolp def) (commandp def))



reply via email to

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