emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Re: Adding target and custom id links doesn't ask for descriptio


From: Ihor Radchenko
Subject: [PATCH] Re: Adding target and custom id links doesn't ask for description
Date: Wed, 10 Aug 2022 13:39:39 +0800

Carlos Pita <carlosjosepita@gmail.com> writes:

> When storing a <<target>> or CUSTOM_ID link with org-store-link and then 
> adding it with C-c C-l, org doesn’t ask for a description but automatically 
> inserts an ugly description like:
>
>     ~/Desktop/Org/captures.org::target
>
> or:
>
>     ~/Desktop/Org/captures.org::#7EFBCEA1-0D17-45B9-A125-10FE581752F8
>
> The entire path is inserted even when the target itself is simply “target”. 
> But, more importantly, no chance to change the description is given to the 
> user.

I can replicate. I do see much point copy-pasting the link into
description. Moreover, this code is carried around since 15 years ago
from the commit

93c665b56 Intermediate state, I am just trying comiting now

:3

I suggest to set description to nil and thus ask the user in such
scenario.

See the attached patch.

>From 4a2079f237f5d23bfa83c2481f34d3bff27dd3e8 Mon Sep 17 00:00:00 2001
Message-Id: 
<4a2079f237f5d23bfa83c2481f34d3bff27dd3e8.1660109574.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Wed, 10 Aug 2022 13:25:26 +0800
Subject: [PATCH] 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 D99A712C-18D1-4A4F-8093-35A0BFB469C4@gmail.com">https://orgmode.org/list/D99A712C-18D1-4A4F-8093-35A0BFB469C4@gmail.com
---
 lisp/ol.el | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/lisp/ol.el b/lisp/ol.el
index b7d74d0bf..29e0d3319 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:"
-- 
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

[Prev in Thread] Current Thread [Next in Thread]