[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [BUG] org-insert-link should use DEFAULT in read-string when asking
Re: [BUG] org-insert-link should use DEFAULT in read-string when asking for description
Sun, 27 Feb 2022 21:46:02 +0530
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
[ Please keep me in the CCs since I don't follow the list. ]
[ஞாயிறு, பிப்ரவரி 27 2022] Max Nikulin wrote:
> On 26/02/2022 21:16, Visuwesh wrote:
>> [சனி, பிப்ரவரி 26 2022] Max Nikulin wrote:
>>> Are you suggesting replacing
>>> (read-string "rs-initial: " "Some initial")
>>> (read-string "rs-default: " nil nil "Some default")
>> Yes, exactly.
> However you agreed that it would be regression since empty description
> use case would be impossible.
No. It is impossible to do it using read-string, but it is possible to
do it by writing a function that calls read-from-minibuffer (and I gave
an example of a function that does this).
>> I admit that I forgot about this but Emacs can be made to not translate
>> empty string to the default argument if you DTRT when calling
>> `read-from-minibuffer' (and `read-shell-command' does this). If writing
>> a new function just to get this functionality is too much, then I guess
> `read-shell-command' still has INITIAL argument and it is used by
> various callers (vc, grep). In addition, unlike for link description,
> I do not see any point in empty shell command (e.g. in vim :! allows
> to see output of previous shell command). So `read-shell-command' may
> behave quite differently.
1. I dislike grep's behaviour. However, I understand why grep
behaves the way it does. It makes far more sense to use the
INITIAL argument in grep, but I don't see the same for
[ In grep, you rarely ever need to change the initial input. ]
2. The reason why I cited read-shell-command does not have anything
to do with the usefulness of empty string (or shell command). I
merely wanted to point out that you can have BOTH the DEFAULT
argument (and no INITIAL), and can make the empty string a valid
output from the function (i.e., without getting substituted by
the DEFAULT argument).
I hope (2) makes sense. I'm struggling to word it.
> Current way to ask for link description has the following properties:
> - Almost no action (just RET) if the user happy with suggested
> description. Default description is provided with hope that it is
> the most convenient option.
> - It is possible to erase everything and to get a link with no description.
> - The user is free to replace default description with arbitrary
> alternative text.
> It is unclear for me how to tame `read-from-minibuffer' to get equally
> convenient behavior using DEFAULT argument instead of formally
> deprecated INITIAL one.
Please read the docstring of read-from-minibuffer. You would be better
served by reading it than me replicating it here. And I gave
read-shell-command as an example so others could study the function.
In essence, you can get the old behaviour (1) but you need to type M-n
beforehand. Its one more key but it is far better than the current
behaviour since it is consistent with rest of the Emacs ecosystem (see
>> I can live with the current behaviour, but this inconsistency is an
>> annoyance since I end up with garbled link names, which I only notice
> Sorry, but I have not figured out what particular problem you met.
Inconsistency is the problem. org-insert-link breaks my muscle memory.
I am not sure if you use the default completion system, but if you do,
org-insert-link sticks out by being intrusive.
With every command I use, when I know that the DEFAULT argument will be
of no use, I simply start typing. However, with org-insert-link I have
to clear the input _first_ then start typing. This never happens
elsewhere, even in grep (which you cite as an example)!