1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-09 15:50:21 +00:00

Use format-prompt for many more prompts

* 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.
This commit is contained in:
Stefan Kangas 2021-10-05 03:34:08 +02:00
parent 19444fb093
commit 6640942221
49 changed files with 161 additions and 204 deletions

View File

@ -498,11 +498,8 @@ If DEFAULT is nil then return empty string for empty input."
'string-lessp) 'string-lessp)
(bookmark-all-names))) (bookmark-all-names)))
(let* ((completion-ignore-case bookmark-completion-ignore-case) (let* ((completion-ignore-case bookmark-completion-ignore-case)
(default (unless (equal "" default) default)) (default (unless (equal "" default) default)))
(prompt (concat prompt (if default (completing-read (format-prompt prompt default)
(format " (%s): " default)
": "))))
(completing-read prompt
(lambda (string pred action) (lambda (string pred action)
(if (eq action 'metadata) (if (eq action 'metadata)
'(metadata (category . bookmark)) '(metadata (category . bookmark))

View File

@ -205,9 +205,8 @@
(progn (progn
(setq cmd-base-default (concat "User-" keyname)) (setq cmd-base-default (concat "User-" keyname))
(setq cmd (completing-read (setq cmd (completing-read
(concat "Define M-x command name (default calc-" (format-prompt "Define M-x command name"
cmd-base-default (concat "calc-" cmd-base-default))
"): ")
obarray 'commandp nil obarray 'commandp nil
(if (and odef (symbolp (cdr odef))) (if (and odef (symbolp (cdr odef)))
(symbol-name (cdr odef)) (symbol-name (cdr odef))
@ -241,8 +240,8 @@
(setq func (setq func
(concat "calcFunc-" (concat "calcFunc-"
(completing-read (completing-read
(concat "Define algebraic function name (default " (format-prompt "Define algebraic function name"
cmd-base-default "): ") cmd-base-default)
(mapcar (lambda (x) (substring x 9)) (mapcar (lambda (x) (substring x 9))
(all-completions "calcFunc-" (all-completions "calcFunc-"
obarray)) obarray))

View File

@ -586,7 +586,7 @@
(defun calc-permanent-variable (&optional var) (defun calc-permanent-variable (&optional var)
(interactive) (interactive)
(calc-wrapper (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) (let (calc-pv-pos)
(and var (or (and (boundp var) (symbol-value var)) (and var (or (and (boundp var) (symbol-value var))
(error "No such variable"))) (error "No such variable")))

View 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)) (setq defunits (math-get-default-units expr))
(unless new-units (unless new-units
(setq new-units (setq new-units
(read-string (concat (read-string (format-prompt
(if (and uoldname (not nouold)) (if (and uoldname (not nouold))
(concat "Old units: " (concat "Old units: "
uoldname uoldname
", new units") ", new units")
"New units") "New units")
(if defunits defunits)))
(concat
" (default "
defunits
"): ")
": "))))
(if (and (if (and
(string= new-units "") (string= new-units "")
defunits) 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)) (let* ((old-units (math-extract-units expr))
(defunits (math-get-default-units expr)) (defunits (math-get-default-units expr))
units units
(new-units (new-units (read-string (format-prompt "New units" defunits))))
(read-string (concat "New units"
(if defunits
(concat
" (default "
defunits
"): ")
": ")))))
(if (and (if (and
(string= new-units "") (string= new-units "")
defunits) 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 expr (math-mul expr uold)))
(setq defunits (math-get-default-units expr)) (setq defunits (math-get-default-units expr))
(setq unew (or new-units (setq unew (or new-units
(completing-read (completing-read (format-prompt
(concat (if uoldname
(if uoldname (concat "Old temperature units: "
(concat "Old temperature units: " uoldname
uoldname ", new units")
", new units") "New temperature units")
"New temperature units") defunits)
(if defunits tempunits)))
(concat " (default "
defunits
"): ")
": "))
tempunits)))
(setq unew (math-read-expr (if (string= unew "") defunits unew))) (setq unew (math-read-expr (if (string= unew "") defunits unew)))
(when (eq (car-safe unew) 'error) (when (eq (car-safe unew) 'error)
(error "Bad format in units expression: %s" (nth 2 unew))) (error "Bad format in units expression: %s" (nth 2 unew)))

View 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 ;; @todo - move from () to into the editable area
(if (string-match ":" prompt) (if (string-match ":" prompt)
(setq prompt (concat (setq prompt (format-prompt
(substring prompt 0 (match-beginning 0)) (substring prompt 0 (match-beginning 0))
" (default " default-as-string ")" default-as-string))
(substring prompt (match-beginning 0)))) (setq prompt (format-prompt prompt default-as-string))))
(setq prompt (concat prompt " (" default-as-string "): "))))
;; ;;
;; Perform the Completion ;; Perform the Completion
;; ;;

View File

@ -1133,7 +1133,7 @@ for the MODE to customize."
(defun customize-read-group () (defun customize-read-group ()
(let ((completion-ignore-case t)) (let ((completion-ignore-case t))
(completing-read "Customize group (default emacs): " (completing-read (format-prompt "Customize group" "emacs")
obarray obarray
(lambda (symbol) (lambda (symbol)
(or (and (get symbol 'custom-loads) (or (and (get symbol 'custom-loads)

View File

@ -444,10 +444,10 @@ List has a form of (file-name full-file-name (attribute-list))."
((eq op-symbol 'chgrp) ((eq op-symbol 'chgrp)
(file-attribute-group-id (file-attribute-group-id
(file-attributes default-file 'string)))))) (file-attributes default-file 'string))))))
(prompt (concat "Change " attribute-name " of %s to" (prompt (format-prompt "Change %s of %%s to"
(if (eq op-symbol 'touch) (when (eq op-symbol 'touch)
" (default now): " "now")
": "))) attribute-name))
(new-attribute (dired-mark-read-string prompt nil op-symbol (new-attribute (dired-mark-read-string prompt nil op-symbol
arg files default arg files default
(cond ((eq op-symbol 'chown) (cond ((eq op-symbol 'chown)

View 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." files in the active region if `dired-mark-region' is non-nil."
(interactive (interactive
(list (read-regexp (list (read-regexp
"Mark unmarked files matching regexp (default all): " (format-prompt "Mark unmarked files matching regexp" "all")
nil 'dired-regexp-history) nil 'dired-regexp-history)
nil current-prefix-arg nil)) nil current-prefix-arg nil))
(let ((dired-marker-char (if unflag-p ?\s dired-marker-char))) (let ((dired-marker-char (if unflag-p ?\s dired-marker-char)))

View File

@ -701,7 +701,8 @@ To specify a nil argument interactively, exit with an empty minibuffer."
(interactive (interactive
(list (let ((name (list (let ((name
(completing-read (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))) (mapcar #'symbol-name (debug--function-list)) nil t)))
(when name (when name
(unless (string= name "") (unless (string= name "")
@ -804,7 +805,8 @@ To specify a nil argument interactively, exit with an empty minibuffer."
(interactive (interactive
(list (let ((name (list (let ((name
(completing-read (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))) (mapcar #'symbol-name (debug--variable-list)) nil t)))
(when name (when name
(unless (string= name "") (unless (string= name "")

View File

@ -3519,7 +3519,8 @@ The removes the effect of `edebug-on-entry'. If FUNCTION is
nil, remove `edebug-on-entry' on all functions." nil, remove `edebug-on-entry' on all functions."
(interactive (interactive
(list (let ((name (completing-read (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))) (let ((functions (edebug--edebug-on-entry-functions)))
(unless functions (unless functions
(user-error "No functions have `edebug-on-entry'")) (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")) (user-error "Found no functions to remove instrumentation from"))
(let ((name (let ((name
(completing-read (completing-read
"Remove instrumentation from (default all functions): " (format-prompt "Remove instrumentation from"
"all functions")
functions))) functions)))
(if (and name (if (and name
(not (equal name ""))) (not (equal name "")))

View 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))) (setq input (file-name-sans-extension (expand-file-name input)))
(expand-file-name (expand-file-name
(read-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) (file-name-directory input)
input))) input)))
@ -1236,9 +1236,7 @@ If no one is selected, symmetric encryption will be performed. ")
(list keys (list keys
(expand-file-name (expand-file-name
(read-file-name (read-file-name
(concat "To file (default " (format-prompt "To file" (file-name-nondirectory default-name))
(file-name-nondirectory default-name)
") ")
(file-name-directory default-name) (file-name-directory default-name)
default-name))))) default-name)))))
(let ((context (epg-make-context epa-protocol))) (let ((context (epg-make-context epa-protocol)))

View File

@ -1100,7 +1100,7 @@ returned. Otherwise, DEFAULT is returned verbatim."
;; prompt. If so, remove it. ;; prompt. If so, remove it.
(setq prompt (replace-regexp-in-string ": ?\\'" "" prompt)) (setq prompt (replace-regexp-in-string ": ?\\'" "" prompt))
(let ((prompt (if default (let ((prompt (if default
(format-message "%s (default `%s'): " prompt default) (format-prompt prompt default)
(format "%s: " prompt))) (format "%s: " prompt)))
aliasfaces nonaliasfaces faces) aliasfaces nonaliasfaces faces)
;; Build up the completion tables. ;; Build up the completion tables.

View 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 Set `buffer-file-format' to the format used, and call any
format-specific mode functions." format-specific mode functions."
(interactive (interactive
(list (format-read "Translate buffer from format (default guess): "))) (list (format-read (format-prompt "Translate buffer from format" "guess"))))
(save-excursion (save-excursion
(goto-char (point-min)) (goto-char (point-min))
(format-decode format (buffer-size) t))) (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." for identifying regular expressions at the beginning of the region."
(interactive (interactive
(list (region-beginning) (region-end) (list (region-beginning) (region-end)
(format-read "Translate region from format (default guess): "))) (format-read (format-prompt "Translate region from format" "guess"))))
(save-excursion (save-excursion
(goto-char from) (goto-char from)
(format-decode format (- to from) nil))) (format-decode format (- to from) nil)))

View File

@ -3933,8 +3933,8 @@ This format is defined by the `gnus-article-time-format' variable."
;; No split name was found. ;; No split name was found.
((null split-name) ((null split-name)
(read-file-name (read-file-name
(concat prompt " (default " (format-prompt prompt
(file-name-nondirectory default-name) "): ") (file-name-nondirectory default-name))
(file-name-directory default-name) (file-name-directory default-name)
default-name)) default-name))
;; A single group name is returned. ;; 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 (funcall function split-name headers
(symbol-value variable))) (symbol-value variable)))
(read-file-name (read-file-name
(concat prompt " (default " (format-prompt prompt
(file-name-nondirectory default-name) "): ") (file-name-nondirectory default-name))
(file-name-directory default-name) (file-name-directory default-name)
default-name)) default-name))
;; A single split name was found ;; 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-name-as-directory name))
((file-exists-p name) name) ((file-exists-p name) name)
(t gnus-article-save-directory)))) (t gnus-article-save-directory))))
(read-file-name (read-file-name (format-prompt prompt name)
(concat prompt " (default " name "): ") dir name)))
dir name)))
;; A list of splits was found. ;; A list of splits was found.
(t (t
(setq split-name (nreverse split-name)) (setq split-name (nreverse split-name))

View File

@ -1310,9 +1310,7 @@ SPEC is a predicate specifier that contains stuff like `or', `and',
initial-input history def) initial-input history def)
"Call `gnus-completing-read-function'." "Call `gnus-completing-read-function'."
(funcall gnus-completing-read-function (funcall gnus-completing-read-function
(concat prompt (when def (format-prompt prompt def)
(concat " (default " def ")"))
": ")
collection require-match initial-input history def)) collection require-match initial-input history def))
(defun gnus-emacs-completing-read (prompt collection &optional require-match (defun gnus-emacs-completing-read (prompt collection &optional require-match

View File

@ -5349,7 +5349,7 @@ Otherwise, generate and save a value for `canlock-password' first."
(zerop (zerop
(length (length
(setq to (completing-read (setq to (completing-read
"Followups to (default no Followup-To header): " (format-prompt "Followups to" "no Followup-To header")
(mapcar #'list (mapcar #'list
(cons "poster" (cons "poster"
(message-tokenize-header (message-tokenize-header

View File

@ -2604,12 +2604,9 @@ new buffer."
(if (eq (length completions) 1) (if (eq (length completions) 1)
(setq default (car completions))) (setq default (car completions)))
(if completions (if completions
(let ((input (completing-read (if default (let ((input (completing-read (format-prompt "Follow reference named"
(concat default)
"Follow reference named (default " completions nil t)))
default "): ")
"Follow reference named: ")
completions nil t)))
(list (if (equal input "") (list (if (equal input "")
default input) default input)
current-prefix-arg)) current-prefix-arg))

View File

@ -833,7 +833,7 @@ The IGNORED argument is ignored."
"Display information about a font whose name is FONTNAME." "Display information about a font whose name is FONTNAME."
(interactive (interactive
(list (completing-read (list (completing-read
"Font name (default current choice for ASCII chars): " (format-prompt "Font name" "current choice for ASCII chars")
(and window-system (and window-system
;; Implied by `window-system'. ;; Implied by `window-system'.
(fboundp 'x-list-fonts) (fboundp 'x-list-fonts)
@ -1004,7 +1004,7 @@ This shows which font is used for which character(s)."
(mapcar 'cdr fontset-alias-alist))) (mapcar 'cdr fontset-alias-alist)))
(completion-ignore-case t)) (completion-ignore-case t))
(list (completing-read (list (completing-read
"Fontset (default used by the current frame): " (format-prompt "Fontset" "used by the current frame")
fontset-list nil t))))) fontset-list nil t)))))
(if (= (length fontset) 0) (if (= (length fontset) 0)
(setq fontset (face-attribute 'default :fontset)) (setq fontset (face-attribute 'default :fontset))

View 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 The variable `quail-keyboard-layout-type' holds the currently selected
keyboard type." keyboard type."
(interactive (interactive
(list (completing-read "Keyboard type (default current choice): " (list (completing-read (format-prompt "Keyboard type" "current choice")
quail-keyboard-layout-alist quail-keyboard-layout-alist
nil t))) nil t)))
(or (and keyboard-type (> (length keyboard-type) 0)) (or (and keyboard-type (> (length keyboard-type) 0))

View File

@ -60,7 +60,7 @@ If the argument is nil, we return the display table to its standard state."
(list (list
(let* ((completion-ignore-case t)) (let* ((completion-ignore-case t))
(completing-read (completing-read
"Cyrillic language (default nil): " (format-prompt "Cyrillic language" "nil")
cyrillic-language-alist nil t nil nil nil)))) cyrillic-language-alist nil t nil nil nil))))
(or standard-display-table (or standard-display-table

View File

@ -74,12 +74,9 @@ according to the choice made, and returns a symbol."
(rmail-summary-exists) (rmail-summary-exists)
(and (setq old (rmail-get-keywords)) (and (setq old (rmail-get-keywords))
(mapc #'rmail-make-label (split-string old ", ")))) (mapc #'rmail-make-label (split-string old ", "))))
(completing-read (concat prompt (completing-read (format-prompt prompt
(if rmail-last-label (and rmail-last-label
(concat " (default " (symbol-name rmail-last-label)))
(symbol-name rmail-last-label)
"): ")
": "))
rmail-label-obarray rmail-label-obarray
nil nil
nil)))) nil))))

View 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? ") (unless (y-or-n-p "This entity is truncated; save anyway? ")
(error "Aborted"))) (error "Aborted")))
(setq filename (expand-file-name (setq filename (expand-file-name
(read-file-name (format "Save as (default: %s): " filename) (read-file-name (format-prompt "Save as" filename)
directory directory
(expand-file-name filename directory)) (expand-file-name filename directory))
directory)) directory))

View File

@ -107,9 +107,8 @@ error: %S\n"
(read-file (read-file
(expand-file-name (expand-file-name
(read-file-name (read-file-name
(concat "Output message to mail file (default " (format-prompt "Output message to mail file"
(file-name-nondirectory default-file) (file-name-nondirectory default-file))
"): ")
(file-name-directory default-file) (file-name-directory default-file)
(abbreviate-file-name default-file)) (abbreviate-file-name default-file))
(file-name-directory default-file)))) (file-name-directory default-file))))

View File

@ -1786,7 +1786,7 @@ Returns t if section is found, nil otherwise."
Man--last-section Man--last-section
(car Man--sections))) (car Man--sections)))
(completion-ignore-case t) (completion-ignore-case t)
(prompt (concat "Go to section (default " default "): ")) (prompt (format-prompt "Go to section" default))
(chosen (completing-read prompt Man--sections (chosen (completing-read prompt Man--sections
nil nil nil nil default))) nil nil nil nil default)))
(list chosen)) (list chosen))
@ -1850,7 +1850,7 @@ Specify which REFERENCE to use; default is based on word at point."
(defaults (defaults
(mapcar 'substring-no-properties (mapcar 'substring-no-properties
(cons default Man--refpages))) (cons default Man--refpages)))
(prompt (concat "Refer to (default " default "): ")) (prompt (format-prompt "Refer to" default))
(chosen (completing-read prompt Man--refpages (chosen (completing-read prompt Man--refpages
nil nil nil nil defaults))) nil nil nil nil defaults)))
chosen))) chosen)))

View File

@ -1918,10 +1918,7 @@ key, a click, or a menu-item"))
(let* ((default (thing-at-point 'sexp)) (let* ((default (thing-at-point 'sexp))
(topic (topic
(read-from-minibuffer (read-from-minibuffer
(format "Subject to look up%s: " (format-prompt "Subject to look up" default)
(if default
(format " (default \"%s\")" default)
""))
nil nil nil nil default))) nil nil nil nil default)))
(list (if (zerop (length topic)) (list (if (zerop (length topic))
default default

View File

@ -1230,8 +1230,9 @@ only return the directory part of FILE."
;; found another machine with the same user. ;; found another machine with the same user.
;; Try that account. ;; Try that account.
(read-passwd (read-passwd
(format "passwd for %s@%s (default same as %s@%s): " (format-prompt "passwd for %s@%s"
user host user other) (format "same as %s@%s" user other)
user host)
nil nil
(ange-ftp-lookup-passwd other user)) (ange-ftp-lookup-passwd other user))

View File

@ -1815,10 +1815,13 @@ by their respective `org-store-link-plist' properties if present."
;; Load history list for current prompt. ;; Load history list for current prompt.
(setq org-capture--prompt-history (setq org-capture--prompt-history
(gethash prompt org-capture--prompt-history-table)) (gethash prompt org-capture--prompt-history-table))
(push (org-completing-read (push (org-completing-read
(concat (or prompt "Enter string") ;; `format-prompt' is new in Emacs 28.1.
(and default (format " [%s]" default)) (if (fboundp 'format-prompt)
": ") (format-prompt (or prompt "Enter string") default)
(concat (or prompt "Enter string")
(and default (format " [%s]" default))
": "))
completions completions
nil nil nil 'org-capture--prompt-history default) nil nil nil 'org-capture--prompt-history default)
strings) strings)

View File

@ -640,11 +640,13 @@ this function appends the default value from
org-refile-target-table)) org-refile-target-table))
(completion-ignore-case t) (completion-ignore-case t)
cdef cdef
(prompt (concat prompt (prompt (let ((default (or (car org-refile-history)
(or (and (car org-refile-history) (and (assoc cbnex tbl) (setq cdef cbnex)
(concat " (default " (car org-refile-history) ")")) cbnex))))
(and (assoc cbnex tbl) (setq cdef cbnex) ;; `format-prompt' is new in Emacs 28.1.
(concat " (default " cbnex ")"))) ": ")) (if (fboundp 'format-prompt)
(format-prompt prompt default)
(concat prompt " (default " default ": "))))
pa answ parent-target child parent old-hist) pa answ parent-target child parent old-hist)
(setq old-hist org-refile-history) (setq old-hist org-refile-history)
(setq answ (funcall cfunc prompt tbl nil (not new-nodes) (setq answ (funcall cfunc prompt tbl nil (not new-nodes)

View File

@ -1772,8 +1772,8 @@ supported but discouraged. It will be removed in a future version of Emacs."
`(:annotation-function `(:annotation-function
,(lambda (s) (cdr (assoc s proced-signal-list)))))) ,(lambda (s) (cdr (assoc s proced-signal-list))))))
(proced-with-processes-buffer process-alist (proced-with-processes-buffer process-alist
(list (completing-read (concat "Send signal [" pnum (list (completing-read (format-prompt "Send signal [%s]"
"] (default TERM): ") "TERM" pnum)
proced-signal-list proced-signal-list
nil nil nil nil "TERM") nil nil nil nil "TERM")
process-alist)))) process-alist))))
@ -1797,8 +1797,8 @@ supported but discouraged. It will be removed in a future version of Emacs."
`(:annotation-function `(:annotation-function
,(lambda (s) (cdr (assoc s proced-signal-list)))))) ,(lambda (s) (cdr (assoc s proced-signal-list))))))
(proced-with-processes-buffer process-alist (proced-with-processes-buffer process-alist
(setq signal (completing-read (concat "Send signal [" pnum (setq signal (completing-read (format-prompt "Send signal [%s]"
"] (default TERM): ") "TERM" pnum)
proced-signal-list proced-signal-list
nil nil nil nil "TERM")))))) nil nil nil nil "TERM"))))))

View File

@ -702,11 +702,8 @@ BRANCH should be either nil (false branch), t (true branch) or `both'."
(x-popup-menu cpp-button-event (x-popup-menu cpp-button-event
(list prompt (cons prompt cpp-face-default-list))) (list prompt (cons prompt cpp-face-default-list)))
(let ((name (car (rassq default cpp-face-default-list)))) (let ((name (car (rassq default cpp-face-default-list))))
(cdr (assoc (completing-read (if name (cdr (assoc (completing-read (format-prompt "%s" name prompt)
(concat prompt cpp-face-default-list nil t)
" (default " name "): ")
(concat prompt ": "))
cpp-face-default-list nil t)
cpp-face-all-list)))) cpp-face-all-list))))
default)) default))

View 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." "Set the indentation width of the tree display."
(interactive) (interactive)
(let ((width (string-to-number (read-string (let ((width (string-to-number (read-string
(concat "Indentation (default " (format-prompt
(int-to-string ebrowse--indentation) "Indentation"
"): ") (int-to-string ebrowse--indentation))
nil nil ebrowse--indentation)))) nil nil ebrowse--indentation))))
(when (cl-plusp width) (when (cl-plusp width)
(setq-local ebrowse--indentation width) (setq-local ebrowse--indentation width)

View File

@ -292,7 +292,7 @@ file the tag was in."
(or (locate-dominating-file default-directory "TAGS") (or (locate-dominating-file default-directory "TAGS")
default-directory))) default-directory)))
(list (read-file-name (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 to TAGS from default-directory up to root.
default-tag-dir default-tag-dir
(expand-file-name "TAGS" 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)) (car list))
;; Finally, prompt the user for a file name. ;; Finally, prompt the user for a file name.
(expand-file-name (expand-file-name
(read-file-name "Visit tags table (default TAGS): " (read-file-name (format-prompt "Visit tags table" "TAGS")
default-directory default-directory
"TAGS" "TAGS"
t)))))) t))))))

View File

@ -1057,11 +1057,9 @@ REGEXP is used as a string in the prompt."
default-extension default-extension
(car grep-files-history) (car grep-files-history)
(car (car grep-files-aliases)))) (car (car grep-files-aliases))))
(files (completing-read (files (completing-read
(concat "Search for \"" regexp (format-prompt "Search for \"%s\" in files matching wildcard"
"\" in files matching wildcard" default regexp)
(if default (concat " (default " default ")"))
": ")
#'read-file-name-internal #'read-file-name-internal
nil nil nil 'grep-files-history nil nil nil 'grep-files-history
(delete-dups (delete-dups

View File

@ -2456,7 +2456,7 @@ This allows #ifdef VAR to be hidden."
(t (t
nil)))) nil))))
(var (read-minibuffer "Define what? " default)) (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"))) nil nil t nil "1")))
(list var val))) (list var val)))
(hif-set-var var (or val 1)) (hif-set-var var (or val 1))

View File

@ -1357,9 +1357,7 @@ The default is a name found in the buffer around point."
default "")) default ""))
(label (label
;; Do completion with default. ;; Do completion with default.
(completing-read (if (not (string= default "")) (completing-read (format-prompt "Label" default)
(concat "Label (default " default "): ")
"Label: ")
;; Complete with the defuns found in the ;; Complete with the defuns found in the
;; current-buffer. ;; current-buffer.
(let ((buf (current-buffer))) (let ((buf (current-buffer)))

View File

@ -2484,11 +2484,8 @@ Interaction supports completion."
(if (eq (try-completion default prolog-info-alist) nil) (if (eq (try-completion default prolog-info-alist) nil)
(setq default nil)) (setq default nil))
;; Read the PredSpec from the user ;; Read the PredSpec from the user
(completing-read (completing-read (format-prompt "Help on predicate" default)
(if (zerop (length default)) prolog-info-alist nil t nil nil default)))
"Help on predicate: "
(concat "Help on predicate (default " default "): "))
prolog-info-alist nil t nil nil default)))
(defun prolog-build-info-alist (&optional verbose) (defun prolog-build-info-alist (&optional verbose)
"Build an alist of all builtins and library predicates. "Build an alist of all builtins and library predicates.

View File

@ -4773,10 +4773,14 @@ Interactively, prompt for symbol."
(interactive (interactive
(let ((symbol (python-eldoc--get-symbol-at-point)) (let ((symbol (python-eldoc--get-symbol-at-point))
(enable-recursive-minibuffers t)) (enable-recursive-minibuffers t))
(list (read-string (if symbol (list (read-string
(format "Describe symbol (default %s): " symbol) ;; `format-prompt' is new in Emacs 28.1.
"Describe symbol: ") (if (fboundp 'format-prompt)
nil nil symbol)))) (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))) (message (python-eldoc--get-doc-at-point symbol)))
(defun python-describe-at-point (symbol process) (defun python-describe-at-point (symbol process)

View File

@ -3219,14 +3219,7 @@ For both `:file' and `:completion', there can also be a
symbol symbol
(let* ((default (plist-get plist :default)) (let* ((default (plist-get plist :default))
(last-value (sql-default-value symbol)) (last-value (sql-default-value symbol))
(prompt-def (prompt-def (format-prompt prompt default))
(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))
(use-dialog-box nil)) (use-dialog-box nil))
(cond (cond
((plist-member plist :file) ((plist-member plist :file)
@ -3311,7 +3304,7 @@ function like this: (sql-get-login \\='user \\='password \\='database)."
(let ((plist (cdr-safe w))) (let ((plist (cdr-safe w)))
(pcase (or (car-safe w) w) (pcase (or (car-safe w) w)
('user ('user
(sql-get-login-ext 'sql-user "User: " 'sql-user-history plist)) (sql-get-login-ext 'sql-user "User" 'sql-user-history plist))
('password ('password
(setq-default sql-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))))) (read-passwd "Password: " nil (sql-default-value 'sql-password)))))
('server ('server
(sql-get-login-ext 'sql-server "Server: " 'sql-server-history plist)) (sql-get-login-ext 'sql-server "Server" 'sql-server-history plist))
('database ('database
(sql-get-login-ext 'sql-database "Database: " (sql-get-login-ext 'sql-database "Database"
'sql-database-history plist)) 'sql-database-history plist))
('port ('port
(sql-get-login-ext 'sql-port "Port: " (sql-get-login-ext 'sql-port "Port"
nil (append '(:number t) plist))))))) nil (append '(:number t) plist)))))))
(defun sql-find-sqli-buffer (&optional product connection) (defun sql-find-sqli-buffer (&optional product connection)

View File

@ -5478,8 +5478,11 @@ becomes:
(let* ((pop-up-windows t)) (let* ((pop-up-windows t))
(let ((name (expand-file-name (let ((name (expand-file-name
(read-file-name (read-file-name
(format "Find this error in: (default %s) " ;; `format-prompt' is new in Emacs 28.1.
file) (if (fboundp 'format-prompt)
(format-prompt "Find this error in" file)
(format "Find this error in (default %s): "
file))
nil ;; dir nil ;; dir
file t)))) file t))))
(setq buffer (setq buffer
@ -7863,14 +7866,14 @@ If search fails, other files are checked based on
(let* ((default (verilog-get-default-symbol)) (let* ((default (verilog-get-default-symbol))
;; The following variable is used in verilog-comp-function ;; The following variable is used in verilog-comp-function
(verilog-buffer-to-use (current-buffer)) (verilog-buffer-to-use (current-buffer))
(label (if (not (string= default "")) (label
;; Do completion with default (completing-read (cond ((fboundp 'format-prompt)
(completing-read (concat "Goto-Label: (default " ;; `format-prompt' is new in Emacs 28.1.
default ") ") (format-prompt "Goto-Label" default))
#'verilog-comp-defun nil nil "") ((not (string= default ""))
;; There is no default value. Complete without it (concat "Goto-Label (default " default "): "))
(completing-read "Goto-Label: " (t "Goto-Label: "))
#'verilog-comp-defun nil nil ""))) #'verilog-comp-defun nil nil ""))
pt) pt)
;; Make sure library paths are correct, in case need to resolve module ;; Make sure library paths are correct, in case need to resolve module
(verilog-auto-reeval-locals) (verilog-auto-reeval-locals)

View File

@ -1310,12 +1310,17 @@ definitions."
(xref--prompt-p this-command)) (xref--prompt-p this-command))
(let ((id (let ((id
(completing-read (completing-read
(if def ;; `format-prompt' is new in Emacs 28.1
(format "%s (default %s): " (if (fboundp 'format-prompt)
(substring prompt 0 (string-match (format-prompt (substring prompt 0 (string-match
"[ :]+\\'" prompt)) "[ :]+\\'" prompt))
def) def)
prompt) (if def
(format "%s (default %s): "
(substring prompt 0 (string-match
"[ :]+\\'" prompt))
def)
prompt))
(xref-backend-identifier-completion-table backend) (xref-backend-identifier-completion-table backend)
nil nil nil nil nil nil
'xref--read-identifier-history def))) 'xref--read-identifier-history def)))

View File

@ -3774,7 +3774,9 @@ function is redefined."
(setq name (intern name)) (setq name (intern name))
(let* ((cur-printer (gethash name ses--local-printer-hashmap)) (let* ((cur-printer (gethash name ses--local-printer-hashmap))
(default (and cur-printer (ses--locprn-def cur-printer)))) (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))) default)))
(list name def))) (list name def)))

View File

@ -2840,9 +2840,8 @@ Returns a list of strings."
(if (memq system-type '(windows-nt ms-dos)) (if (memq system-type '(windows-nt ms-dos))
(artist-figlet-get-font-list-windows) (artist-figlet-get-font-list-windows)
(artist-figlet-get-font-list))) (artist-figlet-get-font-list)))
(font (completing-read (concat "Select font (default " (font (completing-read (format-prompt "Select font"
artist-figlet-default-font artist-figlet-default-font)
"): ")
(mapcar (mapcar
(lambda (font) (cons font font)) (lambda (font) (cons font font))
avail-fonts)))) avail-fonts))))

View File

@ -2457,7 +2457,7 @@ Only applies the FSPEC to the args part of FORMAT."
(default (tex-compile-default fspec))) (default (tex-compile-default fspec)))
(list default-directory (list default-directory
(completing-read (completing-read
(format "Command [%s]: " (tex-summarize-command default)) (format-prompt "Command" (tex-summarize-command default))
(mapcar (lambda (x) (mapcar (lambda (x)
(list (tex-format-cmd (eval (car x) t) fspec))) (list (tex-format-cmd (eval (car x) t) fspec)))
tex-compile-commands) tex-compile-commands)

View File

@ -96,15 +96,15 @@ Non-interactively, OLD and NEW may each be a file or a buffer."
(interactive (interactive
(let* ((newf (if (and buffer-file-name (file-exists-p buffer-file-name)) (let* ((newf (if (and buffer-file-name (file-exists-p buffer-file-name))
(read-file-name (read-file-name
(concat "Diff new file (default " (format-prompt "Diff new file"
(file-name-nondirectory buffer-file-name) "): ") (file-name-nondirectory buffer-file-name))
nil buffer-file-name t) nil buffer-file-name t)
(read-file-name "Diff new file: " nil nil t))) (read-file-name "Diff new file: " nil nil t)))
(oldf (file-newest-backup newf))) (oldf (file-newest-backup newf)))
(setq oldf (if (and oldf (file-exists-p oldf)) (setq oldf (if (and oldf (file-exists-p oldf))
(read-file-name (read-file-name
(concat "Diff original file (default " (format-prompt "Diff original file"
(file-name-nondirectory oldf) "): ") (file-name-nondirectory oldf))
(file-name-directory oldf) oldf t) (file-name-directory oldf) oldf t)
(read-file-name "Diff original file: " (read-file-name "Diff original file: "
(file-name-directory newf) nil t))) (file-name-directory newf) nil t)))

View File

@ -503,15 +503,11 @@ are two possible targets for this %spatch. However, these files do not exist."
patch-file-name) patch-file-name)
(setq patch-file-name (setq patch-file-name
(read-file-name (read-file-name
(format "Patch is in file%s: " (format-prompt "Patch is in file"
(cond ((and buffer-file-name (and buffer-file-name
(equal (expand-file-name dir) (equal (expand-file-name dir)
(file-name-directory buffer-file-name))) (file-name-directory buffer-file-name))
(concat (file-name-nondirectory buffer-file-name)))
" (default "
(file-name-nondirectory buffer-file-name)
")"))
(t "")))
dir buffer-file-name 'must-match)) dir buffer-file-name 'must-match))
(if (file-directory-p patch-file-name) (if (file-directory-p patch-file-name)
(error "Patch file cannot be a directory: %s" patch-file-name) (error "Patch file cannot be a directory: %s" patch-file-name)

View File

@ -3103,11 +3103,7 @@ Hit \\[ediff-recenter] to reset the windows afterward."
(lambda () (when defaults (lambda () (when defaults
(setq minibuffer-default defaults))) (setq minibuffer-default defaults)))
(read-file-name (read-file-name
(format "%s%s " (format-prompt prompt (or default-file default-dir))
prompt
(cond (default-file
(concat " (default " default-file "):"))
(t (concat " (default " default-dir "):"))))
default-dir default-dir
(or default-file default-dir) (or default-file default-dir)
t ; must match, no-confirm t ; must match, no-confirm

View File

@ -1284,8 +1284,7 @@ marked instead. A directory can never be marked."
(intern (intern
(upcase (upcase
(completing-read (completing-read
(concat (format-prompt "Mark files in state" default)
"Mark files in state" (if default (concat " [" default "]")) ": ")
(mapcar (lambda (x) (mapcar (lambda (x)
(list (downcase (symbol-name (car x))))) (list (downcase (symbol-name (car x)))))
cvs-states) cvs-states)

View File

@ -1863,13 +1863,10 @@ Return t if the buffer had changes, nil otherwise."
(vc-working-revision first)))) (vc-working-revision first))))
(when (string= rev1-default "") (setq rev1-default nil)))) (when (string= rev1-default "") (setq rev1-default nil))))
;; construct argument list ;; construct argument list
(let* ((rev1-prompt (if rev1-default (let* ((rev1-prompt (format-prompt "Older revision" rev1-default))
(concat "Older revision (default " (rev2-prompt (format-prompt "Newer revision"
rev1-default "): ") ;; (or rev2-default
"Older revision: ")) "current source"))
(rev2-prompt (concat "Newer revision (default "
;; (or rev2-default
"current source): "))
(rev1 (vc-read-revision rev1-prompt files backend rev1-default)) (rev1 (vc-read-revision rev1-prompt files backend rev1-default))
(rev2 (vc-read-revision rev2-prompt files backend nil))) ;; rev2-default (rev2 (vc-read-revision rev2-prompt files backend nil))) ;; rev2-default
(when (string= rev1 "") (setq rev1 nil)) (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)) (with-current-buffer (or (buffer-base-buffer) (current-buffer))
(vc-ensure-vc-buffer) (vc-ensure-vc-buffer)
(list (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))))) (list buffer-file-name)))))
(set-buffer (or (buffer-base-buffer) (current-buffer))) (set-buffer (or (buffer-base-buffer) (current-buffer)))
(vc-ensure-vc-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)))) (read-directory-name "Directory: " default-directory nil t))))
(list (list
dir dir
(vc-read-revision "Tag name to retrieve (default latest revisions): " (vc-read-revision (format-prompt "Tag name to retrieve" "latest revisions")
(list dir) (list dir)
(vc-responsible-backend dir))))) (vc-responsible-backend dir)))))
(let* ((backend (vc-responsible-backend dir)) (let* ((backend (vc-responsible-backend dir))

View File

@ -3325,7 +3325,7 @@ It reads a file name from an editable text field."
;;; (file (file-name-nondirectory value)) ;;; (file (file-name-nondirectory value))
;;; (menu-tag (widget-apply widget :menu-tag-get)) ;;; (menu-tag (widget-apply widget :menu-tag-get))
;;; (must-match (widget-get widget :must-match)) ;;; (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))) ;;; dir nil must-match file)))
;;; (widget-value-set widget (abbreviate-file-name answer)) ;;; (widget-value-set widget (abbreviate-file-name answer))
;;; (widget-setup) ;;; (widget-setup)