emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: Carlos Pita <carlosjosepita@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: [PATCH] Re: Adding target and custom id links doesn't ask for description
Date: Wed, 10 Aug 2022 13:39:39 +0800	[thread overview]
Message-ID: <87a68c4pyc.fsf@localhost> (raw)
In-Reply-To: <D99A712C-18D1-4A4F-8093-35A0BFB469C4@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 869 bytes --]

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


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

See the attached patch.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-store-link-Default-to-empty-description-for-targ.patch --]
[-- Type: text/x-patch, Size: 1806 bytes --]

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 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?)
 	(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.
@@ -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)))
 			 ;; Probably before first headline, link only to file.
 			 (concat "file:"

[-- Attachment #3: Type: text/plain, Size: 207 bytes --]

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

  parent reply	other threads:[~2022-08-10  5:41 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-02 17:44 Adding target and custom id links doesn't ask for description Carlos Pita
2022-08-02 18:58 ` Carlos Pita
2022-08-03 11:35   ` Max Nikulin
2022-08-10  5:39 ` Ihor Radchenko [this message]
2022-08-10 12:30   ` [PATCH] " Carlos Pita
2022-08-11 15:50     ` Max Nikulin
2022-08-12 19:18       ` Carlos Pita
2022-08-13  5:01         ` [PATCH v2] " Ihor Radchenko
2022-08-14  9:53           ` Max Nikulin
2022-09-11 13:18             ` Max Nikulin
2022-09-12 11:02               ` Ihor Radchenko
2022-09-12 16:05                 ` Max Nikulin
2022-09-13 13:08           ` Ihor Radchenko

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:

  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=87a68c4pyc.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=carlosjosepita@gmail.com \
    --cc=emacs-orgmode@gnu.org \


* 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


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