Re: [BUG] org-store-link on document title

2023-07-14 Thread Max Nikulin

On 29/06/2023 22:54, Ihor Radchenko wrote:

Anthony Carrico writes:


On 6/29/23 09:20, Ihor Radchenko wrote:

Sure. And if it were a plain file link, there would be no reason to
assign TITLE as description. Because the link would be to a generic line
in file.


What? The title is the perfect description for the file!


That's because you expect Org to create a link to file.
But what Org does (by default) is a link to specific _line_ in file.


I find expectation to use the title property reasonable. Text search 
links are not created for lines after first heading. Current behavior is 
not documented and (if I understand it correctly) was introduced in


https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=12c09be3a
2020-02-19 18:03:53 +0100 Nicolas Goaziou: Refactor context part in file 
links


However there is a number of unit tests, so it was certainly an intended 
change.


So my vote is for [[file:document.org][title property]] when the 
document has at least on heading.




Re: [BUG] org-store-link on document title

2023-06-29 Thread Anthony Carrico

On 6/29/23 11:54, Ihor Radchenko wrote:

You can set :store property for "file" links in `org-link-parameters' to
adjust for your personal use case.

That is good advice.

--
Anthony Carrico





Re: [BUG] org-store-link on document title

2023-06-29 Thread Ihor Radchenko
Anthony Carrico  writes:

> On 6/29/23 09:20, Ihor Radchenko wrote:
>> Sure. And if it were a plain file link, there would be no reason to
>> assign TITLE as description. Because the link would be to a generic line
>> in file.
>
> What? The title is the perfect description for the file!

That's because you expect Org to create a link to file.
But what Org does (by default) is a link to specific _line_ in file.

> I would say that 90% of the links in my org notes are file links with 
> the title as the description. I tend to use *deft* to search a lot of 
> small pages without deep outlines.

You can set :store property for "file" links in `org-link-parameters' to
adjust for your personal use case.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [BUG] org-store-link on document title

2023-06-29 Thread Anthony Carrico

On 6/29/23 09:20, Ihor Radchenko wrote:

Sure. And if it were a plain file link, there would be no reason to
assign TITLE as description. Because the link would be to a generic line
in file.


What? The title is the perfect description for the file!

I would say that 90% of the links in my org notes are file links with 
the title as the description. I tend to use *deft* to search a lot of 
small pages without deep outlines.


--
Anthony Carrico




Re: [BUG] org-store-link on document title

2023-06-29 Thread Ihor Radchenko
Anthony Carrico  writes:

> #+begin_example
> [[id:5f4cdb46-d18d-41bb-914e-da7faa12][test org title link]]
> #+end_example
>
> ...hmm, you are correct that this option does add the proper default 
> description, but this is not a just plain file link anymore.

Sure. And if it were a plain file link, there would be no reason to
assign TITLE as description. Because the link would be to a generic line
in file.

That said, existence of hard-coded parts of `org-store-link' are not
ideal. We should ideally make things more flexible. Patches welcome!

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [BUG] org-store-link on document title

2023-06-29 Thread Anthony Carrico

On 6/28/23 16:16, Ihor Radchenko wrote:> It has been added back in Org 9.5.

Thanks, I'm on 9.5.5, so I can test it...


You can set `org-id-link-to-org-use-id' to non-nil (4.5 Handling Links).
Then, Org will store link to current file/heading instead of more
generic link. Latest version of Org will also auto-assign TITLE as the
link description.


#+begin_example
:PROPERTIES:
:ID:   5f4cdb46-d18d-41bb-914e-da7faa12
:END:
#+TITLE: test org title link
#+end_example

#+begin_example
[[id:5f4cdb46-d18d-41bb-914e-da7faa12][test org title link]]
#+end_example

...hmm, you are correct that this option does add the proper default 
description, but this is not a just plain file link anymore.


--
Anthony Carrico



Re: [BUG] org-store-link on document title

2023-06-28 Thread Ihor Radchenko
Anthony Carrico  writes:

> On 6/28/23 15:56, Ihor Radchenko wrote:
>> Latest version of Org will also auto-assign TITLE as the
>> link description.
>
> Nice, sound like this issue is already fixed. Looking forward to the 
> upgrade.

It has been added back in Org 9.5.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [BUG] org-store-link on document title

2023-06-28 Thread Anthony Carrico

On 6/28/23 15:56, Ihor Radchenko wrote:

Latest version of Org will also auto-assign TITLE as the
link description.


Nice, sound like this issue is already fixed. Looking forward to the 
upgrade.


--
Anthony Carrico




Re: [BUG] org-store-link on document title

2023-06-28 Thread Ihor Radchenko
Anthony Carrico  writes:

> To duplicate:
>
> Create file test.org as in this example:
> #+begin_example
> #+TITLE: test org title link
> #+end_example
>
> 1. go to title line of test.org, and do org-store link: 'C-c l'
> 2. go to new file test2.org, and do org-insert-link: 'C-c C-l M-p '
>
> Here is the actual file test2.org produced by this method:
> #+begin_example
> [[file:test.org::+TITLE: test org title link]]
> #+end_example
>
> This isn't great because there is no description.

Org does not know if you want to store link to file or to this specific
line. The current default is trying to store link to current line,
stripping "#" to disambiguate from custom ID search string.
See 4.8 Search Options in File Links

> 1. Expected file test2.org:
> #+begin_example
> [[file:test.org::+TITLE: test org title link][test org title link]]
> #+end_example
>
> Or even better:
>
> 2. Desired file test2.org:
> #+begin_example
> [[file:test.org][test org title link]]
> #+end_example

You can set `org-id-link-to-org-use-id' to non-nil (4.5 Handling Links).
Then, Org will store link to current file/heading instead of more
generic link. Latest version of Org will also auto-assign TITLE as the
link description.

Canceled.
You may consider sending patch for Org manual if you think that we can
do a better job describing how Org handles links.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



[BUG] org-store-link on document title

2023-06-28 Thread Anthony Carrico

On 6/28/23 12:48, Ihor Radchenko wrote:
> I cannot reproduce.
> Please provide more details and report this under a different email
> subject, so that we can easily distinguish the two bugs.
> See https://orgmode.org/manual/Feedback.html#Feedback

Ah, very sorry for the distraction on the "This link has already been 
stored" issue.


I'll describe the behavior I observe, and a more useful behavior. I'm 
not sure this constitutes an actual bug, since org-store-link isn't 
documented to work on the title line of a document.


Org mode version 9.5.5 (release_9.5.5 @ /usr/share/emacs/28.2/lisp/org/)
GNU Emacs 28.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.36, 
cairo version 1.17.6) of 2023-01-02


To duplicate:

Create file test.org as in this example:
#+begin_example
#+TITLE: test org title link
#+end_example

1. go to title line of test.org, and do org-store link: 'C-c l'
2. go to new file test2.org, and do org-insert-link: 'C-c C-l M-p '

Here is the actual file test2.org produced by this method:
#+begin_example
[[file:test.org::+TITLE: test org title link]]
#+end_example

This isn't great because there is no description.

1. Expected file test2.org:
#+begin_example
[[file:test.org::+TITLE: test org title link][test org title link]]
#+end_example

Or even better:

2. Desired file test2.org:
#+begin_example
[[file:test.org][test org title link]]
#+end_example

Here the title is used as the description, and the file itself is 
linked, rather than the title line.


The second option makes more sense to me. Why? Because at the title line 
I intend to store a link to the document labeled with the title, and at 
a headline I intend to store a link to a section of the document labeled 
with the headline.


This option also produces cleaner html output (at least a few years 
ago--see org mailing list around 2020-08-06 with subject "ISSUE: Unable 
to resolve link (html export)").


--
Anthony Carrico