emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Adding target and custom id links doesn't ask for description
@ 2022-08-02 17:44 Carlos Pita
  2022-08-02 18:58 ` Carlos Pita
  2022-08-10  5:39 ` [PATCH] " Ihor Radchenko
  0 siblings, 2 replies; 5+ messages in thread
From: Carlos Pita @ 2022-08-02 17:44 UTC (permalink / raw)
  To: emacs-orgmode

Hi all,

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.

This behavior is not observed when an ID link is stored, which seems pretty inconsistent since there is no clear difference wrt the CUSTOM_ID case.

The inconvenience of this behavior and the inconsistent treatment of ID vs CUSTOM_ID makes me believe that this is not intended but a bug (perhaps a regression, but I’ve not been using org-mode for long enough to say).

The source of this behavior is in org-store-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)))

so that auto-desc is later assumed in org-insert-link, even then the store function has provided no description at all!

Best regards
—
Carlos




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Adding target and custom id links doesn't ask for description
  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 ` [PATCH] " Ihor Radchenko
  1 sibling, 1 reply; 5+ messages in thread
From: Carlos Pita @ 2022-08-02 18:58 UTC (permalink / raw)
  To: emacs-orgmode

A few more details.

My org-mode version 9.5.4 (9.5.4-ge0b05b).

This is the link that org-insert-link inserts for <<here>>:

    [[here][file:~/Desktop/Org/capturas.org::here]]

This is the link that org-insert-link inserts for CUSTOM_ID = cusid:

    [[#cusid][file:~/Desktop/Org/capturas.org::#cusid]]

Perhaps description and link are swapped? In both cases the full path is redundant since the link is pointing to the current file, but the verbosity is arguably less adequate for the description field.

Best regards
—
Carlos

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Adding target and custom id links doesn't ask for description
  2022-08-02 18:58 ` Carlos Pita
@ 2022-08-03 11:35   ` Max Nikulin
  0 siblings, 0 replies; 5+ messages in thread
From: Max Nikulin @ 2022-08-03 11:35 UTC (permalink / raw)
  To: Carlos Pita, emacs-orgmode

On 03/08/2022 01:58, Carlos Pita wrote:
> 
> This is the link that org-insert-link inserts for <<here>>:
> 
>      [[here][file:~/Desktop/Org/capturas.org::here]]
> 
> This is the link that org-insert-link inserts for CUSTOM_ID = cusid:
> 
>      [[#cusid][file:~/Desktop/Org/capturas.org::#cusid]]
> 
> Perhaps description and link are swapped? In both cases the full path
> is redundant since the link is pointing to the current file, but the 
> verbosity is arguably less adequate for the description field.

In my opinion, attempt to fix storing of <<target>> links broke such use 
cases, however I am unsure that we are complaining about exactly the 
same things. My attempts to alleviate the issue:

Max Nikulin. Re: Bug: org-store-link uses CUSTOM_ID instead of target 
point. Sat, 6 Nov 2021 19:51:29 +0700. 
https://list.orgmode.org/e2c807a7-1924-6f08-9e63-4f70aee9d3b5@gmail.com


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] Re: Adding target and custom id links doesn't ask for description
  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-10  5:39 ` Ihor Radchenko
  2022-08-10 12:30   ` Carlos Pita
  1 sibling, 1 reply; 5+ messages in thread
From: Ihor Radchenko @ 2022-08-10  5:39 UTC (permalink / raw)
  To: Carlos Pita; +Cc: emacs-orgmode

[-- 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

:3

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

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


[-- 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Re: Adding target and custom id links doesn't ask for description
  2022-08-10  5:39 ` [PATCH] " Ihor Radchenko
@ 2022-08-10 12:30   ` Carlos Pita
  0 siblings, 0 replies; 5+ messages in thread
From: Carlos Pita @ 2022-08-10 12:30 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

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

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


I'm fine with that. Alternatively the default may be the target or custom
id (that is, the same that is in the link part), again letting the user
change it. Thanks!

Best regards,
Carlos

[-- Attachment #2: Type: text/html, Size: 940 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-08-10 12:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH] " Ihor Radchenko
2022-08-10 12:30   ` Carlos Pita

Code repositories for project(s) associated with this 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).