emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Reuben Thomas <rrt@sc3d.org>
To: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
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: Fri, 8 Sep 2017 00:06:51 +0100	[thread overview]
Message-ID: <CAOnWdohqaBMSp3h1_RiGc7HFmdUR3eDzGkhLN98Mzvm-9FMNaw@mail.gmail.com> (raw)
In-Reply-To: <87o9qols74.fsf@nicolasgoaziou.fr>


[-- Attachment #1.1: Type: text/plain, Size: 933 bytes --]

On 5 September 2017 at 23:02, Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:

> Reuben Thomas <rrt@sc3d.org> writes:
>
> > ​If 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
>
> Ack.
>
> > and that if that function returns nil, then the link location is used.
> > I would also clarify the docstring regarding the second behaviour.
>
> It may not be a terribly useful behaviour anyway. You can always use
> (lambda (link description) link) as
> `org-make-link-description-function'.
>
> Perhaps we can simply remove "When nil, the link location will be used"
> from the docstring. Your call.
>

​I've removed it.​

​Attached, a revised patch.

-- 
https://rrt.sc3d.org

[-- Attachment #1.2: Type: text/html, Size: 1736 bytes --]

[-- Attachment #2: 0001-Fix-logic-of-calling-org-make-link-desciption-functi.patch --]
[-- Type: text/x-patch, Size: 3928 bytes --]

From df6e155c0e14bae6cebb2e8ac904405163c32b7d Mon Sep 17 00:00:00 2001
From: Reuben Thomas <rrt@sc3d.org>
Date: Tue, 5 Sep 2017 17:00:25 +0100
Subject: [PATCH] Fix logic of calling org-make-link-desciption-function

* lisp/org.el (org-insert-link): Simplify so that description is only
prompted for once, if auto-desc is not set, and takes as its default
value, in order, default-description, the return value of
org-make-link-description-function (if the variable is non-nil), and
the current desc. Update the docstring to reflect that
default-description takes precedence over
org-make-link-description-function.
(org-make-link-description-function): Remove from docstring the
statement that if the variable is nil, then the link will be used as
the default description. This is undesirable, and was not in any case
implemented.
---
 lisp/org.el | 41 ++++++++++++++++++++---------------------
 1 file changed, 20 insertions(+), 21 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 889987c..4347111 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -1939,10 +1939,10 @@ in the Org buffer so that the change takes effect."
 
 (defcustom org-make-link-description-function nil
   "Function to use for generating link descriptions from links.
-When nil, the link location will be used.  This function must take
-two parameters: the first one is the link, the second one is the
-description generated by `org-insert-link'.  The function should
-return the description to use."
+This function must take two parameters: the first one is the
+link, the second one is the description generated by
+`org-insert-link'.  The function should return the description to
+use."
   :group 'org-link
   :type '(choice (const nil) (function)))
 
@@ -10152,15 +10152,14 @@ the current directory or below.
 A `\\[universal-argument] \\[universal-argument] \\[universal-argument]' \
 prefix negates `org-keep-stored-link-after-insertion'.
 
-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.
-
 If the LINK-LOCATION parameter is non-nil, this value will be used as
 the link location instead of reading one interactively.
 
-If the DEFAULT-DESCRIPTION parameter is non-nil, this value will be used
-as the default description."
+If the DEFAULT-DESCRIPTION parameter is non-nil, this value will
+be used as the default description.  Otherwise, 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."
   (interactive "P")
   (let* ((wcf (current-window-configuration))
 	 (origbuf (current-buffer))
@@ -10294,17 +10293,17 @@ Use TAB to complete link prefixes, then RET for type-specific completion support
 	  (when (equal desc origpath)
 	    (setq desc path)))))
 
-    (if org-make-link-description-function
-	(setq desc
-	      (or (condition-case nil
-		      (funcall org-make-link-description-function link desc)
-		    (error (progn (message "Can't get link description from `%s'"
-					   (symbol-name org-make-link-description-function))
-				  (sit-for 2) nil)))
-		  (read-string "Description: " default-description)))
-      (if default-description (setq desc default-description)
-	(setq desc (or (and auto-desc desc)
-		       (read-string "Description: " desc)))))
+    (unless auto-desc
+      (setq desc (read-string "Description: "
+			      (or default-description
+				  (when org-make-link-description-function
+				    (condition-case nil
+					(funcall org-make-link-description-function link desc)
+				      (error (progn (message "Can't get link description from `%s'"
+							     (symbol-name org-make-link-description-function))
+						    (sit-for 2) nil))))
+				  
+				  desc))))
 
     (unless (string-match "\\S-" desc) (setq desc nil))
     (when remove (apply 'delete-region remove))
-- 
2.7.4


  reply	other threads:[~2017-09-07 23:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-05 16:27 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/)] Reuben Thomas
2017-09-05 20:49 ` Nicolas Goaziou
2017-09-05 21:05   ` Reuben Thomas
2017-09-05 22:02     ` Nicolas Goaziou
2017-09-07 23:06       ` Reuben Thomas [this message]
2017-09-08  5:00         ` Nicolas Goaziou

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

  List information: https://www.orgmode.org/

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

  git send-email \
    --in-reply-to=CAOnWdohqaBMSp3h1_RiGc7HFmdUR3eDzGkhLN98Mzvm-9FMNaw@mail.gmail.com \
    --to=rrt@sc3d.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@nicolasgoaziou.fr \
    /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 public inbox

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

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