unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* completing-read depricated initial-input
@ 2022-06-21  7:56 carlmarcos--- via Users list for the GNU Emacs text editor
       [not found] ` <N54Fw5q--3-2@tutanota.com-N54INof----2>
                   ` (2 more replies)
  0 siblings, 3 replies; 73+ messages in thread
From: carlmarcos--- via Users list for the GNU Emacs text editor @ 2022-06-21  7:56 UTC (permalink / raw)
  To: Help Gnu Emacs


Have been reading the docstring of `completing-read`.

(completing-read PROMPT COLLECTION &optional PREDICATE REQUIRE-MATCH
INITIAL-INPUT HIST DEF INHERIT-INPUT-METHOD)

INITIAL-INPUT states that this feature is deprecated - it is best to pass nil
for INITIAL-INPUT and supply the default value DEF instead.  

When do you plan to remove the `INITIAL-INPUT` argument from `completing-read`?


^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
       [not found] ` <N54Fw5q--3-2@tutanota.com-N54INof----2>
@ 2022-06-21  9:51   ` carlmarcos--- via Users list for the GNU Emacs text editor
  2022-06-21 11:19     ` Michael Heerdegen
  2022-06-22  8:50     ` Jean Louis
  0 siblings, 2 replies; 73+ messages in thread
From: carlmarcos--- via Users list for the GNU Emacs text editor @ 2022-06-21  9:51 UTC (permalink / raw)
  To: carlmarcos; +Cc: Help Gnu Emacs


Jun 21, 2022, 07:56 by help-gnu-emacs@gnu.org:

>
> Have been reading the docstring of `completing-read`.
>
> (completing-read PROMPT COLLECTION &optional PREDICATE REQUIRE-MATCH
> INITIAL-INPUT HIST DEF INHERIT-INPUT-METHOD)
>
> INITIAL-INPUT states that this feature is deprecated - it is best to pass nil
> for INITIAL-INPUT and supply the default value DEF instead.  
>
> When do you plan to remove the `INITIAL-INPUT` argument from `completing-read`?
>
I differ with the plan to depricate `INITIAL-INPUT`.  This is because it is useful to immediately
show a value when using `completing-read`.  New users do not usually know many keybinding sequences such as `M-n` to show `DEF`.  Besides the utility of having an initial value that is different from a default.

Particularly when using `t` for `REQUIRE-MATCH`, it is useful to already have an initial value.  An alternative is to allow the first entry in the sequence to show up, but then continue with the second element in the list when the user wants to traverse through the remaining options.

For cases where `REQUIRE-MATCH` is `nil`, it is reasonable not to put anything in the user entry of `complete-read`.
 


^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-21  7:56 carlmarcos--- via Users list for the GNU Emacs text editor
       [not found] ` <N54Fw5q--3-2@tutanota.com-N54INof----2>
@ 2022-06-21 10:26 ` Robert Pluim
  2022-06-21 11:15   ` carlmarcos--- via Users list for the GNU Emacs text editor
  2022-06-21 12:39 ` Christopher Dimech
  2 siblings, 1 reply; 73+ messages in thread
From: Robert Pluim @ 2022-06-21 10:26 UTC (permalink / raw)
  To: help-gnu-emacs; +Cc: carlmarcos

>>>>> On Tue, 21 Jun 2022 09:56:59 +0200 (CEST), carlmarcos--- via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> said:

    >> Have been reading the docstring of `completing-read`.

    >> (completing-read PROMPT COLLECTION &optional PREDICATE REQUIRE-MATCH
    >> INITIAL-INPUT HIST DEF INHERIT-INPUT-METHOD)

    >> INITIAL-INPUT states that this feature is deprecated - it is best to pass nil
    >> for INITIAL-INPUT and supply the default value DEF instead.  

    >> When do you plan to remove the `INITIAL-INPUT` argument from `completing-read`?

No such plan exists. At best Emacs could start ignoring that arg, but
we canʼt just change the signature of such a public function.

Robert
-- 



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-21 10:26 ` Robert Pluim
@ 2022-06-21 11:15   ` carlmarcos--- via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 73+ messages in thread
From: carlmarcos--- via Users list for the GNU Emacs text editor @ 2022-06-21 11:15 UTC (permalink / raw)
  To: Robert Pluim; +Cc: help-gnu-emacs



-- 
 Sent with Tutanota, enjoy secure & ad-free emails. 



Jun 21, 2022, 10:26 by rpluim@gmail.com:

>>>>>> On Tue, 21 Jun 2022 09:56:59 +0200 (CEST), carlmarcos--- via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> said:
>>>>>>
>
> >> Have been reading the docstring of `completing-read`.
>
>  >> (completing-read PROMPT COLLECTION &optional PREDICATE REQUIRE-MATCH
>  >> INITIAL-INPUT HIST DEF INHERIT-INPUT-METHOD)
>
>  >> INITIAL-INPUT states that this feature is deprecated - it is best to pass nil
>  >> for INITIAL-INPUT and supply the default value DEF instead.  
>
>  >> When do you plan to remove the `INITIAL-INPUT` argument from `completing-read`?
>
> No such plan exists. At best Emacs could start ignoring that arg, but
> we canʼt just change the signature of such a public function.
>
> Robert
>
Have put some explanation on the value of keeping the functionality of `INITIAL-INPUT`, rather than
stopping it having any effect.  I can see the value of using an initial value for certain situations, rather than  always having the field empty, particularly when one has `REQUIRE-MATCH` being `t`.




^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-21  9:51   ` carlmarcos--- via Users list for the GNU Emacs text editor
@ 2022-06-21 11:19     ` Michael Heerdegen
  2022-06-21 12:39       ` Emanuel Berg
  2022-06-22  8:50     ` Jean Louis
  1 sibling, 1 reply; 73+ messages in thread
From: Michael Heerdegen @ 2022-06-21 11:19 UTC (permalink / raw)
  To: help-gnu-emacs

carlmarcos--- via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:

> I differ with the plan to depricate `INITIAL-INPUT`.

I often miss it, too.  I don't recall why it had been deprecated.  But
you still can get the same thing using `minibuffer-setup-hook', e.g.

#+begin_src emacs-lisp
(minibuffer-with-setup-hook (lambda () (insert "b"))
  (completing-read "Input: " (list "a" "b")))
#+end_src

Michael.




^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-21 11:19     ` Michael Heerdegen
@ 2022-06-21 12:39       ` Emanuel Berg
  2022-06-21 12:46         ` Michael Heerdegen
  0 siblings, 1 reply; 73+ messages in thread
From: Emanuel Berg @ 2022-06-21 12:39 UTC (permalink / raw)
  To: help-gnu-emacs

Michael Heerdegen wrote:

>> I differ with the plan to depricate `INITIAL-INPUT`.
>
> I often miss it, too. I don't recall why it had been
> deprecated.

This isn't explained somewhere?

I mean just a one-liner would probably do most cases ...

"Funked up formal parameter."

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-21  7:56 carlmarcos--- via Users list for the GNU Emacs text editor
       [not found] ` <N54Fw5q--3-2@tutanota.com-N54INof----2>
  2022-06-21 10:26 ` Robert Pluim
@ 2022-06-21 12:39 ` Christopher Dimech
  2022-06-21 14:09   ` [External] : " Drew Adams
  2 siblings, 1 reply; 73+ messages in thread
From: Christopher Dimech @ 2022-06-21 12:39 UTC (permalink / raw)
  To: eliz, monnier; +Cc: Help Gnu Emacs, carlmarcos, michael_heerdegen


Jun 21, 2022, 11:19 by michael_heerdegen@web.de:

    carlmarcos--- via Users list for the GNU Emacs text editor
    <help-gnu-emacs@gnu.org> writes:

        I differ with the plan to depricate `INITIAL-INPUT`.


    I often miss it, too. I don't recall why it had been deprecated. But
    you still can get the same thing using `minibuffer-setup-hook', e.g.

    #+begin_src emacs-lisp
    (minibuffer-with-setup-hook (lambda () (insert "b"))
    (completing-read "Input: " (list "a" "b")))
    #+end_src

    Michael.


Eli and Stefan, those working with `completing-read` can see the value of
having the functionality of INITIAL-INPUT in completing-read.  Could you
contemplate not deprecating the functionality INITIAL-INPUT.  Because the
argument does have usefulness, which will be possible to do if deprecated.





^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-21 12:39       ` Emanuel Berg
@ 2022-06-21 12:46         ` Michael Heerdegen
  0 siblings, 0 replies; 73+ messages in thread
From: Michael Heerdegen @ 2022-06-21 12:46 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg <incal@dataswamp.org> writes:

> > I often miss it, too. I don't recall why it had been
> > deprecated.
>
> This isn't explained somewhere?

In my Emacs it is - in the docstring of the function.

Michael.




^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
@ 2022-06-21 14:56 Anders Munch
  2022-06-22  8:45 ` Jean Louis
  0 siblings, 1 reply; 73+ messages in thread
From: Anders Munch @ 2022-06-21 14:56 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

carlmarcos wrote:
> New users do not usually know many keybinding sequences such as `M-n` to show `DEF`.

I'm not sure why an old user would know M-n either.   It's not very discoverable.

regards, Anders

^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-21 14:09   ` [External] : " Drew Adams
@ 2022-06-21 18:21     ` Arash Esbati
  2022-06-21 19:04       ` Emanuel Berg
  2022-06-21 20:41       ` [External] : " Drew Adams
  0 siblings, 2 replies; 73+ messages in thread
From: Arash Esbati @ 2022-06-21 18:21 UTC (permalink / raw)
  To: Drew Adams
  Cc: Christopher Dimech, eliz@gnu.org, monnier@iro.umontreal.ca,
	Help Gnu Emacs, carlmarcos@tutanota.com, michael_heerdegen@web.de

Drew Adams <drew.adams@oracle.com> writes:

> 3. The "argument" for deprecating it amounted to only
>    a statement that stylistically some preferred that
>    only the DEF (default value) argument be used.

I thought the argument was "INITIAL-INPUT in too intrusive in the
minibuffer, most notably, when it's not what the user wants, and then
the hassle with C-a C-k and such begins".  And if I compare:

(let ((default "FOO"))
  (completing-read (format "Prompt (default %s): " default)
                   '("FOO" "BAR" "BAZ")
                   nil nil nil nil default))

where I hit ENTER or TAB makes more sense to me than this:

(let ((default "FOO"))
  (completing-read "Prompt: "
                   '("FOO" "BAR" "BAZ")
                   nil nil default))

where I hit ENTER or have to delete the entry before I can proceed with
TAB.

As a personal note, the INITIAL-INPUT was something in AUCTeX which
bugged for me for a long time, especially in queries for length
arguments.  I can't say how often I've deleted "1.0\linewidth" in my
life.

Best, Arash



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-21 18:21     ` Arash Esbati
@ 2022-06-21 19:04       ` Emanuel Berg
  2022-06-21 20:41       ` [External] : " Drew Adams
  1 sibling, 0 replies; 73+ messages in thread
From: Emanuel Berg @ 2022-06-21 19:04 UTC (permalink / raw)
  To: help-gnu-emacs

Arash Esbati wrote:

> (let ((default "FOO"))
>   (completing-read (format "Prompt (default %s): " default)
>                    '("FOO" "BAR" "BAZ")
>                    nil nil nil nil default))

Not pretty!

Not saying it should be changed for that reason but for future
(other) Elisp maybe `cl--parsing-keywords', an alist or just
something ... else ... comes to mind!

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-21 20:41       ` [External] : " Drew Adams
@ 2022-06-21 21:28         ` Arash Esbati
  2022-06-21 22:07           ` [External] : " Drew Adams
  2022-06-22  3:09           ` Po Lu
  0 siblings, 2 replies; 73+ messages in thread
From: Arash Esbati @ 2022-06-21 21:28 UTC (permalink / raw)
  To: Drew Adams
  Cc: Christopher Dimech, eliz@gnu.org, monnier@iro.umontreal.ca,
	Help Gnu Emacs, carlmarcos@tutanota.com, michael_heerdegen@web.de

Drew Adams <drew.adams@oracle.com> writes:

>> > 3. The "argument" for deprecating it amounted to only
>> >    a statement that stylistically some preferred that
>> >    only the DEF (default value) argument be used.
>       ^^^^
>>
>> I thought the argument was "INITIAL-INPUT in too
>> intrusive in the minibuffer, most notably, when
>> it's not what the user wants, and then the hassle
>> with C-a C-k and such begins".
>
> That's an argument about UI interaction style.  And
> the "only" is the real key to what's misguided.

I agree that there are cases where INITIAL-INPUT still has its place,
but as I said, I remember the reason for phasing it out was different
than stylistic preferences.

> `completing-read' is extremely general, allowing for many different
> interactions for many different kinds of use cases.

True, unfortunately.

> BTW, independently of this discussion (and even
> independently of completion), there should be a
> single key to empty the minibuffer.  (Icicles
> has provided `M-k' for that forever.)  

I presume you've suggested this addition to Emacs?

>> As a personal note, the INITIAL-INPUT was something in AUCTeX which
>> bugged for me for a long time, especially in queries for length
>> arguments.  I can't say how often I've deleted "1.0\linewidth" in my
>> life.
>
> That you don't want INITIAL-INPUT is one thing.
> That some library might not make a good decision
> about its use is another thing.
>
> Whether INITIAL-INPUT should be deprecated is
> a third thing - something completely different.

Not sure about this one.  I mean, Emacs has a lot of external (i.e., not
maintained in core) libraries and it would be a major advantage if they
all feel the same when you use them.  Hence, I understand the general
direction of "deprecating a feature" to streamline the look&feel, but
you're still free to use the old feature if you think it has a added
value from a user perspective.  In my example above, it wasn't a good
decision, so I changed it.

Best, Arash



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-21 21:28         ` Arash Esbati
  2022-06-21 22:07           ` [External] : " Drew Adams
@ 2022-06-22  3:09           ` Po Lu
  2022-06-22  3:46             ` Emanuel Berg
                               ` (2 more replies)
  1 sibling, 3 replies; 73+ messages in thread
From: Po Lu @ 2022-06-22  3:09 UTC (permalink / raw)
  To: Arash Esbati
  Cc: Drew Adams, Christopher Dimech, eliz@gnu.org,
	monnier@iro.umontreal.ca, Help Gnu Emacs, carlmarcos@tutanota.com,
	michael_heerdegen@web.de

Arash Esbati <arash@gnu.org> writes:

> I agree that there are cases where INITIAL-INPUT still has its place,
> but as I said, I remember the reason for phasing it out was different
> than stylistic preferences.

What other reason can there be?  I can't think of any non-stylistic
reason to discourage using that argument.

If you think it is counterproductive to insert some initial value into
the minibuffer itself, then by all means recommend against using it.

But don't obsolete the means of doing so.  You do not have a place in
dictating how users write their Lisp programs.



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-22  3:09           ` Po Lu
@ 2022-06-22  3:46             ` Emanuel Berg
  2022-06-22  4:56             ` Christopher Dimech
  2022-06-23  8:20             ` Arash Esbati
  2 siblings, 0 replies; 73+ messages in thread
From: Emanuel Berg @ 2022-06-22  3:46 UTC (permalink / raw)
  To: help-gnu-emacs

Po Lu wrote:

>> I agree that there are cases where INITIAL-INPUT still has
>> its place, but as I said, I remember the reason for phasing
>> it out was different than stylistic preferences.
>
> What other reason can there be? I can't think of any
> non-stylistic reason to discourage using that argument.

Maybe stop thinking about it and instead let your subconscious
figure it out for you?

Anyway this is what I think is the best interface:

(let ((name "Danger"))
  (read-string (format "name: [%s] " name) nil nil name) )

You then see:

name: [Danger] _

So if you hit RET you get the default (the suggestion), i.e.
"Danger", if you print you print and if you want to edit
"Danger" hit M-n and it's inserted only pint isn't moved.

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-22  3:09           ` Po Lu
  2022-06-22  3:46             ` Emanuel Berg
@ 2022-06-22  4:56             ` Christopher Dimech
  2022-06-23  8:20             ` Arash Esbati
  2 siblings, 0 replies; 73+ messages in thread
From: Christopher Dimech @ 2022-06-22  4:56 UTC (permalink / raw)
  To: Po Lu
  Cc: Arash Esbati, Drew Adams, eliz@gnu.org, monnier@iro.umontreal.ca,
	Help Gnu Emacs, carlmarcos@tutanota.com, michael_heerdegen@web.de


> Sent: Wednesday, June 22, 2022 at 3:09 PM
> From: "Po Lu" <luangruo@yahoo.com>
> To: "Arash Esbati" <arash@gnu.org>
> Cc: "Drew Adams" <drew.adams@oracle.com>, "Christopher Dimech" <dimech@gmx.com>, "eliz@gnu.org" <eliz@gnu.org>, "monnier@iro.umontreal.ca" <monnier@iro.umontreal.ca>, "Help Gnu Emacs" <help-gnu-emacs@gnu.org>, "carlmarcos@tutanota.com" <carlmarcos@tutanota.com>, "michael_heerdegen@web.de" <michael_heerdegen@web.de>
> Subject: Re: completing-read depricated initial-input
>
> Arash Esbati <arash@gnu.org> writes:
>
> > I agree that there are cases where INITIAL-INPUT still has its place,
> > but as I said, I remember the reason for phasing it out was different
> > than stylistic preferences.
>
> What other reason can there be?  I can't think of any non-stylistic
> reason to discourage using that argument.
>
> If you think it is counterproductive to insert some initial value into
> the minibuffer itself, then by all means recommend against using it.
>
> But don't obsolete the means of doing so.


Because `completing-read` is a very general function, on purpose, and
has historically been getting more and more general, the presence of
INITIAL-INPUT does have purpose.  Would want to keep `completing-read`
as a general canonical function for user input.  And I do use it, especially
when `REQUIRE-MATCH` in `t`.

Obsoleting the means of using it will introduce functional difficulties rather
than solving or simplifying anything.

There is enough agreement about the generality of `completing-read` to keep
the functionality of INITIAL-INPUT.







^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-21 14:56 completing-read depricated initial-input Anders Munch
@ 2022-06-22  8:45 ` Jean Louis
  0 siblings, 0 replies; 73+ messages in thread
From: Jean Louis @ 2022-06-22  8:45 UTC (permalink / raw)
  To: Anders Munch, help-gnu-emacs@gnu.org



On June 21, 2022 2:56:59 PM UTC, Anders Munch <ajm@flonidan.dk> wrote:
>carlmarcos wrote:
>> New users do not usually know many keybinding sequences such as `M-n`
>to show `DEF`.
>
>I'm not sure why an old user would know M-n either.   It's not very
>discoverable.

It is in manual for mining history, as long time Emacs user I am using this so often, every day, together with M-p, and I even forgot how I learned it.

Reason that I maybe use it more then average users is that my Dynamic Knowledge Repository  handes database backed selections, for example choice of a country, or language.


Jean



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-21  9:51   ` carlmarcos--- via Users list for the GNU Emacs text editor
  2022-06-21 11:19     ` Michael Heerdegen
@ 2022-06-22  8:50     ` Jean Louis
  2022-06-22  9:32       ` Emanuel Berg
  1 sibling, 1 reply; 73+ messages in thread
From: Jean Louis @ 2022-06-22  8:50 UTC (permalink / raw)
  To: carlmarcos,
	carlmarcos--- via Users list for the GNU Emacs text editor
  Cc: Help Gnu Emacs



On June 21, 2022 9:51:07 AM UTC, carlmarcos--- via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
>Jun 21, 2022, 07:56 by help-gnu-emacs@gnu.org:
>
>>
>> Have been reading the docstring of `completing-read`.
>>
>> (completing-read PROMPT COLLECTION &optional PREDICATE REQUIRE-MATCH
>> INITIAL-INPUT HIST DEF INHERIT-INPUT-METHOD)
>>
>> INITIAL-INPUT states that this feature is deprecated - it is best to
>pass nil
>> for INITIAL-INPUT and supply the default value DEF instead.  
>>
>> When do you plan to remove the `INITIAL-INPUT` argument from
>`completing-read`?
>>
>I differ with the plan to depricate `INITIAL-INPUT`.  This is because
>it is useful to immediately
>show a value when using `completing-read`.  New users do not usually
>know many keybinding sequences such as `M-n` to show `DEF`.  Besides
>the utility of having an initial value that is different from a
>default.

I agree to this notion as being heavy user of this function.


Jean



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-22  8:50     ` Jean Louis
@ 2022-06-22  9:32       ` Emanuel Berg
  0 siblings, 0 replies; 73+ messages in thread
From: Emanuel Berg @ 2022-06-22  9:32 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

> New users do not usually know many keybinding sequences such
> as `M-n` to show `DEF`.

Maybe not but why can only do it as good and fast and powerful
as possible, what some people may or may not know at some
point of their learning curve can't influence that.

>> Besides the utility of having an initial value that is
>> different from a default.
>
> I agree to this notion as being heavy user of this function.

No ... it doesn't work like that, if you can't say what that
is it shouldn't be there. The default is the default, what is
the initial value? Useful? Oh-no.

What's wrong with this and when doesn't it work? I dare you ...

(let ((name "Danger"))
  (read-string (format "name: [%s] " name) nil nil name) )

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
@ 2022-06-22 10:02 Anders Munch
  2022-06-22 11:58 ` Emanuel Berg
  2022-06-22 13:23 ` Eli Zaretskii
  0 siblings, 2 replies; 73+ messages in thread
From: Anders Munch @ 2022-06-22 10:02 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

Jean Louis wrote:
> It is in manual for mining history, as long time Emacs user I am using this so often, every day, together with M-p, and I even forgot how I learned it.

Mining?  Oh, you mean minibuffer history, section 8.5, I suppose that was an autocorrect?  That is some kind of discoverable, I guess, but a weak one.

Trying it out, I can't seem to come up with any minibuffer-using commands where this "future history" contains anything useful, so I guess that explains why I never memorised the feature.  xref-find-definitions is especially weird: It walks through most or maybe all of the symbols in my TAGS file in something like the order they are found in the file.  Anyone know what's up with that?

regards, Anders


^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-22 10:02 Anders Munch
@ 2022-06-22 11:58 ` Emanuel Berg
  2022-06-22 13:23 ` Eli Zaretskii
  1 sibling, 0 replies; 73+ messages in thread
From: Emanuel Berg @ 2022-06-22 11:58 UTC (permalink / raw)
  To: help-gnu-emacs

Anders Munch wrote:

>> It is in manual for mining history, as long time Emacs user
>> I am using this so often, every day, together with M-p, and
>> I even forgot how I learned it.
>
> Mining? Oh, you mean minibuffer history, section 8.5,
> I suppose that was an autocorrect? That is some kind of
> discoverable, I guess, but a weak one.

Jean has real experience from mining so for him it's trivial
to extract.

  (info "(emacs) Minibuffer History")

> Trying it out, I can't seem to come up with any
> minibuffer-using commands where this "future history"
> contains anything useful, so I guess that explains why
> I never memorised the feature. xref-find-definitions is
> especially weird: It walks through most or maybe all of the
> symbols in my TAGS file in something like the order they are
> found in the file. Anyone know what's up with that?

On the contrary, it's _vertical_ and known as linear or
sequential search.

https://en.wikipedia.org/wiki/Linear_search

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
@ 2022-06-22 13:17 Anders Munch
  0 siblings, 0 replies; 73+ messages in thread
From: Anders Munch @ 2022-06-22 13:17 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

I wrote:
> xref-find-definitions is especially weird: It 
> walks through most or maybe all of the symbols in my TAGS file in 
> something like the order they are found in the file. Anyone know 
> what's up with that?

Emanuel Berg wrote:
> On the contrary, it's _vertical_ and known as linear or sequential search.

Don't be condescending.  
Especially since you are technically wrong <wink>: For it to be a _search_ you need to be searching for something.  I was just walking through the entries one by one.

What I saw was in file order, but not including every symbol in the file: Every class name was there, but not every method name.  The missing methods might have shown up further down the sequence, but I did not take the time to M-n through every single entry to see if that would happen, since there's 145,827 entries in the particular TAGS file.

regards, Anders




^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-22 10:02 Anders Munch
  2022-06-22 11:58 ` Emanuel Berg
@ 2022-06-22 13:23 ` Eli Zaretskii
  1 sibling, 0 replies; 73+ messages in thread
From: Eli Zaretskii @ 2022-06-22 13:23 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Anders Munch <ajm@flonidan.dk>
> Date: Wed, 22 Jun 2022 10:02:07 +0000
> 
> Trying it out, I can't seem to come up with any minibuffer-using commands where this "future history" contains anything useful

It's supposed to guess what you would want to type next.  Thus its
name.



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
@ 2022-06-22 13:43 Anders Munch
  0 siblings, 0 replies; 73+ messages in thread
From: Anders Munch @ 2022-06-22 13:43 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

Eli Zaretskii wrote:
> It's supposed to guess what you would want to type next.  Thus its name.

What I meant is that I tried various things that used the minibuffer to see what kind of guess they came up with, and then I relayed my experiences.
It wasn't useful to me, but that doesn't mean it's not useful to others.  I didn't mean to imply otherwise.

regards, Anders




^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-21 22:07           ` [External] : " Drew Adams
@ 2022-06-23  7:59             ` Arash Esbati
  2022-06-23 10:06               ` carlmarcos--- via Users list for the GNU Emacs text editor
                                 ` (2 more replies)
  0 siblings, 3 replies; 73+ messages in thread
From: Arash Esbati @ 2022-06-23  7:59 UTC (permalink / raw)
  To: Drew Adams
  Cc: Christopher Dimech, eliz@gnu.org, monnier@iro.umontreal.ca,
	Help Gnu Emacs, carlmarcos@tutanota.com, michael_heerdegen@web.de

Drew Adams <drew.adams@oracle.com> writes:

>> > `completing-read' is extremely general, allowing for many different
>> > interactions for many different kinds of use cases.
>> 
>> True, unfortunately.
>
> Why "unfortunately"?

Because extremely general tools give one many ways to do things.  It is
just hard if you find out afterwards that things went in the wrong
direction and you try to clean up.  No other reason.

> And there's `read-from-minibuffer', which is
> even more general.

Therefore we have `read-string'.

> I'd rather have Emacs implement, test, and maintain it than do so
> myself, if possible. ;-)

Good strategy ;-)

>> but you're still free to use the old feature if you
>> think it has a added value from a user perspective.
>
> Sure.  With the risk that what's deprecated might be
> desupported at some point.
>
> (At which point you can always choose to copy the old
> code and continue to use it.  With the bother of
> dealing with incompatibilities, inconsistencies, and
> having to keep some bits synchronized...)

I don't think this will happen for `completing-read'.  Looking at other
places than the docstring of `completing-read', you find:

 • Emacs Lisp Ref:

   21.5 Initial Input[1]

   Several of the functions for minibuffer input have an argument called
   initial. This is a mostly-deprecated feature for specifying that the
   minibuffer should start out with certain text, instead of empty as
   usual. [...]

   We discourage use of a non-nil value for initial, because initial
   input is an intrusive interface. History lists and default values
   provide a much more convenient method to offer useful default inputs
   to the user.

   There is just one situation where you should specify a string for an
   initial argument. This is when you specify a cons cell for the
   history argument. See Minibuffer History.

   21.6.2 Completion and the Minibuffer[2]

   Function: completing-read [...]
   The argument initial is mostly deprecated; we recommend using a
   non-nil value only in conjunction with specifying a cons cell for
   history. See Initial Input. For default input, use default instead.

  • `read-string' docstring:

    Read a string from the minibuffer, prompting with string PROMPT.
    If non-nil, second arg INITIAL-INPUT is a string to insert before reading.
      This argument has been superseded by DEFAULT-VALUE and should
      normally be nil in new code.  It behaves as INITIAL-CONTENTS in
      ‘read-from-minibuffer’ (which see).

Note the terms "mostly-deprecated", "discourage", "recommend",
"superseded".  So maybe the docstring of `completing-read' should be
adjusted to the statements above in order to avoid confusion?

Best, Arash

Footnotes:
[1]  https://www.gnu.org/software/emacs/manual/html_node/elisp/Initial-Input.html
[2]  https://www.gnu.org/software/emacs/manual/html_node/elisp/Minibuffer-Completion.html



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-22  3:09           ` Po Lu
  2022-06-22  3:46             ` Emanuel Berg
  2022-06-22  4:56             ` Christopher Dimech
@ 2022-06-23  8:20             ` Arash Esbati
  2022-06-23  8:27               ` Emanuel Berg
  2 siblings, 1 reply; 73+ messages in thread
From: Arash Esbati @ 2022-06-23  8:20 UTC (permalink / raw)
  To: Po Lu
  Cc: Drew Adams, Christopher Dimech, eliz@gnu.org,
	monnier@iro.umontreal.ca, Help Gnu Emacs, carlmarcos@tutanota.com,
	michael_heerdegen@web.de

Po Lu <luangruo@yahoo.com> writes:

> Arash Esbati <arash@gnu.org> writes:
>
>> I agree that there are cases where INITIAL-INPUT still has its place,
>> but as I said, I remember the reason for phasing it out was different
>> than stylistic preferences.
>
> What other reason can there be?  I can't think of any non-stylistic
> reason to discourage using that argument.

Improved user experience?  But that means we have to find out what our
definitions of "stylistic preferences / reason" are in the first place,
but we don't have to go there.

> If you think it is counterproductive to insert some initial value into
> the minibuffer itself, then by all means recommend against using it.

This is already done by Emacs itself.  Please see my other answer to
Drew where I quoted some text.

> But don't obsolete the means of doing so.

I'm not the decision maker here, and I don't have the impression that
the means are getting obsoleted.

> You do not have a place in dictating how users write their Lisp
> programs.

What do you mean with that "You"?  I'm not involved in Emacs development
and I'm not dictating anything; and I see no reason for you to get
harsh.

Best, Arash



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23  8:20             ` Arash Esbati
@ 2022-06-23  8:27               ` Emanuel Berg
  2022-06-23  8:57                 ` Tassilo Horn
  0 siblings, 1 reply; 73+ messages in thread
From: Emanuel Berg @ 2022-06-23  8:27 UTC (permalink / raw)
  To: help-gnu-emacs

Arash Esbati wrote:

>>> I agree that there are cases where INITIAL-INPUT still has
>>> its place, but as I said, I remember the reason for
>>> phasing it out was different than stylistic preferences.
>>
>> What other reason can there be? [...]
>
> Improved user experience?

Why/how so?

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23  8:27               ` Emanuel Berg
@ 2022-06-23  8:57                 ` Tassilo Horn
  2022-06-23 10:10                   ` Emanuel Berg
  0 siblings, 1 reply; 73+ messages in thread
From: Tassilo Horn @ 2022-06-23  8:57 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: help-gnu-emacs

Emanuel Berg <incal@dataswamp.org> writes:

>>>> I agree that there are cases where INITIAL-INPUT still has its
>>>> place, but as I said, I remember the reason for phasing it out was
>>>> different than stylistic preferences.
>>>
>>> What other reason can there be? [...]
>>
>> Improved user experience?
>
> Why/how so?

You have to delete the initial input if it's not what you want or if you
want to see the other possibilities.  So basically all occurrences where
INITIAL-INPUT is used as a kind of default value are better handled with
the DEF argument.

The only places where I can see it's useful is when all possible
completions have a common prefix and that is given as initial-input (but
then you only save one TAB) or with completing-read-multiple when it's
highly likely that the user wants to use the defaults given as
initial-input and just insert some more.  (completing-read-multiple
doesn't explicitly state that INITIAL-INPUT is deprecated.)

Bye,
Tassilo



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23  7:59             ` Arash Esbati
@ 2022-06-23 10:06               ` carlmarcos--- via Users list for the GNU Emacs text editor
  2022-06-23 20:57                 ` Emanuel Berg
  2022-06-23 11:19               ` Michael Heerdegen
  2022-06-23 16:23               ` [External] : " Drew Adams
  2 siblings, 1 reply; 73+ messages in thread
From: carlmarcos--- via Users list for the GNU Emacs text editor @ 2022-06-23 10:06 UTC (permalink / raw)
  To: Arash Esbati
  Cc: Drew Adams, Christopher Dimech, eliz@gnu.org,
	monnier@iro.umontreal.ca, Help Gnu Emacs,
	michael_heerdegen@web.de


Jun 23, 2022, 07:59 by arash@gnu.org:

> Drew Adams <drew.adams@oracle.com> writes:
>
>>> > `completing-read' is extremely general, allowing for many different
>>> > interactions for many different kinds of use cases.
>>>
>>> True, unfortunately.
>>>
>>
>> Why "unfortunately"?
>>
>
> Because extremely general tools give one many ways to do things.  It is
> just hard if you find out afterwards that things went in the wrong
> direction and you try to clean up.  No other reason.
>
>> And there's `read-from-minibuffer', which is
>> even more general.
>>
>
> Therefore we have `read-string'.
>
>> I'd rather have Emacs implement, test, and maintain it than do so
>> myself, if possible. ;-)
>>
>
> Good strategy ;-)
>
>>> but you're still free to use the old feature if you
>>> think it has a added value from a user perspective.
>>>
>>
>> Sure.  With the risk that what's deprecated might be
>> desupported at some point.
>>
>> (At which point you can always choose to copy the old
>> code and continue to use it.  With the bother of
>> dealing with incompatibilities, inconsistencies, and
>> having to keep some bits synchronized...)
>>
>
> I don't think this will happen for `completing-read'.  Looking at other
> places than the docstring of `completing-read', you find:
>
>  • Emacs Lisp Ref:
>
>  21.5 Initial Input[1]
>
>  Several of the functions for minibuffer input have an argument called
>  initial. This is a mostly-deprecated feature for specifying that the
>  minibuffer should start out with certain text, instead of empty as
>  usual. [...]
>
>  We discourage use of a non-nil value for initial, because initial
>  input is an intrusive interface. History lists and default values
>  provide a much more convenient method to offer useful default inputs
>  to the user.
>
>   21.6.2 Completion and the Minibuffer[2]
>
>  Function: completing-read [...]
>  The argument initial is mostly deprecated; we recommend using a
>  non-nil value only in conjunction with specifying a cons cell for
>  history. See Initial Input. For default input, use default instead.
>
This is where I disagree.  The documentation discouraging and recommending
not to use it, reads as a statement that lacks any persuasive discussion.

It is not valuable to discourage something simply because it is usually found that
 it is empty.  A designer might know better what he is trying to achieve.  At times it
is better to display some indicative words to the user, than nothing at all (an empty field).

INITIAL-INPUT allows one to display a personally preferable feature whilst keeping
the usual default intact. One must not confuse "initial" with "default".  An initial value
could be assigned to some preferential usage that differs from some well known canonical
 setting.

    



>  • `read-string' docstring:
>
>  Read a string from the minibuffer, prompting with string PROMPT.
>  If non-nil, second arg INITIAL-INPUT is a string to insert before reading.
>  This argument has been superseded by DEFAULT-VALUE and should
>  normally be nil in new code.  It behaves as INITIAL-CONTENTS in
>  ‘read-from-minibuffer’ (which see).
>
> Note the terms "mostly-deprecated", "discourage", "recommend",
> "superseded".  So maybe the docstring of `completing-read' should be
> adjusted to the statements above in order to avoid confusion?
>
I do not see that the deprecation was superceded through some improved
 coding mechanism.


> Best, Arash
>
> Footnotes:
> [1]  https://www.gnu.org/software/emacs/manual/html_node/elisp/Initial-Input.html
> [2]  https://www.gnu.org/software/emacs/manual/html_node/elisp/Minibuffer-Completion.html
>



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23  8:57                 ` Tassilo Horn
@ 2022-06-23 10:10                   ` Emanuel Berg
  2022-06-23 11:26                     ` Tassilo Horn
  2022-06-23 11:58                     ` Arash Esbati
  0 siblings, 2 replies; 73+ messages in thread
From: Emanuel Berg @ 2022-06-23 10:10 UTC (permalink / raw)
  To: help-gnu-emacs

Tassilo Horn wrote:

>>>>> I agree that there are cases where INITIAL-INPUT still
>>>>> has its place, but as I said, I remember the reason for
>>>>> phasing it out was different than stylistic preferences.
>>>>
>>>> What other reason can there be? [...]
>>>
>>> Improved user experience?
>>
>> Why/how so?
>
> You have to delete the initial input if it's not what you
> want or if you want to see the other possibilities.
> So basically all occurrences where INITIAL-INPUT is used as
> a kind of default value are better handled with the
> DEF argument.

I know but ... why are you telling me this?

IMO this is the best way of doing it:

(let ((name "Danger"))
  (read-string (format "name: [%s] " name) nil nil name) )

> The only places where I can see it's useful is when all
> possible completions have a common prefix [...]

It is useful there but only in terms on relying on completion
over a huge set of pretty much similar symbol names which is
a situation that shouldn't be encouraged to begin with, and
neither should completion BTW. And, alltho, as Merlin the
Great Wizard was fond of saying, there is no right or wrong,
just what is and what isn't, it still holds that two wrongs
don't make one right.

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23  7:59             ` Arash Esbati
  2022-06-23 10:06               ` carlmarcos--- via Users list for the GNU Emacs text editor
@ 2022-06-23 11:19               ` Michael Heerdegen
  2022-06-23 12:12                 ` Arash Esbati
                                   ` (4 more replies)
  2022-06-23 16:23               ` [External] : " Drew Adams
  2 siblings, 5 replies; 73+ messages in thread
From: Michael Heerdegen @ 2022-06-23 11:19 UTC (permalink / raw)
  To: Arash Esbati
  Cc: Drew Adams, Christopher Dimech, eliz@gnu.org,
	monnier@iro.umontreal.ca, Help Gnu Emacs, carlmarcos@tutanota.com

Arash Esbati <arash@gnu.org> writes:

> Note the terms "mostly-deprecated", "discourage", "recommend",
> "superseded".  So maybe the docstring of `completing-read' should be
> adjusted to the statements above in order to avoid confusion?

The purpose of `completing-read' is a bit different from `read-string'
and `read-from-minibuffer'.  Providing INITIAL-INPUT is useful for the
latter, but much less for `completing-read' in my opinion.  If at all
(anybody who has a believable real-life example?).

Michael.



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23 10:10                   ` Emanuel Berg
@ 2022-06-23 11:26                     ` Tassilo Horn
  2022-06-23 11:48                       ` carlmarcos--- via Users list for the GNU Emacs text editor
  2022-06-23 21:34                       ` Emanuel Berg
  2022-06-23 11:58                     ` Arash Esbati
  1 sibling, 2 replies; 73+ messages in thread
From: Tassilo Horn @ 2022-06-23 11:26 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: help-gnu-emacs

Emanuel Berg <incal@dataswamp.org> writes:

>>>> Improved user experience?
>>>
>>> Why/how so?
>>
>> You have to delete the initial input if it's not what you
>> want or if you want to see the other possibilities.
>> So basically all occurrences where INITIAL-INPUT is used as
>> a kind of default value are better handled with the
>> DEF argument.
>
> I know but ... why are you telling me this?

Because you've asked why/how not using INITIAL-INPUT with
completing-read has an improved user experience.

> IMO this is the best way of doing it:
>
> (let ((name "Danger"))
>   (read-string (format "name: [%s] " name) nil nil name) )

But it has nothing to do with completing-read.

>> The only places where I can see it's useful is when all
>> possible completions have a common prefix [...]
>
> It is useful there but only in terms on relying on completion over a
> huge set of pretty much similar symbol names which is a situation that
> shouldn't be encouraged to begin with, and neither should completion
> BTW.

Huh?  Completion is a must especially when there are many and similar
completions.  Would you consider M-x/C-h {f,v,etc} without completion
being a good user interface?

> And, alltho, as Merlin the Great Wizard was fond of saying, there is
> no right or wrong, just what is and what isn't, it still holds that
> two wrongs don't make one right.

Sure.  But the thing is that people writing packages usually don't
provide an option if INITIAL-INPUT should be used or not.  Therefore,
whatever choice they make is forced upon their users (well, unless the
user knows of :filter-args advices).  For that reason it makes sense to
document a guideline on how to do things as Arash cited in
<86mte3lsj2.fsf_-_@gnu.org>.

Bye,
Tassilo



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23 11:26                     ` Tassilo Horn
@ 2022-06-23 11:48                       ` carlmarcos--- via Users list for the GNU Emacs text editor
  2022-06-23 21:38                         ` Emanuel Berg
  2022-06-23 21:34                       ` Emanuel Berg
  1 sibling, 1 reply; 73+ messages in thread
From: carlmarcos--- via Users list for the GNU Emacs text editor @ 2022-06-23 11:48 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: Emanuel Berg, help-gnu-emacs


Jun 23, 2022, 11:26 by tsdh@gnu.org:

> Emanuel Berg <incal@dataswamp.org> writes:
>
>>>>> Improved user experience?
>>>>>
>>>>
>>>> Why/how so?
>>>>
>>>
>>> You have to delete the initial input if it's not what you
>>> want or if you want to see the other possibilities.
>>> So basically all occurrences where INITIAL-INPUT is used as
>>> a kind of default value are better handled with the
>>> DEF argument.
>>>
>>
>> I know but ... why are you telling me this?
>>
>
> Because you've asked why/how not using INITIAL-INPUT with
> completing-read has an improved user experience.
>
>> IMO this is the best way of doing it:
>>
>> (let ((name "Danger"))
>>  (read-string (format "name: [%s] " name) nil nil name) )
>>
>
> But it has nothing to do with completing-read.
>
>>> The only places where I can see it's useful is when all
>>> possible completions have a common prefix [...]
>>>
>>
>> It is useful there but only in terms on relying on completion over a
>> huge set of pretty much similar symbol names which is a situation that
>> shouldn't be encouraged to begin with, and neither should completion
>> BTW.
>>
>
> Huh?  Completion is a must especially when there are many and similar
> completions.  Would you consider M-x/C-h {f,v,etc} without completion
> being a good user interface?
>
>> And, alltho, as Merlin the Great Wizard was fond of saying, there is
>> no right or wrong, just what is and what isn't, it still holds that
>> two wrongs don't make one right.
>>
>
> Sure.  But the thing is that people writing packages usually don't
> provide an option if INITIAL-INPUT should be used or not.  Therefore,
> whatever choice they make is forced upon their users (well, unless the
> user knows of :filter-args advices).  For that reason it makes sense to
> document a guideline on how to do things as Arash cited in
> <86mte3lsj2.fsf_-_@gnu.org>.
>
So now emacs is getting into the habit of trashing code by looking at written
packages by figuring out what is not usually done by the majority?  It is a bad
strategy, to say the least.  Even worse, it looks as if the documentation in putting
in people's head that INITIAL-INPUT should not be used in any function where
it is defined as an argument.



> Bye,
> Tassilo
>



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23 10:10                   ` Emanuel Berg
  2022-06-23 11:26                     ` Tassilo Horn
@ 2022-06-23 11:58                     ` Arash Esbati
  2022-06-23 12:10                       ` Lars Ingebrigtsen
  2022-06-23 21:42                       ` Emanuel Berg
  1 sibling, 2 replies; 73+ messages in thread
From: Arash Esbati @ 2022-06-23 11:58 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg <incal@dataswamp.org> writes:

> Tassilo Horn wrote:
>
>> You have to delete the initial input if it's not what you
>> want or if you want to see the other possibilities.
>> So basically all occurrences where INITIAL-INPUT is used as
>> a kind of default value are better handled with the
>> DEF argument.
>
> I know but ... why are you telling me this?

Because you asked?  I parsed your question exactly the same way Tassilo
did.

> IMO this is the best way of doing it:
>
> (let ((name "Danger"))
>   (read-string (format "name: [%s] " name) nil nil name) )

I think the current standard in Emacs is like this:

(let ((name "Danger"))
  (read-string (format "Name (default %s): " name)
               nil nil name))

Best, Arash



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23 11:58                     ` Arash Esbati
@ 2022-06-23 12:10                       ` Lars Ingebrigtsen
  2022-06-23 14:26                         ` Tassilo Horn
  2022-06-23 21:49                         ` Emanuel Berg
  2022-06-23 21:42                       ` Emanuel Berg
  1 sibling, 2 replies; 73+ messages in thread
From: Lars Ingebrigtsen @ 2022-06-23 12:10 UTC (permalink / raw)
  To: Arash Esbati; +Cc: help-gnu-emacs

Arash Esbati <arash@gnu.org> writes:

> I think the current standard in Emacs is like this:
>
> (let ((name "Danger"))
>   (read-string (format "Name (default %s): " name)
>                nil nil name))

Or rather:

(let ((name "Danger"))
  (read-string (format-prompt "Name" name) nil nil name))

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



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23 11:19               ` Michael Heerdegen
@ 2022-06-23 12:12                 ` Arash Esbati
  2022-06-23 14:52                   ` Michael Heerdegen
  2022-06-23 21:06                   ` Emanuel Berg
  2022-06-23 14:36                 ` Jean Louis
                                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 73+ messages in thread
From: Arash Esbati @ 2022-06-23 12:12 UTC (permalink / raw)
  To: Michael Heerdegen
  Cc: Drew Adams, Christopher Dimech, eliz@gnu.org,
	monnier@iro.umontreal.ca, Help Gnu Emacs, carlmarcos@tutanota.com

Michael Heerdegen <michael_heerdegen@web.de> writes:

> The purpose of `completing-read' is a bit different from `read-string'
> and `read-from-minibuffer'.  Providing INITIAL-INPUT is useful for the
> latter, but much less for `completing-read' in my opinion.  If at all
> (anybody who has a believable real-life example?).

If you have a common prefix which should be shown in the candidates
list, in (La)TeX for instance:

(let ((list '("iffalse" "iftrue" "else" "fi")))
  (completing-read "Macro: "
                   (mapcar (lambda (x) (concat "\\" x)) list)
                   nil nil "\\"))

Something like this looks odd:

(let ((list '("iffalse" "iftrue" "else" "fi")))
  (completing-read "Macro: \\" list))

Best, Arash



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23 12:10                       ` Lars Ingebrigtsen
@ 2022-06-23 14:26                         ` Tassilo Horn
  2022-06-23 14:46                           ` Arash Esbati
  2022-06-24  2:17                           ` Emanuel Berg
  2022-06-23 21:49                         ` Emanuel Berg
  1 sibling, 2 replies; 73+ messages in thread
From: Tassilo Horn @ 2022-06-23 14:26 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Arash Esbati, help-gnu-emacs

Lars Ingebrigtsen <larsi@gnus.org> writes:

> (let ((name "Danger"))
>   (read-string (format-prompt "Name" name) nil nil name))

Nice!

  Probably introduced at or before Emacs version 28.1.

Hm, ok, that will take a while before AUCTeX can start using it.

Bye,
Tassilo



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23 11:19               ` Michael Heerdegen
  2022-06-23 12:12                 ` Arash Esbati
@ 2022-06-23 14:36                 ` Jean Louis
  2022-06-24  2:35                   ` Emanuel Berg
  2022-06-23 15:19                 ` Jean Louis
                                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 73+ messages in thread
From: Jean Louis @ 2022-06-23 14:36 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: help-gnu-emacs

I like my function `rcd-ask' as it saves me generation of history variables automatically. 

(defun rcd-symbol-if-not-exist (variable &optional value description)
  "Return symbol for VARIABLE string. 

It will generate new VARIABLE if it does not exist.

VALUE and DESCRIPTION are optional."
  (let* ((variable (replace-regexp-in-string "[^[:alnum:]]" "-" (downcase variable)))
	 (rcd-symbol (intern variable))
	 (description (or description (format "Generated variable `%s'" variable))))
    (if (boundp rcd-symbol)
	rcd-symbol
      (eval (list 'defvar rcd-symbol value description)))))

(defun rcd-ask-history-variable (prompt)
  "Generate history variable based on PROMPT."
  (let* ((description (format "History for `%s' prompt." prompt)))
    (rcd-symbol-if-not-exist (concat "rcd-" prompt "-history") nil description)))

(defun rcd-ask (&optional prompt initial-contents keymap read default-value)
  "Modified function `read-from-minibuffer'.

This is shorter, simpler function that generates the prompt
automatically, generates history variable automatically and
inherits the input method. The input will be returned trimmed."
  (let* ((prompt (or prompt "Input data: "))
	 (history (rcd-ask-history-variable prompt))
	 (input (read-from-minibuffer prompt initial-contents keymap read history default-value t))
	 (input (string-trim input)))
    input))

;; (rcd-ask "First name: ") ⇒ "Emmanuel"
;; In the next step "Emmanuel" is automatically history, and one can get him by M-n M-p
;; (rcd-ask "First name: ")
;; (rcd-ask) ⇒ "Here is some string"

And I also like this function that asks few TIMES for something:

(defun rcd-ask-times (times &optional prompt initial-contents keymap read default-value)
  "Return list of queries by multiples TIMES"
  (let ((list ())
	(count 0))
    (while (< count times)
      (push (rcd-ask (concat (format "[#%s] " (1+ count)) prompt) initial-contents keymap read default-value) list)
    (setq count (1+ count)))
    (reverse list)))

;; (rcd-ask-times 3 "Query: ") ⇒ ("Emmanuel" "Berg" "Sweden")


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23 14:26                         ` Tassilo Horn
@ 2022-06-23 14:46                           ` Arash Esbati
  2022-06-23 15:18                             ` Robert Pluim
  2022-06-24  2:22                             ` Emanuel Berg
  2022-06-24  2:17                           ` Emanuel Berg
  1 sibling, 2 replies; 73+ messages in thread
From: Arash Esbati @ 2022-06-23 14:46 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: Lars Ingebrigtsen, help-gnu-emacs

Tassilo Horn <tsdh@gnu.org> writes:

> Lars Ingebrigtsen <larsi@gnus.org> writes:
>
>> (let ((name "Danger"))
>>   (read-string (format-prompt "Name" name) nil nil name))
>
> Nice!

Indeed, and the best part of it is `minibuffer-default-prompt-format'
which you can customize.

>   Probably introduced at or before Emacs version 28.1.
>
> Hm, ok, that will take a while before AUCTeX can start using it.

I'd say it's up to the AUCTeX maintainers to bump the minimum required
Emacs version at a faster pace ;-)

Best, Arash



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23 12:12                 ` Arash Esbati
@ 2022-06-23 14:52                   ` Michael Heerdegen
  2022-06-23 21:07                     ` Emanuel Berg
  2022-06-23 21:06                   ` Emanuel Berg
  1 sibling, 1 reply; 73+ messages in thread
From: Michael Heerdegen @ 2022-06-23 14:52 UTC (permalink / raw)
  To: Arash Esbati
  Cc: Drew Adams, Christopher Dimech, eliz@gnu.org,
	monnier@iro.umontreal.ca, Help Gnu Emacs, carlmarcos@tutanota.com

Arash Esbati <arash@gnu.org> writes:

> (let ((list '("iffalse" "iftrue" "else" "fi")))
>   (completing-read "Macro: "
>                    (mapcar (lambda (x) (concat "\\" x)) list)
>                    nil nil "\\"))

A convincing example, in my opinion.

Michael.



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23 14:46                           ` Arash Esbati
@ 2022-06-23 15:18                             ` Robert Pluim
  2022-06-23 20:46                               ` Arash Esbati
  2022-06-24  2:22                             ` Emanuel Berg
  1 sibling, 1 reply; 73+ messages in thread
From: Robert Pluim @ 2022-06-23 15:18 UTC (permalink / raw)
  To: Arash Esbati; +Cc: Tassilo Horn, Lars Ingebrigtsen, help-gnu-emacs

>>>>> On Thu, 23 Jun 2022 16:46:53 +0200, Arash Esbati <arash@gnu.org> said:

    Arash> Tassilo Horn <tsdh@gnu.org> writes:
    >> Lars Ingebrigtsen <larsi@gnus.org> writes:
    >> 
    >>> (let ((name "Danger"))
    >>> (read-string (format-prompt "Name" name) nil nil name))
    >> 
    >> Nice!

    Arash> Indeed, and the best part of it is `minibuffer-default-prompt-format'
    Arash> which you can customize.

    >> Probably introduced at or before Emacs version 28.1.
    >> 
    >> Hm, ok, that will take a while before AUCTeX can start using it.

    Arash> I'd say it's up to the AUCTeX maintainers to bump the minimum required
    Arash> Emacs version at a faster pace ;-)

Either that, or they can depend on the 'compat' package, and then just
use emacs-28 features with wild abandon.

Robert
-- 



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23 11:19               ` Michael Heerdegen
  2022-06-23 12:12                 ` Arash Esbati
  2022-06-23 14:36                 ` Jean Louis
@ 2022-06-23 15:19                 ` Jean Louis
  2022-06-23 15:24                 ` Jean Louis
  2022-06-23 21:05                 ` Stefan Monnier
  4 siblings, 0 replies; 73+ messages in thread
From: Jean Louis @ 2022-06-23 15:19 UTC (permalink / raw)
  To: Michael Heerdegen
  Cc: Arash Esbati, Drew Adams, Christopher Dimech, eliz@gnu.org,
	monnier@iro.umontreal.ca, Help Gnu Emacs, carlmarcos@tutanota.com

* Michael Heerdegen <michael_heerdegen@web.de> [2022-06-23 14:22]:
> Arash Esbati <arash@gnu.org> writes:
> 
> > Note the terms "mostly-deprecated", "discourage", "recommend",
> > "superseded".  So maybe the docstring of `completing-read' should be
> > adjusted to the statements above in order to avoid confusion?
> 
> The purpose of `completing-read' is a bit different from `read-string'
> and `read-from-minibuffer'.  Providing INITIAL-INPUT is useful for the
> latter, but much less for `completing-read' in my opinion.  If at all
> (anybody who has a believable real-life example?).

I am used to automatically generate history variables based on
prompt. And I use often read-from-minibuffer wrapped in my function,
this below is using automatically inserted initial contents based on
history variable. I find that useful.

(defun rcd-ask (&optional prompt initial-contents keymap read default-value auto-initial-contents)
  "Modified function `read-from-minibuffer'.

This is shorter, simpler function that generates the prompt
automatically, generates history variable automatically and
inherits the input method. The input will be returned trimmed."
  (let* ((prompt (or prompt "Input data: "))
	 (history (rcd-ask-history-variable prompt))
	 (initial-contents (or initial-contents (when auto-initial-contents (car (symbol-value history)))))
	 (input (read-from-minibuffer prompt initial-contents keymap read history default-value t))
	 (input (string-trim input)))
    input))

;; (rcd-ask "First name: " "Emmanuel") ⇒ "Emmanuel"
;; (rcd-ask "First name: ") ⇒ "Berg"
;; rcd-first-name---history ⇒ ("Berg" "Emmanuel" "Jean" "Louis")

Then we get automatic initial contents based on the prompt:

(rcd-ask "First name: " nil nil nil nil t)

as then minibuffer says "First name: Berg" and waits for input.

Having initial contents based on last value of the history is useful on my side.

But then again I have another wrapper that uses `completing-read'
which I also want to adapt to use auto-initial-input based on last
value of history variable. For example I am often entering country
names, and often people from same country, having last history
variable as auto-initial-input is useful

(defun rcd-completing-read-sql-hash (prompt sql pg &optional history initial-input not-require-match)
  "Complete selection by using SQL.

First column shall be unique id, followed by text
representation.  Example SQL query:

SELECT people_id, people_firstname || ' ' || people_lastname FROM people

PG is database handle.  HISTORY is supported with INITIAL-INPUT
Argument PROMPT will be displayed to user."
  (let* ((hash (rcd-sql-hash-with-key sql pg))
	 (completion-ignore-case t)
	 (require-match (if not-require-match nil t))
	 (history (or history (rcd-ask-history-variable prompt)))
	 (choice (completing-read prompt hash nil require-match initial-input history))
	 (choice (string-trim choice))
	 (id (gethash choice hash)))
    (if id id
      (if not-require-match 
	  choice))))

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23 11:19               ` Michael Heerdegen
                                   ` (2 preceding siblings ...)
  2022-06-23 15:19                 ` Jean Louis
@ 2022-06-23 15:24                 ` Jean Louis
  2022-06-23 21:05                 ` Stefan Monnier
  4 siblings, 0 replies; 73+ messages in thread
From: Jean Louis @ 2022-06-23 15:24 UTC (permalink / raw)
  To: Michael Heerdegen
  Cc: Arash Esbati, Drew Adams, Christopher Dimech, eliz@gnu.org,
	monnier@iro.umontreal.ca, Help Gnu Emacs, carlmarcos@tutanota.com

* Michael Heerdegen <michael_heerdegen@web.de> [2022-06-23 14:22]:
> Arash Esbati <arash@gnu.org> writes:
> 
> > Note the terms "mostly-deprecated", "discourage", "recommend",
> > "superseded".  So maybe the docstring of `completing-read' should be
> > adjusted to the statements above in order to avoid confusion?
> 
> The purpose of `completing-read' is a bit different from `read-string'
> and `read-from-minibuffer'.  Providing INITIAL-INPUT is useful for the
> latter, but much less for `completing-read' in my opinion.  If at all
> (anybody who has a believable real-life example?).

Thanks, it gave me idea so I have improved my function to
automatically insert auto-initial-input based on last value of
automatically generated history variable.

It spares my time in some entries, and I do many of them per day..

(defun rcd-completing-read-sql-hash (prompt sql pg &optional history initial-input not-require-match auto-initial-input)
  "Complete selection by using SQL.

First column shall be unique id, followed by text
representation.  Example SQL query:

SELECT people_id, people_firstname || ' ' || people_lastname FROM people

PG is database handle.  HISTORY is supported with INITIAL-INPUT
Argument PROMPT will be displayed to user."
  (let* ((hash (rcd-sql-hash-with-key sql pg))
	 (completion-ignore-case t)
	 (require-match (if not-require-match nil t))
	 (history (or history (rcd-ask-history-variable prompt)))
	 (initial-input (or initial-input (when auto-initial-input (car (symbol-value history)))))
	 (choice (completing-read prompt hash nil require-match initial-input history))
	 (choice (string-trim choice))
	 (id (gethash choice hash)))
    (if id id
      (if not-require-match 
	  choice))))

Example:

That would show user's name and email address and ID number, and I
would get ID number as result.

(rcd-completing-read-sql-hash "People: " "SELECT people_id, people_firstname || ' ' || people_lastname FROM people LIMIT 10" cf-db nil nil nil t) ⇒ 32367


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23 15:18                             ` Robert Pluim
@ 2022-06-23 20:46                               ` Arash Esbati
  2022-06-24  8:40                                 ` Philip Kaludercic
  0 siblings, 1 reply; 73+ messages in thread
From: Arash Esbati @ 2022-06-23 20:46 UTC (permalink / raw)
  To: Robert Pluim
  Cc: Tassilo Horn, Lars Ingebrigtsen, help-gnu-emacs,
	Philip Kaludercic

Robert Pluim <rpluim@gmail.com> writes:

>>>>>> On Thu, 23 Jun 2022 16:46:53 +0200, Arash Esbati <arash@gnu.org> said:
>
>     Arash> I'd say it's up to the AUCTeX maintainers to bump the minimum required
>     Arash> Emacs version at a faster pace ;-)
>
> Either that, or they can depend on the 'compat' package, and then just
> use emacs-28 features with wild abandon.

Thanks for reminding me of compat.  I think compat-28.el has currently a
bug since the return value of `format-prompt' is not the same as in
Emacs>=28:

(format-prompt "Foo" "")
=> "Foo: "

This is what compat-28.el does:

(defun compat-format-prompt (prompt default &rest format-args)
  "Format PROMPT with DEFAULT.
If FORMAT-ARGS is nil, PROMPT is used as a plain string.  If
FORMAT-ARGS is non-nil, PROMPT is used as a format control
string, and FORMAT-ARGS are the arguments to be substituted into
it.  See `format' for details.

If DEFAULT is a list, the first element is used as the default.
If not, the element is used as is.

If DEFAULT is nil or an empty string, no \"default value\" string
is included in the return value."
  (concat
   (if (null format-args)
       prompt
     (apply #'format prompt format-args))
   (and default
        (or (not (stringp default))
            (not (null default)))
        ;;  (length> default 0) ; This is in Emacs stock version
        (format " (default %s)"
                (if (consp default)
                    (car default)
                  default)))
   ": "))

(compat-format-prompt "Foo" "")
=> "Foo (default ): "

compat doesn't check if DEFAULT is an empty string.  I'm CC'ing Philip,
maybe he can comment.

Best, Arash



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23 10:06               ` carlmarcos--- via Users list for the GNU Emacs text editor
@ 2022-06-23 20:57                 ` Emanuel Berg
  0 siblings, 0 replies; 73+ messages in thread
From: Emanuel Berg @ 2022-06-23 20:57 UTC (permalink / raw)
  To: help-gnu-emacs

carlmarcos--- via Users list for the GNU Emacs text editor wrote:

> One must not confuse "initial" with "default".

I have heard the word "initial" before but what's the
use case? Is it the completion stuff already mentioned?

If so then that argument can safely be moved, preferable to
the dust heap of programming history.

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23 16:23               ` [External] : " Drew Adams
@ 2022-06-23 20:58                 ` Arash Esbati
  2022-06-23 21:54                   ` Christopher Dimech
  2022-06-24  2:49                   ` Emanuel Berg
  0 siblings, 2 replies; 73+ messages in thread
From: Arash Esbati @ 2022-06-23 20:58 UTC (permalink / raw)
  To: Drew Adams
  Cc: Christopher Dimech, eliz@gnu.org, monnier@iro.umontreal.ca,
	Help Gnu Emacs, carlmarcos@tutanota.com, michael_heerdegen@web.de

Drew Adams <drew.adams@oracle.com> writes:

>> Because extremely general tools give one many
>> ways to do things.
>
> And?  Emacs and Elisp are all about giving us
> many ways to do things.  They even give you lots
> of rope to hang yourself with.
>
>> It is just hard if you find out afterwards that
>> things went in the wrong direction and you try
>> to clean up.  No other reason.
>
> Too general/abstract.  Can you elaborate with
> some specifics?

I don't have any specific example in my mind, I was also thinking about
what you said above about the rope and hang yourself.

> No one's obliged to use the very general function
> `completing-read'.  And no one's obliged to use
> it with a non-nil INITIAL-INPUT arg.

Agreed.

But in terms of coming to some sort of conclusion: This thread started
with the question:

  When do you plan to remove the `INITIAL-INPUT` argument from
  `completing-read`?

I think the answer is: This will not happen, so don't worry.

If so, is the docstring of `completing-read' inaccurate or misleading?
If so, should there be a bug report and/or a change suggestion?

WDYT?

Best, Arash



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23 11:19               ` Michael Heerdegen
                                   ` (3 preceding siblings ...)
  2022-06-23 15:24                 ` Jean Louis
@ 2022-06-23 21:05                 ` Stefan Monnier
  2022-06-23 22:10                   ` Christopher Dimech
  2022-06-24  2:29                   ` Emanuel Berg
  4 siblings, 2 replies; 73+ messages in thread
From: Stefan Monnier @ 2022-06-23 21:05 UTC (permalink / raw)
  To: Michael Heerdegen
  Cc: Arash Esbati, Drew Adams, Christopher Dimech, eliz@gnu.org,
	Help Gnu Emacs, carlmarcos@tutanota.com

I haven't really followed that thread, but IMO the `initial-input` arg
should be changed into `setup-function` (so we don't have to use the
hideous `minibuffer-with-setup-function` hack) and using a string there
should be deprecated (the rare places where inserting an initial string
makes sense can use a setup-function instead).

Also the prompt handling should be changed so that it automatically
inserts the default into the prompt.  Doing that in a reliable and
backward compatible way is not completely straightforward, tho, so maybe
a simpler solution is to introduce a whole new function instead.

Then a user-customization could also be used to choose between the
current default (where the default is added to the prompt) or the other
option of always inserting the default as initial value (pre-selected
so it can be deleted with a quick DEL).


        Stefan




^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23 12:12                 ` Arash Esbati
  2022-06-23 14:52                   ` Michael Heerdegen
@ 2022-06-23 21:06                   ` Emanuel Berg
  1 sibling, 0 replies; 73+ messages in thread
From: Emanuel Berg @ 2022-06-23 21:06 UTC (permalink / raw)
  To: help-gnu-emacs

Arash Esbati wrote:

> If you have a common prefix which should be shown in the
> candidates list, in (La)TeX for instance:
>
> (let ((list '("iffalse" "iftrue" "else" "fi")))
>   (completing-read "Macro: "
>                    (mapcar (lambda (x) (concat "\\" x)) list)
>                    nil nil "\\"))
>
> Something like this looks odd:
>
> (let ((list '("iffalse" "iftrue" "else" "fi")))
>   (completing-read "Macro: \\" list))

Neither looks good but the second is much less complicated and
error-prone and also more clear since there isn't the two nil
arguments.

If it is just about identifying a common and thus mandatory
prefix `completing-read' could just as well do it, the
alternatives could then all retain their intended and
complete form.

It's Thursday today, not (format "Thurs%s" shared-day-suffix)

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23 14:52                   ` Michael Heerdegen
@ 2022-06-23 21:07                     ` Emanuel Berg
  0 siblings, 0 replies; 73+ messages in thread
From: Emanuel Berg @ 2022-06-23 21:07 UTC (permalink / raw)
  To: help-gnu-emacs

Michael Heerdegen wrote:

> A convincing example, in my opinion.

But it's done manually when there isn't a reason to ...

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23 11:26                     ` Tassilo Horn
  2022-06-23 11:48                       ` carlmarcos--- via Users list for the GNU Emacs text editor
@ 2022-06-23 21:34                       ` Emanuel Berg
  1 sibling, 0 replies; 73+ messages in thread
From: Emanuel Berg @ 2022-06-23 21:34 UTC (permalink / raw)
  To: help-gnu-emacs

Tassilo Horn wrote:

>> It is useful there but only in terms on relying on
>> completion over a huge set of pretty much similar symbol
>> names which is a situation that shouldn't be encouraged to
>> begin with, and neither should completion BTW.
>
> Huh? Completion is a must especially when there are many and
> similar completions. Would you consider M-x/C-h {f,v,etc}
> without completion being a good user interface?

It's a good interface when the thing to be examined is
at point.

> Sure. But the thing is that people writing packages usually
> don't provide an option if INITIAL-INPUT should be used or
> not. Therefore, whatever choice they make is forced upon
> their users (well, unless the user knows of :filter-args
> advices). For that reason it makes sense to document
> a guideline on how to do things

Actually I already called it not to do that ...

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23 11:48                       ` carlmarcos--- via Users list for the GNU Emacs text editor
@ 2022-06-23 21:38                         ` Emanuel Berg
  2022-06-24  8:03                           ` Christopher Dimech
  0 siblings, 1 reply; 73+ messages in thread
From: Emanuel Berg @ 2022-06-23 21:38 UTC (permalink / raw)
  To: help-gnu-emacs

carlmarcos--- via Users list for the GNU Emacs text editor wrote:

> So now emacs is getting into the habit of trashing code by
> looking at written packages by figuring out what is not
> usually done by the majority? It is a bad strategy, to say
> the least. Even worse, it looks as if the documentation in
> putting in people's head that INITIAL-INPUT should not be
> used in any function where it is defined as an argument.

It's called techno-totalitarianism and even as we speak
computers all over the world are busy pushing it still further
and further, and eventually it'll be like an art of
perfection, almost.

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23 11:58                     ` Arash Esbati
  2022-06-23 12:10                       ` Lars Ingebrigtsen
@ 2022-06-23 21:42                       ` Emanuel Berg
  1 sibling, 0 replies; 73+ messages in thread
From: Emanuel Berg @ 2022-06-23 21:42 UTC (permalink / raw)
  To: help-gnu-emacs

Arash Esbati wrote:

>> I know but ... why are you telling me this?
>
> Because you asked? I parsed your question exactly the same
> way Tassilo did.

That's the problem with you people.

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23 12:10                       ` Lars Ingebrigtsen
  2022-06-23 14:26                         ` Tassilo Horn
@ 2022-06-23 21:49                         ` Emanuel Berg
  1 sibling, 0 replies; 73+ messages in thread
From: Emanuel Berg @ 2022-06-23 21:49 UTC (permalink / raw)
  To: help-gnu-emacs

Lars Ingebrigtsen wrote:

> Or rather:
>
> (let ((name "Danger"))
>   (read-string (format-prompt "Name" name) nil nil name))

+1

The code still doesn't look good tho with the double nil and
then 'name' again :$

So then maybe the middle name should be Overkill?

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23 20:58                 ` Arash Esbati
@ 2022-06-23 21:54                   ` Christopher Dimech
  2022-06-24  2:49                   ` Emanuel Berg
  1 sibling, 0 replies; 73+ messages in thread
From: Christopher Dimech @ 2022-06-23 21:54 UTC (permalink / raw)
  To: Arash Esbati
  Cc: Drew Adams, eliz@gnu.org, monnier@iro.umontreal.ca,
	Help Gnu Emacs, carlmarcos@tutanota.com, michael_heerdegen@web.de


> Sent: Friday, June 24, 2022 at 8:58 AM
> From: "Arash Esbati" <arash@gnu.org>
> To: "Drew Adams" <drew.adams@oracle.com>
> Cc: "Christopher Dimech" <dimech@gmx.com>, "eliz@gnu.org" <eliz@gnu.org>, "monnier@iro.umontreal.ca" <monnier@iro.umontreal.ca>, "Help Gnu Emacs" <help-gnu-emacs@gnu.org>, "carlmarcos@tutanota.com" <carlmarcos@tutanota.com>, "michael_heerdegen@web.de" <michael_heerdegen@web.de>
> Subject: Re: completing-read depricated initial-input
>
> Drew Adams <drew.adams@oracle.com> writes:
>
> >> Because extremely general tools give one many
> >> ways to do things.
> >
> > And?  Emacs and Elisp are all about giving us
> > many ways to do things.  They even give you lots
> > of rope to hang yourself with.
> >
> >> It is just hard if you find out afterwards that
> >> things went in the wrong direction and you try
> >> to clean up.  No other reason.
> >
> > Too general/abstract.  Can you elaborate with
> > some specifics?
>
> I don't have any specific example in my mind, I was also thinking about
> what you said above about the rope and hang yourself.
>
> > No one's obliged to use the very general function
> > `completing-read'.  And no one's obliged to use
> > it with a non-nil INITIAL-INPUT arg.
>
> Agreed.
>
> But in terms of coming to some sort of conclusion: This thread started
> with the question:
>
>   When do you plan to remove the `INITIAL-INPUT` argument from
>   `completing-read`?
>
> I think the answer is: This will not happen, so don't worry.

The bigger problem is really about whether the functionality associated with
INITIAL-INPUT will end?

> If so, is the docstring of `completing-read' inaccurate or misleading?
> If so, should there be a bug report and/or a change suggestion?
>
> WDYT?
>
> Best, Arash
>



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23 21:05                 ` Stefan Monnier
@ 2022-06-23 22:10                   ` Christopher Dimech
  2022-06-23 22:19                     ` Stefan Monnier
  2022-06-24  7:08                     ` Jean Louis
  2022-06-24  2:29                   ` Emanuel Berg
  1 sibling, 2 replies; 73+ messages in thread
From: Christopher Dimech @ 2022-06-23 22:10 UTC (permalink / raw)
  To: Stefan Monnier
  Cc: Michael Heerdegen, Arash Esbati, Drew Adams, eliz@gnu.org,
	Help Gnu Emacs, carlmarcos@tutanota.com



> Sent: Friday, June 24, 2022 at 9:05 AM
> From: "Stefan Monnier" <monnier@iro.umontreal.ca>
> To: "Michael Heerdegen" <michael_heerdegen@web.de>
> Cc: "Arash Esbati" <arash@gnu.org>, "Drew Adams" <drew.adams@oracle.com>, "Christopher Dimech" <dimech@gmx.com>, "eliz@gnu.org" <eliz@gnu.org>, "Help Gnu Emacs" <help-gnu-emacs@gnu.org>, "carlmarcos@tutanota.com" <carlmarcos@tutanota.com>
> Subject: Re: completing-read depricated initial-input
>
> I haven't really followed that thread, but IMO the `initial-input` arg
> should be changed into `setup-function` (so we don't have to use the
> hideous `minibuffer-with-setup-function` hack) and using a string there
> should be deprecated (the rare places where inserting an initial string
> makes sense can use a setup-function instead).
>
> Also the prompt handling should be changed so that it automatically
> inserts the default into the prompt.  Doing that in a reliable and
> backward compatible way is not completely straightforward, tho, so maybe
> a simpler solution is to introduce a whole new function instead.
>
> Then a user-customization could also be used to choose between the
> current default (where the default is added to the prompt) or the other
> option of always inserting the default as initial value (pre-selected
> so it can be deleted with a quick DEL).
>

Inserting default would make sense.  We should not continue with the
initial-value name then.  Stating that DEF will be displayed  as first
instance.  Making things smoother and clearer to understand.



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23 22:10                   ` Christopher Dimech
@ 2022-06-23 22:19                     ` Stefan Monnier
  2022-06-23 22:28                       ` Christopher Dimech
  2022-06-24  7:08                     ` Jean Louis
  1 sibling, 1 reply; 73+ messages in thread
From: Stefan Monnier @ 2022-06-23 22:19 UTC (permalink / raw)
  To: Christopher Dimech
  Cc: Michael Heerdegen, Arash Esbati, Drew Adams, eliz@gnu.org,
	Help Gnu Emacs, carlmarcos@tutanota.com

> Inserting default would make sense.

That depends on the UI we want to provide.

So it shouldn't be part of the API but instead part of the user customizations.


        Stefan




^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23 22:19                     ` Stefan Monnier
@ 2022-06-23 22:28                       ` Christopher Dimech
  0 siblings, 0 replies; 73+ messages in thread
From: Christopher Dimech @ 2022-06-23 22:28 UTC (permalink / raw)
  To: Stefan Monnier
  Cc: Michael Heerdegen, Arash Esbati, Drew Adams, eliz@gnu.org,
	Help Gnu Emacs, carlmarcos@tutanota.com



> Sent: Friday, June 24, 2022 at 10:19 AM
> From: "Stefan Monnier" <monnier@iro.umontreal.ca>
> To: "Christopher Dimech" <dimech@gmx.com>
> Cc: "Michael Heerdegen" <michael_heerdegen@web.de>, "Arash Esbati" <arash@gnu.org>, "Drew Adams" <drew.adams@oracle.com>, "eliz@gnu.org" <eliz@gnu.org>, "Help Gnu Emacs" <help-gnu-emacs@gnu.org>, "carlmarcos@tutanota.com" <carlmarcos@tutanota.com>
> Subject: Re: completing-read depricated initial-input
>
> > Inserting default would make sense.
>
> That depends on the UI we want to provide.
>
> So it shouldn't be part of the API but instead part of the user customizations.
>
> Stefan

I'll agree with that.  Just do not have initial-input and def working interchangeably.
It only leads to bad or tricky habits.





^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23 14:26                         ` Tassilo Horn
  2022-06-23 14:46                           ` Arash Esbati
@ 2022-06-24  2:17                           ` Emanuel Berg
  1 sibling, 0 replies; 73+ messages in thread
From: Emanuel Berg @ 2022-06-24  2:17 UTC (permalink / raw)
  To: help-gnu-emacs

Tassilo Horn wrote:

>> (let ((name "Danger"))
>>   (read-string (format-prompt "Name" name) nil nil name))
>
> Nice!

Actually no, try to replace existing code with that ... It's
the two occurrences of name (above) that makes it clumsy
and ugly.

Also this is not needed functionally, it's logical that it
isn't but as an example see for example `read-number' which
already does this for you. Eval this:

  (read-number "pills/day: "  4)

S0 why not `read-string' as well?

However - one can do one's own function for that ...

(defun read-string-1 (ps &optional def hist)
  (setq ps (format-prompt ps def))
  (read-string ps nil hist def))
  
(read-string-1 "name" "Danger")

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23 14:46                           ` Arash Esbati
  2022-06-23 15:18                             ` Robert Pluim
@ 2022-06-24  2:22                             ` Emanuel Berg
  1 sibling, 0 replies; 73+ messages in thread
From: Emanuel Berg @ 2022-06-24  2:22 UTC (permalink / raw)
  To: help-gnu-emacs

Arash Esbati wrote:

> Indeed, and the best part of it is
> `minibuffer-default-prompt-format' which you can customize.

Oh, excellent!

Instant

  (setq minibuffer-default-prompt-format " [%s]")

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23 21:05                 ` Stefan Monnier
  2022-06-23 22:10                   ` Christopher Dimech
@ 2022-06-24  2:29                   ` Emanuel Berg
  1 sibling, 0 replies; 73+ messages in thread
From: Emanuel Berg @ 2022-06-24  2:29 UTC (permalink / raw)
  To: help-gnu-emacs

Stefan Monnier wrote:

> I haven't really followed that thread, but IMO the
> `initial-input` arg should be changed into `setup-function`
> (so we don't have to use the hideous
> `minibuffer-with-setup-function` hack) and using a string
> there should be deprecated (the rare places where inserting
> an initial string makes sense can use a setup-function
> instead).

I thought about that to, good idea but if so move the
'setup-fun' formal parameter to the right of 'def' so there
don't have to be nil in between all the time in Elisp code,
because to have/want a default value will be much more common.

> Also the prompt handling should be changed so that it
> automatically inserts the default into the prompt.

100%, and not just that, everything and anything that can be
automated one should never leave to a human, programmer or
not ...

> Doing that in a reliable and backward compatible way is not
> completely straightforward, tho, so maybe a simpler solution
> is to introduce a whole new function instead.

Right.

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23 14:36                 ` Jean Louis
@ 2022-06-24  2:35                   ` Emanuel Berg
  2022-06-24  6:59                     ` Jean Louis
  0 siblings, 1 reply; 73+ messages in thread
From: Emanuel Berg @ 2022-06-24  2:35 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

> ;; (rcd-ask-times 3 "Query: ") ⇒ ("Emmanuel" "Berg" "Sweden")

Haha :)

Emanuel is history for sure. But does that mean Jean
is psycho?

From what novel series?

  - I'm psycho.

  - I'm history.

https://www.quora.com/Isaac-Asimov-gave-the-world-an-introduction-to-psycho-history-What-is-your-take-on-the-subject

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23 20:58                 ` Arash Esbati
  2022-06-23 21:54                   ` Christopher Dimech
@ 2022-06-24  2:49                   ` Emanuel Berg
  1 sibling, 0 replies; 73+ messages in thread
From: Emanuel Berg @ 2022-06-24  2:49 UTC (permalink / raw)
  To: help-gnu-emacs

Arash Esbati wrote:

> in terms of coming to some sort of conclusion: This thread
> started with the question:

Arash, do you know what animal is the least predictable?

Answer: https://www.youtube.com/watch?v=L5sQYUFGAc0

>   When do you plan to remove the `INITIAL-INPUT` argument from
>   `completing-read`?
>
> I think the answer is: This will not happen, so don't worry.

It will be obliterated.

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-24  2:35                   ` Emanuel Berg
@ 2022-06-24  6:59                     ` Jean Louis
  0 siblings, 0 replies; 73+ messages in thread
From: Jean Louis @ 2022-06-24  6:59 UTC (permalink / raw)
  To: help-gnu-emacs

* Emanuel Berg <incal@dataswamp.org> [2022-06-24 05:37]:
> Jean Louis wrote:
> 
> > ;; (rcd-ask-times 3 "Query: ") ⇒ ("Emmanuel" "Berg" "Sweden")
> 
> Haha :)
> 
> Emanuel is history for sure. But does that mean Jean
> is psycho?
> 
> From what novel series?
> 
>   - I'm psycho.
> 
>   - I'm history.

I knew you will get the joke.

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23 22:10                   ` Christopher Dimech
  2022-06-23 22:19                     ` Stefan Monnier
@ 2022-06-24  7:08                     ` Jean Louis
  2022-06-24  8:19                       ` Christopher Dimech
  2022-06-24  8:19                       ` Emanuel Berg
  1 sibling, 2 replies; 73+ messages in thread
From: Jean Louis @ 2022-06-24  7:08 UTC (permalink / raw)
  To: Christopher Dimech
  Cc: Stefan Monnier, Michael Heerdegen, Arash Esbati, Drew Adams,
	eliz@gnu.org, Help Gnu Emacs, carlmarcos@tutanota.com

* Christopher Dimech <dimech@gmx.com> [2022-06-24 01:11]:
> Inserting default would make sense.  We should not continue with the
> initial-value name then.  Stating that DEF will be displayed  as first
> instance.  Making things smoother and clearer to understand.

I do not find it so. I do not say how function works, but I wish
 to say what I expect as user. 

How I understand the "default" is that it should be the value
that function gives as result in case when user does not write
anything else, hits enter.

However, it does not work this way with `read-from-minibuffer',
so I will file bug report.

(read-from-minibuffer "Your name: " nil nil nil nil "Jean") ⇒ ""

However, in this function it does work the expected way:

(completing-read "Your name: " '("Jean" "Emmanuel" "Adebayo") nil nil nil nil "Jean") ⇒ "Jean"

(completing-read "Your name: " '("Jean" "Emmanuel" "Adebayo") nil nil nil nil "Adebayo") ⇒ "Adebayo"

So I have filed bug report today, as that is not consistent behavior.

Initial input is something else, that is something I wish to
see there in front of me, ready to be chosen by pressing enter.

Those are totally different events. 

1) I maybe do not want to show any initial input, but if I press
   enter, I need my default

2) I maybe want to show the initial input, but if I delete it and
   press enter with empty string, I still need my default, which may
   be different from initial input.

For me it would be rather damaging to remove initial input as I do
work with it often, there are people employed working with it, it
would affect the business.

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23 21:38                         ` Emanuel Berg
@ 2022-06-24  8:03                           ` Christopher Dimech
  0 siblings, 0 replies; 73+ messages in thread
From: Christopher Dimech @ 2022-06-24  8:03 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: help-gnu-emacs


> Sent: Friday, June 24, 2022 at 9:38 AM
> From: "Emanuel Berg" <incal@dataswamp.org>
> To: help-gnu-emacs@gnu.org
> Subject: Re: completing-read depricated initial-input
>
> carlmarcos--- via Users list for the GNU Emacs text editor wrote:
>
> > So now emacs is getting into the habit of trashing code by
> > looking at written packages by figuring out what is not
> > usually done by the majority? It is a bad strategy, to say
> > the least. Even worse, it looks as if the documentation in
> > putting in people's head that INITIAL-INPUT should not be
> > used in any function where it is defined as an argument.
>
> It's called techno-totalitarianism and even as we speak
> computers all over the world are busy pushing it still further
> and further, and eventually it'll be like an art of
> perfection, almost.
>
> --
> underground experts united
> https://dataswamp.org/~incal

Right.  Ending up with a robot like Sofia that you can't screw.
But she'll screw you.



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-24  7:08                     ` Jean Louis
@ 2022-06-24  8:19                       ` Christopher Dimech
  2022-06-24 11:00                         ` Jean Louis
  2022-06-24  8:19                       ` Emanuel Berg
  1 sibling, 1 reply; 73+ messages in thread
From: Christopher Dimech @ 2022-06-24  8:19 UTC (permalink / raw)
  To: Jean Louis
  Cc: Stefan Monnier, Michael Heerdegen, Arash Esbati, Drew Adams,
	eliz@gnu.org, Help Gnu Emacs, carlmarcos@tutanota.com



> Sent: Friday, June 24, 2022 at 7:08 PM
> From: "Jean Louis" <bugs@gnu.support>
> To: "Christopher Dimech" <dimech@gmx.com>
> Cc: "Stefan Monnier" <monnier@iro.umontreal.ca>, "Michael Heerdegen" <michael_heerdegen@web.de>, "Arash Esbati" <arash@gnu.org>, "Drew Adams" <drew.adams@oracle.com>, "eliz@gnu.org" <eliz@gnu.org>, "Help Gnu Emacs" <help-gnu-emacs@gnu.org>, "carlmarcos@tutanota.com" <carlmarcos@tutanota.com>
> Subject: Re: completing-read depricated initial-input
>
> * Christopher Dimech <dimech@gmx.com> [2022-06-24 01:11]:
> > Inserting default would make sense.  We should not continue with the
> > initial-value name then.  Stating that DEF will be displayed  as first
> > instance.  Making things smoother and clearer to understand.
> 
> I do not find it so. I do not say how function works, but I wish
>  to say what I expect as user. 
> 
> How I understand the "default" is that it should be the value
> that function gives as result in case when user does not write
> anything else, hits enter.

That how it should be understood
 
> However, it does not work this way with `read-from-minibuffer',
> so I will file bug report.
> 
> (read-from-minibuffer "Your name: " nil nil nil nil "Jean") ⇒ ""
> 
> However, in this function it does work the expected way:
> 
> (completing-read "Your name: " '("Jean" "Emmanuel" "Adebayo") nil nil nil nil "Jean") ⇒ "Jean"
> 
> (completing-read "Your name: " '("Jean" "Emmanuel" "Adebayo") nil nil nil nil "Adebayo") ⇒ "Adebayo"
> 
> So I have filed bug report today, as that is not consistent behavior.
> 
> Initial input is something else, that is something I wish to
> see there in front of me, ready to be chosen by pressing enter.
> 
> Those are totally different events. 
> 
> 1) I maybe do not want to show any initial input, but if I press
>    enter, I need my default
> 
> 2) I maybe want to show the initial input, but if I delete it and
>    press enter with empty string, I still need my default, which may
>    be different from initial input.
> 
> For me it would be rather damaging to remove initial input as I do
> work with it often, there are people employed working with it, it
> would affect the business.
> 
> -- 
> Jean

I agree Jean, but it looks like the reasoning is taking a long discussion
to be appreciated.  initial-value is not related to a default or anything
but on what gets displayed as soon an you enter minibuffer read.




^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-24  7:08                     ` Jean Louis
  2022-06-24  8:19                       ` Christopher Dimech
@ 2022-06-24  8:19                       ` Emanuel Berg
  2022-06-24 11:31                         ` Jean Louis
  1 sibling, 1 reply; 73+ messages in thread
From: Emanuel Berg @ 2022-06-24  8:19 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

> (read-from-minibuffer "Your name: " nil nil nil nil "Jean")

Holy cow, there's no need to hard code that! What if you were
to change your name (nom de guerre if you wish) for romantic
and/or conspiratorial reasons? Use `user-full-name'
instead ...

(BTW 4 nil in a row. How many do you need to strike
the jackpot?)

>> Inserting default would make sense. We should not continue
>> with the initial-value name then. Stating that DEF will be
>> displayed as first instance. Making things smoother and
>> clearer to understand.
>
> I do not find it so. I do not say how function works, but
> I wish to say what I expect as user.

We have been thinking of it in very practical terms so far.

I already asked, what concept is the initial value? I'm not
aware of any such concept in this context. One can think of
several UIs (including GUIs) where the initial value has been
inserted to communicate the default value, and enable -
transparently, even - for the user to submit this value.
In that sense, it isn't that bad: the default value is shown
loud and clear, it can be edited and when its submitted this
happens with the same method so no extras in terms of
technology at that end.

However ...

We don't want that for the default value so all that doesn't
matter anymore (or to us).

If we look at it from even further away the initial value
makes even less sense. "Why is the computer putting stuff
there? It's the area where the human user should put stuff."

So in general it doesn't make sense, specifically it _could_
make sense but it doesn't since we have another, better method
for that.

There is only one use case (completion with a common prefix)
however that can either be automated _or_ solved with the
default method _and_ relying on completion to navigate huge
search spaces of similar members, that's a poor situation to
begin with, maybe it gets mildly better with completion but
that's obviously nothing to base general policy on.

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-23 20:46                               ` Arash Esbati
@ 2022-06-24  8:40                                 ` Philip Kaludercic
  0 siblings, 0 replies; 73+ messages in thread
From: Philip Kaludercic @ 2022-06-24  8:40 UTC (permalink / raw)
  To: Arash Esbati
  Cc: Robert Pluim, Tassilo Horn, Lars Ingebrigtsen, help-gnu-emacs

Arash Esbati <arash@gnu.org> writes:

> Robert Pluim <rpluim@gmail.com> writes:
>
>>>>>>> On Thu, 23 Jun 2022 16:46:53 +0200, Arash Esbati <arash@gnu.org> said:
>>
>>     Arash> I'd say it's up to the AUCTeX maintainers to bump the minimum required
>>     Arash> Emacs version at a faster pace ;-)
>>
>> Either that, or they can depend on the 'compat' package, and then just
>> use emacs-28 features with wild abandon.
>
> Thanks for reminding me of compat.  I think compat-28.el has currently a
> bug since the return value of `format-prompt' is not the same as in
> Emacs>=28:
>
> (format-prompt "Foo" "")
> => "Foo: "
>
> This is what compat-28.el does:
>
> (defun compat-format-prompt (prompt default &rest format-args)
>   "Format PROMPT with DEFAULT.
> If FORMAT-ARGS is nil, PROMPT is used as a plain string.  If
> FORMAT-ARGS is non-nil, PROMPT is used as a format control
> string, and FORMAT-ARGS are the arguments to be substituted into
> it.  See `format' for details.
>
> If DEFAULT is a list, the first element is used as the default.
> If not, the element is used as is.
>
> If DEFAULT is nil or an empty string, no \"default value\" string
> is included in the return value."
>   (concat
>    (if (null format-args)
>        prompt
>      (apply #'format prompt format-args))
>    (and default
>         (or (not (stringp default))
>             (not (null default)))
>         ;;  (length> default 0) ; This is in Emacs stock version
>         (format " (default %s)"
>                 (if (consp default)
>                     (car default)
>                   default)))
>    ": "))
>
> (compat-format-prompt "Foo" "")
> => "Foo (default ): "
>
> compat doesn't check if DEFAULT is an empty string.  I'm CC'ing Philip,
> maybe he can comment.

You are right, this is a bug.  When "reimplementing" format-prompt with
backwards compatibility in mind, I replaced the (length> default 0) with
(not (null default)).  This would work on lists, but not on arrays.  I
have replaced it and updated the tests.

> Best, Arash



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-24  8:19                       ` Christopher Dimech
@ 2022-06-24 11:00                         ` Jean Louis
  2022-06-24 16:58                           ` Christopher Dimech
  0 siblings, 1 reply; 73+ messages in thread
From: Jean Louis @ 2022-06-24 11:00 UTC (permalink / raw)
  To: Christopher Dimech; +Cc: help-gnu-emacs

* Christopher Dimech <dimech@gmx.com> [2022-06-24 11:19]:
> I agree Jean, but it looks like the reasoning is taking a long
> discussion to be appreciated.  initial-value is not related to a
> default or anything but on what gets displayed as soon an you enter
> minibuffer read.

That is true, and I am well aware of it, just I do not understand why
you do not understand that I am well aware of it... 👀


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-24  8:19                       ` Emanuel Berg
@ 2022-06-24 11:31                         ` Jean Louis
  2022-06-25 18:54                           ` Emanuel Berg
  0 siblings, 1 reply; 73+ messages in thread
From: Jean Louis @ 2022-06-24 11:31 UTC (permalink / raw)
  To: help-gnu-emacs

* Emanuel Berg <incal@dataswamp.org> [2022-06-24 11:26]:
> Jean Louis wrote:
> 
> > (read-from-minibuffer "Your name: " nil nil nil nil "Jean")
> 
> Holy cow, there's no need to hard code that! What if you were
> to change your name (nom de guerre if you wish) for romantic
> and/or conspiratorial reasons? Use `user-full-name'
> instead ...

Which name? That is not name, that is:

1. jean, blue jean, denim -- ((usually plural) close-fitting trousers of heavy denim for manual work or casual wear)

Jokes aside... 👁️

> >> Inserting default would make sense. We should not continue
> >> with the initial-value name then. Stating that DEF will be
> >> displayed as first instance. Making things smoother and
> >> clearer to understand.
> >
> > I do not find it so. I do not say how function works, but
> > I wish to say what I expect as user.
> 
> We have been thinking of it in very practical terms so far.
> 
> I already asked, what concept is the initial value? I'm not
> aware of any such concept in this context. One can think of
> several UIs (including GUIs) where the initial value has been
> inserted to communicate the default value, and enable -
> transparently, even - for the user to submit this value.
> In that sense, it isn't that bad: the default value is shown
> loud and clear, it can be edited and when its submitted this
> happens with the same method so no extras in terms of
> technology at that end.

It is my sincere hope you will understand the difference between those
two.

1) Default is what will be chosen if use press enter, regardless if
   user sees that default or not. That is my expectation, but
   read-from-minibuffer in development version does not behave this
   way. 

   Personally I have heavy uses of defaults, such as "Default address"
   while some addresses are rather different "Work address" or
   "Temporary address". I need default address, thus it is usable for
   me. 

2) Initial value is usable as it is visible and makes it easier to
   make the choice, but it is not necessarily default.

   My personal example is that some people have one address in
   Germany, other in Austria, but one of those addresses is default
   (this word now has no relation to Emacs). If letter has been sent
   last 2 times to Austria, system can recognize it and offer such as
   initial input. But if Austria is not choosen, or if nothing in
   particular has been seen in the prompt and user hits RET, then
   default German address would be choosen.

   Another example is that I am entering phone numbers every
   day. Communication line is "Phone" but type is "Default", which
   means nothing in particular. However, I start entering many mobile
   numbers, than I appreciate that system looks in past and offers me
   "Mobile" as initial input, just to press enter, while my Default
   would be choosen if I delete it and press enter on empty
   minibuffer.

   ┌───────────────────────┬────────┐
   │ Addreses in last year │ Count  │
   ├───────────────────────┼────────┤
   │ Addresses             │ 197299 │
   └───────────────────────┴────────┘

   The above personal example I go through many times per day.

   In my example I do not use initial-value to communicate default,
   but to communicate the choice which could be more probable based on
   last information. That choice may be dynamically chosen, it is not
   hard code.

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-24 11:00                         ` Jean Louis
@ 2022-06-24 16:58                           ` Christopher Dimech
  0 siblings, 0 replies; 73+ messages in thread
From: Christopher Dimech @ 2022-06-24 16:58 UTC (permalink / raw)
  To: Jean Louis; +Cc: help-gnu-emacs


> Sent: Friday, June 24, 2022 at 11:00 PM
> From: "Jean Louis" <bugs@gnu.support>
> To: "Christopher Dimech" <dimech@gmx.com>
> Cc: help-gnu-emacs@gnu.org
> Subject: Re: completing-read depricated initial-input
>
> * Christopher Dimech <dimech@gmx.com> [2022-06-24 11:19]:
> > I agree Jean, but it looks like the reasoning is taking a long
> > discussion to be appreciated.  initial-value is not related to a
> > default or anything but on what gets displayed as soon an you enter
> > minibuffer read.
> 
> That is true, and I am well aware of it, just I do not understand why
> you do not understand that I am well aware of it... 👀
> 
> Jean
 
The comment was for people reading the list whilst interacting with you
regarding your clear thinking.



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-24 11:31                         ` Jean Louis
@ 2022-06-25 18:54                           ` Emanuel Berg
  2022-06-25 19:51                             ` Jean Louis
  0 siblings, 1 reply; 73+ messages in thread
From: Emanuel Berg @ 2022-06-25 18:54 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

> Initial value is usable as it is visible and makes it easier
> to make the choice, but it is not necessarily default.
>
> My personal example is that some people have one address in
> Germany, other in Austria, but one of those addresses is
> default (this word now has no relation to Emacs). If letter
> has been sent last 2 times to Austria, system can recognize
> it and offer such as initial input.

That's something similar to a cache memory which is based on
the principle of spacial and temporal proximity, I still don't
see why whatever suggestion it comes up with isn't then the
default value simply?

It is shown and if you want to edit it first, it is inserted
with M-n.

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-25 18:54                           ` Emanuel Berg
@ 2022-06-25 19:51                             ` Jean Louis
  2022-06-26 17:36                               ` Emanuel Berg
  0 siblings, 1 reply; 73+ messages in thread
From: Jean Louis @ 2022-06-25 19:51 UTC (permalink / raw)
  To: help-gnu-emacs

* Emanuel Berg <incal@dataswamp.org> [2022-06-25 21:56]:
> Jean Louis wrote:
> 
> > Initial value is usable as it is visible and makes it easier
> > to make the choice, but it is not necessarily default.
> >
> > My personal example is that some people have one address in
> > Germany, other in Austria, but one of those addresses is
> > default (this word now has no relation to Emacs). If letter
> > has been sent last 2 times to Austria, system can recognize
> > it and offer such as initial input.
> 
> That's something similar to a cache memory which is based on
> the principle of spacial and temporal proximity, I still don't
> see why whatever suggestion it comes up with isn't then the
> default value simply?
> 
> It is shown and if you want to edit it first, it is inserted
> with M-n.

True. For few entries that is fine. M-n once or multiple times or M-p
followed by RET. Imagine 20 entries per day, that is just fine.

When you have many entries it is easier to press RET. Imagine 500
entries per day. It's faster.


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



^ permalink raw reply	[flat|nested] 73+ messages in thread

* Re: completing-read depricated initial-input
  2022-06-25 19:51                             ` Jean Louis
@ 2022-06-26 17:36                               ` Emanuel Berg
  0 siblings, 0 replies; 73+ messages in thread
From: Emanuel Berg @ 2022-06-26 17:36 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

>> That's something similar to a cache memory which is based
>> on the principle of spacial and temporal proximity, I still
>> don't see why whatever suggestion it comes up with isn't
>> then the default value simply?
>> 
>> It is shown and if you want to edit it first, it is
>> inserted with M-n.
>
> True. For few entries that is fine. M-n once or multiple
> times or M-p followed by RET. Imagine 20 entries per day,
> that is just fine.
>
> When you have many entries it is easier to press RET.
> Imagine 500 entries per day. It's faster.

If you want it all the time you should rather have a variable
for that instead of sending it twice to the function.
That'd be even faster. And make more sense.

And if you do it 500 times a day you should write a program and
automate it completely instead of relying on little clever
shortcuts here and there ...

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 73+ messages in thread

end of thread, other threads:[~2022-06-26 17:36 UTC | newest]

Thread overview: 73+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-21 14:56 completing-read depricated initial-input Anders Munch
2022-06-22  8:45 ` Jean Louis
  -- strict thread matches above, loose matches on Subject: below --
2022-06-22 13:43 Anders Munch
2022-06-22 13:17 Anders Munch
2022-06-22 10:02 Anders Munch
2022-06-22 11:58 ` Emanuel Berg
2022-06-22 13:23 ` Eli Zaretskii
2022-06-21  7:56 carlmarcos--- via Users list for the GNU Emacs text editor
     [not found] ` <N54Fw5q--3-2@tutanota.com-N54INof----2>
2022-06-21  9:51   ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-06-21 11:19     ` Michael Heerdegen
2022-06-21 12:39       ` Emanuel Berg
2022-06-21 12:46         ` Michael Heerdegen
2022-06-22  8:50     ` Jean Louis
2022-06-22  9:32       ` Emanuel Berg
2022-06-21 10:26 ` Robert Pluim
2022-06-21 11:15   ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-06-21 12:39 ` Christopher Dimech
2022-06-21 14:09   ` [External] : " Drew Adams
2022-06-21 18:21     ` Arash Esbati
2022-06-21 19:04       ` Emanuel Berg
2022-06-21 20:41       ` [External] : " Drew Adams
2022-06-21 21:28         ` Arash Esbati
2022-06-21 22:07           ` [External] : " Drew Adams
2022-06-23  7:59             ` Arash Esbati
2022-06-23 10:06               ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-06-23 20:57                 ` Emanuel Berg
2022-06-23 11:19               ` Michael Heerdegen
2022-06-23 12:12                 ` Arash Esbati
2022-06-23 14:52                   ` Michael Heerdegen
2022-06-23 21:07                     ` Emanuel Berg
2022-06-23 21:06                   ` Emanuel Berg
2022-06-23 14:36                 ` Jean Louis
2022-06-24  2:35                   ` Emanuel Berg
2022-06-24  6:59                     ` Jean Louis
2022-06-23 15:19                 ` Jean Louis
2022-06-23 15:24                 ` Jean Louis
2022-06-23 21:05                 ` Stefan Monnier
2022-06-23 22:10                   ` Christopher Dimech
2022-06-23 22:19                     ` Stefan Monnier
2022-06-23 22:28                       ` Christopher Dimech
2022-06-24  7:08                     ` Jean Louis
2022-06-24  8:19                       ` Christopher Dimech
2022-06-24 11:00                         ` Jean Louis
2022-06-24 16:58                           ` Christopher Dimech
2022-06-24  8:19                       ` Emanuel Berg
2022-06-24 11:31                         ` Jean Louis
2022-06-25 18:54                           ` Emanuel Berg
2022-06-25 19:51                             ` Jean Louis
2022-06-26 17:36                               ` Emanuel Berg
2022-06-24  2:29                   ` Emanuel Berg
2022-06-23 16:23               ` [External] : " Drew Adams
2022-06-23 20:58                 ` Arash Esbati
2022-06-23 21:54                   ` Christopher Dimech
2022-06-24  2:49                   ` Emanuel Berg
2022-06-22  3:09           ` Po Lu
2022-06-22  3:46             ` Emanuel Berg
2022-06-22  4:56             ` Christopher Dimech
2022-06-23  8:20             ` Arash Esbati
2022-06-23  8:27               ` Emanuel Berg
2022-06-23  8:57                 ` Tassilo Horn
2022-06-23 10:10                   ` Emanuel Berg
2022-06-23 11:26                     ` Tassilo Horn
2022-06-23 11:48                       ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-06-23 21:38                         ` Emanuel Berg
2022-06-24  8:03                           ` Christopher Dimech
2022-06-23 21:34                       ` Emanuel Berg
2022-06-23 11:58                     ` Arash Esbati
2022-06-23 12:10                       ` Lars Ingebrigtsen
2022-06-23 14:26                         ` Tassilo Horn
2022-06-23 14:46                           ` Arash Esbati
2022-06-23 15:18                             ` Robert Pluim
2022-06-23 20:46                               ` Arash Esbati
2022-06-24  8:40                                 ` Philip Kaludercic
2022-06-24  2:22                             ` Emanuel Berg
2022-06-24  2:17                           ` Emanuel Berg
2022-06-23 21:49                         ` Emanuel Berg
2022-06-23 21:42                       ` Emanuel Berg

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).