Subject: bug#50935: minibuffer-electric-default-mode interface

From: Stefan Kangas <[email-masked]>
Date: Mon, 4 Oct 2021 02:17:38 +0000

Juri Linkov <[email-masked]> writes:

> It seems it's too early to obsolete it.  But maybe still
> 'minibuffer-default-prompt-format' should be mentioned?
> Since it's a user option supporting the same format (but in
> a limited set of prompts) as 'minibuffer-electric-default-mode'.

I guess we have this problem for many defcustoms, unless they are
autoloaded, so for `minibuffer-eldef-shorten-default' we have that:

- "Setting it to a non-nil value" using setq before the library is
  loaded will work.

- "Setting it to a non-nil value" using setq after the library is loaded
  will *not* work, you must use customize.

- You can only set it with customize after the library has been loaded.

I think instead of documenting all that, we could just delete the
reference to `minibuffer-eldef-shorten-default' from the manual, as it
is the same thing as `minibuffer-default-prompt-format', just with a
different interface.  Of course, the latter is not yet perfect, but
anywhere it isn't, that's just a bug, right?  That option would look
like the below diff.

Another option is to just add a reference to
'minibuffer-default-prompt-format' without any deletions, basically
accepting that the text is not perfect and move on.

A third option is to add 'minibuffer-default-prompt-format' on emacs-28,
but make the suggested deletion on master -- which give us more time to
get `minibuffer-default-prompt-format' up to scrap.

Thoughts?

diff --git a/doc/emacs/mini.texi b/doc/emacs/mini.texi
index 6dcee3fa82..2581be30ba 100644
--- a/doc/emacs/mini.texi
+++ b/doc/emacs/mini.texi
@@ -41,11 +41,14 @@ Basic Minibuffer
 canceling the command asking for the argument (@pxref{Quitting}).

 @cindex default argument
+@vindex minibuffer-default-prompt-format
   Sometimes, the prompt shows a @dfn{default argument}, inside
 parentheses before the colon.  This default will be used as the
 argument if you just type @key{RET}.  For example, commands that read
 buffer names usually show a buffer name as the default; you can type
-@key{RET} to operate on that default buffer.
+@key{RET} to operate on that default buffer.  You can customize how
+the default argument is shown with the user option
+@code{minibuffer-default-prompt-format}.

 @cindex Minibuffer Electric Default mode
 @cindex mode, Minibuffer Electric Default
@@ -55,11 +58,7 @@ Basic Minibuffer
 Emacs hides the default argument as soon as you modify the contents of
 the minibuffer (since typing @key{RET} would no longer submit that
 default).  If you ever bring back the original minibuffer text, the
-prompt again shows the default.  Furthermore, if you change the
-variable @code{minibuffer-eldef-shorten-default} to a non-@code{nil}
-value, the default argument is displayed as @samp{[@var{default-arg}]}
-instead of @samp{(default @var{default-arg})}, saving some screen
-space.  To enable this minor mode, type @kbd{M-x
+prompt again shows the default.  To enable this minor mode, type @kbd{M-x
 minibuffer-electric-default-mode}.

   Since the minibuffer appears in the echo area, it can conflict with
diff --git a/lisp/minibuf-eldef.el b/lisp/minibuf-eldef.el
index f67ec353c8..039d0f8828 100644
--- a/lisp/minibuf-eldef.el
+++ b/lisp/minibuf-eldef.el
@@ -56,7 +56,9 @@ minibuffer-default--in-prompt-regexps
      ("\\( \\[.*\\]\\):? *\\'" 1))))

 (defcustom minibuffer-eldef-shorten-default nil
-  "If non-nil, shorten \"(default ...)\" to \"[...]\" in minibuffer prompts."
+  "If non-nil, shorten \"(default ...)\" to \"[...]\" in minibuffer prompts.
+This only takes effect if `minibuffer-electric-default-mode' is
+active."
   :set (lambda (symbol value)
          (set-default symbol value)
 	 (setq-default minibuffer-default-in-prompt-regexps
@@ -183,7 +185,9 @@ minibuffer-electric-default-mode
 the default when it's applicable -- that is, when hitting RET
 would yield the default value.  If the user modifies the input
 such that hitting RET would enter a non-default value, the prompt
-is modified to remove the default indication."
+is modified to remove the default indication.
+
+See also the user option `minibuffer-eldef-shorten-default'."
   :global t
   :group 'minibuffer
   (if minibuffer-electric-default-mode