Use format-prompt in read-string calls (that have default values)

* lisp/vc/vc-annotate.el (vc-annotate):
* lisp/vc/log-edit.el (log-edit-comment-search-backward)
(log-edit-comment-search-forward):
* lisp/textmodes/rst.el (rst-insert-list-new-item):
* lisp/server.el (server-force-delete):
* lisp/mpc.el (mpc):
* lisp/frame.el (set-frame-name):
* lisp/emulation/cua-rect.el (cua-sequence-rectangle):
* lisp/cedet/semantic/symref/list.el (semantic-symref-regexp):
* lisp/calendar/todo-mode.el (todo-read-time): Use `format-prompt'
in `read-string' calls that have defaults.
This commit is contained in:
Lars Ingebrigtsen 2020-09-06 22:59:48 +02:00
parent 52a92c6e7b
commit 95268cdb7e
9 changed files with 37 additions and 24 deletions

View file

@ -6110,11 +6110,12 @@ Valid time strings are those matching `diary-time-regexp'.
Typing `<return>' at the prompt returns the current time, if the
user option `todo-always-add-time-string' is non-nil, otherwise
the empty string (i.e., no time string)."
(let (valid answer)
(let ((default (when todo-always-add-time-string
(format-time-string "%H:%M")))
valid answer)
(while (not valid)
(setq answer (read-string "Enter a clock time: " nil nil
(when todo-always-add-time-string
(format-time-string "%H:%M"))))
(setq answer (read-string (format-prompt "Enter a clock time" default)
nil nil default))
(when (or (string= "" answer)
(string-match diary-time-regexp answer))
(setq valid t)))

View file

@ -85,10 +85,12 @@ current project to find references to the input SYM. The
references are the organized by file and the name of the function
they are used in.
Display the references in `semantic-symref-results-mode'."
(interactive (list (let ((tag (semantic-current-tag)))
(read-string " Symrefs for: " nil nil
(when tag
(regexp-quote (semantic-tag-name tag)))))))
(interactive (list (let* ((tag (semantic-current-tag))
(default (when tag
(regexp-quote
(semantic-tag-name tag)))))
(read-string (format-prompt " Symrefs for" default)
nil nil default))))
;; FIXME: Shouldn't the input be in Emacs regexp format, for
;; consistency? Converting it to extended is not hard.
(semantic-fetch-tags)

View file

@ -1150,9 +1150,9 @@ The numbers are formatted according to the FORMAT string."
(list (if current-prefix-arg
(prefix-numeric-value current-prefix-arg)
(string-to-number
(read-string "Start value: (0) " nil nil "0")))
(read-string (format-prompt "Start value" 0) nil nil "0")))
(string-to-number
(read-string "Increment: (1) " nil nil "1"))
(read-string (format-prompt "Increment" 1) nil nil "1"))
(read-string (concat "Format: (" cua--rectangle-seq-format ") "))))
(if (= (length format) 0)
(setq format cua--rectangle-seq-format)

View file

@ -1581,8 +1581,9 @@ When called interactively, prompt for the name of the frame.
On text terminals, the frame name is displayed on the mode line.
On graphical displays, it is displayed on the frame's title bar."
(interactive
(list (read-string "Frame name: " nil nil
(cdr (assq 'name (frame-parameters))))))
(let ((default (cdr (assq 'name (frame-parameters)))))
(list (read-string (format-prompt "Frame name" default) nil nil
default))))
(modify-frame-parameters (selected-frame)
(list (cons 'name name))))

View file

@ -2750,7 +2750,9 @@ If stopped, start playback."
(if current-prefix-arg
;; FIXME: We should provide some completion here, especially for the
;; case where the user specifies a local socket/file name.
(setq mpc-host (read-string "MPD host and port: " nil nil mpc-host)))
(setq mpc-host (read-string
(format-prompt "MPD host and port" mpc-host)
nil nil mpc-host)))
nil))
(let* ((song-buf (mpc-songs-buf))
(song-win (get-buffer-window song-buf 0)))

View file

@ -728,7 +728,8 @@ If server is running, it is first stopped.
NAME defaults to `server-name'. With argument, ask for NAME."
(interactive
(list (if current-prefix-arg
(read-string "Server name: " nil nil server-name))))
(read-string (format-prompt "Server name" server-name)
nil nil server-name))))
(when server-mode (with-temp-message nil (server-mode -1)))
(let ((file (expand-file-name (or name server-name)
(if server-use-tcp

View file

@ -2371,21 +2371,23 @@ also arranged by `rst-insert-list-new-tag'."
(save-match-data
(cond
((equal cnt "a")
(let ((itemno (read-string "Give starting value [a]: "
nil nil "a")))
(let ((itemno (read-string
(format-prompt "Give starting value" "a")
nil nil "a")))
(downcase (substring itemno 0 1))))
((equal cnt "A")
(let ((itemno (read-string "Give starting value [A]: "
nil nil "A")))
(let ((itemno (read-string
(format-prompt "Give starting value" "A")
nil nil "A")))
(upcase (substring itemno 0 1))))
((equal cnt "I")
(let ((itemno (read-number "Give starting value [1]: " 1)))
(let ((itemno (read-number "Give starting value: " 1)))
(rst-arabic-to-roman itemno)))
((equal cnt "i")
(let ((itemno (read-number "Give starting value [1]: " 1)))
(let ((itemno (read-number "Give starting value: " 1)))
(downcase (rst-arabic-to-roman itemno))))
((equal cnt "1")
(let ((itemno (read-number "Give starting value [1]: " 1)))
(let ((itemno (read-number "Give starting value: " 1)))
(number-to-string itemno)))))))
(if no
(setq itemstyle (replace-match no t t itemstyle)))

View file

@ -244,7 +244,9 @@ If the optional argument STRIDE is present, that is a step-width to use
when going through the comment ring."
;; Why substring rather than regexp ? -sm
(interactive
(list (read-string "Comment substring: " nil nil log-edit-last-comment-match)))
(list (read-string (format-prompt "Comment substring"
log-edit-last-comment-match)
nil nil log-edit-last-comment-match)))
(unless stride (setq stride 1))
(if (string= str "")
(setq str log-edit-last-comment-match)
@ -261,7 +263,9 @@ when going through the comment ring."
(defun log-edit-comment-search-forward (str)
"Search forwards through comment history for a substring match of STR."
(interactive
(list (read-string "Comment substring: " nil nil log-edit-last-comment-match)))
(list (read-string (format-prompt "Comment substring"
log-edit-last-comment-match)
nil nil log-edit-last-comment-match)))
(log-edit-comment-search-backward str -1))
(defun log-edit-comment-to-change-log (&optional whoami file-name)

View file

@ -408,7 +408,7 @@ should be applied to the background or to the foreground."
(if (null current-prefix-arg)
vc-annotate-display-mode
(float (string-to-number
(read-string "Annotate span days (default 20): "
(read-string (format-prompt "Annotate span days" 20)
nil nil "20")))))))
(vc-ensure-vc-buffer)
(setq vc-annotate-display-mode display-mode) ;Not sure why. --Stef