]> git.eshelyaron.com Git - emacs.git/commitdiff
Use `format-prompt' when prompting with default values
authorLars Ingebrigtsen <larsi@gnus.org>
Sun, 6 Sep 2020 14:56:44 +0000 (16:56 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Sun, 6 Sep 2020 14:56:54 +0000 (16:56 +0200)
* lisp/woman.el (woman-file-name):
* lisp/wid-edit.el (widget-file-prompt-value)
(widget-coding-system-prompt-value):
* lisp/w32-fns.el (w32-set-system-coding-system):
* lisp/vc/vc.el (vc-print-root-log):
* lisp/vc/vc-annotate.el (vc-annotate):
* lisp/vc/emerge.el (emerge-read-file-name):
* lisp/vc/ediff.el (ediff-directories)
(ediff-directory-revisions, ediff-directories3)
(ediff-merge-directories, )
(ediff-merge-directories-with-ancestor)
(ediff-merge-directory-revisions)
(ediff-merge-directory-revisions-with-ancestor)
(ediff-merge-revisions, ediff-merge-revisions-with-ancestor)
(ediff-revision):
* lisp/vc/ediff-util.el (ediff-toggle-regexp-match):
* lisp/vc/ediff-mult.el (ediff-filegroup-action):
* lisp/vc/add-log.el (prompt-for-change-log-name):
* lisp/textmodes/table.el (table-insert-row-column)
(table-span-cell, table-split-cell-horizontally)
(table-split-cell, table-justify, table-generate-source)
(table-insert-sequence, table-capture)
(table--read-from-minibuffer, table--query-justification):
* lisp/textmodes/sgml-mode.el (sgml-tag, sgml-tag-help):
* lisp/textmodes/reftex-ref.el (reftex-goto-label):
* lisp/textmodes/refer.el (refer-get-bib-files):
* lisp/textmodes/css-mode.el (css-lookup-symbol):
* lisp/term.el (serial-read-name, serial-read-speed):
* lisp/speedbar.el (speedbar-change-initial-expansion-list):
* lisp/simple.el (previous-matching-history-element)
(set-variable):
* lisp/ses.el (ses-read-cell, ses-set-column-width):
* lisp/replace.el (query-replace-read-from)
(occur-read-primary-args):
* lisp/rect.el (string-rectangle, string-insert-rectangle):
* lisp/progmodes/tcl.el (tcl-help-on-word):
* lisp/progmodes/sh-script.el (sh-set-shell):
* lisp/progmodes/python.el (python-eldoc-at-point):
* lisp/progmodes/octave.el (octave-completing-read)
(octave-update-function-file-comment, octave-insert-defun):
* lisp/progmodes/inf-lisp.el (lisp-symprompt):
* lisp/progmodes/cperl-mode.el (cperl-info-on-command)
(cperl-perldoc):
* lisp/progmodes/compile.el (compilation-find-file):
* lisp/net/rcirc.el (rcirc-prompt-for-encryption):
* lisp/net/eww.el (eww):
* lisp/net/browse-url.el (browse-url-with-browser-kind):
* lisp/man.el (man):
* lisp/mail/sendmail.el (sendmail-query-user-about-smtp):
* lisp/mail/mailalias.el (build-mail-aliases):
* lisp/mail/mailabbrev.el (merge-mail-abbrevs)
(rebuild-mail-abbrevs):
* lisp/locate.el (locate-prompt-for-search-string):
* lisp/isearch.el (isearch-occur):
* lisp/international/ogonek.el (ogonek-read-encoding)
(ogonek-read-prefix):
* lisp/international/mule.el (read-buffer-file-coding-system)
(set-terminal-coding-system, set-keyboard-coding-system)
(set-next-selection-coding-system, recode-region):
* lisp/international/mule-cmds.el ()
(universal-coding-system-argument, search-unencodable-char)
(select-safe-coding-system-interactively):
* lisp/info.el (Info-search, Info-search-backward, Info-menu):
* lisp/info-look.el (info-lookup-interactive-arguments):
* lisp/imenu.el (imenu--completion-buffer):
* lisp/ibuf-ext.el (mode, used-mode, ibuffer-mark-by-mode):
* lisp/hi-lock.el (hi-lock-unface-buffer)
(hi-lock-read-face-name):
* lisp/help.el (view-emacs-news, where-is):
* lisp/help-fns.el (describe-variable, describe-symbol)
(describe-keymap):
* lisp/gnus/mm-decode.el (mm-save-part):
* lisp/gnus/gnus-sum.el (gnus-summary-browse-url):
* lisp/gnus/gnus-group.el (gnus-group--read-bug-ids)
(gnus-group-set-current-level):
* lisp/frame.el (make-frame-on-monitor)
(close-display-connection, select-frame-by-name):
* lisp/format.el (format-encode-buffer, format-encode-region):
* lisp/files.el (recode-file-name):
* lisp/files-x.el (read-file-local-variable)
(read-file-local-variable-value, )
(read-file-local-variable-mode):
* lisp/ffap.el (ffap-menu-ask):
* lisp/faces.el (face-read-string):
* lisp/facemenu.el (facemenu-set-charset):
* lisp/erc/erc-dcc.el (erc-dcc-do-GET-command):
* lisp/emulation/edt-mapper.el (edt-mapper):
* lisp/emacs-lisp/trace.el (trace--read-args)
(trace-function-foreground, trace-function-background):
* lisp/emacs-lisp/smie.el (smie-config-set-indent):
* lisp/emacs-lisp/re-builder.el (reb-change-syntax):
* lisp/emacs-lisp/package.el (describe-package):
* lisp/emacs-lisp/find-func.el (read-library-name)
(find-function-read):
* lisp/emacs-lisp/ert.el (ert-read-test-name)
(ert-run-tests-interactively):
* lisp/emacs-lisp/disass.el (disassemble):
* lisp/emacs-lisp/debug.el (debug-on-entry)
(debug-on-variable-change):
* lisp/emacs-lisp/advice.el (ad-read-advised-function)
(ad-read-advice-class, ad-read-advice-name, ad-read-regexp):
* lisp/dired-x.el (dired--mark-suffix-interactive-spec):
* lisp/dired-aux.el (dired-diff):
* lisp/cus-edit.el (custom-variable-prompt, customize-mode)
(customize-changed-options):
* lisp/completion.el (interactive-completion-string-reader):
* lisp/calendar/timeclock.el (timeclock-ask-for-project):
* lisp/calc/calcalg3.el (calc-get-fit-variables):
* lisp/calc/calc-store.el (calc-edit-variable):
* lisp/calc/calc-bin.el (calc-word-size):
* lisp/bookmark.el (bookmark-set-internal):
* lisp/abbrev.el (read-abbrev-file): Use `format-prompt' for
prompting (bug#12443).

78 files changed:
lisp/abbrev.el
lisp/bookmark.el
lisp/calc/calc-bin.el
lisp/calc/calc-store.el
lisp/calc/calcalg3.el
lisp/calendar/timeclock.el
lisp/completion.el
lisp/cus-edit.el
lisp/dired-aux.el
lisp/dired-x.el
lisp/emacs-lisp/advice.el
lisp/emacs-lisp/debug.el
lisp/emacs-lisp/disass.el
lisp/emacs-lisp/ert.el
lisp/emacs-lisp/find-func.el
lisp/emacs-lisp/package.el
lisp/emacs-lisp/re-builder.el
lisp/emacs-lisp/smie.el
lisp/emacs-lisp/trace.el
lisp/emulation/edt-mapper.el
lisp/erc/erc-dcc.el
lisp/facemenu.el
lisp/faces.el
lisp/ffap.el
lisp/files-x.el
lisp/files.el
lisp/format.el
lisp/frame.el
lisp/gnus/gnus-group.el
lisp/gnus/gnus-sum.el
lisp/gnus/mm-decode.el
lisp/help-fns.el
lisp/help.el
lisp/hi-lock.el
lisp/ibuf-ext.el
lisp/imenu.el
lisp/info-look.el
lisp/info.el
lisp/international/mule-cmds.el
lisp/international/mule.el
lisp/international/ogonek.el
lisp/isearch.el
lisp/locate.el
lisp/mail/mailabbrev.el
lisp/mail/mailalias.el
lisp/mail/sendmail.el
lisp/man.el
lisp/net/browse-url.el
lisp/net/eww.el
lisp/net/rcirc.el
lisp/progmodes/compile.el
lisp/progmodes/cperl-mode.el
lisp/progmodes/inf-lisp.el
lisp/progmodes/octave.el
lisp/progmodes/python.el
lisp/progmodes/sh-script.el
lisp/progmodes/tcl.el
lisp/rect.el
lisp/replace.el
lisp/ses.el
lisp/simple.el
lisp/speedbar.el
lisp/term.el
lisp/textmodes/css-mode.el
lisp/textmodes/refer.el
lisp/textmodes/reftex-ref.el
lisp/textmodes/sgml-mode.el
lisp/textmodes/table.el
lisp/vc/add-log.el
lisp/vc/ediff-mult.el
lisp/vc/ediff-util.el
lisp/vc/ediff.el
lisp/vc/emerge.el
lisp/vc/vc-annotate.el
lisp/vc/vc.el
lisp/w32-fns.el
lisp/wid-edit.el
lisp/woman.el

index 468b0d995b38f4e3476a05696a7cf9191d02f94d..be6f9ee34377c08d93749f98d7c68511f1ddc7eb 100644 (file)
@@ -209,8 +209,7 @@ it defaults to the value of `abbrev-file-name'.
 Optional second argument QUIETLY non-nil means don't display a message."
   (interactive
    (list
-    (read-file-name (format "Read abbrev file (default %s): "
-                           abbrev-file-name)
+    (read-file-name (format-prompt "Read abbrev file" abbrev-file-name)
                    nil abbrev-file-name t)))
   (load (or file abbrev-file-name) nil quietly)
   (setq abbrevs-changed nil))
index 8a3bcf8e59d45661523aa8626cfd1e965cabeb3c..dcb03adadd8d0859091940f797b4c04a156f5685 100644 (file)
@@ -803,7 +803,7 @@ still there, in order, if the topmost one is ever deleted."
          (let ((str
                 (or name
                     (read-from-minibuffer
-                     (format "%s (default %s): " prompt default)
+                     (format-prompt prompt default)
                      nil
                      bookmark-minibuffer-read-name-map
                      nil nil defaults))))
index e9083b84c61ced533e8db67e3dfeb9a3c5284a66..33fd1af6ffbde43168d47784c0aac3cd258ab89e 100644 (file)
 (defun calc-word-size (n)
   (interactive "P")
   (calc-wrapper
-   (or n (setq n (read-string (format "Binary word size: (default %d) "
-                                     calc-word-size))))
+   (or n (setq n (read-string (format-prompt "Binary word size"
+                                             calc-word-size))))
    (setq n (if (stringp n)
               (if (equal n "")
                   calc-word-size
index 5282b83402143984498f4288cf23cc24c31a2905..79e6cf5c00c86fe0d7bedab6e5fcca28cd6b0580 100644 (file)
 (defun calc-edit-variable (&optional var)
   (interactive)
   (calc-wrapper
-   (or var (setq var (calc-read-var-name
-                     (if calc-last-edited-variable
-                         (format "Edit (default %s): "
-                                 (calc-var-name calc-last-edited-variable))
-                       "Edit: "))))
+   (unless var
+     (setq var (calc-read-var-name
+                (format-prompt "Edit" (and calc-last-edited-variable
+                                          (calc-var-name
+                                            calc-last-edited-variable))))))
    (or var (setq var calc-last-edited-variable))
    (if var
        (let* ((value (calc-var-value var)))
index 67183fb754a87dc7c5e374322e8f429ca8e2edec..75e691a28ffeee67de4d6ed14793ce69bb52478a 100644 (file)
       (setq defv (calc-invent-independent-variables nv)))
   (or defc
       (setq defc (calc-invent-parameter-variables nc defv)))
-  (let ((vars (read-string (format "Fitting variables (default %s; %s): "
-                                  (mapconcat 'symbol-name
-                                             (mapcar (function (lambda (v)
-                                                                 (nth 1 v)))
-                                                     defv)
-                                             ",")
-                                  (mapconcat 'symbol-name
-                                             (mapcar (function (lambda (v)
-                                                                 (nth 1 v)))
-                                                     defc)
-                                             ","))))
+  (let ((vars (read-string (format-prompt
+                            "Fitting variables"
+                            (format "%s; %s)"
+                                   (mapconcat 'symbol-name
+                                              (mapcar (function (lambda (v)
+                                                                  (nth 1 v)))
+                                                      defv)
+                                              ",")
+                                   (mapconcat 'symbol-name
+                                              (mapcar (function (lambda (v)
+                                                                  (nth 1 v)))
+                                                      defc)
+                                              ",")))))
        (coefs nil))
     (setq vars (if (string-match "\\[" vars)
                   (math-read-expr vars)
index d12feaae8c3a032d694861044ad43a46ac18e477..2ee1d34bf15cfbb4b1b1b3bd846a1cb262281914 100644 (file)
@@ -597,9 +597,9 @@ arguments of `completing-read'."
 (defun timeclock-ask-for-project ()
   "Ask the user for the project they are clocking into."
   (completing-read
-   (format "Clock into which project (default %s): "
-          (or timeclock-last-project
-              (car timeclock-project-list)))
+   (format-prompt "Clock into which project"
+                 (or timeclock-last-project
+                     (car timeclock-project-list)))
    timeclock-project-list
    nil nil nil nil
    (or timeclock-last-project
index b2864746fc71a9f04ca024ff0f0fc27b5389d664..ed13455b7119bef835fe999cd3ecec0d8c7ef98f 100644 (file)
@@ -1276,11 +1276,7 @@ String must be longer than `completion-prefix-min-length'."
 
 (defun interactive-completion-string-reader (prompt)
   (let* ((default (symbol-under-or-before-point))
-        (new-prompt
-         (if default
-             (format "%s (default %s): " prompt default)
-             (format "%s: " prompt)))
-        (read (completing-read new-prompt cmpl-obarray)))
+        (read (completing-read (format-prompt prompt default) cmpl-obarray)))
     (if (zerop (length read)) (setq read (or default "")))
     (list read)))
 
index 3557dce58545a1f6c27d6c1e3e86e3535c26aa4f..cb1a78d8e204bba79c9c6ef0c20e7afb5982f3e5 100644 (file)
@@ -485,10 +485,8 @@ Return a list suitable for use in `interactive'."
          (default (and (symbolp v) (custom-variable-p v) (symbol-name v)))
          (enable-recursive-minibuffers t)
          val)
-     (setq val (completing-read
-               (if default (format "Customize variable (default %s): " default)
-                 "Customize variable: ")
-               obarray 'custom-variable-p t nil nil default))
+     (setq val (completing-read (format-prompt "Customize variable" default)
+                               obarray 'custom-variable-p t nil nil default))
      (list (if (equal val "")
               (if (symbolp v) v nil)
             (intern val)))))
@@ -1084,9 +1082,7 @@ for the MODE to customize."
       (if (and group (not current-prefix-arg))
          major-mode
        (intern
-        (completing-read (if group
-                             (format "Mode (default %s): " major-mode)
-                           "Mode: ")
+        (completing-read (format-prompt "Mode" (and group major-mode))
                          obarray
                          'custom-group-of-mode
                          t nil nil (if group (symbol-name major-mode))))))))
@@ -1219,8 +1215,8 @@ that were added or redefined since that version."
   (interactive
    (list
     (read-from-minibuffer
-     (format "Customize options changed, since version (default %s): "
-            customize-changed-options-previous-release))))
+     (format-prompt "Customize options changed, since version"
+                   customize-changed-options-previous-release))))
   (if (equal since-version "")
       (setq since-version nil)
     (unless (condition-case nil
index 82f4455392e630b7e2684a3b33d2b3a53a82fa0f..3ee877ee8dea683d4d52f502695011ff9d21415c 100644 (file)
@@ -153,10 +153,8 @@ the string of command switches used as the third argument of `diff'."
          (lambda ()
            (set (make-local-variable 'minibuffer-default-add-function) nil)
            (setq minibuffer-default defaults))
-       (read-file-name
-        (format "Diff %s with%s: " current
-                (if default (format " (default %s)" default) ""))
-        target-dir default t))
+       (read-file-name (format-prompt "Diff %s with" default current)
+                       target-dir default t))
       (if current-prefix-arg
          (read-string "Options for diff: "
                       (if (stringp diff-switches)
index 05c5a70422c01d0a1161536cb679aa9515ceb530..80a266f7dcd279cedd7b8215f5533d5ab4c2c89f 100644 (file)
@@ -327,21 +327,19 @@ See also the functions:
              (when file
                (file-name-extension file))))
          (suffix
-          (read-string (format "%s extension%s: "
-                               (if (equal current-prefix-arg '(4))
-                                   "UNmarking"
-                                 "Marking")
-                               (if default
-                                   (format " (default %s)" default)
-                                 "")) nil nil default))
+          (read-string (format-prompt
+                        "%s extension" default
+                        (if (equal current-prefix-arg '(4))
+                            "UNmarking"
+                          "Marking"))
+                       nil nil default))
          (marker
           (pcase current-prefix-arg
             ('(4) ?\s)
             ('(16)
              (let* ((dflt (char-to-string dired-marker-char))
                     (input (read-string
-                            (format
-                             "Marker character to use (default %s): " dflt)
+                            (format-prompt "Marker character to use" dflt)
                             nil nil dflt)))
                (aref input 0)))
             (_ dired-marker-char))))
index deac45892ead6fe2b5f5eccff194df95b6d4a99e..0ebd2741d2e383834714ab527623653b5c96625a 100644 (file)
@@ -1856,7 +1856,7 @@ function at point for which PREDICATE returns non-nil)."
                   "There are no qualifying advised functions")))
   (let* ((function
          (completing-read
-          (format "%s (default %s): " (or prompt "Function") default)
+          (format-prompt (or prompt "Function") default)
           ad-advised-functions
           (if predicate
                (lambda (function)
@@ -1884,7 +1884,7 @@ class of FUNCTION)."
                  (cl-return class)))
            (error "ad-read-advice-class: `%s' has no advices" function)))
   (let ((class (completing-read
-               (format "%s (default %s): " (or prompt "Class") default)
+               (format-prompt (or prompt "Class") default)
                ad-advice-class-completion-table nil t)))
     (if (equal class "")
        default
@@ -1902,8 +1902,8 @@ An optional PROMPT is used to prompt for the name."
               (error "ad-read-advice-name: `%s' has no %s advice"
                      function class)
             (car (car name-completion-table))))
-        (prompt (format "%s (default %s): " (or prompt "Name") default))
-        (name (completing-read prompt name-completion-table nil t)))
+        (name (completing-read (format-prompt (or prompt "Name") default)
+                                name-completion-table nil t)))
     (if (equal name "")
        (intern default)
       (intern name))))
@@ -1923,9 +1923,9 @@ be used to prompt for the function."
 (defun ad-read-regexp (&optional prompt)
   "Read a regular expression from the minibuffer."
   (let ((regexp (read-from-minibuffer
-                (concat (or prompt "Regular expression")
-                        (if (equal ad-last-regexp "") ": "
-                          (format " (default %s): " ad-last-regexp))))))
+                 (format-prompt (or prompt "Regular expression")
+                                (and (not (equal ad-last-regexp ""))
+                                     ad-last-regexp)))))
     (setq ad-last-regexp
          (if (equal regexp "") ad-last-regexp regexp))))
 
index ed28997292f96d7f9c1ea1445d83eabfe2804f49..1bdb2a3d8caff3a5f7f71e6f5fb78ca73fd3161b 100644 (file)
@@ -653,9 +653,7 @@ Redefining FUNCTION also cancels it."
      (when (special-form-p fn)
        (setq fn nil))
      (setq val (completing-read
-               (if fn
-                   (format "Debug on entry to function (default %s): " fn)
-                 "Debug on entry to function: ")
+                (format-prompt "Debug on entry to function" fn)
                obarray
                #'(lambda (symbol)
                    (and (fboundp symbol)
@@ -758,8 +756,7 @@ another symbol also cancels it."
    (let* ((var-at-point (variable-at-point))
           (var (and (symbolp var-at-point) var-at-point))
           (val (completing-read
-                (concat "Debug when setting variable"
-                        (if var (format " (default %s): " var) ": "))
+                (format-prompt "Debug when setting variable" var)
                 obarray #'boundp
                 t nil nil (and var (symbol-name var)))))
      (list (if (equal val "") var (intern val)))))
index 51b7db24f3cc9cc0692c96c9be40734722366865..c2faac8085b1ef3d09df4d852bd8debec4eb152b 100644 (file)
@@ -57,10 +57,9 @@ If OBJECT is not already compiled, we compile it, but do not
 redefine OBJECT if it is a symbol."
   (interactive
    (let* ((fn (function-called-at-point))
-          (prompt (if fn (format "Disassemble function (default %s): " fn)
-                    "Disassemble function: "))
           (def (and fn (symbol-name fn))))
-     (list (intern (completing-read prompt obarray 'fboundp t nil nil def))
+     (list (intern (completing-read (format-prompt "Disassemble function" fn)
+                                    obarray 'fboundp t nil nil def))
            nil 0 t)))
   (if (and (consp object) (not (functionp object)))
       (setq object `(lambda () ,object)))
index 241eece05b681176d963c7cad9c42a047703f765..3c347c0b199e02e55e7c7434e0c8bf9c49ddcb52 100644 (file)
@@ -1635,9 +1635,7 @@ Signals an error if no test name was read."
                     nil)))
     (ert-test (setq default (ert-test-name default))))
   (when add-default-to-prompt
-    (setq prompt (if (null default)
-                     (format "%s: " prompt)
-                   (format "%s (default %s): " prompt default))))
+    (setq prompt (format-prompt prompt default)))
   (let ((input (completing-read prompt obarray #'ert-test-boundp
                                 t nil history default nil)))
     ;; completing-read returns an empty string if default was nil and
@@ -2023,9 +2021,7 @@ and how to display message."
                             (car ert--selector-history)
                           "t")))
            (read
-            (completing-read (if (null default)
-                                 "Run tests: "
-                               (format "Run tests (default %s): " default))
+            (completing-read (format-prompt "Run tests" default)
                              obarray #'ert-test-boundp nil nil
                              'ert--selector-history default nil)))
          nil))
index 56b3e32a3e30ac43e09c1ea8fe1d72a399803bd4..9e252d8c529b05b81a768b1fec4dfdb487081aa2 100644 (file)
@@ -315,9 +315,7 @@ if non-nil)."
                 (thing-at-point 'symbol))))
     (when (and def (not (test-completion def table)))
       (setq def nil))
-    (completing-read (if def
-                         (format "Library name (default %s): " def)
-                       "Library name: ")
+    (completing-read (format-prompt "Library name" def)
                      table nil nil nil nil def)))
 
 ;;;###autoload
@@ -485,12 +483,10 @@ otherwise uses `variable-at-point'."
          (prompt-type (cdr (assq type '((nil . "function")
                                         (defvar . "variable")
                                         (defface . "face")))))
-         (prompt (concat "Find " prompt-type
-                         (and symb (format " (default %s)" symb))
-                         ": "))
          (enable-recursive-minibuffers t))
     (list (intern (completing-read
-                   prompt obarray predicate
+                   (format-prompt "Find %s" symb prompt-type)
+                   obarray predicate
                    t nil nil (and symb (symbol-name symb)))))))
 
 (defun find-function-do-it (symbol type switch-fn)
index e6f54d206d8bd936d8c16810ca8b50607570e864..a173fc060a4ce7bcfae3f4c20883457fbcabfaee 100644 (file)
@@ -2338,10 +2338,7 @@ will be deleted."
          (setq guess nil))
        (setq packages (mapcar #'symbol-name packages))
        (let ((val
-              (completing-read (if guess
-                                   (format "Describe package (default %s): "
-                                           guess)
-                                 "Describe package: ")
+              (completing-read (format-prompt "Describe package" guess)
                                packages nil t nil nil (when guess
                                                         (symbol-name guess)))))
          (list (and (> (length val) 0) (intern val)))))))
index 0e1618e010a52845937baff8e94220b2da1e9bae..0672f6075232d5a0f976f2ca4d832ddc97eab58d 100644 (file)
@@ -489,7 +489,7 @@ Optional argument SYNTAX must be specified if called non-interactively."
   (interactive
    (list (intern
          (completing-read
-          (format "Select syntax (default %s): " reb-re-syntax)
+          (format-prompt "Select syntax" reb-re-syntax)
           '(read string sregex rx)
           nil t nil nil (symbol-name reb-re-syntax)
            'reb-change-syntax-hist))))
index 38a7b8b54c9bd02acb0c419495812f8277503f2a..1b700afd12d2746e48786b60975fda1342864c5b 100644 (file)
@@ -2120,10 +2120,9 @@ position corresponding to each rule."
                         (throw 'found (list kind token
                                             (or (nth 3 rewrite) res)))))))))
          (default-new (smie-config--guess-value sig))
-         (newstr (read-string (format "Adjust rule (%S %S -> %S) to%s: "
-                                      (nth 0 sig) (nth 1 sig) (nth 2 sig)
-                                      (if (not default-new) ""
-                                        (format " (default %S)" default-new)))
+         (newstr (read-string (format-prompt
+                               "Adjust rule (%S %S -> %S) to" default-new
+                               (nth 0 sig) (nth 1 sig) (nth 2 sig))
                               nil nil (format "%S" default-new)))
          (new (car (read-from-string newstr))))
     (let ((old (rassoc sig smie-config--buffer-local)))
index 4ebb7ff711d729a38a428a0f00d71342b68640ad..627305689c7bb61fa28bf016aeaff5ac48e9c8c8 100644 (file)
@@ -265,20 +265,13 @@ be printed along with the arguments in the trace."
 If `current-prefix-arg' is non-nil, also read a buffer and a \"context\"
 \(Lisp expression).  Return (FUNCTION BUFFER FUNCTION-CONTEXT)."
   (cons
-   (let ((default (function-called-at-point))
-         (beg (string-match ":[ \t]*\\'" prompt)))
-     (intern (completing-read (if default
-                                  (format
-                                   "%s (default %s)%s"
-                                   (substring prompt 0 beg)
-                                   default
-                                   (if beg (substring prompt beg) ": "))
-                                prompt)
+   (let ((default (function-called-at-point)))
+     (intern (completing-read (format-prompt prompt default)
                               obarray 'fboundp t nil nil
                               (if default (symbol-name default)))))
    (when current-prefix-arg
      (list
-      (read-buffer "Output to buffer: " trace-buffer)
+      (read-buffer (format-prompt "Output to buffer" trace-buffer))
       (let ((exp
              (let ((minibuffer-completing-symbol t))
                (read-from-minibuffer "Context expression: "
@@ -308,7 +301,7 @@ functions that switch buffers, or do any other display-oriented
 stuff - use `trace-function-background' instead.
 
 To stop tracing a function, use `untrace-function' or `untrace-all'."
-  (interactive (trace--read-args "Trace function"))
+  (interactive (trace--read-args "Trace function"))
   (trace-function-internal function buffer nil context))
 
 ;;;###autoload
@@ -316,7 +309,7 @@ To stop tracing a function, use `untrace-function' or `untrace-all'."
   "Trace calls to function FUNCTION, quietly.
 This is like `trace-function-foreground', but without popping up
 the output buffer or changing the window configuration."
-  (interactive (trace--read-args "Trace function in background"))
+  (interactive (trace--read-args "Trace function in background"))
   (trace-function-internal function buffer t context))
 
 ;;;###autoload
index 2fffcbb154a0587024c51bed136d83238e8c2e30..5dd81fab3b652dffb8acc6195637e5780019ffbb 100644 (file)
               (if window-system (concat "-" (upcase (symbol-name window-system))))
               "-keys")))
     (set-visited-file-name
-     (read-file-name (format "Save key mapping to file (default %s): " file) nil file)))
+     (read-file-name (format-prompt "Save key mapping to file" file)
+                     nil file)))
   (save-buffer)
 
   (message "That's it!  Press any key to exit")
index 477f148197b62ac908ee7cb57d89b66731232203..1bce986a806d6db28e3fda72261e839745750abd 100644 (file)
@@ -516,8 +516,8 @@ PROC is the server process."
          (filename (or file (plist-get elt :file) "unknown")))
     (if elt
         (let* ((file (read-file-name
-                      (format "Local filename (default %s): "
-                              (file-name-nondirectory filename))
+                      (format-prompt "Local filename"
+                                     (file-name-nondirectory filename))
                       (or erc-dcc-get-default-directory
                           default-directory)
                       (expand-file-name (file-name-nondirectory filename)
index 419b76101b5b2fbb5dc16396756c9af4fa92b6e2..3ed4b54d2231269166f8e9e505d949d5afa19810 100644 (file)
@@ -445,7 +445,7 @@ sets the CHARSET property of the character at point."
   (interactive (list (progn
                       (barf-if-buffer-read-only)
                       (read-charset
-                        (format "Use charset (default %s): " (charset-after))
+                        (format-prompt "Use charset" (charset-after))
                         (charset-after)))
                     (if (and mark-active (not current-prefix-arg))
                         (region-beginning))
index ba85973bf103735ccfab3b6551613f52998f3dfd..7c23e58fd9de372b15b7fc8402488267665f7465 100644 (file)
@@ -1212,10 +1212,7 @@ Value is the new attribute value."
   (setq name (concat (upcase (substring name 0 1)) (substring name 1)))
   (let* ((completion-ignore-case t)
         (value (completing-read
-                 (format-message (if default
-                                     "%s for face `%s' (default %s): "
-                                   "%s for face `%s': ")
-                                 name face default)
+                 (format-prompt "%s for face `%s'" default name face)
                 completion-alist nil nil nil nil default)))
     (if (equal value "") default value)))
 
index af7d84cd099bdb386e99db457db78a1e01b723c1..3e65c687af6e897084bc6e914b02d937a8203ae5 100644 (file)
@@ -1751,7 +1751,7 @@ Function CONT is applied to the entry chosen by the user."
        ;; Bug: prompting may assume unique strings, no "".
        (setq choice
              (completing-read
-              (format "%s (default %s): " title (car (car alist)))
+              (format-prompt title (car (car alist)))
               alist nil t
               ;; (cons (car (car alist)) 0)
               nil)))
index 5d863626fa542296c72c0914e08b8e62b2f03001..911e7ba9e3d09f90dc9acb99439eb34e8b0085fa 100644 (file)
@@ -45,9 +45,7 @@ Intended to be used in the `interactive' spec of
                       (symbol-name default)))
          (variable
          (completing-read
-          (if default
-              (format "%s (default %s): " prompt default)
-            (format "%s: " prompt))
+           (format-prompt prompt default)
           obarray
           (lambda (sym)
             (or (custom-variable-p sym)
@@ -65,9 +63,7 @@ Intended to be used in the `interactive' spec of
     (let* ((default (and (symbolp major-mode) (symbol-name major-mode)))
            (value
             (completing-read
-             (if default
-                 (format "Add %s with value (default %s): " variable default)
-               (format "Add %s with value: " variable))
+             (format-prompt "Add %s with value" default variable)
              obarray
              (lambda (sym)
                (string-match-p "-mode\\'" (symbol-name sym)))
@@ -79,11 +75,8 @@ Intended to be used in the `interactive' spec of
    ((eq variable 'coding)
     (let ((default (and (symbolp buffer-file-coding-system)
                         (symbol-name buffer-file-coding-system))))
-      (read-coding-system
-       (if default
-           (format "Add %s with value (default %s): " variable default)
-         (format "Add %s with value: " variable))
-       default)))
+      (read-coding-system (format-prompt "Add %s with value" default variable)
+                          default)))
    (t
     (let ((default (format "%S"
                            (cond ((eq variable 'unibyte) t)
@@ -102,9 +95,7 @@ Intended to be used in the `interactive' spec of
   (let* ((default (and (symbolp major-mode) (symbol-name major-mode)))
         (mode
          (completing-read
-          (if default
-              (format "Mode or subdirectory (default %s): " default)
-            (format "Mode or subdirectory: "))
+          (format-prompt "Mode or subdirectory" default)
           obarray
           (lambda (sym)
             (and (string-match-p "-mode\\'" (symbol-name sym))
index 5f5902d0cb6eea65ae9a143bc0cf4c336aa084ad..e6629d2a21ad544f9bff0134b104628d96dfff66 100644 (file)
@@ -1563,8 +1563,8 @@ use with M-x."
                (and (not (memq 'eight-bit-control charsets))
                     (not (memq 'eight-bit-graphic charsets)))))
         (setq from-coding (read-coding-system
-                           (format "Recode filename %s from (default %s): "
-                                   filename default-coding)
+                           (format-prompt "Recode filename %s from"
+                                          filename default-coding)
                            default-coding))
        (setq from-coding (read-coding-system
                          (format "Recode filename %s from: " filename))))
@@ -1576,8 +1576,8 @@ use with M-x."
                          (format "Recode filename %s from %s to: "
                                  filename from-coding)))
        (setq to-coding (read-coding-system
-                       (format "Recode filename %s from %s to (default %s): "
-                               filename from-coding default-coding)
+                       (format-prompt "Recode filename %s from %s to"
+                                      default-coding filename from-coding)
                        default-coding)))
      (list filename from-coding to-coding)))
 
index f3559ba9b21160e10e944939e4e28aaa6ce9a504..905ca2d9ec97c41bd6f931ecccc1d1923a3b08be 100644 (file)
@@ -342,8 +342,8 @@ for identifying regular expressions at the beginning of the region."
 FORMAT defaults to `buffer-file-format'.  It is a symbol naming one of the
 formats defined in `format-alist', or a list of such symbols."
   (interactive
-   (list (format-read (format "Translate buffer to format (default %s): "
-                             buffer-file-format))))
+   (list (format-read (format-prompt "Translate buffer to format"
+                                    buffer-file-format))))
   (format-encode-region (point-min) (point-max) format))
 
 (defun format-encode-region (beg end &optional format)
@@ -352,8 +352,8 @@ FORMAT defaults to `buffer-file-format'.  It is a symbol naming
 one of the formats defined in `format-alist', or a list of such symbols."
   (interactive
    (list (region-beginning) (region-end)
-        (format-read (format "Translate region to format (default %s): "
-                             buffer-file-format))))
+        (format-read (format-prompt "Translate region to format"
+                                    buffer-file-format))))
   (if (null format)    (setq format buffer-file-format))
   (if (symbolp format) (setq format (list format)))
   (save-excursion
index 081d3010e9bb780395150927645d384355da99d5..70088545a68f918e27a5915c89be9b0bc84790aa 100644 (file)
@@ -733,7 +733,7 @@ argument PARAMETERS specifies additional frame parameters."
    (list
     (let* ((default (cdr (assq 'name (frame-monitor-attributes)))))
       (completing-read
-       (format "Make frame on monitor (default %s): " default)
+       (format-prompt "Make frame on monitor" default)
        (or (delq nil (mapcar (lambda (a)
                                (cdr (assq 'name a)))
                              (display-monitor-attributes-list)))
@@ -760,7 +760,7 @@ If DISPLAY is nil, that stands for the selected frame's display."
    (list
     (let* ((default (frame-parameter nil 'display))
            (display (completing-read
-                     (format "Close display (default %s): " default)
+                     (format-prompt "Close display" default)
                      (delete-dups
                       (mapcar (lambda (frame)
                                 (frame-parameter frame 'display))
@@ -1130,7 +1130,7 @@ If there is no frame by that name, signal an error."
    (let* ((frame-names-alist (make-frame-names-alist))
           (default (car (car frame-names-alist)))
           (input (completing-read
-                  (format "Select Frame (default %s): " default)
+                  (format-prompt "Select Frame" default)
                   frame-names-alist nil t nil 'frame-name-history)))
      (if (= (length input) 0)
         (list default)
index ad6e0e30bca7f7e15306820ba9e7dc73e0a0c080..cafaf69a96b1a197412f80c2cef220038bcbe96e 100644 (file)
@@ -2416,9 +2416,8 @@ the bug number, and browsing the URL must return mbox output."
     ;; Pass DEF as the value of COLLECTION instead of DEF because:
     ;; a) null input should not cause DEF to be returned and
     ;; b) TAB and M-n still work this way.
-    (or (completing-read-multiple
-        (format "Bug IDs%s: " (if def (format " (default %s)" def) ""))
-        (and def (list (format "%s" def))))
+    (or (completing-read-multiple (format-prompt "Bug IDs" def)
+                                 (and def (list (format "%s" def))))
        def)))
 
 (defun gnus-read-ephemeral-bug-group (ids mbox-url &optional window-conf)
@@ -3744,9 +3743,8 @@ Uses the process/prefix convention."
        (error "No group on the current line"))
       (string-to-number
        (let ((s (read-string
-                (format "Level (default %s): "
-                        (or (gnus-group-group-level)
-                            gnus-level-default-subscribed)))))
+                (format-prompt "Level" (or (gnus-group-group-level)
+                                           gnus-level-default-subscribed)))))
         (if (string-match "^\\s-*$" s)
             (int-to-string (or (gnus-group-group-level)
                                gnus-level-default-subscribed))
index 8f37fc88284b216de9b50ca238a95dde0283f0d0..0cde893d2153ed7472d4248cd46aed28c4660f0d 100644 (file)
@@ -9389,10 +9389,10 @@ default."
            (cond ((= (length urls) 1)
                   (car urls))
                  ((> (length urls) 1)
-                  (completing-read (format "URL to browse (default %s): "
-                                           (gnus-shorten-url (car urls) 40))
-                                   urls nil t nil nil
-                                   (car urls)))))
+                  (completing-read
+                   (format-prompt "URL to browse"
+                                  (gnus-shorten-url (car urls) 40))
+                   urls nil t nil nil (car urls)))))
       (if target
          (if external
              (funcall browse-url-secondary-browser-function target)
index 7f8ab5f9ef5f36f32aa58f7a9969644d9255e71a..a01fd2729afd5a8959f4f5cd5c60c42f391adac6 100644 (file)
@@ -1364,10 +1364,7 @@ PROMPT overrides the default one used to ask user for a file name."
          (setq file
                (read-file-name
                 (or prompt
-                    (format "Save MIME part to%s: "
-                            (if filename
-                                (format " (default %s)" filename)
-                              "")))
+                    (format-prompt "Save MIME part to" filename))
                 (or directory mm-default-directory default-directory)
                 (expand-file-name
                  (or filename "")
index 617f6ae5e8013ae3e5b310d663dd3dd11364826c..a9943ccd7f40a3162d4f5b97558b41447e1e3142 100644 (file)
@@ -922,10 +922,7 @@ it is displayed along with the global value."
          (orig-buffer (current-buffer))
         val)
      (setq val (completing-read
-                (if (symbolp v)
-                    (format
-                     "Describe variable (default %s): " v)
-                  "Describe variable: ")
+                (format-prompt "Describe variable" (and (symbolp v) v))
                 #'help--symbol-completion-table
                 (lambda (vv)
                   ;; In case the variable only exists in the buffer
@@ -1422,10 +1419,8 @@ current buffer and the selected frame, respectively."
           (v-or-f (if found v-or-f (function-called-at-point)))
           (found (or found v-or-f))
           (enable-recursive-minibuffers t)
-          (val (completing-read (if found
-                                   (format
-                                     "Describe symbol (default %s): " v-or-f)
-                                 "Describe symbol: ")
+          (val (completing-read (format-prompt "Describe symbol"
+                                               (and found v-or-f))
                                #'help--symbol-completion-table
                                (lambda (vv)
                                   (cl-some (lambda (x) (funcall (nth 1 x) vv))
@@ -1601,7 +1596,7 @@ keymap value."
   (interactive
    (let* ((km (help-fns--most-relevant-active-keymap))
           (val (completing-read
-                (format "Keymap (default %s): " km)
+                (format-prompt "Keymap" km)
                 obarray
                 (lambda (m) (and (boundp m) (keymapp (symbol-value m))))
                 t nil 'keymap-name-history
index 1b0149616f2e8be0b91b4031067656ad0b4e33b2..45159d44779c93c413a79bfbe05ba0b5b2536264 100644 (file)
@@ -364,7 +364,7 @@ With argument, display info only for the selected version."
              (sort (delete-dups res) #'string>)))
           (current (car all-versions)))
       (setq version (completing-read
-                    (format "Read NEWS for the version (default %s): " current)
+                    (format-prompt "Read NEWS for the version" current)
                     all-versions nil nil nil nil current))
       (if (integerp (string-to-number version))
          (setq version (string-to-number version))
@@ -533,12 +533,9 @@ If INSERT (the prefix arg) is non-nil, insert the message in the buffer."
    (let ((fn (function-called-at-point))
         (enable-recursive-minibuffers t)
         val)
-     (setq val (completing-read
-               (if fn
-                   (format "Where is command (default %s): " fn)
-                 "Where is command: ")
-               obarray 'commandp t nil nil
-               (and fn (symbol-name fn))))
+     (setq val (completing-read (format-prompt "Where is command" fn)
+                               obarray 'commandp t nil nil
+                               (and fn (symbol-name fn))))
      (list (unless (equal val "") (intern val))
           current-prefix-arg)))
   (unless definition (error "No command"))
index 0ffe77d276346834a1920b35699cc7d69f2c18ff..0fe651ace34a353dafa17ff772f1924d6f4118cb 100644 (file)
@@ -657,10 +657,7 @@ then remove all hi-lock highlighting."
                                         (car pattern)))
                                   hi-lock-interactive-patterns))))
        (list
-        (completing-read (if (null defaults)
-                             "Regexp to unhighlight: "
-                           (format "Regexp to unhighlight (default %s): "
-                                   (car defaults)))
+        (completing-read (format-prompt "Regexp to unhighlight" (car defaults))
                          (mapcar (lambda (pattern)
                                    (cons (or (car (rassq pattern hi-lock-interactive-lighters))
                                              (car pattern))
@@ -747,8 +744,7 @@ with completion and history."
           (if (and hi-lock-auto-select-face (not current-prefix-arg))
        (setq face (or (pop hi-lock--unused-faces) (car defaults)))
       (setq face (completing-read
-                 (format "Highlight using face (default %s): "
-                         (car defaults))
+                 (format-prompt "Highlight using face" (car defaults))
                  obarray 'facep t nil 'face-name-history defaults))
       ;; Update list of un-used faces.
       (setq hi-lock--unused-faces (remove face hi-lock--unused-faces))
index c9ca1f87424e7a22825c52b2cba683d8171be835..80c5b073985649752dd5636ac960d141a616ec1a 100644 (file)
@@ -1234,14 +1234,12 @@ Called interactively, accept a comma separated list of mode names."
                        (symbol-name (buffer-local-value
                                      'major-mode buf)))))
      (mapcar #'intern
-      (completing-read-multiple
-       (if default
-           (format "Filter by major mode (default %s): " default)
-         "Filter by major mode: ")
-       obarray
-       (lambda (e)
-           (string-match "-mode\\'" (if (symbolp e) (symbol-name e) e)))
-       t nil nil default)))
+             (completing-read-multiple
+              (format-prompt "Filter by major mode" default)
+              obarray
+              (lambda (e)
+                (string-match "-mode\\'" (if (symbolp e) (symbol-name e) e)))
+              t nil nil default)))
    :accept-list t)
   (eq qualifier (buffer-local-value 'major-mode buf)))
 
@@ -1259,11 +1257,9 @@ currently used by buffers."
                        (symbol-name (buffer-local-value
                                      'major-mode buf)))))
      (mapcar #'intern
-      (completing-read-multiple
-       (if default
-           (format "Filter by major mode (default %s): " default)
-         "Filter by major mode: ")
-       (ibuffer-list-buffer-modes) nil t nil nil default)))
+             (completing-read-multiple
+              (format-prompt "Filter by major mode" default)
+              (ibuffer-list-buffer-modes) nil t nil nil default)))
    :accept-list t)
   (eq qualifier (buffer-local-value 'major-mode buf)))
 
@@ -1881,9 +1877,7 @@ Otherwise buffers whose name matches an element of
                                      'major-mode buf)))))
      (list (intern
             (completing-read
-             (if default
-                 (format "Mark by major mode (default %s): " default)
-               "Mark by major mode: ")
+             (format-prompt "Mark by major mode" default)
              (ibuffer-list-buffer-modes) nil t nil nil default)))))
   (ibuffer-mark-on-buffer
    #'(lambda (buf)
index 3a16dcb9ac367b45b3d6d838fe53297524636565..8fdacb0214dc123c0d796eaec5a5bc5c38bc7508 100644 (file)
@@ -765,10 +765,13 @@ Return one of the entries in index-alist or nil."
            index-alist))))
     (when (stringp name)
       (setq name (or (imenu-find-default name prepared-index-alist) name)))
-    (cond (prompt)
-         ((and name (imenu--in-alist name prepared-index-alist))
-          (setq prompt (format "Index item (default %s): " name)))
-         (t (setq prompt "Index item: ")))
+    (unless prompt
+      (setq prompt (format-prompt
+                    "Index item"
+                   (and name
+                         (imenu--in-alist name prepared-index-alist)
+                         ;; Default to `name' if it's in the alist.
+                         name))))
     (let ((minibuffer-setup-hook minibuffer-setup-hook))
       ;; Display the completion buffer.
       (if (not imenu-eager-completion-buffer)
index 40f7f6003e782ae112348240d045150a8c55d4ee..bcc2930ffc09a48dd96ab679123fe5d4d43b20f8 100644 (file)
@@ -297,9 +297,7 @@ If optional argument QUERY is non-nil, query for the help mode."
         (completion-ignore-case (info-lookup->ignore-case topic mode))
         (enable-recursive-minibuffers t)
         (value (completing-read
-                (if default
-                    (format "Describe %s (default %s): " topic default)
-                  (format "Describe %s: " topic))
+                (format-prompt "Describe %s" default topic)
                 completions nil nil nil 'info-lookup-history default)))
     (list (if (equal value "") default value) mode)))
 
index ab678c26b62a2893c24fa54972f41d640cd231da..dc1102aab3018eeffc2bd364164fb9b100a761cc 100644 (file)
@@ -1995,12 +1995,9 @@ the Top node in FILENAME."
   "Search for REGEXP, starting from point, and select node it's found in.
 If DIRECTION is `backward', search in the reverse direction."
   (interactive (list (read-string
-                     (if Info-search-history
-                         (format "Regexp search%s (default %s): "
-                                 (if case-fold-search "" " case-sensitively")
-                                 (car Info-search-history))
-                       (format "Regexp search%s: "
-                               (if case-fold-search "" " case-sensitively")))
+                      (format-prompt
+                       "Regexp search%s" (car Info-search-history)
+                      (if case-fold-search "" " case-sensitively"))
                      nil 'Info-search-history)))
   (deactivate-mark)
   (when (equal regexp "")
@@ -2124,12 +2121,9 @@ If DIRECTION is `backward', search in the reverse direction."
 (defun Info-search-backward (regexp &optional bound noerror count)
   "Search for REGEXP in the reverse direction."
   (interactive (list (read-string
-                     (if Info-search-history
-                         (format "Regexp search%s backward (default %s): "
-                                 (if case-fold-search "" " case-sensitively")
-                                 (car Info-search-history))
-                       (format "Regexp search%s backward: "
-                               (if case-fold-search "" " case-sensitively")))
+                      (format-prompt
+                       "Regexp search%s backward" (car Info-search-history)
+                      (if case-fold-search "" " case-sensitively"))
                      nil 'Info-search-history)))
   (Info-search regexp bound noerror count 'backward))
 
@@ -2816,10 +2810,7 @@ new buffer."
        (while (null item)
         (setq item (let ((completion-ignore-case t)
                          (Info-complete-menu-buffer (current-buffer)))
-                     (completing-read (if default
-                                          (format "Menu item (default %s): "
-                                                  default)
-                                        "Menu item: ")
+                     (completing-read (format-prompt "Menu item" default)
                                       #'Info-complete-menu-item nil t nil nil
                                        default))))
        (list item current-prefix-arg))))
index 75d1c611e62abc28e0e8de278563dde033972ad8..ccc8ac9f9e64d36aed4d84a35d37c3f2de9c7d14 100644 (file)
@@ -325,9 +325,7 @@ wrong, use this command again to toggle back to the right mode."
                                'undecided))
                       buffer-file-coding-system)))
      (list (read-coding-system
-           (if default
-               (format "Coding system for following command (default %s): " default)
-             "Coding system for following command: ")
+            (format-prompt "Coding system for following command" default)
            default))))
   (prefix-command-preserve-state)
   (setq mule-cmds--prefixed-command-next-coding-system coding-system)
@@ -613,9 +611,8 @@ When called from a program, the value is the position of the unencodable
 character found, or nil if all characters are encodable."
   (interactive
    (list (let ((default (or buffer-file-coding-system 'us-ascii)))
-          (read-coding-system
-           (format "Coding-system (default %s): " default)
-           default))))
+          (read-coding-system (format-prompt "Coding-system" default)
+                              default))))
   (let ((pos (unencodable-char-position (point) (point-max) coding-system)))
     (if pos
        (goto-char (1+ pos))
@@ -804,9 +801,8 @@ or specify any other coding system (and risk losing\n\
 
       ;; Read a coding system.
       (setq coding-system
-           (read-coding-system
-            (format "Select coding system (default %s): " default)
-            default))
+           (read-coding-system (format-prompt "Select coding system" default)
+                               default))
       (setq last-coding-system-specified coding-system))
 
     (kill-buffer "*Warning*")
index 092abc09b05b2019804c05ea9ee47b5eaf1629db..c4febb26d4f82f0d61661d39c1666f58d848ee41 100644 (file)
@@ -1247,7 +1247,7 @@ Internal use only.")
           (concat "\\(?:" completion-pcm--delim-wild-regex
                   "\\|\\([[:alpha:]]\\)[[:digit:]]\\)"))
          (cs (completing-read
-              (format "Coding system for saving file (default %s): " default)
+              (format-prompt "Coding system for saving file" default)
               combined-table
               nil t nil 'coding-system-history
               (if default (symbol-name default)))))
@@ -1350,8 +1350,7 @@ graphical terminals."
                                 default-terminal-coding-system)
                            default-terminal-coding-system)))
           (read-coding-system
-           (format "Coding system for terminal display (default %s): "
-                   default)
+           (format-prompt "Coding system for terminal display" default)
            default))))
   (if (and (not coding-system)
           (not (terminal-coding-system)))
@@ -1384,8 +1383,7 @@ graphical terminals."
                (default (if (eq (coding-system-type coding) 'raw-text)
                             default-keyboard-coding-system)))
           (read-coding-system
-           (format "Coding system for keyboard input (default %s): "
-                   default)
+           (format-prompt "Coding system for keyboard input" default)
            default))))
   (let ((coding-type (coding-system-type coding-system))
        (saved-meta-mode
@@ -1480,10 +1478,8 @@ the text is encoded or decoded by CODING-SYSTEM."
 This setting is effective for the next communication only."
   (interactive
    (list (read-coding-system
-         (if last-next-selection-coding-system
-             (format "Coding system for the next selection (default %S): "
-                     last-next-selection-coding-system)
-           "Coding system for the next selection: ")
+         (format-prompt "Coding system for the next selection"
+                        last-next-selection-coding-system)
          last-next-selection-coding-system)))
   (if coding-system
       (setq last-next-selection-coding-system coding-system)
@@ -2170,8 +2166,7 @@ Part of the job of this function is setting `buffer-undo-list' appropriately."
         (read-coding-system "Text was really in: ")
         (let ((coding (or buffer-file-coding-system last-coding-system-used)))
           (read-coding-system
-           (concat "But was interpreted as"
-                   (if coding (format " (default %S): " coding) ": "))
+           (format-prompt "But was interpreted as" coding)
            coding))))
   (or (and new-coding coding)
       (error "Coding system not specified"))
index 9ab9e3b0f656e059e264f3ace6c091b856dab345..37fcda70b37254c3870b62cba4207cd59139df92 100644 (file)
@@ -300,9 +300,8 @@ The functions come in the following groups.
 Store the name in the parameter-variable DEFAULT-NAME-VAR.
 PROMPT is a string to be shown when the user is asked for a name."
  (let ((encoding
-        (completing-read
-         (format "%s (default %s): " prompt (symbol-value default-name-var))
-         ogonek-name-encoding-alist nil t)))
+        (completing-read (format-prompt prompt (symbol-value default-name-var))
+                         ogonek-name-encoding-alist nil t)))
   ;; change the default name to the one just read, and
   ;; return the new default as the name you read
   (set default-name-var
@@ -314,8 +313,7 @@ The result is stored in the variable DEFAULT-PREFIX-VAR.
 PROMPT is a string to be shown when the user is asked for a new prefix."
   (let ((prefix-string
          (read-string
-          (format "%s (default %s): " prompt
-                  (char-to-string (eval default-prefix-var))))))
+          (format-prompt prompt (char-to-string (eval default-prefix-var))))))
     (if (> (length prefix-string) 1)
         (error "! Only one character expected")
       ;; set the default prefix character to the one just read
index 81e83d795091f8e16bf3447ff9fc5b8cc3790104..7fb1d8a3ca68b75d7a00f02cf2ac273d990e37d5 100644 (file)
@@ -2337,7 +2337,7 @@ characters in that string."
                   (with-isearch-suspended
                    (setq regexp-collect
                          (read-regexp
-                          (format "Regexp to collect (default %s): " default)
+                          (format-prompt "Regexp to collect" default)
                           default 'occur-collect-regexp-history)))
                   regexp-collect))
             ;; Otherwise normal occur takes numerical prefix argument.
index 9f402716d020e78dd88aaba530d12ba1938c0ce9..bc78e06eab20157a5e51e232d434bf5072fe4bc7 100644 (file)
@@ -267,9 +267,7 @@ that is, with a prefix arg, you get the default behavior."
     (let* ((default (locate-word-at-point))
           (input
            (read-from-minibuffer
-            (if  (> (length default) 0)
-                (format "Locate (default %s): " default)
-              (format "Locate: "))
+             (format-prompt "Locate" default)
             nil nil nil 'locate-history-list default t)))
       (and (equal input "") default
           (setq input default))
index a6a606828f9400bcc4fc0e695a9fd3e22a6e3039..09afad7aa470f3842a7937798b993b8d06f23bf9 100644 (file)
@@ -534,8 +534,7 @@ of a mail alias.  The value is set up, buffer-local, when first needed.")
                      (default-directory (expand-file-name "~/"))
                      (def mail-personal-alias-file))
                  (read-file-name
-                  (format "Read additional aliases from file (default %s): "
-                           def)
+                  (format-prompt "Read additional aliases from file" def)
                    default-directory
                    (expand-file-name def default-directory)
                    t))))
@@ -548,7 +547,7 @@ of a mail alias.  The value is set up, buffer-local, when first needed.")
                      (default-directory (expand-file-name "~/"))
                      (def mail-personal-alias-file))
                  (read-file-name
-                  (format "Read mail aliases from file (default %s): " def)
+                  (format-prompt "Read mail aliases from file" def)
                   default-directory
                   (expand-file-name def default-directory)
                   t))))
index 8e7aaf949371e11bc02b83ede5b3e20403407260..1f688734d478287f4baeb9ece7b51ff237f6166e 100644 (file)
@@ -255,9 +255,9 @@ removed from alias expansions."
 By default, this is the file specified by `mail-personal-alias-file'."
   (interactive
    (list
-    (read-file-name (format "Read mail alias file (default %s): "
-                           mail-personal-alias-file)
-                   nil mail-personal-alias-file t)))
+    (read-file-name
+     (format-prompt "Read mail alias file" mail-personal-alias-file)
+     nil mail-personal-alias-file t)))
   (setq file (expand-file-name (or file mail-personal-alias-file)))
   ;; In case mail-aliases is t, make sure define-mail-alias
   ;; does not recursively call build-mail-aliases.
index 65d598c3bacb191f64f13698f8c86328726cca4c..dd6eecbfd093496c772ec21cbcdd9fec435b18fc 100644 (file)
@@ -529,7 +529,7 @@ This also saves the value of `send-mail-function' via Customize."
            (display-buffer (current-buffer))
            (let ((completion-ignore-case t))
               (completing-read
-               (format "Send mail via (default %s): " (caar options))
+               (format-prompt "Send mail via" (caar options))
                options nil 'require-match nil nil (car options))))))
     ;; Return the choice.
     (cdr (assoc-string choice options t))))
index da8a15f69b9a8706e558bdfe2b28357e704cc231..6427241541128d20028744c8a193d331916a54d3 100644 (file)
@@ -1014,10 +1014,9 @@ to auto-complete your input based on the installed manual pages."
                (completion-ignore-case t)
                Man-completion-cache    ;Don't cache across calls.
                (input (completing-read
-                       (format "Manual entry%s"
-                               (if (string= default-entry "")
-                                   ": "
-                                 (format " (default %s): " default-entry)))
+                       (format-prompt "Manual entry"
+                                       (and (not (equal default-entry ""))
+                                            default-entry))
                         'Man-completion-table
                        nil nil nil 'Man-topic-history default-entry)))
           (if (string= input "")
index 2b8d4d0ce625771e01d8998690e1a0ae8bfcf13f..e7dad48cf4a647854d52400c116d73ae79f81b3b 100644 (file)
@@ -922,7 +922,7 @@ opposite of the browser kind of `browse-url-browser-function'."
                        'external
                      'internal))
           (k (intern (completing-read
-                      (format "Browser kind (default %s): " default)
+                      (format-prompt "Browser kind" default)
                       '(internal external)
                       nil t nil nil
                       default))))
index 4b897fa34e6d68bbebf37046762dad47987f2622..b720edc7fef929c6ff7c2339fdd64335841e5970 100644 (file)
@@ -307,11 +307,10 @@ If BUFFER, the data to be rendered is in that buffer.  In that
 case, this function doesn't actually fetch URL.  BUFFER will be
 killed after rendering."
   (interactive
-   (let* ((uris (eww-suggested-uris))
-         (prompt (concat "Enter URL or keywords"
-                         (if uris (format " (default %s)" (car uris)) "")
-                         ": ")))
-     (list (read-string prompt nil 'eww-prompt-history uris)
+   (let ((uris (eww-suggested-uris)))
+     (list (read-string (format-prompt "Enter URL or keywords"
+                                       (and uris (car uris)))
+                        nil 'eww-prompt-history uris)
            (prefix-numeric-value current-prefix-arg))))
   (setq url (eww--dwim-expand-url url))
   (pop-to-buffer-same-window
index 1766e192f2df052ba20228fa5982deb22c9a3397..f296ae3afe16ce70201f3ca5be7547b3e438a152 100644 (file)
@@ -625,7 +625,7 @@ SERVER-PLIST is the property list for the server."
         (default (or (plist-get server-plist :encryption)
                      "plain")))
     (intern
-     (completing-read (format "Encryption (default %s): " default)
+     (completing-read (format-prompt "Encryption" default)
                       choices nil t nil nil default))))
 
 (defun rcirc-keepalive ()
index 1b1920bf1954828c6bf9fa3b9e922044bc537eca..13b672bd53b64f54931a18a6163310775f04f15e 100644 (file)
@@ -2913,11 +2913,8 @@ attempts to find a file whose name is produced by (format FMT FILENAME)."
            (and w (progn (compilation-set-window w marker)
                           (compilation-set-overlay-arrow w))))
           (let* ((name (read-file-name
-                        (format "Find this %s in%s: "
-                                compilation-error
-                                (if filename
-                                    (format " (default %s)" filename)
-                                  ""))
+                        (format-prompt "Find this %s in"
+                                       filename compilation-error)
                         spec-dir filename t nil
                         ;; The predicate below is fine when called from
                         ;; minibuffer-complete-and-exit, but it's too
index 7a1c2e4d24ea264466b8cfdc94ade0a1638e351b..af179e2797e86f2cb1864bb883575e26456af7c3 100644 (file)
@@ -6306,8 +6306,7 @@ Customized by setting variables `cperl-shrink-wrap-info-frame',
   (interactive
    (let* ((default (cperl-word-at-point))
          (read (read-string
-                (format "Find doc for Perl function (default %s): "
-                        default))))
+                (format-prompt "Find doc for Perl function" default))))
      (list (if (equal read "")
               default
             read))))
@@ -8266,10 +8265,7 @@ the appropriate statement modifier."
   (interactive
    (list (let* ((default-entry (cperl-word-at-point))
                 (input (read-string
-                        (format "perldoc entry%s: "
-                                (if (string= default-entry "")
-                                    ""
-                                  (format " (default %s)" default-entry))))))
+                        (format-prompt "perldoc entry" default-entry))))
            (if (string= input "")
                (if (string= default-entry "")
                    (error "No perldoc args given")
index 9f34a377f4a036c2a48c1cd6ef4b0746e2903f9b..59db646ff328ce24fa91c82c08f1819d41eb1648 100644 (file)
@@ -554,10 +554,7 @@ Used by these commands to determine defaults."
 
 ;;; Reads a string from the user.
 (defun lisp-symprompt (prompt default)
-  (list (let* ((prompt (if default
-                          (format "%s (default %s): " prompt default)
-                        (concat prompt ": ")))
-              (ans (read-string prompt)))
+  (list (let ((ans (read-string (format-prompt prompt default))))
          (if (zerop (length ans)) default ans))))
 
 
index 3dd9b8dae6af64d4060be113275f74e277d5a102..55a78c6cc85fb4b72114c62125492aeb2a3cca8b 100644 (file)
@@ -1048,10 +1048,9 @@ directory and makes this the current buffer's default directory."
                  (save-excursion
                    (skip-syntax-backward "-(")
                    (thing-at-point 'symbol)))))
-    (completing-read
-     (format (if def "Function (default %s): " "Function: ") def)
-     (inferior-octave-completion-table)
-     nil nil nil nil def)))
+    (completing-read (format-prompt "Function" def)
+                     (inferior-octave-completion-table)
+                     nil nil nil nil def)))
 
 (defun octave-goto-function-definition (fn)
   "Go to the function definition of FN in current buffer."
@@ -1172,10 +1171,7 @@ q: Don't fix\n" func file))
                               (min (line-end-position 4) end)
                               t)
                          (match-string 1))))
-           (old-func (read-string (format (if old-func
-                                              "Name to replace (default %s): "
-                                            "Name to replace: ")
-                                          old-func)
+           (old-func (read-string (format-prompt "Name to replace" old-func)
                                   nil nil old-func)))
       (if (and func old-func (not (equal func old-func)))
           (perform-replace old-func func 'query
@@ -1454,7 +1450,7 @@ The block marked is the one that contains point or follows point."
 Prompt for the function's name, arguments and return values (to be
 entered without parens)."
   (let* ((defname (file-name-sans-extension (buffer-name)))
-         (name (read-string (format "Function name (default %s): " defname)
+         (name (read-string (format-prompt "Function name" defname)
                             nil nil defname))
          (args (read-string "Arguments: "))
          (vals (read-string "Return values: ")))
index d83af83b32e43d29434524b5d94fcb4dcfa4faa5..ccbcb0813058b6dc1e152617d0f84fd81be6be17 100644 (file)
@@ -4585,9 +4585,7 @@ Interactively, prompt for symbol."
   (interactive
    (let ((symbol (python-eldoc--get-symbol-at-point))
          (enable-recursive-minibuffers t))
-     (list (read-string (if symbol
-                            (format "Describe symbol (default %s): " symbol)
-                          "Describe symbol: ")
+     (list (read-string (format-prompt "Describe symbol" symbol)
                         nil nil symbol))))
   (message (python-eldoc--get-doc-at-point symbol)))
 
index 5a47594878e288f0a2cf07c20c1031f544397cb4..3c249b7bc0e455c141be981d2f796451ed519dfa 100644 (file)
@@ -2206,8 +2206,7 @@ Shell script files can cause this function be called automatically
 when the file is visited by having a `sh-shell' file-local variable
 whose value is the shell name (don't quote it)."
   (interactive (list (completing-read
-                      (format "Shell (default %s): "
-                              sh-shell-file)
+                      (format-prompt "Shell" sh-shell-file)
                       ;; This used to use interpreter-mode-alist, but that is
                       ;; no longer appropriate now that uses regexps.
                       ;; Maybe there could be a separate variable that lists
index 7ffa6d41dacf6e04f742aafe0c607b1ad5e6f399..33aad2d39f7c492478957571906729944b172142 100644 (file)
@@ -1346,9 +1346,8 @@ Prefix argument means invert sense of `tcl-use-smart-word-finder'."
                       (not tcl-use-smart-word-finder)
                     tcl-use-smart-word-finder))))
        (completing-read
-        (if (or (null word) (string= word ""))
-            "Help on Tcl command: "
-          (format "Help on Tcl command (default %s): " word))
+         (format-prompt "Help on Tcl command: "
+                        (and (not (equal word "")) word))
         tcl-help-alist nil t nil nil word)))
     current-prefix-arg))
   (if (not (equal tcl-help-directory-list tcl-help-saved-dirs))
index 9922aac9ec93af5a07780e899348ee0b5a67a697..ebf309a88fefdee56e86707b915458d95d8dda5e 100644 (file)
@@ -521,8 +521,9 @@ Called from a program, takes three args; START, END and STRING."
                              #'rectangle--string-erase-preview nil t)
                    (add-hook 'post-command-hook
                              #'rectangle--string-preview nil t))
-               (read-string (format "String rectangle (default %s): "
-                                    (or (car string-rectangle-history) ""))
+               (read-string (format-prompt
+                             "String rectangle"
+                             (or (car string-rectangle-history) ""))
                             nil 'string-rectangle-history
                             (car string-rectangle-history)
                             'inherit-input-method))))))
@@ -549,8 +550,8 @@ This command does not delete or overwrite any existing text."
          (list
           (region-beginning)
           (region-end)
-          (read-string (format "String insert rectangle (default %s): "
-                               (or (car string-rectangle-history) ""))
+          (read-string (format-prompt "String insert rectangle"
+                                      (or (car string-rectangle-history) ""))
                        nil 'string-rectangle-history
                        (car string-rectangle-history)))))
   (apply-on-rectangle 'string-rectangle-line start end string nil))
index 69092c16f96a56fd5d3ae5c8469aeca8190a92c2..a751822c79a95eac5c28c5ee89ae0c0e7c0081d2 100644 (file)
@@ -208,12 +208,15 @@ wants to replace FROM with TO."
           (minibuffer-allow-text-properties t) ; separator uses text-properties
           (prompt
            (cond ((and query-replace-defaults separator)
-                   (format "%s (default %s): " prompt (car minibuffer-history)))
+                   (format-prompt prompt (car minibuffer-history)))
                   (query-replace-defaults
-                   (format "%s (default %s -> %s): " prompt
-                           (query-replace-descr (caar query-replace-defaults))
-                           (query-replace-descr (cdar query-replace-defaults))))
-                  (t (format "%s: " prompt))))
+                   (format-prompt
+                    prompt (format "%s -> %s"
+                                   (query-replace-descr
+                                    (caar query-replace-defaults))
+                                   (query-replace-descr
+                                    (cdar query-replace-defaults)))))
+                  (t (format-prompt prompt nil))))
           (from
            ;; The save-excursion here is in case the user marks and copies
            ;; a region in order to specify the minibuffer input.
@@ -1487,7 +1490,7 @@ which means to discard all text properties."
                ;; Get the regexp for collection pattern.
                (let ((default (car occur-collect-regexp-history)))
                  (read-regexp
-                  (format "Regexp to collect (default %s): " default)
+                  (format-prompt "Regexp to collect" default)
                   default 'occur-collect-regexp-history)))
            ;; Otherwise normal occur takes numerical prefix argument.
            (when current-prefix-arg
index 96b219fc6014ed4248568920506010a195455b1d..5707067e7657e442031b273cc25a4acbda81a1b3 100644 (file)
@@ -2540,10 +2540,8 @@ cell formula was unsafe and user declined confirmation."
            (if (equal initial "\"")
                (progn
                  (if (not (stringp curval)) (setq curval nil))
-                 (read-string (if curval
-                                  (format "String Cell %s (default %s): "
-                                          ses--curcell curval)
-                                (format "String Cell %s: " ses--curcell))
+                 (read-string (format-prompt "String Cell %s"
+                                             curval ses--curcell)
                               nil 'ses-read-string-history curval))
              (read-from-minibuffer
               (format "Cell %s: " ses--curcell)
@@ -3007,9 +3005,9 @@ inserts a new row if at bottom of print area.  Repeat COUNT times."
      (list col
           (if current-prefix-arg
               (prefix-numeric-value current-prefix-arg)
-            (read-from-minibuffer (format "Column %s width (default %d): "
-                                          (ses-column-letter col)
-                                          (ses-col-width col))
+            (read-from-minibuffer (format-prompt "Column %s width"
+                                                 (ses-col-width col)
+                                                 (ses-column-letter col))
                                   nil  ; No initial contents.
                                   nil  ; No override keymap.
                                   t    ; Convert to Lisp object.
index eedbff2d0879c8a4ec67297ec63bcd7b983ef720..376585d8e82ffd08270c0b72118f6b743b5d6668 100644 (file)
@@ -2129,11 +2129,9 @@ See also `minibuffer-history-case-insensitive-variables'."
   (interactive
    (let* ((enable-recursive-minibuffers t)
          (regexp (read-from-minibuffer
-                   (format "Previous element matching regexp%s: "
-                           (if minibuffer-history-search-history
-                               (format " (default %s)"
-                                       (car minibuffer-history-search-history))
-                             ""))
+                   (format-prompt "Previous element matching regexp"
+                                  (and minibuffer-history-search-history
+                                       (car minibuffer-history-search-history)))
                   nil minibuffer-local-map nil
                   'minibuffer-history-search-history
                   (car minibuffer-history-search-history))))
@@ -8312,7 +8310,7 @@ makes it easier to edit it."
   (interactive
    (let* ((default-var (variable-at-point))
           (var (if (custom-variable-p default-var)
-                  (read-variable (format "Set variable (default %s): " default-var)
+                  (read-variable (format-prompt "Set variable" default-var)
                                  default-var)
                 (read-variable "Set variable: ")))
          (minibuffer-help-form `(describe-variable ',var))
index 5b98eb36bb907a7e8f4865234826911dd1867ba0..aab6a3a1283c78cd92ba1cc8f51068bde28624f2 100644 (file)
@@ -1759,8 +1759,9 @@ This is based on `speedbar-initial-expansion-list-name' referencing
   "Change speedbar's default expansion list to NEW-DEFAULT."
   (interactive
    (list
-    (completing-read (format "Speedbar Mode (default %s): "
-                            speedbar-previously-used-expansion-list-name)
+    (completing-read (format-prompt
+                      "Speedbar Mode"
+                     speedbar-previously-used-expansion-list-name)
                     speedbar-initial-expansion-mode-alist
                     nil t "" nil
                     speedbar-previously-used-expansion-list-name)))
index e77c2c1331b83121206e3454d004cac7686ffe48..f0470d806cd88faac2bb933753b326fa4f588677 100644 (file)
@@ -4278,8 +4278,7 @@ well as the newer ports COM10 and higher."
                  ;; `prompt': The most recently used port is provided as
                  ;; the default value, which is used when the user
                  ;; simply presses return.
-                 (if (stringp h) (format "Serial port (default %s): " h)
-                   "Serial port: ")
+                 (format-prompt "Serial port" h)
                  ;; `directory': Most systems have their serial ports
                  ;; in the same directory, so start in the directory
                  ;; of the most recently used port, or in a reasonable
@@ -4294,8 +4293,7 @@ well as the newer ports COM10 and higher."
                  ;; serial port.
                  "")
               (read-from-minibuffer
-               (if (stringp h) (format "Serial port (default %s): " h)
-                 "Serial port: ")
+               (format-prompt "Serial port" h)
                nil nil nil '(file-name-history . 1) nil nil))))
     (if (or (null x) (and (stringp x) (zerop (length x))))
         (setq x h)
@@ -4317,7 +4315,7 @@ Try to be nice by providing useful defaults and history."
              (cond ((string= h serial-no-speed)
                     "Speed (default nil = set by port): ")
                    (h
-                    (format "Speed (default %s b/s): " h))
+                    (format-prompt "Speed" (format "%s b/s" h)))
                    (t
                    (format "Speed (b/s): ")))
              nil nil nil '(history . 1) nil nil)))
index cc5879880c8e5461032b2805c6d091f09d71b5c9..8c824461d22fe51bd2021143bbdd6e4eaed4c3db 100644 (file)
@@ -1883,12 +1883,9 @@ on what is seen near point."
    (list
     (let* ((sym (css--mdn-find-symbol))
           (enable-recursive-minibuffers t)
-          (value (completing-read
-                  (if sym
-                      (format "Describe CSS symbol (default %s): " sym)
-                    "Describe CSS symbol: ")
-                  css--mdn-completion-list nil nil nil
-                  'css--mdn-lookup-history sym)))
+          (value (completing-read (format-prompt "Describe CSS symbol" sym)
+                                  css--mdn-completion-list nil nil nil
+                                  'css--mdn-lookup-history sym)))
       (if (equal value "") sym value))))
   (when symbol
     ;; If we see a single-colon pseudo-element like ":after", turn it
index 8d8223a73263b12f4e6a6e95efe8f5a2be189bc8..c8fd0bea00416b8fcdc3c22e10d34e28737441d8 100644 (file)
@@ -336,9 +336,9 @@ found on the last `refer-find-entry' or `refer-find-next-entry'."
              (list (expand-file-name
                     (if (eq major-mode 'bibtex-mode)
                         (read-file-name
-                         (format ".bib file (default %s): "
-                                 (file-name-nondirectory
-                                  (buffer-file-name)))
+                         (format-prompt ".bib file"
+                                        (file-name-nondirectory
+                                         (buffer-file-name)))
                          (file-name-directory (buffer-file-name))
                          (file-name-nondirectory (buffer-file-name))
                          t)
index b79bb292c8abb38e7a23e40a0c03930988b0d3cb..4c780d8d8c3a6fe90737a651ea1b006f56fdf2e8 100644 (file)
@@ -861,9 +861,7 @@ Optional prefix argument OTHER-WINDOW goes to the label in another window."
         (default (when (looking-back "\\\\\\(?:page\\)?ref{[-a-zA-Z0-9_*.:]*"
                                       (line-beginning-position))
                    (reftex-this-word "-a-zA-Z0-9_*.:")))
-         (label (completing-read (if default
-                                    (format "Label (default %s): " default)
-                                  "Label: ")
+         (label (completing-read (format-prompt "Label" default)
                                 docstruct
                                  (lambda (x) (stringp (car x))) t nil nil
                                 default))
index 04f1dddf5fc035390d7580443f211913b02fb370..e0ef786953e7e5d39817d1ed525674b7c434580f 100644 (file)
@@ -779,7 +779,7 @@ If you like tags and attributes in uppercase, customize
            (setq sgml-tag-last
                 (completing-read
                  (if (> (length sgml-tag-last) 0)
-                     (format "Tag (default %s): " sgml-tag-last)
+                     (format-prompt "Tag" sgml-tag-last)
                    "Tag: ")
                  sgml-tag-alist nil nil nil 'sgml-tag-history sgml-tag-last)))
   ?< str |
@@ -878,9 +878,7 @@ With prefix argument, only self insert."
    (list (let ((def (save-excursion
                      (if (eq (following-char) ?<) (forward-char))
                      (sgml-beginning-of-tag))))
-          (completing-read (if def
-                               (format "Tag (default %s): " def)
-                             "Tag: ")
+          (completing-read (format-prompt "Tag" def)
                            sgml-tag-alist nil nil nil
                            'sgml-tag-history def))))
   (or (and tag (> (length tag) 0))
index 33f181b80c30f3f7cb32bceeef3e34e5d595077b..cfe6ce5ce6140515cc9ec679efe66bb7cf7ce28d 100644 (file)
@@ -1824,11 +1824,11 @@ See `table-insert-row' and `table-insert-column'."
      (list (intern (let ((completion-ignore-case t)
                         (default (car table-insert-row-column-history)))
                     (downcase (completing-read
-                               (format "Insert %s row%s/column%s (default %s): "
-                                       (if (> n 1) (format "%d" n) "a")
-                                       (if (> n 1) "s" "")
-                                       (if (> n 1) "s" "")
-                                       default)
+                               (format-prompt
+                                 "Insert %s row%s/column%s" default
+                                (if (> n 1) (format "%d" n) "a")
+                                (if (> n 1) "s" "")
+                                (if (> n 1) "s" ""))
                                '(("row") ("column"))
                                nil t nil 'table-insert-row-column-history default))))
           n)))
@@ -2534,7 +2534,7 @@ DIRECTION is one of symbols; right, left, above or below."
                                 (caar direction-list)))
           (completion-ignore-case t))
       (intern (downcase (completing-read
-                        (format "Span into (default %s): " default-direction)
+                        (format-prompt "Span into" default-direction)
                         direction-list
                         nil t nil 'table-cell-span-direction-history default-direction))))))
   (unless (memq direction '(right left above below))
@@ -2697,7 +2697,7 @@ Creates a cell on the left and a cell on the right of the current point location
                                   ("Title"
                                    ("Split" . "split") ("Left" . "left") ("Right" . "right"))))
                 (downcase (completing-read
-                           (format "Existing cell contents to (default %s): " default)
+                           (format-prompt "Existing cell contents to" default)
                            '(("split") ("left") ("right"))
                            nil t nil 'table-cell-split-contents-to-history default)))))))
     (unless (eq contents-to 'split)
@@ -2769,7 +2769,7 @@ ORIENTATION is a symbol either horizontally or vertically."
           (completion-ignore-case t)
           (default (car table-cell-split-orientation-history)))
       (intern (downcase (completing-read
-                        (format "Split orientation (default %s): " default)
+                        (format-prompt "Split orientation" default)
                         '(("horizontally") ("vertically"))
                         nil t nil 'table-cell-split-orientation-history default))))))
   (unless (memq orientation '(horizontally vertically))
@@ -2789,7 +2789,7 @@ WHAT is a symbol `cell', `row' or `column'.  JUSTIFY is a symbol
                (completion-ignore-case t)
                (default (car table-target-history)))
           (intern (downcase (completing-read
-                             (format "Justify what (default %s): " default)
+                             (format-prompt "Justify what" default)
                              '(("cell") ("row") ("column"))
                              nil t nil 'table-target-history default))))
         (table--query-justification)))
@@ -2943,7 +2943,7 @@ CALS (DocBook DTD):
          (completion-ignore-case t)
          (default (car table-source-language-history))
          (language (downcase (completing-read
-                              (format "Language (default %s): " default)
+                              (format-prompt "Language" default)
                               table-source-languages
                               nil t nil 'table-source-language-history default))))
      (list
@@ -3366,7 +3366,7 @@ Example:
           (let* ((completion-ignore-case t)
                  (default (car table-sequence-justify-history)))
             (intern (downcase (completing-read
-                               (format "Justify (default %s): " default)
+                               (format-prompt "Justify" default)
                                '(("left") ("center") ("right"))
                                nil t nil 'table-sequence-justify-history default)))))))
   (unless (or (called-interactively-p 'interactive) (table--probe-cell))
@@ -3668,7 +3668,7 @@ companion command to `table-capture' this way.
        (if (and (string= col-delim-regexp "") (string= row-delim-regexp "")) 'left
          (intern
           (downcase (completing-read
-                     (format "Justify (default %s): " default)
+                     (format-prompt "Justify" default)
                      '(("left") ("center") ("right"))
                      nil t nil 'table-capture-justify-history default)))))
       (if (and (string= col-delim-regexp "") (string= row-delim-regexp "")) "1"
@@ -4253,9 +4253,8 @@ cache buffer into the designated cell in the table buffer."
 PROMPT-HISTORY is a cons cell which car is the prompt string and the
 cdr is the history symbol."
   (let ((default (car (symbol-value (cdr prompt-history)))))
-    (read-from-minibuffer
-     (format "%s (default %s): " (car prompt-history) default)
-     "" nil nil (cdr prompt-history) default))
+    (read-from-minibuffer (format-prompt (car prompt-history) default)
+                          "" nil nil (cdr prompt-history) default))
   (car (symbol-value (cdr prompt-history))))
 
 (defun table--buffer-substring-and-trim (beg end)
@@ -4312,7 +4311,7 @@ Returns the coordinate of the final point location."
   (let* ((completion-ignore-case t)
         (default (car table-justify-history)))
     (intern (downcase (completing-read
-                      (format "Justify (default %s): " default)
+                      (format-prompt "Justify" default)
                       '(("left") ("center") ("right") ("top") ("middle") ("bottom") ("none"))
                       nil t nil 'table-justify-history default)))))
 
index d302fb16eda9119e4134271051dbfb4c9c118a22..54bb3569788331b913c05db75d5fbe49a18439d2 100644 (file)
@@ -667,7 +667,7 @@ With a numeric prefix ARG, go back ARG comments."
   "Prompt for a change log name."
   (let* ((default (change-log-name))
         (name (expand-file-name
-               (read-file-name (format "Log file (default %s): " default)
+               (read-file-name (format-prompt "Log file" default)
                                nil default))))
     ;; Handle something that is syntactically a directory name.
     ;; Look for ChangeLog or whatever in that directory.
index 2b1b07927f844e2f394fc1993cc4c0db3e975958..c977291a524e41dc35feb84ca4296afef0f07e7b 100644 (file)
@@ -1807,11 +1807,9 @@ all marked sessions must be active."
                 (ediff-show-meta-buffer session-buf)
               (setq regexp
                     (read-string
-                     (if (stringp default-regexp)
-                         (format
-                          "Filter filenames through regular expression (default %s): "
-                          default-regexp)
-                       "Filter filenames through regular expression: ")
+                      (format-prompt
+                       "Filter filenames through regular expression"
+                       default-regexp)
                      nil
                      'ediff-filtering-regexp-history
                      (eval ediff-default-filtering-regexp t)))
index f56d31c7136fd5ef2740bd4d242c0de0c6d564d3..52878bad8a7c4772f4c44919a848f308e203817d 100644 (file)
@@ -2181,19 +2181,18 @@ a regular expression typed in by the user."
       (setq ediff-skip-diff-region-function ediff-hide-regexp-matches-function
            regexp-A
            (read-string
-            (format
-             "Ignore A-regions matching this regexp (default %s): "
-             ediff-regexp-hide-A))
+            (format-prompt
+             "Ignore A-regions matching this regexp" ediff-regexp-hide-A))
            regexp-B
            (read-string
-            (format
-             "Ignore B-regions matching this regexp (default %s): "
+            (format-prompt
+             "Ignore B-regions matching this regexp"
              ediff-regexp-hide-B)))
       (if ediff-3way-comparison-job
          (setq regexp-C
                (read-string
-                (format
-                 "Ignore C-regions matching this regexp (default %s): "
+                (format-prompt
+                 "Ignore C-regions matching this regexp"
                  ediff-regexp-hide-C))))
       (if (eq ediff-hide-regexp-connective 'and)
          (setq msg-connective "BOTH"
@@ -2220,20 +2219,18 @@ a regular expression typed in by the user."
            ediff-focus-on-regexp-matches-function
            regexp-A
            (read-string
-            (format
-             "Focus on A-regions matching this regexp (default %s): "
-             ediff-regexp-focus-A))
+            (format-prompt
+             "Focus on A-regions matching this regexp" ediff-regexp-focus-A))
            regexp-B
            (read-string
-            (format
-             "Focus on B-regions matching this regexp (default %s): "
-             ediff-regexp-focus-B)))
+            (format-prompt
+             "Focus on B-regions matching this regexp" ediff-regexp-focus-B)))
       (if ediff-3way-comparison-job
          (setq regexp-C
                (read-string
-                (format
-                 "Focus on C-regions matching this regexp (default %s): "
-                 ediff-regexp-focus-C))))
+                (format-prompt
+                 "Focus on C-regions matching this regexp"
+                  ediff-regexp-focus-C))))
       (if (eq ediff-focus-regexp-connective 'and)
          (setq msg-connective "BOTH"
                alt-msg-connective "ONE OF"
index 133d2109f5b67946e1861189fe45ccb0eec6cd22..ae2f8ad6c1c2deda4fec063a9513ce3b75abf867 100644 (file)
@@ -566,10 +566,8 @@ expression; only file names that match the regexp are considered."
                             (ediff-strip-last-dir f))
                           nil 'must-match)
           (read-string
-           (if (stringp default-regexp)
-               (format "Filter filenames through regular expression (default %s): "
-                        default-regexp)
-             "Filter filenames through regular expression: ")
+           (format-prompt "Filter filenames through regular expression"
+                          default-regexp)
            nil
            'ediff-filtering-regexp-history
            (eval ediff-default-filtering-regexp))
@@ -594,10 +592,8 @@ names.  Only the files that are under revision control are taken into account."
      (list (read-directory-name
            "Directory to compare with revision:" dir-A nil 'must-match)
           (read-string
-           (if (stringp default-regexp)
-               (format "Filter filenames through regular expression (default %s): "
-                        default-regexp)
-             "Filter filenames through regular expression: ")
+           (format-prompt
+             "Filter filenames through regular expression" default-regexp)
            nil
            'ediff-filtering-regexp-history
            (eval ediff-default-filtering-regexp))
@@ -632,10 +628,8 @@ regular expression; only file names that match the regexp are considered."
                             (ediff-strip-last-dir f))
                           nil 'must-match)
           (read-string
-           (if (stringp default-regexp)
-               (format "Filter filenames through regular expression (default %s): "
-                        default-regexp)
-             "Filter filenames through regular expression: ")
+           (format-prompt "Filter filenames through regular expression"
+                          default-regexp)
            nil
            'ediff-filtering-regexp-history
            (eval ediff-default-filtering-regexp))
@@ -665,10 +659,8 @@ MERGE-AUTOSTORE-DIR is the directory in which to store merged files."
                             (ediff-strip-last-dir f))
                           nil 'must-match)
           (read-string
-           (if (stringp default-regexp)
-               (format "Filter filenames through regular expression (default %s): "
-                        default-regexp)
-             "Filter filenames through regular expression: ")
+           (format-prompt "Filter filenames through regular expression"
+                          default-regexp)
            nil
            'ediff-filtering-regexp-history
            (eval ediff-default-filtering-regexp))
@@ -707,10 +699,8 @@ MERGE-AUTOSTORE-DIR is the directory in which to store merged files."
                                   (ediff-strip-last-dir f))
                                 nil 'must-match)
           (read-string
-           (if (stringp default-regexp)
-               (format "Filter filenames through regular expression (default %s): "
-                        default-regexp)
-             "Filter filenames through regular expression: ")
+           (format-prompt "Filter filenames through regular expression"
+                          default-regexp)
            nil
            'ediff-filtering-regexp-history
            (eval ediff-default-filtering-regexp))
@@ -735,10 +725,8 @@ MERGE-AUTOSTORE-DIR is the directory in which to store merged files."
      (list (read-directory-name
            "Directory to merge with revisions:" dir-A nil 'must-match)
           (read-string
-           (if (stringp default-regexp)
-               (format "Filter filenames through regular expression (default %s): "
-                        default-regexp)
-             "Filter filenames through regular expression: ")
+           (format-prompt "Filter filenames through regular expression"
+                          default-regexp)
            nil
            'ediff-filtering-regexp-history
            (eval ediff-default-filtering-regexp))
@@ -767,10 +755,8 @@ MERGE-AUTOSTORE-DIR is the directory in which to store merged files."
            "Directory to merge with revisions and ancestors:"
            dir-A nil 'must-match)
           (read-string
-           (if (stringp default-regexp)
-               (format "Filter filenames through regular expression (default %s): "
-                        default-regexp)
-             "Filter filenames through regular expression: ")
+           (format-prompt "Filter filenames through regular expression"
+                          default-regexp)
            nil
            'ediff-filtering-regexp-history
            (eval ediff-default-filtering-regexp))
@@ -1353,16 +1339,18 @@ the merge buffer."
   (let (rev1 rev2)
     (setq rev1
          (read-string
-          (format-message
-           "Version 1 to merge (default %s's working version): "
-           (if (stringp file)
-               (file-name-nondirectory file) "current buffer")))
+          (format-prompt "Version 1 to merge"
+                          (concat
+                          (if (stringp file)
+                               (file-name-nondirectory file)
+                             "current buffer")
+                           "'s working version")))
          rev2
          (read-string
-          (format
-           "Version 2 to merge (default %s): "
-           (if (stringp file)
-               (file-name-nondirectory file) "current buffer"))))
+          (format-prompt "Version 2 to merge"
+                         (if (stringp file)
+                             (file-name-nondirectory file)
+                            "current buffer"))))
     (ediff-load-version-control)
     ;; ancestor-revision=nil
     (funcall
@@ -1388,22 +1376,26 @@ the merge buffer."
   (let (rev1 rev2 ancestor-rev)
     (setq rev1
          (read-string
-          (format-message
-           "Version 1 to merge (default %s's working version): "
-           (if (stringp file)
-               (file-name-nondirectory file) "current buffer")))
+          (format-prompt "Version 1 to merge"
+                          (concat
+                          (if (stringp file)
+                              (file-name-nondirectory file)
+                             "current buffer")
+                           "'s working version")))
          rev2
          (read-string
-          (format
-           "Version 2 to merge (default %s): "
-           (if (stringp file)
-               (file-name-nondirectory file) "current buffer")))
+          (format-prompt "Version 2 to merge"
+                         (if (stringp file)
+                             (file-name-nondirectory file)
+                            "current buffer")))
          ancestor-rev
-         (read-string
-          (format-message
-           "Ancestor version (default %s's base revision): "
-           (if (stringp file)
-               (file-name-nondirectory file) "current buffer"))))
+         (read-string (format-prompt
+                       "Ancestor version"
+                        (concat
+                        (if (stringp file)
+                            (file-name-nondirectory file)
+                           "current buffer")
+                         "'s base revision"))))
     (ediff-load-version-control)
     (funcall
      (intern (format "ediff-%S-merge-internal" ediff-version-control-package))
@@ -1503,13 +1495,14 @@ arguments after setting up the Ediff buffers."
       (save-buffer (current-buffer)))
   (let (rev1 rev2)
     (setq rev1
-         (read-string
-          (format "Revision 1 to compare (default %s's latest revision): "
-                  (file-name-nondirectory file)))
+         (read-string (format-prompt "Revision 1 to compare"
+                                     (concat (file-name-nondirectory file)
+                                              "'s latest revision")))
          rev2
          (read-string
-          (format "Revision 2 to compare (default %s's current state): "
-                  (file-name-nondirectory file))))
+          (format-prompt "Revision 2 to compare"
+                         (concat (file-name-nondirectory file)
+                                  "'s current state"))))
     (ediff-load-version-control)
     (funcall
      (intern (format "ediff-%S-internal" ediff-version-control-package))
index fc8c318e3af4856c6e010ef59e850605f98f3681..d2d419ac7861e4ed1420fa3554442a738f7a99ea 100644 (file)
@@ -2757,15 +2757,14 @@ Otherwise, signal an error."
         alternative-default-dir
         (not (string-equal alternative-default-dir
                            (file-name-directory A-file))))
-    (read-file-name (format "%s (default %s): "
-                           prompt (file-name-nondirectory A-file))
+    (read-file-name (format-prompt prompt (file-name-nondirectory A-file))
                    alternative-default-dir
                    (concat alternative-default-dir
                            (file-name-nondirectory A-file))
                    (and must-match 'confirm)))
    ;; If there is a default file, use it.
    (default-file
-     (read-file-name (format "%s (default %s): " prompt default-file)
+     (read-file-name (format-prompt prompt default-file)
                     ;; If emerge-default-last-directories is set, use the
                     ;; directory from the same argument of the last call of
                     ;; Emerge as the default for this argument.
index d82cadc70dd9e16c2138e28ee0cfaff3eb379a26..18bcc6c2f10805cecb3c13821c7d8c75f28d2805 100644 (file)
@@ -403,7 +403,7 @@ should be applied to the background or to the foreground."
           (let ((def (vc-working-revision buffer-file-name)))
             (if (null current-prefix-arg) def
               (vc-read-revision
-               (format "Annotate from revision (default %s): " def)
+               (format-prompt "Annotate from revision" def)
                (list buffer-file-name) nil def)))
           (if (null current-prefix-arg)
               vc-annotate-display-mode
index f0a08044e28e0fc7ed9b5a9af89ec4a6c77944f8..4cbd2658f801db9f4e152740037f57ff7436f89f 100644 (file)
@@ -2516,11 +2516,8 @@ with its diffs (if the underlying VCS supports that)."
    (cond
     ((eq current-prefix-arg 1)
      (let* ((default (thing-at-point 'word t))
-           (revision (read-string
-                      (if default
-                          (format "Revision to show (default %s): " default)
-                        "Revision to show: ")
-                      nil nil default)))
+           (revision (read-string (format-prompt "Revision to show" default)
+                                  nil nil default)))
        (list 1 revision)))
     ((numberp current-prefix-arg)
      (list current-prefix-arg))
index c252c0b18f8825b2e0bb937fa900b186fc38a0df..e159d1888e5c5ca330537112a299c54f5fa54275 100644 (file)
@@ -202,8 +202,7 @@ This function is provided for backward compatibility, since
   (interactive
    (list (let ((default locale-coding-system))
            (read-coding-system
-            (format "Coding system for system calls (default %s): "
-                    default)
+            (format-prompt "Coding system for system calls" default)
             default))))
   (check-coding-system coding-system)
   (setq locale-coding-system coding-system))
index f58a0fb7a3a439e08142e3cbd6387dc0129ae0a5..e9799dc00fdbbcfdf71ecab68896166799506f9f 100644 (file)
@@ -3181,11 +3181,10 @@ It reads a file name from an editable text field."
   (abbreviate-file-name
    (if unbound
        (read-file-name prompt)
-     (let ((prompt2 (format "%s (default %s): " prompt value))
-          (dir (file-name-directory value))
+     (let ((dir (file-name-directory value))
           (file (file-name-nondirectory value))
           (must-match (widget-get widget :must-match)))
-       (read-file-name prompt2 dir nil must-match file)))))
+       (read-file-name (format-prompt prompt value) dir nil must-match file)))))
 
 ;;;(defun widget-file-action (widget &optional event)
 ;;;  ;; Read a file name from the minibuffer.
@@ -3297,10 +3296,10 @@ It reads a directory name from an editable text field."
   "Read coding-system from minibuffer."
   (if (widget-get widget :base-only)
       (intern
-       (completing-read (format "%s (default %s): " prompt value)
+       (completing-read (format-prompt prompt value)
                        (mapcar #'list (coding-system-list t)) nil nil nil
                        coding-system-history))
-      (read-coding-system (format "%s (default %s): " prompt value) value)))
+      (read-coding-system (format-prompt prompt value) value)))
 
 (defun widget-coding-system-action (widget &optional event)
   (let ((answer
index 891a1263ace962df73c8c65cf186f0fb7ff45e92..eeacceadc27aab522e71199b4e3417d769c80f07 100644 (file)
@@ -1277,14 +1277,11 @@ cache to be re-read."
                                  (test-completion
                                   word-at-point woman-topic-all-completions))
                         word-at-point)))
-               (completing-read
-                (if default
-                    (format "Manual entry (default %s): " default)
-                  "Manual entry: ")
-                woman-topic-all-completions nil 1
-                nil
-                'woman-topic-history
-                default))))
+               (completing-read (format-prompt "Manual entry" default)
+                                woman-topic-all-completions nil 1
+                                nil
+                                'woman-topic-history
+                                default))))
     ;; Note that completing-read always returns a string.
     (unless (= (length topic) 0)
       (cond