all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Visuwesh <visuweshm@gmail.com>
To: Max Nikulin <manikulin@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [BUG] org-insert-link should use DEFAULT in read-string when asking for description
Date: Sun, 27 Feb 2022 21:46:02 +0530	[thread overview]
Message-ID: <877d9g5lq5.fsf@gmail.com> (raw)
In-Reply-To: <svfkuf$17i5$1@ciao.gmane.io> (Max Nikulin's message of "Sun, 27 Feb 2022 17:48:45 +0700")

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

Two things:

    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
       org-insert-link.

       [ 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
below also).

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


  reply	other threads:[~2022-02-27 16:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-25 14:19 [BUG] org-insert-link should use DEFAULT in read-string when asking for description Visuwesh
2022-02-26  8:50 ` Max Nikulin
2022-02-26 14:16   ` Visuwesh
2022-02-27 10:48     ` Max Nikulin
2022-02-27 16:16       ` Visuwesh [this message]
2022-03-01 16:36         ` Max Nikulin

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=877d9g5lq5.fsf@gmail.com \
    --to=visuweshm@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=manikulin@gmail.com \
    /path/to/YOUR_REPLY

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

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

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.