emacs-diffs
[Top][All Lists]
Advanced

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

master 660d13b: Use format-prompt in calls to completing-read with a def


From: Lars Ingebrigtsen
Subject: master 660d13b: Use format-prompt in calls to completing-read with a default value
Date: Sun, 6 Sep 2020 14:45:15 -0400 (EDT)

branch: master
commit 660d13bd7b47c1b7db990adcc671b55b6f1f83f2
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Use format-prompt in calls to completing-read with a default value
    
    * lisp/textmodes/rst.el (rst-insert-list-new-item):
    * lisp/tab-bar.el (tab-bar-switch-to-tab):
    * lisp/profiler.el (profiler-start):
    * lisp/frame.el (set-frame-font):
    * lisp/erc/erc.el (erc-join-channel):
    * lisp/emacs-lock.el (emacs-lock--set-mode):
    * lisp/emacs-lisp/elp.el (elp-set-master):
    * lisp/emacs-lisp/checkdoc.el ()
    (checkdoc-this-string-valid-engine):
    * lisp/calendar/todo-mode.el (todo-find-filtered-items-file):
    * lisp/calendar/calendar.el (calendar-set-date-style): Use
    `format-prompt' in calls to completing-read that has a default
    value, but didn't mention that in the prompt.
---
 lisp/calendar/calendar.el   |  2 +-
 lisp/calendar/todo-mode.el  |  4 +++-
 lisp/emacs-lisp/checkdoc.el |  3 ++-
 lisp/emacs-lisp/elp.el      |  6 +++---
 lisp/emacs-lock.el          | 11 ++++++-----
 lisp/erc/erc.el             |  3 ++-
 lisp/frame.el               |  6 +++---
 lisp/profiler.el            |  2 +-
 lisp/tab-bar.el             |  3 ++-
 lisp/textmodes/rst.el       |  2 +-
 10 files changed, 24 insertions(+), 18 deletions(-)

diff --git a/lisp/calendar/calendar.el b/lisp/calendar/calendar.el
index 5742614..20887af 100644
--- a/lisp/calendar/calendar.el
+++ b/lisp/calendar/calendar.el
@@ -994,7 +994,7 @@ pre-existing calendar windows."
   "Set the style of calendar and diary dates to STYLE (a symbol).
 The valid styles are described in the documentation of `calendar-date-style'."
   (interactive (list (intern
-                      (completing-read "Date style: "
+                      (completing-read (format-prompt "Date style" "american")
                                        '("american" "european" "iso") nil t
                                        nil nil "american"))))
   (or (memq style '(american european iso))
diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el
index 0e4446f..02a7316 100644
--- a/lisp/calendar/todo-mode.el
+++ b/lisp/calendar/todo-mode.el
@@ -4076,7 +4076,9 @@ regexp items."
                        ((equal (file-name-extension f) "todt") "top")
                        ((equal (file-name-extension f) "tody") "diary"))))
        (push (cons (concat sf-name " (" type ")") f) falist)))
-    (setq file (completing-read "Choose a filtered items file: " falist nil t 
nil
+    (setq file (completing-read (format-prompt "Choose a filtered items file"
+                                               (caar falist))
+                                falist nil t nil
                                 'todo--fifiles-history (caar falist)))
     (setq file (cdr (assoc-string file falist)))
     (find-file file)
diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el
index 1029b52..23121c2 100644
--- a/lisp/emacs-lisp/checkdoc.el
+++ b/lisp/emacs-lisp/checkdoc.el
@@ -1573,7 +1573,8 @@ mouse-[0-3]\\)\\)\\>"))
                     ;; a prefix.
                     (let ((disambiguate
                            (completing-read
-                            "Disambiguating Keyword (default variable): "
+                            (format-prompt "Disambiguating Keyword"
+                                            "variable")
                             '(("function") ("command") ("variable")
                               ("option") ("symbol"))
                             nil t nil nil "variable")))
diff --git a/lisp/emacs-lisp/elp.el b/lisp/emacs-lisp/elp.el
index f68c0fa..a94978a 100644
--- a/lisp/emacs-lisp/elp.el
+++ b/lisp/emacs-lisp/elp.el
@@ -342,9 +342,9 @@ Use optional LIST if provided instead."
   (interactive
    (list
     (intern
-     (completing-read "Master function: " obarray
-                      #'elp--instrumented-p
-                      t nil nil (if elp-master (symbol-name elp-master))))))
+     (let ((default (if elp-master (symbol-name elp-master))))
+       (completing-read (format-prompt "Master function" default)
+                        obarray #'elp--instrumented-p t nil nil default)))))
   ;; When there's a master function, recording is turned off by default.
   (setq elp-master funsym
        elp-record-p nil)
diff --git a/lisp/emacs-lock.el b/lisp/emacs-lock.el
index 5f393a0..ba75a93 100644
--- a/lisp/emacs-lock.el
+++ b/lisp/emacs-lock.el
@@ -176,11 +176,12 @@ Return a value appropriate for 
`kill-buffer-query-functions' (which see)."
                arg)
               ((and (eq arg current-prefix-arg) (consp current-prefix-arg))
                ;; called with C-u M-x emacs-lock-mode, so ask the user
-               (intern (completing-read "Locking mode: "
-                                        '("all" "exit" "kill")
-                                        nil t nil nil
-                                        (symbol-name
-                                         emacs-lock-default-locking-mode))))
+               (intern (completing-read
+                        (format-prompt "Locking mode"
+                                       emacs-lock-default-locking-mode)
+                        '("all" "exit" "kill")
+                        nil t nil nil
+                        (symbol-name emacs-lock-default-locking-mode))))
               ((eq mode t)
                ;; turn on, so use previous setting, or customized default
                (or emacs-lock--old-mode emacs-lock-default-locking-mode))
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index 8712113..e7e43f8 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -4072,7 +4072,8 @@ If `point' is at the beginning of a channel name, use 
that as default."
           (table (when (erc-server-buffer-live-p)
                    (set-buffer (process-buffer erc-server-process))
                    erc-channel-list)))
-      (completing-read "Join channel: " table nil nil nil nil chnl))
+      (completing-read (format-prompt "Join channel" chnl)
+                       table nil nil nil nil chnl))
     (when (or current-prefix-arg erc-prompt-for-channel-key)
       (read-from-minibuffer "Channel key (RET for none): " nil))))
   (erc-cmd-JOIN channel (when (>= (length key) 1) key)))
diff --git a/lisp/frame.el b/lisp/frame.el
index 7008854..05da1ea 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -1412,12 +1412,12 @@ as though the font-related attributes of the `default' 
face had been
 \"set in this session\", so that the font is applied to future frames."
   (interactive
    (let* ((completion-ignore-case t)
-         (font (completing-read "Font name: "
+          (default (frame-parameter nil 'font))
+         (font (completing-read (format-prompt "Font name" default)
                                 ;; x-list-fonts will fail with an error
                                 ;; if this frame doesn't support fonts.
                                 (x-list-fonts "*" nil (selected-frame))
-                                 nil nil nil nil
-                                 (frame-parameter nil 'font))))
+                                 nil nil nil nil default)))
      (list font current-prefix-arg nil)))
   (when (or (stringp font) (fontp font))
     (let* ((this-frame (selected-frame))
diff --git a/lisp/profiler.el b/lisp/profiler.el
index 3243e64..0a5ddc1 100644
--- a/lisp/profiler.el
+++ b/lisp/profiler.el
@@ -816,7 +816,7 @@ If MODE is `cpu' or `cpu+mem', time-based profiler will be 
started.
 Also, if MODE is `mem' or `cpu+mem', then memory profiler will be started."
   (interactive
    (list (if (not (fboundp 'profiler-cpu-start)) 'mem
-           (intern (completing-read "Mode (default cpu): "
+           (intern (completing-read (format-prompt "Mode" "cpu")
                                     '("cpu" "mem" "cpu+mem")
                                     nil t nil nil "cpu")))))
   (cl-ecase mode
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index cee88cb..d8f932e 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -665,7 +665,8 @@ to get the name of the last visited tab, the second last, 
and so on."
    (let* ((recent-tabs (mapcar (lambda (tab)
                                  (alist-get 'name tab))
                                (tab-bar--tabs-recent))))
-     (list (completing-read "Switch to tab by name (default recent): "
+     (list (completing-read (format-prompt "Switch to tab by name"
+                                           (car recent-tabs))
                             recent-tabs nil nil nil nil recent-tabs))))
   (tab-bar-select-tab (1+ (or (tab-bar--tab-index-by-name name) 0))))
 
diff --git a/lisp/textmodes/rst.el b/lisp/textmodes/rst.el
index 5fadec4..db17a90 100644
--- a/lisp/textmodes/rst.el
+++ b/lisp/textmodes/rst.el
@@ -2363,7 +2363,7 @@ If user selects enumerations, a further prompt is given.  
User need to
 input a starting item, for example 'e' for 'A)' style.  The position is
 also arranged by `rst-insert-list-new-tag'."
   (let* ((itemstyle (completing-read
-                    "Select preferred item style [#.]: "
+                    (format-prompt "Select preferred item style" "#.")
                     rst-initial-items nil t nil nil "#."))
         (cnt (if (string-match (rst-re 'cntexp-tag) itemstyle)
                  (match-string 0 itemstyle)))



reply via email to

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