]> git.eshelyaron.com Git - emacs.git/commitdiff
Use format-prompt for many more prompts
authorStefan Kangas <stefan@marxist.se>
Tue, 5 Oct 2021 01:34:08 +0000 (03:34 +0200)
committerStefan Kangas <stefan@marxist.se>
Tue, 5 Oct 2021 01:44:56 +0000 (03:44 +0200)
* lisp/bookmark.el (bookmark-completing-read):
* lisp/calc/calc-prog.el (calc-user-define-formula):
* lisp/calc/calc-store.el (calc-permanent-variable):
* lisp/calc/calc-units.el (calc-convert-units)
(calc-convert-exact-units, calc-convert-temperature):
* lisp/cedet/semantic/complete.el
(semantic-complete-read-tag-engine):
* lisp/cus-edit.el (customize-read-group):
* lisp/dired-aux.el (dired-do-chxxx):
* lisp/dired-x.el (dired-mark-unmarked-files):
* lisp/emacs-lisp/debug.el (cancel-debug-on-entry)
(cancel-debug-on-variable-change):
* lisp/emacs-lisp/edebug.el (edebug-cancel-on-entry)
(edebug-remove-instrumentation):
* lisp/epa.el (epa-read-file-name, epa-export-keys):
* lisp/faces.el (read-face-name):
* lisp/format.el (format-decode-buffer, format-decode-region):
* lisp/gnus/gnus-art.el (gnus-read-save-file-name):
* lisp/gnus/gnus-util.el (gnus-completing-read):
* lisp/gnus/message.el (message-check-news-header-syntax):
* lisp/info.el (Info-follow-reference):
* lisp/international/mule-diag.el (describe-font)
(describe-fontset):
* lisp/international/quail.el (quail-show-keyboard-layout):
* lisp/language/cyril-util.el
(standard-display-cyrillic-translit):
* lisp/mail/rmailkwd.el (rmail-read-label):
* lisp/mail/rmailmm.el (rmail-mime-save):
* lisp/mail/rmailout.el (rmail-output-read-file-name):
* lisp/man.el (Man-goto-section, Man-follow-manual-reference):
* lisp/menu-bar.el (emacs-index--prompt):
* lisp/net/ange-ftp.el (ange-ftp-get-passwd):
* lisp/proced.el (proced-send-signal):
* lisp/progmodes/cpp.el (cpp-choose-face):
* lisp/progmodes/ebrowse.el (ebrowse-set-tree-indentation):
* lisp/progmodes/etags.el (visit-tags-table)
(visit-tags-table-buffer):
* lisp/progmodes/grep.el (grep-read-files):
* lisp/progmodes/hideif.el (hide-ifdef-define):
* lisp/progmodes/pascal.el (pascal-goto-defun):
* lisp/progmodes/prolog.el (prolog-read-predicate):
* lisp/progmodes/sql.el (sql-get-login-ext):
* lisp/ses.el (ses-define-local-printer):
* lisp/textmodes/artist.el (artist-figlet-choose-font):
* lisp/textmodes/tex-mode.el (tex-compile):
* lisp/vc/diff.el (diff):
* lisp/vc/ediff-ptch.el (ediff-prompt-for-patch-file):
* lisp/vc/ediff-util.el (ediff-read-file-name):
* lisp/vc/pcvs.el (cvs-mode-mark-on-state):
* lisp/vc/vc.el (vc-diff-build-argument-list-internal)
(vc-revision-other-window, vc-retrieve-tag):
* lisp/wid-edit.el: Prefer format-prompt unconditionally.

* lisp/org/org-capture.el (org-capture-fill-template):
* lisp/org/org-refile.el (org-refile-get-location):
* lisp/progmodes/python.el (python-eldoc-at-point):
* lisp/progmodes/verilog-mode.el (verilog-surelint-off)
(verilog-goto-defun):
* lisp/progmodes/xref.el (xref--read-identifier): Prefer format-prompt
when it is fboundp.

49 files changed:
lisp/bookmark.el
lisp/calc/calc-prog.el
lisp/calc/calc-store.el
lisp/calc/calc-units.el
lisp/cedet/semantic/complete.el
lisp/cus-edit.el
lisp/dired-aux.el
lisp/dired-x.el
lisp/emacs-lisp/debug.el
lisp/emacs-lisp/edebug.el
lisp/epa.el
lisp/faces.el
lisp/format.el
lisp/gnus/gnus-art.el
lisp/gnus/gnus-util.el
lisp/gnus/message.el
lisp/info.el
lisp/international/mule-diag.el
lisp/international/quail.el
lisp/language/cyril-util.el
lisp/mail/rmailkwd.el
lisp/mail/rmailmm.el
lisp/mail/rmailout.el
lisp/man.el
lisp/menu-bar.el
lisp/net/ange-ftp.el
lisp/org/org-capture.el
lisp/org/org-refile.el
lisp/proced.el
lisp/progmodes/cpp.el
lisp/progmodes/ebrowse.el
lisp/progmodes/etags.el
lisp/progmodes/grep.el
lisp/progmodes/hideif.el
lisp/progmodes/pascal.el
lisp/progmodes/prolog.el
lisp/progmodes/python.el
lisp/progmodes/sql.el
lisp/progmodes/verilog-mode.el
lisp/progmodes/xref.el
lisp/ses.el
lisp/textmodes/artist.el
lisp/textmodes/tex-mode.el
lisp/vc/diff.el
lisp/vc/ediff-ptch.el
lisp/vc/ediff-util.el
lisp/vc/pcvs.el
lisp/vc/vc.el
lisp/wid-edit.el

index d64966df5af25ea50bb165460bfdb0b63dad24b4..5c4a9803b39db2e66e1ad2b0f05132dfafc236e6 100644 (file)
@@ -498,11 +498,8 @@ If DEFAULT is nil then return empty string for empty input."
                                                'string-lessp)
                                        (bookmark-all-names)))
     (let* ((completion-ignore-case bookmark-completion-ignore-case)
-           (default (unless (equal "" default) default))
-          (prompt (concat prompt (if default
-                                      (format " (%s): " default)
-                                    ": "))))
-      (completing-read prompt
+           (default (unless (equal "" default) default)))
+      (completing-read (format-prompt prompt default)
                        (lambda (string pred action)
                          (if (eq action 'metadata)
                              '(metadata (category . bookmark))
index f9dd9eb98a90d9289d5b4ab8773a6415466bbdf8..77adf6b7927f15993c8118f0aa521dc6bc182bf4 100644 (file)
         (progn
           (setq cmd-base-default (concat "User-" keyname))
            (setq cmd (completing-read
-                      (concat "Define M-x command name (default calc-"
-                              cmd-base-default
-                              "): ")
+                      (format-prompt "Define M-x command name"
+                                     (concat "calc-" cmd-base-default))
                       obarray 'commandp nil
                       (if (and odef (symbolp (cdr odef)))
                           (symbol-name (cdr odef))
           (setq func
                  (concat "calcFunc-"
                          (completing-read
-                          (concat "Define algebraic function name (default "
-                                  cmd-base-default "): ")
+                          (format-prompt "Define algebraic function name"
+                                         cmd-base-default)
                           (mapcar (lambda (x) (substring x 9))
                                   (all-completions "calcFunc-"
                                                    obarray))
index ee29c440fe480c878effcda53b8f0ce6215b570f..b3968555b6291d5d101b2f8c24b6b826c32b7930 100644 (file)
 (defun calc-permanent-variable (&optional var)
   (interactive)
   (calc-wrapper
-   (or var (setq var (calc-read-var-name "Save variable (default all): ")))
+   (or var (setq var (calc-read-var-name (format-prompt "Save variable" "all"))))
    (let (calc-pv-pos)
      (and var (or (and (boundp var) (symbol-value var))
                  (error "No such variable")))
index fd6f3a7b67b210513ec265e9c63df3ead54ed912..f6d749db117bd5f8b4b9e3ed3a19a850f0cdb766 100644 (file)
@@ -486,18 +486,13 @@ If COMP or STD is non-nil, put that in the units table instead."
      (setq defunits (math-get-default-units expr))
      (unless new-units
        (setq new-units
-             (read-string (concat
+             (read-string (format-prompt
                            (if (and uoldname (not nouold))
                                (concat "Old units: "
                                        uoldname
                                        ", new units")
                              "New units")
-                           (if defunits
-                               (concat
-                                " (default "
-                                defunits
-                                "): ")
-                             ": "))))
+                           defunits)))
        (if (and
             (string= new-units "")
             defunits)
@@ -533,14 +528,7 @@ If COMP or STD is non-nil, put that in the units table instead."
      (let* ((old-units (math-extract-units expr))
             (defunits (math-get-default-units expr))
             units
-            (new-units
-             (read-string (concat "New units"
-                                  (if defunits
-                                     (concat
-                                      " (default "
-                                      defunits
-                                      "): ")
-                                   ": ")))))
+            (new-units (read-string (format-prompt "New units" defunits))))
        (if (and
             (string= new-units "")
             defunits)
@@ -596,19 +584,14 @@ If COMP or STD is non-nil, put that in the units table instead."
         (setq expr (math-mul expr uold)))
      (setq defunits (math-get-default-units expr))
      (setq unew (or new-units
-                    (completing-read
-                     (concat
-                      (if uoldname
-                          (concat "Old temperature units: "
-                                  uoldname
-                                  ", new units")
-                        "New temperature units")
-                      (if defunits
-                          (concat " (default "
-                                  defunits
-                                  "): ")
-                        ": "))
-                     tempunits)))
+                    (completing-read (format-prompt
+                                      (if uoldname
+                                          (concat "Old temperature units: "
+                                                  uoldname
+                                                  ", new units")
+                                        "New temperature units")
+                                      defunits)
+                                     tempunits)))
      (setq unew (math-read-expr (if (string= unew "") defunits unew)))
      (when (eq (car-safe unew) 'error)
        (error "Bad format in units expression: %s" (nth 2 unew)))
index 6cfbdd5f03f98c326f5c00408a88e5f7dbd97279..375b97a7a5d9c66af7730f4b423eeb4f78d5c322 100644 (file)
@@ -224,11 +224,10 @@ HISTORY is a symbol representing a variable to story the history in."
 
       ;; @todo - move from () to into the editable area
       (if (string-match ":" prompt)
-         (setq prompt (concat
-                       (substring prompt 0 (match-beginning 0))
-                       " (default " default-as-string ")"
-                       (substring prompt (match-beginning 0))))
-       (setq prompt (concat prompt " (" default-as-string "): "))))
+          (setq prompt (format-prompt
+                        (substring prompt 0 (match-beginning 0))
+                        default-as-string))
+        (setq prompt (format-prompt prompt default-as-string))))
     ;;
     ;; Perform the Completion
     ;;
index 814003587b87a06d95c1064c91b1e09b3a990128..34a6db508d54c79468f8d5a35e378efb3e6c9393 100644 (file)
@@ -1133,7 +1133,7 @@ for the MODE to customize."
 
 (defun customize-read-group ()
   (let ((completion-ignore-case t))
-    (completing-read "Customize group (default emacs): "
+    (completing-read (format-prompt "Customize group" "emacs")
                      obarray
                      (lambda (symbol)
                        (or (and (get symbol 'custom-loads)
index 4b8d27107152b6b496905d862fa155f68415dfea..a1c6316d3f756d1178b21fd188df4b8ebd02665c 100644 (file)
@@ -444,10 +444,10 @@ List has a form of (file-name full-file-name (attribute-list))."
                          ((eq op-symbol 'chgrp)
                           (file-attribute-group-id
                            (file-attributes default-file 'string))))))
-        (prompt (concat "Change " attribute-name " of %s to"
-                        (if (eq op-symbol 'touch)
-                            " (default now): "
-                          ": ")))
+         (prompt (format-prompt "Change %s of %%s to"
+                                (when (eq op-symbol 'touch)
+                                    "now")
+                                attribute-name))
         (new-attribute (dired-mark-read-string prompt nil op-symbol
                                                arg files default
                                                (cond ((eq op-symbol 'chown)
index 7c6f49f2ae4cec91dd5d8130d78624f0d8318dd4..7f889a2bfd68edbcd5e088f93682f371d227e778 100644 (file)
@@ -554,7 +554,7 @@ If the region is active in Transient Mark mode, operate only on
 files in the active region if `dired-mark-region' is non-nil."
   (interactive
    (list (read-regexp
-         "Mark unmarked files matching regexp (default all): "
+          (format-prompt "Mark unmarked files matching regexp" "all")
           nil 'dired-regexp-history)
         nil current-prefix-arg nil))
   (let ((dired-marker-char (if unflag-p ?\s dired-marker-char)))
index 0592db85df4f0759a956c09bd8c2c0dc867af747..163528acf6f133e8556ceba0999a275d27dff72d 100644 (file)
@@ -701,7 +701,8 @@ To specify a nil argument interactively, exit with an empty minibuffer."
   (interactive
    (list (let ((name
                (completing-read
-                "Cancel debug on entry to function (default all functions): "
+                 (format-prompt "Cancel debug on entry to function"
+                                "all functions")
                 (mapcar #'symbol-name (debug--function-list)) nil t)))
           (when name
             (unless (string= name "")
@@ -804,7 +805,8 @@ To specify a nil argument interactively, exit with an empty minibuffer."
   (interactive
    (list (let ((name
                 (completing-read
-                 "Cancel debug on set for variable (default all variables): "
+                 (format-prompt "Cancel debug on set for variable"
+                                "all variables")
                  (mapcar #'symbol-name (debug--variable-list)) nil t)))
            (when name
              (unless (string= name "")
index 4f3c05baa98322e5b0f745143dc7161a80f6534a..a38c8bd5ca9f9e65ba6dcd29ead99ec676a24ebc 100644 (file)
@@ -3519,7 +3519,8 @@ The removes the effect of `edebug-on-entry'.  If FUNCTION is
 nil, remove `edebug-on-entry' on all functions."
   (interactive
    (list (let ((name (completing-read
-                      "Cancel edebug on entry to (default all functions): "
+                      (format-prompt "Cancel edebug on entry to"
+                                     "all functions")
                       (let ((functions (edebug--edebug-on-entry-functions)))
                         (unless functions
                           (user-error "No functions have `edebug-on-entry'"))
@@ -4548,7 +4549,8 @@ instrumentation for, defaulting to all functions."
         (user-error "Found no functions to remove instrumentation from"))
       (let ((name
              (completing-read
-              "Remove instrumentation from (default all functions): "
+              (format-prompt "Remove instrumentation from"
+                             "all functions")
               functions)))
         (if (and name
                  (not (equal name "")))
index 57d355cb3e0d3c9f6b3f41fb2bdb3c726ed581d7..e4b89e984d21a3ddb5104d42269a61daff11f9af 100644 (file)
@@ -648,7 +648,7 @@ If SECRET is non-nil, list secret keys instead of public keys."
   (setq input (file-name-sans-extension (expand-file-name input)))
   (expand-file-name
    (read-file-name
-    (concat "To file (default " (file-name-nondirectory input) ") ")
+    (format-prompt "To file" (file-name-nondirectory input))
     (file-name-directory input)
     input)))
 
@@ -1236,9 +1236,7 @@ If no one is selected, symmetric encryption will be performed.  ")
      (list keys
           (expand-file-name
            (read-file-name
-            (concat "To file (default "
-                    (file-name-nondirectory default-name)
-                    ") ")
+             (format-prompt "To file" (file-name-nondirectory default-name))
             (file-name-directory default-name)
             default-name)))))
   (let ((context (epg-make-context epa-protocol)))
index 7b96d938c56066b33bfc682ad8887ad2da60a46b..302bfa245ec65880eecaa7b842c7933cc97055cc 100644 (file)
@@ -1100,7 +1100,7 @@ returned.  Otherwise, DEFAULT is returned verbatim."
   ;; prompt.  If so, remove it.
   (setq prompt (replace-regexp-in-string ": ?\\'" "" prompt))
   (let ((prompt (if default
-                    (format-message "%s (default `%s'): " prompt default)
+                    (format-prompt prompt default)
                   (format "%s: " prompt)))
         aliasfaces nonaliasfaces faces)
     ;; Build up the completion tables.
index 71cf885d417d90ba15e66ec51579eeecb5026399..a2f378efa72dc1b3bc926091fa4e990d326b8e8a 100644 (file)
@@ -320,7 +320,7 @@ If the format is not specified, attempt a regexp-based guess.
 Set `buffer-file-format' to the format used, and call any
 format-specific mode functions."
   (interactive
-   (list (format-read "Translate buffer from format (default guess): ")))
+   (list (format-read (format-prompt "Translate buffer from format" "guess"))))
   (save-excursion
     (goto-char (point-min))
     (format-decode format (buffer-size) t)))
@@ -331,7 +331,7 @@ Arg FORMAT is optional; if omitted the format will be determined by looking
 for identifying regular expressions at the beginning of the region."
   (interactive
    (list (region-beginning) (region-end)
-        (format-read "Translate region from format (default guess): ")))
+         (format-read (format-prompt "Translate region from format" "guess"))))
   (save-excursion
     (goto-char from)
     (format-decode format (- to from) nil)))
index 7b6e15d6f87f28affaf58debae98a306ff96ab86..c2ec3f1f977699a9235f732018faa9dc7b89a80d 100644 (file)
@@ -3933,8 +3933,8 @@ This format is defined by the `gnus-article-time-format' variable."
                      ;; No split name was found.
                      ((null split-name)
                       (read-file-name
-                       (concat prompt " (default "
-                               (file-name-nondirectory default-name) "): ")
+                        (format-prompt prompt
+                                       (file-name-nondirectory default-name))
                        (file-name-directory default-name)
                        default-name))
                      ;; A single group name is returned.
@@ -3943,8 +3943,8 @@ This format is defined by the `gnus-article-time-format' variable."
                             (funcall function split-name headers
                                      (symbol-value variable)))
                       (read-file-name
-                       (concat prompt " (default "
-                               (file-name-nondirectory default-name) "): ")
+                        (format-prompt prompt
+                                       (file-name-nondirectory default-name))
                        (file-name-directory default-name)
                        default-name))
                      ;; A single split name was found
@@ -3956,9 +3956,8 @@ This format is defined by the `gnus-article-time-format' variable."
                                          (file-name-as-directory name))
                                         ((file-exists-p name) name)
                                         (t gnus-article-save-directory))))
-                        (read-file-name
-                         (concat prompt " (default " name "): ")
-                         dir name)))
+                         (read-file-name (format-prompt prompt name)
+                                         dir name)))
                      ;; A list of splits was found.
                      (t
                       (setq split-name (nreverse split-name))
index fb285962d6fba84265cb0f10092776366b86158a..5bf2869983edcf0b2bf987f8f72906648d1a1318 100644 (file)
@@ -1310,9 +1310,7 @@ SPEC is a predicate specifier that contains stuff like `or', `and',
                                     initial-input history def)
   "Call `gnus-completing-read-function'."
   (funcall gnus-completing-read-function
-           (concat prompt (when def
-                            (concat " (default " def ")"))
-                   ": ")
+           (format-prompt prompt def)
            collection require-match initial-input history def))
 
 (defun gnus-emacs-completing-read (prompt collection &optional require-match
index b08d8c26c9a668f38a91b607a2eceac69afc21d6..7ca43d603ff329b0d0ec6d53c47cdb12847e10e7 100644 (file)
@@ -5349,7 +5349,7 @@ Otherwise, generate and save a value for `canlock-password' first."
                   (zerop
                    (length
                     (setq to (completing-read
-                              "Followups to (default no Followup-To header): "
+                               (format-prompt "Followups to" "no Followup-To header")
                               (mapcar #'list
                                       (cons "poster"
                                             (message-tokenize-header
index 8c08eaec3c8cd54fa152418ebb548a0e22543f25..41889d6de1753c84064ff5aba04d83dd2b94cd44 100644 (file)
@@ -2604,12 +2604,9 @@ new buffer."
      (if (eq (length completions) 1)
          (setq default (car completions)))
      (if completions
-        (let ((input (completing-read (if default
-                                          (concat
-                                           "Follow reference named (default "
-                                           default "): ")
-                                        "Follow reference named: ")
-                                      completions nil t)))
+         (let ((input (completing-read (format-prompt "Follow reference named"
+                                                      default)
+                                       completions nil t)))
           (list (if (equal input "")
                     default input)
                  current-prefix-arg))
index 862c577bd5de5f356a13ee145b3f4b60091384c7..5cc73e436713fe786c47ab48eef16e43be60a2ed 100644 (file)
@@ -833,7 +833,7 @@ The IGNORED argument is ignored."
   "Display information about a font whose name is FONTNAME."
   (interactive
    (list (completing-read
-          "Font name (default current choice for ASCII chars): "
+          (format-prompt "Font name" "current choice for ASCII chars")
           (and window-system
                ;; Implied by `window-system'.
                (fboundp 'x-list-fonts)
@@ -1004,7 +1004,7 @@ This shows which font is used for which character(s)."
                          (mapcar 'cdr fontset-alias-alist)))
           (completion-ignore-case t))
        (list (completing-read
-             "Fontset (default used by the current frame): "
+              (format-prompt "Fontset" "used by the current frame")
              fontset-list nil t)))))
   (if (= (length fontset) 0)
       (setq fontset (face-attribute 'default :fontset))
index 50ff307b73a6dac5c4a60d2c93a390c888d28dac..89ab450aeee2fd80dfabd53fe38ae7081e56ae7c 100644 (file)
@@ -917,7 +917,7 @@ The format of KBD-LAYOUT is the same as `quail-keyboard-layout'."
 The variable `quail-keyboard-layout-type' holds the currently selected
 keyboard type."
   (interactive
-   (list (completing-read "Keyboard type (default current choice): "
+   (list (completing-read (format-prompt "Keyboard type" "current choice")
                          quail-keyboard-layout-alist
                          nil t)))
   (or (and keyboard-type (> (length keyboard-type) 0))
index 04e681d743d5521ef6c22c684657e0204b746b62..e404288ddcabea1def45a1ee81637f81c10c6325 100644 (file)
@@ -60,7 +60,7 @@ If the argument is nil, we return the display table to its standard state."
    (list
     (let* ((completion-ignore-case t))
       (completing-read
-       "Cyrillic language (default nil): "
+       (format-prompt "Cyrillic language" "nil")
        cyrillic-language-alist nil t nil nil nil))))
 
   (or standard-display-table
index 58a8eb7a37008c8107e51ccc271e711ee9396807..d8fcc1c0a991ef3ce39fa5348a1157e196ecc6e5 100644 (file)
@@ -74,12 +74,9 @@ according to the choice made, and returns a symbol."
                (rmail-summary-exists)
                (and (setq old (rmail-get-keywords))
                     (mapc #'rmail-make-label (split-string old ", "))))
-           (completing-read (concat prompt
-                                    (if rmail-last-label
-                                        (concat " (default "
-                                                (symbol-name rmail-last-label)
-                                                "): ")
-                                      ": "))
+            (completing-read (format-prompt prompt
+                                            (and rmail-last-label
+                                                 (symbol-name rmail-last-label)))
                             rmail-label-obarray
                             nil
                             nil))))
index 99bff66657b5e9c293ed37e8400832eeb4adf7ef..66a1e9a4dbd900db9ba52edbbb52bd068951021d 100644 (file)
@@ -254,7 +254,7 @@ TRUNCATED is non-nil if the text of this entity was truncated."))
        (unless (y-or-n-p "This entity is truncated; save anyway? ")
          (error "Aborted")))
     (setq filename (expand-file-name
-                   (read-file-name (format "Save as (default: %s): " filename)
+                    (read-file-name (format-prompt "Save as" filename)
                                    directory
                                    (expand-file-name filename directory))
                    directory))
index 91f86a234d40e2c8cbefcb6f30196dbd4ed2fd89..1f5bb2d9f1b493a9f6de2b0b7d91a98e400b4a05 100644 (file)
@@ -107,9 +107,8 @@ error: %S\n"
         (read-file
          (expand-file-name
           (read-file-name
-           (concat "Output message to mail file (default "
-                   (file-name-nondirectory default-file)
-                   "): ")
+            (format-prompt "Output message to mail file"
+                           (file-name-nondirectory default-file))
            (file-name-directory default-file)
            (abbreviate-file-name default-file))
           (file-name-directory default-file))))
index 4ef2deac4f374e48765c70073df4f0339321946b..2bde1fc7fb282cc362d0f9b1585593f5a1a1c22c 100644 (file)
@@ -1786,7 +1786,7 @@ Returns t if section is found, nil otherwise."
                        Man--last-section
                      (car Man--sections)))
           (completion-ignore-case t)
-          (prompt (concat "Go to section (default " default "): "))
+          (prompt (format-prompt "Go to section" default))
           (chosen (completing-read prompt Man--sections
                                    nil nil nil nil default)))
      (list chosen))
@@ -1850,7 +1850,7 @@ Specify which REFERENCE to use; default is based on word at point."
             (defaults
               (mapcar 'substring-no-properties
                        (cons default Man--refpages)))
-            (prompt (concat "Refer to (default " default "): "))
+             (prompt (format-prompt "Refer to" default))
             (chosen (completing-read prompt Man--refpages
                                      nil nil nil nil defaults)))
         chosen)))
index b2577c085fc2101e6ac00124067cffb50b4589f5..40a1730637d1393686fa7dd8daf3581f629135a2 100644 (file)
@@ -1918,10 +1918,7 @@ key, a click, or a menu-item"))
   (let* ((default (thing-at-point 'sexp))
          (topic
           (read-from-minibuffer
-           (format "Subject to look up%s: "
-                   (if default
-                       (format " (default \"%s\")" default)
-                     ""))
+           (format-prompt "Subject to look up" default)
            nil nil nil nil default)))
     (list (if (zerop (length topic))
               default
index 56a1d76d71a1bde0ad1dfff0d1bfb2810c8ea42f..876e138f284510d021d0777f176bc1ff30384e5d 100644 (file)
@@ -1230,8 +1230,9 @@ only return the directory part of FILE."
                            ;; found another machine with the same user.
                            ;; Try that account.
                            (read-passwd
-                            (format "passwd for %s@%s (default same as %s@%s): "
-                                    user host user other)
+                             (format-prompt "passwd for %s@%s"
+                                            (format "same as %s@%s" user other)
+                                            user host)
                             nil
                             (ange-ftp-lookup-passwd other user))
 
index a9350c58d524abf60acc46ff96a0d9089d6470de..1756b34fc5b12fa6b17f4d8c63dbd62363b4fdae 100644 (file)
@@ -1815,10 +1815,13 @@ by their respective `org-store-link-plist' properties if present."
                     ;; Load history list for current prompt.
                     (setq org-capture--prompt-history
                           (gethash prompt org-capture--prompt-history-table))
-                    (push (org-completing-read
-                           (concat (or prompt "Enter string")
-                                   (and default (format " [%s]" default))
-                                   ": ")
+                     (push (org-completing-read
+                            ;; `format-prompt' is new in Emacs 28.1.
+                            (if (fboundp 'format-prompt)
+                                (format-prompt (or prompt "Enter string") default)
+                              (concat (or prompt "Enter string")
+                                      (and default (format " [%s]" default))
+                                      ": "))
                            completions
                            nil nil nil 'org-capture--prompt-history default)
                           strings)
index 678759e10db8625e7495bae29ceac1573968ccf1..73eaad6bf525f3a2f26019e3e72aa7ebd52e2a17 100644 (file)
@@ -640,11 +640,13 @@ this function appends the default value from
               org-refile-target-table))
         (completion-ignore-case t)
         cdef
-        (prompt (concat prompt
-                        (or (and (car org-refile-history)
-                                 (concat " (default " (car org-refile-history) ")"))
-                            (and (assoc cbnex tbl) (setq cdef cbnex)
-                                 (concat " (default " cbnex ")"))) ": "))
+         (prompt (let ((default (or (car org-refile-history)
+                                    (and (assoc cbnex tbl) (setq cdef cbnex)
+                                         cbnex))))
+                   ;; `format-prompt' is new in Emacs 28.1.
+                   (if (fboundp 'format-prompt)
+                       (format-prompt prompt default)
+                     (concat prompt " (default " default ": "))))
         pa answ parent-target child parent old-hist)
     (setq old-hist org-refile-history)
     (setq answ (funcall cfunc prompt tbl nil (not new-nodes)
index fec2a29c847b6a95662e32d884f833f15c996226..9a8eaf54e787939771736075a5d4d68659b474c7 100644 (file)
@@ -1772,8 +1772,8 @@ supported but discouraged.  It will be removed in a future version of Emacs."
            `(:annotation-function
              ,(lambda (s) (cdr (assoc s proced-signal-list))))))
      (proced-with-processes-buffer process-alist
-       (list (completing-read (concat "Send signal [" pnum
-                                      "] (default TERM): ")
+       (list (completing-read (format-prompt "Send signal [%s]"
+                                             "TERM" pnum)
                               proced-signal-list
                               nil nil nil nil "TERM")
              process-alist))))
@@ -1797,8 +1797,8 @@ supported but discouraged.  It will be removed in a future version of Emacs."
              `(:annotation-function
                ,(lambda (s) (cdr (assoc s proced-signal-list))))))
         (proced-with-processes-buffer process-alist
-          (setq signal (completing-read (concat "Send signal [" pnum
-                                                "] (default TERM): ")
+          (setq signal (completing-read (format-prompt "Send signal [%s]"
+                                                       "TERM" pnum)
                                         proced-signal-list
                                         nil nil nil nil "TERM"))))))
 
index d800365e66d5d4b1a643201ce574f16a2ee9b748..baee72b332d556ac40d6ac5ed5f36504a18ade2e 100644 (file)
@@ -702,11 +702,8 @@ BRANCH should be either nil (false branch), t (true branch) or `both'."
          (x-popup-menu cpp-button-event
                        (list prompt (cons prompt cpp-face-default-list)))
        (let ((name (car (rassq default cpp-face-default-list))))
-         (cdr (assoc (completing-read (if name
-                                          (concat prompt
-                                                  " (default " name "): ")
-                                        (concat prompt ": "))
-                                      cpp-face-default-list nil t)
+          (cdr (assoc (completing-read (format-prompt "%s" name prompt)
+                                       cpp-face-default-list nil t)
                      cpp-face-all-list))))
       default))
 
index ab0329d7eec49dbab51dc4eb1dea0054ea2bff30..6e416d064a84a91a692da67b7f4693c5fd47c313 100644 (file)
@@ -1330,9 +1330,9 @@ Pop to member buffer if no prefix ARG, to tree buffer otherwise."
   "Set the indentation width of the tree display."
   (interactive)
   (let ((width (string-to-number (read-string
-                                  (concat "Indentation (default "
-                                          (int-to-string ebrowse--indentation)
-                                          "): ")
+                                  (format-prompt
+                                   "Indentation"
+                                   (int-to-string ebrowse--indentation))
                                   nil nil ebrowse--indentation))))
     (when (cl-plusp width)
       (setq-local ebrowse--indentation width)
index f53b09d9e8cc8d7e6f14159318fa01ccfb96c0c5..d2ce813daaeede10445a36f120e0525495f93633 100644 (file)
@@ -292,7 +292,7 @@ file the tag was in."
            (or (locate-dominating-file default-directory "TAGS")
                default-directory)))
      (list (read-file-name
-            "Visit tags table (default TAGS): "
+            (format-prompt "Visit tags table" "TAGS")
             ;; default to TAGS from default-directory up to root.
             default-tag-dir
             (expand-file-name "TAGS" default-tag-dir)
@@ -625,7 +625,7 @@ Returns t if it visits a tags table, or nil if there are no more in the list."
                  (car list))
                ;; Finally, prompt the user for a file name.
                (expand-file-name
-                (read-file-name "Visit tags table (default TAGS): "
+                 (read-file-name (format-prompt "Visit tags table" "TAGS")
                                 default-directory
                                 "TAGS"
                                 t))))))
index ec2850737c87515be611f9b477024a9f26a9a3c0..001989e39adcec6f9c8803866dd6773024ae6f17 100644 (file)
@@ -1057,11 +1057,9 @@ REGEXP is used as a string in the prompt."
               default-extension
               (car grep-files-history)
               (car (car grep-files-aliases))))
-        (files (completing-read
-                (concat "Search for \"" regexp
-                        "\" in files matching wildcard"
-                        (if default (concat " (default " default ")"))
-                        ": ")
+         (files (completing-read
+                 (format-prompt "Search for \"%s\" in files matching wildcard"
+                                default regexp)
                 #'read-file-name-internal
                 nil nil nil 'grep-files-history
                 (delete-dups
index a18a67249ae73c4b12553c60e2b93db1958af7b6..87732c1048969515780ba5ca0cd38bc5e81ad5ac 100644 (file)
@@ -2456,7 +2456,7 @@ This allows #ifdef VAR to be hidden."
                            (t
                             nil))))
           (var (read-minibuffer "Define what? " default))
-          (val (read-from-minibuffer (format "Set %s to? (default 1): " var)
+          (val (read-from-minibuffer (format-prompt "Set %s to?" "1" var)
                                      nil nil t nil "1")))
      (list var val)))
   (hif-set-var var (or val 1))
index e6e6e40aa193c271fcb4f23922e36fdff5a8176f..5938da542ac4182b740cd8269854f2866dd41d60 100644 (file)
@@ -1357,9 +1357,7 @@ The default is a name found in the buffer around point."
                      default ""))
         (label
           ;; Do completion with default.
-          (completing-read (if (not (string= default ""))
-                               (concat "Label (default " default "): ")
-                             "Label: ")
+          (completing-read (format-prompt "Label" default)
                            ;; Complete with the defuns found in the
                            ;; current-buffer.
                            (let ((buf (current-buffer)))
index 74a023775f85d058d0f6a62cff1e70e429178881..118117131f44a2bdfe283079ada00f245f5f02c4 100644 (file)
@@ -2484,11 +2484,8 @@ Interaction supports completion."
     (if (eq (try-completion default prolog-info-alist) nil)
         (setq default nil))
     ;; Read the PredSpec from the user
-    (completing-read
-     (if (zerop (length default))
-         "Help on predicate: "
-       (concat "Help on predicate (default " default "): "))
-     prolog-info-alist nil t nil nil default)))
+    (completing-read (format-prompt "Help on predicate" default)
+                     prolog-info-alist nil t nil nil default)))
 
 (defun prolog-build-info-alist (&optional verbose)
   "Build an alist of all builtins and library predicates.
index 43ee3c0c152105e521a13511e1e149d9fd515c34..b1f61c89a41c5c4a5f1fb49daf2e95cbbd385175 100644 (file)
@@ -4773,10 +4773,14 @@ 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: ")
-                        nil nil symbol))))
+     (list (read-string
+            ;; `format-prompt' is new in Emacs 28.1.
+            (if (fboundp 'format-prompt)
+                (format-prompt "Describe symbol" symbol)
+              (if symbol
+                  (format "Describe symbol (default %s): " symbol)
+                "Describe symbol: "))
+            nil nil symbol))))
   (message (python-eldoc--get-doc-at-point symbol)))
 
 (defun python-describe-at-point (symbol process)
index 02eccb33012f7e3d70cc22ed2dd815dca98e1ec1..283c057e522209520a6fff4b491ee8db7a775e2c 100644 (file)
@@ -3219,14 +3219,7 @@ For both `:file' and `:completion', there can also be a
    symbol
    (let* ((default (plist-get plist :default))
           (last-value (sql-default-value symbol))
-          (prompt-def
-           (if default
-               (if (string-match "\\(\\):[ \t]*\\'" prompt)
-                   (replace-match (format " (default \"%s\")" default) t t prompt 1)
-                 (replace-regexp-in-string "[ \t]*\\'"
-                                           (format " (default \"%s\") " default)
-                                           prompt t t))
-             prompt))
+          (prompt-def (format-prompt prompt default))
           (use-dialog-box nil))
      (cond
       ((plist-member plist :file)
@@ -3311,7 +3304,7 @@ function like this: (sql-get-login \\='user \\='password \\='database)."
     (let ((plist (cdr-safe w)))
       (pcase (or (car-safe w) w)
         ('user
-         (sql-get-login-ext 'sql-user "User" 'sql-user-history plist))
+         (sql-get-login-ext 'sql-user "User" 'sql-user-history plist))
 
         ('password
          (setq-default sql-password
@@ -3330,14 +3323,14 @@ function like this: (sql-get-login \\='user \\='password \\='database)."
                          (read-passwd "Password: " nil (sql-default-value 'sql-password)))))
 
         ('server
-         (sql-get-login-ext 'sql-server "Server" 'sql-server-history plist))
+         (sql-get-login-ext 'sql-server "Server" 'sql-server-history plist))
 
         ('database
-         (sql-get-login-ext 'sql-database "Database"
+         (sql-get-login-ext 'sql-database "Database"
                             'sql-database-history plist))
 
         ('port
-         (sql-get-login-ext 'sql-port "Port"
+         (sql-get-login-ext 'sql-port "Port"
                             nil (append '(:number t) plist)))))))
 
 (defun sql-find-sqli-buffer (&optional product connection)
index d98230d9a0ebe67588474caf20f03273becba9b4..5ef382b91efcac9c66c40d620e15d671b73ae5be 100644 (file)
@@ -5478,8 +5478,11 @@ becomes:
                     (let* ((pop-up-windows t))
                       (let ((name (expand-file-name
                                    (read-file-name
-                                    (format "Find this error in: (default %s) "
-                                            file)
+                                    ;; `format-prompt' is new in Emacs 28.1.
+                                    (if (fboundp 'format-prompt)
+                                        (format-prompt "Find this error in" file)
+                                      (format "Find this error in (default %s): "
+                                              file))
                                     nil ;; dir
                                     file t))))
                         (setq buffer
@@ -7863,14 +7866,14 @@ If search fails, other files are checked based on
   (let* ((default (verilog-get-default-symbol))
         ;; The following variable is used in verilog-comp-function
         (verilog-buffer-to-use (current-buffer))
-        (label (if (not (string= default ""))
-                   ;; Do completion with default
-                   (completing-read (concat "Goto-Label: (default "
-                                            default ") ")
-                                    #'verilog-comp-defun nil nil "")
-                 ;; There is no default value. Complete without it
-                 (completing-read "Goto-Label: "
-                                  #'verilog-comp-defun nil nil "")))
+         (label
+          (completing-read (cond ((fboundp 'format-prompt)
+                                  ;; `format-prompt' is new in Emacs 28.1.
+                                  (format-prompt "Goto-Label" default))
+                                 ((not (string= default ""))
+                                  (concat "Goto-Label (default " default "): "))
+                                 (t "Goto-Label: "))
+                           #'verilog-comp-defun nil nil ""))
         pt)
     ;; Make sure library paths are correct, in case need to resolve module
     (verilog-auto-reeval-locals)
index 267ee16400e5b4a90925d206faf8485185a6a22b..210fc2b1d8b2c0afea130ba549cd40d3627d8acf 100644 (file)
@@ -1310,12 +1310,17 @@ definitions."
                (xref--prompt-p this-command))
            (let ((id
                   (completing-read
-                   (if def
-                       (format "%s (default %s): "
-                               (substring prompt 0 (string-match
-                                                    "[ :]+\\'" prompt))
-                               def)
-                     prompt)
+                   ;; `format-prompt' is new in Emacs 28.1
+                   (if (fboundp 'format-prompt)
+                       (format-prompt (substring prompt 0 (string-match
+                                                           "[ :]+\\'" prompt))
+                                      def)
+                     (if def
+                         (format "%s (default %s): "
+                                 (substring prompt 0 (string-match
+                                                      "[ :]+\\'" prompt))
+                                 def)
+                       prompt))
                    (xref-backend-identifier-completion-table backend)
                    nil nil nil
                    'xref--read-identifier-history def)))
index ea966295b18040fb84c271644641c765c186c471..51843eab03255215f84ad2abd694583b87c56d4e 100644 (file)
@@ -3774,7 +3774,9 @@ function is redefined."
      (setq name (intern name))
      (let* ((cur-printer (gethash name ses--local-printer-hashmap))
             (default (and cur-printer (ses--locprn-def cur-printer))))
-            (setq def (ses-read-printer (format "Enter definition of printer %S" name)
+            (setq def (ses-read-printer (format-prompt
+                                         "Enter definition of printer %S"
+                                         default name)
                                         default)))
             (list name def)))
 
index c42286e5bc3edfc31ce112b5aa86e46779b1bcd9..25f0c35aa5dc873519c47b1e38a6c9ce6c1dac19 100644 (file)
@@ -2840,9 +2840,8 @@ Returns a list of strings."
           (if (memq system-type '(windows-nt ms-dos))
               (artist-figlet-get-font-list-windows)
             (artist-figlet-get-font-list)))
-        (font (completing-read (concat "Select font (default "
-                                       artist-figlet-default-font
-                                       "): ")
+         (font (completing-read (format-prompt "Select font"
+                                               artist-figlet-default-font)
                                (mapcar
                                 (lambda (font) (cons font font))
                                 avail-fonts))))
index 6fd66b2502fc2991beb3ae5465a376496b89e5c8..5fba93c76eb75424631f756bb78a5003caad1005 100644 (file)
@@ -2457,7 +2457,7 @@ Only applies the FSPEC to the args part of FORMAT."
          (default (tex-compile-default fspec)))
      (list default-directory
           (completing-read
-           (format "Command [%s]: " (tex-summarize-command default))
+            (format-prompt "Command" (tex-summarize-command default))
            (mapcar (lambda (x)
                      (list (tex-format-cmd (eval (car x) t) fspec)))
                    tex-compile-commands)
index 352fa693ffbd1f8191f5c1aa318aa56cd944d01c..4061fedd5789ec1ff914b0bc7ee0ae06b802ef4f 100644 (file)
@@ -96,15 +96,15 @@ Non-interactively, OLD and NEW may each be a file or a buffer."
   (interactive
    (let* ((newf (if (and buffer-file-name (file-exists-p buffer-file-name))
                    (read-file-name
-                    (concat "Diff new file (default "
-                            (file-name-nondirectory buffer-file-name) "): ")
+                     (format-prompt "Diff new file"
+                                    (file-name-nondirectory buffer-file-name))
                     nil buffer-file-name t)
                  (read-file-name "Diff new file: " nil nil t)))
           (oldf (file-newest-backup newf)))
      (setq oldf (if (and oldf (file-exists-p oldf))
                    (read-file-name
-                    (concat "Diff original file (default "
-                            (file-name-nondirectory oldf) "): ")
+                     (format-prompt "Diff original file"
+                                    (file-name-nondirectory oldf))
                     (file-name-directory oldf) oldf t)
                  (read-file-name "Diff original file: "
                                  (file-name-directory newf) nil t)))
index 4135e8b4702b40e28c238c73922c72e689e6bdb6..7622cf4c196485988b0cb8b58c116ef610260074 100644 (file)
@@ -503,15 +503,11 @@ are two possible targets for this %spatch.  However, these files do not exist."
        patch-file-name)
     (setq patch-file-name
          (read-file-name
-          (format "Patch is in file%s: "
-                  (cond ((and buffer-file-name
-                              (equal (expand-file-name dir)
-                                     (file-name-directory buffer-file-name)))
-                         (concat
-                          " (default "
-                          (file-name-nondirectory buffer-file-name)
-                          ")"))
-                        (t "")))
+           (format-prompt "Patch is in file"
+                          (and buffer-file-name
+                               (equal (expand-file-name dir)
+                                      (file-name-directory buffer-file-name))
+                               (file-name-nondirectory buffer-file-name)))
           dir buffer-file-name 'must-match))
     (if (file-directory-p patch-file-name)
        (error "Patch file cannot be a directory: %s" patch-file-name)
index 9016d1df5c499cf2c5735dff8ab1b6de761dfb24..346c3c0a6663117f85bab3a392db88d4d456a16d 100644 (file)
@@ -3103,11 +3103,7 @@ Hit \\[ediff-recenter] to reset the windows afterward."
                (lambda () (when defaults
                             (setq minibuffer-default defaults)))
              (read-file-name
-              (format "%s%s "
-                      prompt
-                      (cond (default-file
-                              (concat " (default " default-file "):"))
-                            (t (concat " (default " default-dir "):"))))
+               (format-prompt prompt (or default-file default-dir))
               default-dir
               (or default-file default-dir)
               t                        ; must match, no-confirm
index bbc81ef195d6fee433a4e1138eae0fb4a03462f6..8f662e845895f76ba51e8c9edb68243d9b83fa15 100644 (file)
@@ -1284,8 +1284,7 @@ marked instead.  A directory can never be marked."
       (intern
        (upcase
        (completing-read
-        (concat
-         "Mark files in state" (if default (concat " [" default "]")) ": ")
+         (format-prompt "Mark files in state" default)
         (mapcar (lambda (x)
                   (list (downcase (symbol-name (car x)))))
                 cvs-states)
index 5b259fcdb33956973347f0a4b9bdafd6896a3988..edc4169465acbcd49ad1f0744b577b2716316e41 100644 (file)
@@ -1863,13 +1863,10 @@ Return t if the buffer had changes, nil otherwise."
                                             (vc-working-revision first))))
       (when (string= rev1-default "") (setq rev1-default nil))))
     ;; construct argument list
-    (let* ((rev1-prompt (if rev1-default
-                            (concat "Older revision (default "
-                                    rev1-default "): ")
-                          "Older revision: "))
-           (rev2-prompt (concat "Newer revision (default "
-                                ;; (or rev2-default
-                                "current source): "))
+    (let* ((rev1-prompt (format-prompt "Older revision" rev1-default))
+           (rev2-prompt (format-prompt "Newer revision"
+                                       ;; (or rev2-default
+                                       "current source"))
            (rev1 (vc-read-revision rev1-prompt files backend rev1-default))
            (rev2 (vc-read-revision rev2-prompt files backend nil))) ;; rev2-default
       (when (string= rev1 "") (setq rev1 nil))
@@ -2082,7 +2079,7 @@ If `F.~REV~' already exists, use it instead of checking it out again."
    (with-current-buffer (or (buffer-base-buffer) (current-buffer))
      (vc-ensure-vc-buffer)
      (list
-      (vc-read-revision "Revision to visit (default is working revision): "
+      (vc-read-revision (format-prompt "Revision to visit" "working revision")
                         (list buffer-file-name)))))
   (set-buffer (or (buffer-base-buffer) (current-buffer)))
   (vc-ensure-vc-buffer)
@@ -2378,7 +2375,7 @@ This function runs the hook `vc-retrieve-tag-hook' when finished."
              (read-directory-name "Directory: " default-directory nil t))))
      (list
       dir
-      (vc-read-revision "Tag name to retrieve (default latest revisions): "
+      (vc-read-revision (format-prompt "Tag name to retrieve" "latest revisions")
                         (list dir)
                         (vc-responsible-backend dir)))))
   (let* ((backend (vc-responsible-backend dir))
index 05606fbfb4adf2f40119baff5749247fd801ba95..fb06a95f51ccc8b01ea4942888872edf1750d7dc 100644 (file)
@@ -3325,7 +3325,7 @@ It reads a file name from an editable text field."
 ;;;     (file (file-name-nondirectory value))
 ;;;     (menu-tag (widget-apply widget :menu-tag-get))
 ;;;     (must-match (widget-get widget :must-match))
-;;;     (answer (read-file-name (concat menu-tag " (default " value "): ")
+;;;     (answer (read-file-name (format-prompt menu-tag value)
 ;;;                             dir nil must-match file)))
 ;;;    (widget-value-set widget (abbreviate-file-name answer))
 ;;;    (widget-setup)