emacs-diffs
[Top][All Lists]
Advanced

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

master 816975f 1/2: Use format-prompt in some read-string calls


From: Lars Ingebrigtsen
Subject: master 816975f 1/2: Use format-prompt in some read-string calls
Date: Sun, 6 Sep 2020 18:17:27 -0400 (EDT)

branch: master
commit 816975f4bbf906c838753e7e43f74b5a190376b6
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Use format-prompt in some read-string calls
    
    * lisp/progmodes/prolog.el (prolog-help-on-predicate):
    * lisp/cmuscheme.el (scheme-trace-procedure):
    * lisp/calendar/todo-mode.el (todo-convert-legacy-files): Use
    format-prompt in some read-string calls (that have default values).
    
    * lisp/printing.el (pr-interactive-regexp): No need to use "" as
    the default value, because that's the default default value.
    (pr-interactive-n-up): Use read-number instead of read-string and
    then parsing the string.
---
 lisp/calendar/todo-mode.el |  5 ++---
 lisp/cmuscheme.el          |  5 ++---
 lisp/printing.el           | 30 +++++++++++++-----------------
 lisp/progmodes/prolog.el   |  8 ++------
 4 files changed, 19 insertions(+), 29 deletions(-)

diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el
index 0da87a7..3975a9b 100644
--- a/lisp/calendar/todo-mode.el
+++ b/lisp/calendar/todo-mode.el
@@ -4726,9 +4726,8 @@ name in `todo-directory'.  See also the documentation 
string of
              (todo-convert-legacy-date-time)))
            (forward-line))
          (setq file (concat todo-directory
-                            (read-string
-                             (format "Save file as (default \"%s\"): " default)
-                             nil nil default)
+                            (read-string (format-prompt "Save file as" default)
+                                         nil nil default)
                             ".todo"))
          (unless (file-exists-p todo-directory)
            (make-directory todo-directory))
diff --git a/lisp/cmuscheme.el b/lisp/cmuscheme.el
index d4bec95..7191b93 100644
--- a/lisp/cmuscheme.el
+++ b/lisp/cmuscheme.el
@@ -327,9 +327,8 @@ With a prefix argument switch off tracing of procedure 
PROC."
   (interactive
    (list (let ((current (symbol-at-point))
                (action (if current-prefix-arg "Untrace" "Trace")))
-           (if current
-               (read-string (format "%s procedure [%s]: " action current) nil 
nil (symbol-name current))
-             (read-string (format "%s procedure: " action))))
+           (read-string (format-prompt "%s procedure" current action)
+                        nil nil (and current (symbol-name current))))
          current-prefix-arg))
   (when (= (length proc) 0)
     (error "Invalid procedure name"))
diff --git a/lisp/printing.el b/lisp/printing.el
index b8879be..86a2434 100644
--- a/lisp/printing.el
+++ b/lisp/printing.el
@@ -5284,22 +5284,18 @@ If menu binding was not done, calls `pr-menu-bind'."
 
 
 (defun pr-interactive-n-up (mess)
-  (or (stringp mess) (setq mess "*"))
-  (save-match-data
-    (let* ((fmt-prompt "%s[%s] N-up printing (default 1): ")
-          (prompt "")
-          (str (read-string (format fmt-prompt prompt mess) nil nil "1"))
-          int)
-      (while (if (string-match "^\\s *[0-9]+$" str)
-                (setq int (string-to-number str)
-                      prompt (cond ((< int 1)   "Integer below 1; ")
-                                   ((> int 100) "Integer above 100; ")
-                                   (t           nil)))
-              (setq prompt "Invalid integer syntax; "))
-       (ding)
-       (setq str
-             (read-string (format fmt-prompt prompt mess) str nil "1")))
-      int)))
+  (unless (stringp mess)
+    (setq mess "*"))
+  (let (int)
+    (while (or (< (setq int (read-number (format "[%s] N-up printing:" mess) 
1))
+                  0)
+               (> int 100))
+      (if (< int 0)
+         (message "Integer below 1")
+       (message "Integer above 100"))
+      (sit-for 1)
+      (ding))
+    int))
 
 
 (defun pr-interactive-dir (mess)
@@ -5323,7 +5319,7 @@ If menu binding was not done, calls `pr-menu-bind'."
 
 
 (defun pr-interactive-regexp (mess)
-  (read-string (format "[%s] File regexp to print: " mess) nil nil ""))
+  (read-string (format "[%s] File regexp to print: " mess)))
 
 
 (defun pr-interactive-dir-args (mess)
diff --git a/lisp/progmodes/prolog.el b/lisp/progmodes/prolog.el
index a209d21..fa281dd 100644
--- a/lisp/progmodes/prolog.el
+++ b/lisp/progmodes/prolog.el
@@ -2369,12 +2369,8 @@ In effect it sets the `fill-prefix' when inside comments 
and then calls
    ;; in prolog-help-function-i
    (t
     (let* ((word (prolog-atom-under-point))
-           (predicate (read-string
-                       (format "Help on predicate%s: "
-                               (if word
-                                   (concat " (default " word ")")
-                                 ""))
-                       nil nil word))
+           (predicate (read-string (format-prompt "Help on predicate" word)
+                                   nil nil word))
            ;;point
            )
       (if prolog-help-function-i



reply via email to

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