From mboxrd@z Thu Jan 1 00:00:00 1970 From: Reuben Thomas Subject: Re: Bug: Fix for org-make-link-description-function use in org-insert-link [9.0.10 (9.0.10-5-g1654a5-elpa @ /home/rrt/.emacs.d/elpa/org-20170904/)] Date: Tue, 5 Sep 2017 22:05:59 +0100 Message-ID: References: <874lsh5cwj.fsf@sc3d.org> <87a828na5m.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="001a113d70761869b40558779856" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52142) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpL2s-00052S-11 for emacs-orgmode@gnu.org; Tue, 05 Sep 2017 17:06:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpL2m-0007E5-Up for emacs-orgmode@gnu.org; Tue, 05 Sep 2017 17:06:06 -0400 Received: from mail-oi0-x22a.google.com ([2607:f8b0:4003:c06::22a]:33692) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dpL2m-0007Dl-N0 for emacs-orgmode@gnu.org; Tue, 05 Sep 2017 17:06:00 -0400 Received: by mail-oi0-x22a.google.com with SMTP id r20so2953301oie.0 for ; Tue, 05 Sep 2017 14:06:00 -0700 (PDT) In-Reply-To: <87a828na5m.fsf@nicolasgoaziou.fr> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Nicolas Goaziou Cc: "emacs-orgmode@gnu.org" --001a113d70761869b40558779856 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On 5 September 2017 at 21:49, Nicolas Goaziou wrote: > Hello, > =E2=80=8BHi, thanks for looking at this.=E2=80=8B > Reuben Thomas writes: > > > This seems to be incorrect behaviour, as the docstring for > > org-insert-link says: > > > > If `org-make-link-description-function' is non-nil, this function > will be > > called with the link target, and the result will be the default > > link description. > > > > The implication is that the value returned is used as the default, not > > that it overrides the prompt. > > I agree. > > > First, org-make-link-description-function is called if it is non-nil, > > and used to set default-description. > > I think the optional parameter from the function call should still > prevail. I.e., shouldn't this function be called when > DEFAULT-DESCRIPTION is nil (e.g., called interatively)? > =E2=80=8BThis question occurred to me too, but I didn't form an opinion. Ho= wever, I am inclined to agree with you on thinking about it some more.=E2=80=8B > > Then (unless auto-desc is non-nil) the description is prompted for with > > default-description as the default value (unless > > org-make-link-description-function returned nil, in which case the > > current value of desc, if any, is used). > > > > There is one further matter that my patch does not address: the > > docstring for org-make-link-description-function says: > > > > =E2=80=9CWhen [org-make-link-description-function is] nil, the link loc= ation > > will be used.=E2=80=9D > > > > This does not happen (it=E2=80=99s precisely the behaviour I=E2=80=99ve= been trying to > > obtain!), and my patch does not make it happen. Indeed, it=E2=80=99s no= t clear > > that it=E2=80=99s desirable (if one is using numbered sections, for exa= mple). > > Obviously, it would not be desirable. > > However, I think it should read "When > `org-make-link-description-function' _returns_ nil, the link location is > used". This is not what is implemented either, tho. > =E2=80=8BIf you (or someone) can confirm your interpretation above, I would= be happy to update my patch to implement the two behaviours required, namely, that org-make-link-description-function is only called if the default-description argument to org-insert-link is nil, and that if that function returns nil, then the link location is used. I would also clarify the docstring regarding the second behaviour. --=20 https://rrt.sc3d.org --001a113d70761869b40558779856 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On 5 September 2017 at 21:49, N= icolas Goaziou <mail@nicolasgoaziou.fr> wrote:
Hello,

=E2=80=8BHi, thanks for looking at this.= =E2=80=8B
=C2=A0
Reuben Thomas <rrt@sc3d.org> writ= es:

> This seems to be incorrect behaviour, as the docstring for
> org-insert-link says:
>
>=C2=A0 =C2=A0If `org-make-link-description-function' is non-ni= l, this function will be
>=C2=A0 =C2=A0called with the link target, and the result will be the de= fault
>=C2=A0 =C2=A0link description.
>
> The implication is that the value returned is used as the default, not=
> that it overrides the prompt.

I agree.

> First, org-make-link-description-function is called if it is non-= nil,
> and used to set default-description.

I think the optional parameter from the function call should still prevail. I.e., shouldn't this function be called when
DEFAULT-DESCRIPTION is nil (e.g., called interatively)?

=E2=80=8BThis question occurred to me too, b= ut I didn't form an opinion. However, I am inclined to agree with you o= n thinking about it some more.=E2=80=8B
=C2=A0
> Then (unless auto-desc is non-nil) the description is prompted for wit= h
> default-description as the default value (unless
> org-make-link-description-function returned nil, in which case th= e
> current value of desc, if any, is used).
>
> There is one further matter that my patch does not address: the
> docstring for org-make-link-description-function says:
>
> =E2=80=9CWhen [org-make-link-description-function is] nil, the li= nk location
> will be used.=E2=80=9D
>
> This does not happen (it=E2=80=99s precisely the behaviour I=E2=80=99v= e been trying to
> obtain!), and my patch does not make it happen. Indeed, it=E2=80=99s n= ot clear
> that it=E2=80=99s desirable (if one is using numbered sections, for ex= ample).

Obviously, it would not be desirable.

However, I think it should read "When
`org-make-link-description-function' _returns_ nil, the link locat= ion is
used". This is not what is implemented either, tho.

=E2=80=8BIf you (or someone) can confirm your in= terpretation above, I would be happy to update my patch to implement the tw= o behaviours required, namely, that org-make-link-description-function is o= nly called if the default-description argument to org-insert-link is nil, a= nd that if that function returns nil, then the link location is used. I wou= ld also clarify the docstring regarding the second behaviour.

--
--001a113d70761869b40558779856--