unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: Stefan Kangas <stefankangas@gmail.com>
Cc: Dani Moncayo <dmoncayo@gmail.com>,
	Stefan Monnier <monnier@iro.umontreal.ca>,
	12443@debbugs.gnu.org
Subject: bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy)
Date: Tue, 25 Aug 2020 17:19:38 +0200	[thread overview]
Message-ID: <87imd669dh.fsf@gnus.org> (raw)
In-Reply-To: <CADwFkm=GDYPWYoFT57fBsd+OHbyw0sufc70r8p3zQDTpAy1RLQ@mail.gmail.com> (Stefan Kangas's message of "Tue, 25 Aug 2020 05:55:44 -0700")

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





  parent reply	other threads:[~2020-08-25 15:19 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-14 13:53 bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy) Dani Moncayo
2012-09-14 15:56 ` Stefan Monnier
2012-09-14 16:39   ` Drew Adams
2012-09-14 19:17     ` Dani Moncayo
2012-09-14 19:10   ` Dani Moncayo
2012-09-14 19:41     ` Stefan Monnier
2012-09-14 20:42       ` Dani Moncayo
2012-09-14 20:50         ` Jambunathan K
2012-09-14 20:55           ` Drew Adams
2012-09-14 22:47         ` Juri Linkov
2020-08-25 12:30           ` Lars Ingebrigtsen
2020-08-25 12:55             ` Stefan Kangas
2020-08-25 13:45               ` Stefan Monnier
2020-08-25 15:19               ` Lars Ingebrigtsen [this message]
2020-08-25 15:34                 ` Drew Adams
2020-08-25 16:19                 ` Stefan Kangas
2020-08-25 18:23                 ` Juri Linkov
2020-08-25 19:12                   ` Lars Ingebrigtsen
2020-08-25 20:00                   ` Stefan Monnier
2020-08-26 12:10                     ` Lars Ingebrigtsen
2020-08-27 18:48                       ` Juri Linkov
2020-08-28 14:11                         ` Lars Ingebrigtsen
2020-08-28 15:21                           ` Stefan Monnier
2020-08-30 13:16                             ` Lars Ingebrigtsen
2020-09-06 15:02                             ` Lars Ingebrigtsen
2020-09-06 17:46                               ` Lars Ingebrigtsen
2020-09-06 18:10                                 ` Lars Ingebrigtsen
2020-09-06 18:49                                 ` Drew Adams
2020-09-06 20:18                                   ` Michael Heerdegen
2020-09-06 20:38                                     ` Lars Ingebrigtsen
2020-09-06 20:42                                       ` Lars Ingebrigtsen
2020-09-06 21:55                                         ` Michael Heerdegen
2020-09-06 21:57                                           ` Lars Ingebrigtsen
2020-09-06 21:50                                       ` Michael Heerdegen
2020-09-06 21:56                                         ` Lars Ingebrigtsen
2020-09-07 18:46                                 ` Juri Linkov
2020-09-07 19:27                                   ` Lars Ingebrigtsen
2020-09-08 18:32                                     ` Juri Linkov
2020-09-08 20:37                                       ` Lars Ingebrigtsen
2020-09-09 18:50                                         ` Juri Linkov
2020-09-10 13:14                                           ` Lars Ingebrigtsen
2020-09-11  9:11                                             ` Andrii Kolomoiets
2020-09-11 12:53                                               ` Lars Ingebrigtsen
2020-09-14  8:40                                                 ` Andrii Kolomoiets
2020-09-14 11:15                                                   ` Lars Ingebrigtsen
2020-10-13  2:31                                                     ` Lars Ingebrigtsen
2020-09-12 19:04                                             ` Juri Linkov
2020-09-13  8:53                                               ` Juri Linkov
2020-09-13 14:30                                                 ` Eli Zaretskii
2020-09-13 13:00                                               ` Lars Ingebrigtsen
2020-09-07 20:11                                   ` Lars Ingebrigtsen
2021-01-17 19:05                               ` bug#12443: 24.2.50; Default values in the minibuffer prompt (fix Basil L. Contovounesios
2021-01-18 16:40                                 ` Lars Ingebrigtsen
2021-01-18 18:06                                   ` Basil L. Contovounesios
2020-08-28 14:13                         ` bug#12443: 24.2.50; Default values in the minibuffer prompt (fix inconsisntecy) Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87imd669dh.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=12443@debbugs.gnu.org \
    --cc=dmoncayo@gmail.com \
    --cc=monnier@iro.umontreal.ca \
    --cc=stefankangas@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).