|
From: | Max Nikulin |
Subject: | Re: [BUG] org-insert-link should use DEFAULT in read-string when asking for description |
Date: | Tue, 1 Mar 2022 23:36:02 +0700 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 |
On 27/02/2022 23:16, Visuwesh wrote:
[ஞாயிறு, பிப்ரவரி 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") by (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 guess2. 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).
In my opinion deprecation of the INITIAL argument without some descent replacement was a mistake. I suspect that such statement appeared without realizing of the problem with discriminating default vs. empty value. `read-string' oversimplify it by assumption that users do not need empty values at all. Your first argument was that INITIAL is deprecated but in the next message you pointed to a function that still uses the INITIAL argument. On the other hand `read-shell-command' belongs to command for which empty return value is hardly meaningful despite it is possible. That is why I disputed that `read-shell-command' is a good example of `read-from-minibuffer' usage in the context of `org-insert-link'.
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 below also).
I do not think it is a good idea to require extra M-n to keep the *current* description when a user hit C-c C-l to edit the link target with no intention to touch its description.
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)!
I agree that it is great to be able to just start typing to replace default description. Unfortunately similar to significant fraction of interfaces, `org-insert-link' behavior is a result of trade-offs and compromises. If you see a way to improve it, please, submit a patch or at least post a code that can be tried from a src block or from the *scratch* buffer to evaluate possible regressions and unaddressed use cases.
[Prev in Thread] | Current Thread | [Next in Thread] |