bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsi


From: Lars Ingebrigtsen
Subject: bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy)
Date: Tue, 25 Aug 2020 17:19:38 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Stefan Kangas <stefankangas@gmail.com> writes:

> How about taking it even further?   Something along the lines of:
>
>     (format-prompt PROMPT &optional DEFAULT)
>
>     (format-prompt "Set bookmark" default)
>     => "Set bookmark [foobar]: "
>
>     (format-prompt "Goto char")
>     => "Goto char: "
>
> (This would avoid having to always remember to use double formats like
> above.)

I like it.  I just grepped for '(default %' just to see how this would
look in practice.  Most of them look good:

diff --git a/lisp/dired-x.el b/lisp/dired-x.el
index 873d586ca1..5335855d6e 100644
--- a/lisp/dired-x.el
+++ b/lisp/dired-x.el
@@ -339,8 +339,7 @@ dired--mark-suffix-interactive-spec
             ('(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/frame.el b/lisp/frame.el
index 081d3010e9..d9e49d50ba 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -760,7 +760,7 @@ close-display-connection
    (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))

However, there's things like:

         (setq from-coding (read-coding-system
                            (format "Recode filename %s from (default %s): "
                                    filename default-coding)
                            default-coding))

These are surprisingly rare, but, uhm...  perhaps format-prompt could
take a format string?  The function would then look like:

(defun format-prompt (prompt default &rest format-args)
  )

where it would call `format' on PROMPT and FORMAT-ARGS.

So that would then be:

         (setq from-coding (read-coding-system
                            (format-prompt "Recode filename %s"
                                            default-coding filename)
                            default-coding))


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





reply via email to

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