emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 95268cd 1/3: Use format-prompt in read-string calls (that have de


From: Lars Ingebrigtsen
Subject: master 95268cd 1/3: Use format-prompt in read-string calls (that have default values)
Date: Sun, 6 Sep 2020 17:21:33 -0400 (EDT)

branch: master
commit 95268cdb7e63c2ef881d74039284bbb88e132d84
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    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.
---
 lisp/calendar/todo-mode.el         |  9 +++++----
 lisp/cedet/semantic/symref/list.el | 10 ++++++----
 lisp/emulation/cua-rect.el         |  4 ++--
 lisp/frame.el                      |  5 +++--
 lisp/mpc.el                        |  4 +++-
 lisp/server.el                     |  3 ++-
 lisp/textmodes/rst.el              | 16 +++++++++-------
 lisp/vc/log-edit.el                |  8 ++++++--
 lisp/vc/vc-annotate.el             |  2 +-
 9 files changed, 37 insertions(+), 24 deletions(-)

diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el
index 02a7316..0da87a7 100644
--- a/lisp/calendar/todo-mode.el
+++ b/lisp/calendar/todo-mode.el
@@ -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)))
diff --git a/lisp/cedet/semantic/symref/list.el 
b/lisp/cedet/semantic/symref/list.el
index 23f5f89..fc7f9db 100644
--- a/lisp/cedet/semantic/symref/list.el
+++ b/lisp/cedet/semantic/symref/list.el
@@ -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)
diff --git a/lisp/emulation/cua-rect.el b/lisp/emulation/cua-rect.el
index 663995a..d2c6dd0 100644
--- a/lisp/emulation/cua-rect.el
+++ b/lisp/emulation/cua-rect.el
@@ -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)
diff --git a/lisp/frame.el b/lisp/frame.el
index 05da1ea..7751ae1 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -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))))
 
diff --git a/lisp/mpc.el b/lisp/mpc.el
index 47fe4de..d22b7ab 100644
--- a/lisp/mpc.el
+++ b/lisp/mpc.el
@@ -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)))
diff --git a/lisp/server.el b/lisp/server.el
index 9934e1c..436a6ca 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -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
diff --git a/lisp/textmodes/rst.el b/lisp/textmodes/rst.el
index db17a90..f2fcd62 100644
--- a/lisp/textmodes/rst.el
+++ b/lisp/textmodes/rst.el
@@ -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)))
diff --git a/lisp/vc/log-edit.el b/lisp/vc/log-edit.el
index cd19b4e..1c69bdf 100644
--- a/lisp/vc/log-edit.el
+++ b/lisp/vc/log-edit.el
@@ -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)
diff --git a/lisp/vc/vc-annotate.el b/lisp/vc/vc-annotate.el
index 18bcc6c..5198bcc 100644
--- a/lisp/vc/vc-annotate.el
+++ b/lisp/vc/vc-annotate.el
@@ -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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]