diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2020-09-06 16:56:44 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2020-09-06 16:56:54 +0200 |
commit | 7d927fa8dd5b557e77a0b3dbafc252ede1211c52 (patch) | |
tree | 8941696ecda9e191c74e4fcd0357fe9e4aa323db /lisp | |
parent | d5c399b4d41f48193bdef9571ef04d9a0531b905 (diff) | |
download | emacs-7d927fa8dd5b557e77a0b3dbafc252ede1211c52.tar.gz |
Use `format-prompt' when prompting with default values
* 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).
Diffstat (limited to 'lisp')
78 files changed, 310 insertions, 450 deletions
diff --git a/lisp/abbrev.el b/lisp/abbrev.el index 468b0d995b3..be6f9ee3437 100644 --- a/lisp/abbrev.el +++ b/lisp/abbrev.el @@ -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)) diff --git a/lisp/bookmark.el b/lisp/bookmark.el index 8a3bcf8e59d..dcb03adadd8 100644 --- a/lisp/bookmark.el +++ b/lisp/bookmark.el @@ -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)))) diff --git a/lisp/calc/calc-bin.el b/lisp/calc/calc-bin.el index e9083b84c61..33fd1af6ffb 100644 --- a/lisp/calc/calc-bin.el +++ b/lisp/calc/calc-bin.el @@ -126,8 +126,8 @@ (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 diff --git a/lisp/calc/calc-store.el b/lisp/calc/calc-store.el index 5282b834021..79e6cf5c00c 100644 --- a/lisp/calc/calc-store.el +++ b/lisp/calc/calc-store.el @@ -428,11 +428,11 @@ (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))) diff --git a/lisp/calc/calcalg3.el b/lisp/calc/calcalg3.el index 67183fb754a..75e691a28ff 100644 --- a/lisp/calc/calcalg3.el +++ b/lisp/calc/calcalg3.el @@ -470,17 +470,19 @@ (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) diff --git a/lisp/calendar/timeclock.el b/lisp/calendar/timeclock.el index d12feaae8c3..2ee1d34bf15 100644 --- a/lisp/calendar/timeclock.el +++ b/lisp/calendar/timeclock.el @@ -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 diff --git a/lisp/completion.el b/lisp/completion.el index b2864746fc7..ed13455b711 100644 --- a/lisp/completion.el +++ b/lisp/completion.el @@ -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))) diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el index 3557dce5854..cb1a78d8e20 100644 --- a/lisp/cus-edit.el +++ b/lisp/cus-edit.el @@ -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 diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index 82f4455392e..3ee877ee8de 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -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) diff --git a/lisp/dired-x.el b/lisp/dired-x.el index 05c5a70422c..80a266f7dcd 100644 --- a/lisp/dired-x.el +++ b/lisp/dired-x.el @@ -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)))) diff --git a/lisp/emacs-lisp/advice.el b/lisp/emacs-lisp/advice.el index deac45892ea..0ebd2741d2e 100644 --- a/lisp/emacs-lisp/advice.el +++ b/lisp/emacs-lisp/advice.el @@ -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)))) diff --git a/lisp/emacs-lisp/debug.el b/lisp/emacs-lisp/debug.el index ed28997292f..1bdb2a3d8ca 100644 --- a/lisp/emacs-lisp/debug.el +++ b/lisp/emacs-lisp/debug.el @@ -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))))) diff --git a/lisp/emacs-lisp/disass.el b/lisp/emacs-lisp/disass.el index 51b7db24f3c..c2faac8085b 100644 --- a/lisp/emacs-lisp/disass.el +++ b/lisp/emacs-lisp/disass.el @@ -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))) diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el index 241eece05b6..3c347c0b199 100644 --- a/lisp/emacs-lisp/ert.el +++ b/lisp/emacs-lisp/ert.el @@ -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)) diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el index 56b3e32a3e3..9e252d8c529 100644 --- a/lisp/emacs-lisp/find-func.el +++ b/lisp/emacs-lisp/find-func.el @@ -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) diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index e6f54d206d8..a173fc060a4 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -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))))))) diff --git a/lisp/emacs-lisp/re-builder.el b/lisp/emacs-lisp/re-builder.el index 0e1618e010a..0672f607523 100644 --- a/lisp/emacs-lisp/re-builder.el +++ b/lisp/emacs-lisp/re-builder.el @@ -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)))) diff --git a/lisp/emacs-lisp/smie.el b/lisp/emacs-lisp/smie.el index 38a7b8b54c9..1b700afd12d 100644 --- a/lisp/emacs-lisp/smie.el +++ b/lisp/emacs-lisp/smie.el @@ -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))) diff --git a/lisp/emacs-lisp/trace.el b/lisp/emacs-lisp/trace.el index 4ebb7ff711d..627305689c7 100644 --- a/lisp/emacs-lisp/trace.el +++ b/lisp/emacs-lisp/trace.el @@ -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 diff --git a/lisp/emulation/edt-mapper.el b/lisp/emulation/edt-mapper.el index 2fffcbb154a..5dd81fab3b6 100644 --- a/lisp/emulation/edt-mapper.el +++ b/lisp/emulation/edt-mapper.el @@ -510,7 +510,8 @@ (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") diff --git a/lisp/erc/erc-dcc.el b/lisp/erc/erc-dcc.el index 477f148197b..1bce986a806 100644 --- a/lisp/erc/erc-dcc.el +++ b/lisp/erc/erc-dcc.el @@ -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) diff --git a/lisp/facemenu.el b/lisp/facemenu.el index 419b76101b5..3ed4b54d223 100644 --- a/lisp/facemenu.el +++ b/lisp/facemenu.el @@ -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)) diff --git a/lisp/faces.el b/lisp/faces.el index ba85973bf10..7c23e58fd9d 100644 --- a/lisp/faces.el +++ b/lisp/faces.el @@ -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))) diff --git a/lisp/ffap.el b/lisp/ffap.el index af7d84cd099..3e65c687af6 100644 --- a/lisp/ffap.el +++ b/lisp/ffap.el @@ -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))) diff --git a/lisp/files-x.el b/lisp/files-x.el index 5d863626fa5..911e7ba9e3d 100644 --- a/lisp/files-x.el +++ b/lisp/files-x.el @@ -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)) diff --git a/lisp/files.el b/lisp/files.el index 5f5902d0cb6..e6629d2a21a 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -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))) diff --git a/lisp/format.el b/lisp/format.el index f3559ba9b21..905ca2d9ec9 100644 --- a/lisp/format.el +++ b/lisp/format.el @@ -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 diff --git a/lisp/frame.el b/lisp/frame.el index 081d3010e9b..70088545a68 100644 --- a/lisp/frame.el +++ b/lisp/frame.el @@ -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) diff --git a/lisp/gnus/gnus-group.el b/lisp/gnus/gnus-group.el index ad6e0e30bca..cafaf69a96b 100644 --- a/lisp/gnus/gnus-group.el +++ b/lisp/gnus/gnus-group.el @@ -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)) diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el index 8f37fc88284..0cde893d215 100644 --- a/lisp/gnus/gnus-sum.el +++ b/lisp/gnus/gnus-sum.el @@ -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) diff --git a/lisp/gnus/mm-decode.el b/lisp/gnus/mm-decode.el index 7f8ab5f9ef5..a01fd2729af 100644 --- a/lisp/gnus/mm-decode.el +++ b/lisp/gnus/mm-decode.el @@ -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 "") diff --git a/lisp/help-fns.el b/lisp/help-fns.el index 617f6ae5e80..a9943ccd7f4 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -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 diff --git a/lisp/help.el b/lisp/help.el index 1b0149616f2..45159d44779 100644 --- a/lisp/help.el +++ b/lisp/help.el @@ -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")) diff --git a/lisp/hi-lock.el b/lisp/hi-lock.el index 0ffe77d2763..0fe651ace34 100644 --- a/lisp/hi-lock.el +++ b/lisp/hi-lock.el @@ -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)) diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el index c9ca1f87424..80c5b073985 100644 --- a/lisp/ibuf-ext.el +++ b/lisp/ibuf-ext.el @@ -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) diff --git a/lisp/imenu.el b/lisp/imenu.el index 3a16dcb9ac3..8fdacb0214d 100644 --- a/lisp/imenu.el +++ b/lisp/imenu.el @@ -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) diff --git a/lisp/info-look.el b/lisp/info-look.el index 40f7f6003e7..bcc2930ffc0 100644 --- a/lisp/info-look.el +++ b/lisp/info-look.el @@ -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))) diff --git a/lisp/info.el b/lisp/info.el index ab678c26b62..dc1102aab30 100644 --- a/lisp/info.el +++ b/lisp/info.el @@ -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)))) diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el index 75d1c611e62..ccc8ac9f9e6 100644 --- a/lisp/international/mule-cmds.el +++ b/lisp/international/mule-cmds.el @@ -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*") diff --git a/lisp/international/mule.el b/lisp/international/mule.el index 092abc09b05..c4febb26d4f 100644 --- a/lisp/international/mule.el +++ b/lisp/international/mule.el @@ -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")) diff --git a/lisp/international/ogonek.el b/lisp/international/ogonek.el index 9ab9e3b0f65..37fcda70b37 100644 --- a/lisp/international/ogonek.el +++ b/lisp/international/ogonek.el @@ -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 diff --git a/lisp/isearch.el b/lisp/isearch.el index 81e83d79509..7fb1d8a3ca6 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -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. diff --git a/lisp/locate.el b/lisp/locate.el index 9f402716d02..bc78e06eab2 100644 --- a/lisp/locate.el +++ b/lisp/locate.el @@ -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)) diff --git a/lisp/mail/mailabbrev.el b/lisp/mail/mailabbrev.el index a6a606828f9..09afad7aa47 100644 --- a/lisp/mail/mailabbrev.el +++ b/lisp/mail/mailabbrev.el @@ -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)))) diff --git a/lisp/mail/mailalias.el b/lisp/mail/mailalias.el index 8e7aaf94937..1f688734d47 100644 --- a/lisp/mail/mailalias.el +++ b/lisp/mail/mailalias.el @@ -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. diff --git a/lisp/mail/sendmail.el b/lisp/mail/sendmail.el index 65d598c3bac..dd6eecbfd09 100644 --- a/lisp/mail/sendmail.el +++ b/lisp/mail/sendmail.el @@ -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)))) diff --git a/lisp/man.el b/lisp/man.el index da8a15f69b9..64272415411 100644 --- a/lisp/man.el +++ b/lisp/man.el @@ -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 "") diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el index 2b8d4d0ce62..e7dad48cf4a 100644 --- a/lisp/net/browse-url.el +++ b/lisp/net/browse-url.el @@ -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)))) diff --git a/lisp/net/eww.el b/lisp/net/eww.el index 4b897fa34e6..b720edc7fef 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -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 diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el index 1766e192f2d..f296ae3afe1 100644 --- a/lisp/net/rcirc.el +++ b/lisp/net/rcirc.el @@ -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 () diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el index 1b1920bf195..13b672bd53b 100644 --- a/lisp/progmodes/compile.el +++ b/lisp/progmodes/compile.el @@ -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 diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el index 7a1c2e4d24e..af179e2797e 100644 --- a/lisp/progmodes/cperl-mode.el +++ b/lisp/progmodes/cperl-mode.el @@ -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") diff --git a/lisp/progmodes/inf-lisp.el b/lisp/progmodes/inf-lisp.el index 9f34a377f4a..59db646ff32 100644 --- a/lisp/progmodes/inf-lisp.el +++ b/lisp/progmodes/inf-lisp.el @@ -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)))) diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el index 3dd9b8dae6a..55a78c6cc85 100644 --- a/lisp/progmodes/octave.el +++ b/lisp/progmodes/octave.el @@ -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: "))) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index d83af83b32e..ccbcb081305 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -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))) diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index 5a47594878e..3c249b7bc0e 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -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 diff --git a/lisp/progmodes/tcl.el b/lisp/progmodes/tcl.el index 7ffa6d41dac..33aad2d39f7 100644 --- a/lisp/progmodes/tcl.el +++ b/lisp/progmodes/tcl.el @@ -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)) diff --git a/lisp/rect.el b/lisp/rect.el index 9922aac9ec9..ebf309a88fe 100644 --- a/lisp/rect.el +++ b/lisp/rect.el @@ -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)) diff --git a/lisp/replace.el b/lisp/replace.el index 69092c16f96..a751822c79a 100644 --- a/lisp/replace.el +++ b/lisp/replace.el @@ -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 diff --git a/lisp/ses.el b/lisp/ses.el index 96b219fc601..5707067e765 100644 --- a/lisp/ses.el +++ b/lisp/ses.el @@ -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. diff --git a/lisp/simple.el b/lisp/simple.el index eedbff2d087..376585d8e82 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -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)) diff --git a/lisp/speedbar.el b/lisp/speedbar.el index 5b98eb36bb9..aab6a3a1283 100644 --- a/lisp/speedbar.el +++ b/lisp/speedbar.el @@ -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))) diff --git a/lisp/term.el b/lisp/term.el index e77c2c1331b..f0470d806cd 100644 --- a/lisp/term.el +++ b/lisp/term.el @@ -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))) diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index cc5879880c8..8c824461d22 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -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 diff --git a/lisp/textmodes/refer.el b/lisp/textmodes/refer.el index 8d8223a7326..c8fd0bea004 100644 --- a/lisp/textmodes/refer.el +++ b/lisp/textmodes/refer.el @@ -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) diff --git a/lisp/textmodes/reftex-ref.el b/lisp/textmodes/reftex-ref.el index b79bb292c8a..4c780d8d8c3 100644 --- a/lisp/textmodes/reftex-ref.el +++ b/lisp/textmodes/reftex-ref.el @@ -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)) diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 04f1dddf5fc..e0ef786953e 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -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)) diff --git a/lisp/textmodes/table.el b/lisp/textmodes/table.el index 33f181b80c3..cfe6ce5ce61 100644 --- a/lisp/textmodes/table.el +++ b/lisp/textmodes/table.el @@ -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))))) diff --git a/lisp/vc/add-log.el b/lisp/vc/add-log.el index d302fb16eda..54bb3569788 100644 --- a/lisp/vc/add-log.el +++ b/lisp/vc/add-log.el @@ -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. diff --git a/lisp/vc/ediff-mult.el b/lisp/vc/ediff-mult.el index 2b1b07927f8..c977291a524 100644 --- a/lisp/vc/ediff-mult.el +++ b/lisp/vc/ediff-mult.el @@ -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))) diff --git a/lisp/vc/ediff-util.el b/lisp/vc/ediff-util.el index f56d31c7136..52878bad8a7 100644 --- a/lisp/vc/ediff-util.el +++ b/lisp/vc/ediff-util.el @@ -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" diff --git a/lisp/vc/ediff.el b/lisp/vc/ediff.el index 133d2109f5b..ae2f8ad6c1c 100644 --- a/lisp/vc/ediff.el +++ b/lisp/vc/ediff.el @@ -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)) diff --git a/lisp/vc/emerge.el b/lisp/vc/emerge.el index fc8c318e3af..d2d419ac786 100644 --- a/lisp/vc/emerge.el +++ b/lisp/vc/emerge.el @@ -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. diff --git a/lisp/vc/vc-annotate.el b/lisp/vc/vc-annotate.el index d82cadc70dd..18bcc6c2f10 100644 --- a/lisp/vc/vc-annotate.el +++ b/lisp/vc/vc-annotate.el @@ -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 diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index f0a08044e28..4cbd2658f80 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -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)) diff --git a/lisp/w32-fns.el b/lisp/w32-fns.el index c252c0b18f8..e159d1888e5 100644 --- a/lisp/w32-fns.el +++ b/lisp/w32-fns.el @@ -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)) diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el index f58a0fb7a3a..e9799dc00fd 100644 --- a/lisp/wid-edit.el +++ b/lisp/wid-edit.el @@ -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 diff --git a/lisp/woman.el b/lisp/woman.el index 891a1263ace..eeacceadc27 100644 --- a/lisp/woman.el +++ b/lisp/woman.el @@ -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 |