Carlos Pita <carlosjosep...@gmail.com> writes:

>> Carlos, have you tried Ihor's patch? I like the intention, but I do not
>> see any effect.
>>
>
> Yes, I've tested it with target and custom_id links and, as you said, there
> is no change in behavior. The entire URL is still pasted and no chance to
> edit it is given to the user.

Oops. Somehow some way things worked for me at some point when I was
making the patch.

See the updated version of the patch attached. It works on my side.

>From 64c85eed9471b73e379e063dc3becefceb1ec650 Mon Sep 17 00:00:00 2001
Message-Id: <64c85eed9471b73e379e063dc3becefceb1ec650.1660366803.git.yanta...@gmail.com>
From: Ihor Radchenko <yanta...@gmail.com>
Date: Wed, 10 Aug 2022 13:25:26 +0800
Subject: [PATCH v2] org-store-link: Default to empty description for
 target/custom-id links

* lisp/ol.el (org-store-link): Use empty description by default (ask user).

Fixes https://orgmode.org/list/d99a712c-18d1-4a4f-8093-35a0bfb46...@gmail.com
---
 lisp/ol.el | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/lisp/ol.el b/lisp/ol.el
index b7d74d0bf..358a96aae 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -1577,10 +1577,8 @@ (defun org-store-link (arg &optional interactive?)
 		  t))))
 	(setq link (plist-get org-store-link-plist :link))
         ;; If store function actually set `:description' property, use
-        ;; it, even if it is nil.  Otherwise, fallback to link value.
-	(setq desc (if (plist-member org-store-link-plist :description)
-                       (plist-get org-store-link-plist :description)
-		     link)))
+        ;; it, even if it is nil.  Otherwise, fallback to nil (ask user).
+	(setq desc (plist-get org-store-link-plist :description)))
 
        ;; Store a link from a remote editing buffer.
        ((org-src-edit-buffer-p)
@@ -1697,9 +1695,7 @@ (defun org-store-link (arg &optional interactive?)
 		    (and org-id-link-to-org-use-id (org-entry-get nil "ID"))))
 	   (setq link (condition-case nil
 			  (prog1 (org-id-store-link)
-			    (setq desc (or (plist-get org-store-link-plist
-						      :description)
-					   "")))
+			    (setq desc (plist-get org-store-link-plist :description)))
 			(error
 			 ;; Probably before first headline, link only to file.
 			 (concat "file:"
@@ -1761,8 +1757,7 @@ (defun org-store-link (arg &optional interactive?)
 
       ;; We're done setting link and desc, clean up
       (when (consp link) (setq cpltxt (car link) link (cdr link)))
-      (setq link (or link cpltxt)
-	    desc (or desc cpltxt))
+      (setq link (or link cpltxt))
       (cond ((not desc))
 	    ((equal desc "NONE") (setq desc nil))
 	    (t (setq desc (org-link-display-format desc))))
-- 
2.35.1


-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92

Reply via email to