protesilaos / denote

Simple notes for Emacs with an efficient file-naming scheme
https://protesilaos.com/emacs/denote
GNU General Public License v3.0
501 stars 54 forks source link

Using denote with radio target <<<[[denote:IDENTIFIER][DESCRIPTION]]>>> ? #262

Closed reyman closed 4 months ago

reyman commented 6 months ago

Hi,

I'm interested to rewrite some long interview using Denote linking functionalities. There are lot of names/surnames that appear and i'm interested to automatically replace occurences of the word by corresponding denote link indicated by an org radio target <<<>>>, like a wiki permit.

If i take an example with a famous book from Darwin, a similar use case finally :

13 avril 1834. — Le <<<[[denote:20240118T060608][beagle]]>>> jette l’ancre à l’embouchure du Santa Cruz. Ce fleuve se jette dans la mer à environ 60 milles au sud du port Saint-Julien. Pendant son dernier voyage le capitaine Stokes l’avait remonté à une distance d’environ 30 milles, mais le manque de provisions l’obligea alors à revenir en arrière. On ne connaît de ce fleuve que ce qui a été découvert pendant l’excursion dont je viens de parler. Le capitaine Fitz-Roy se décide à le remonter aussi loin que le temps le lui permettra. Le 18, nous partons dans trois baleinières, portant trois semaines de provisions ; notre expédition se compose de vingt-cinq hommes, force suffisante pour défier une armée d’Indiens. La marée montante nous entraîne rapidement, le temps est beau, aussi faisons-nous une longue étape ; nous buvons bientôt l’eau douce du fleuve et le soir nous nous trouvons au-dessus du point où se fait sentir la marée.

5 mai. — Nous commençons à redescendre le fleuve avant le lever du soleil : cette descente s’effectue avec une grande rapidité ; nous faisons ordinairement dix nœuds à l’heure. En un jour, nous avons traversé ce qui nous a coûté cinq jours et demi de travail pénible quand nous remontions le fleuve. Le 8, nous nous retrouvons à bord du [[denote:20240118T060608][beagle]] après vingt et un jours d’expédition. Tous mes compagnons éprouvent un vif désappointement ; quant à moi, j’ai tout lieu de me féliciter de ce voyage, car il m’a permis d’observer une section fort intéressante de la grande formation tertiaire de la Patagonie.

Everywhere beagle appear in the text, radio-target, or another function from denote replace by the same link to [[denote:20240118T060608][beagle]]

Do you thinks it's possible with Denote ?

protesilaos commented 6 months ago

Hello @reyman! I need to refresh my knowledge of Org radio targets. I think it should be possible, but I must double-check.

When do you need this though? Even if we make the change now, it will take a while before it is available on GNU ELPA. I will publish the next version in a few weeks. Maybe in April.

reyman commented 6 months ago

When do you need this though? Even if we make the change now, it will take a while before it is available on GNU ELPA. I will publish the next version in a few weeks. Maybe in April.

Great ! No problem, April is perfect, this feature doesn't block me to build a wiki with manual link around the different interviews.

nobiot commented 6 months ago

@reyman

Radio targets work within a single Org file. Why not just do something like this? Calling org-update-radio-target-regexp, "beagle" becomes a radio target link; in the definition, you can have the denote link if you like... Personally to me, this way, you don't need any additional feature, you can still use the denote link to another note, and looks cleaner without links in the body text.

image

* Links
- <<<beagle>>> :: [[denote:20240118T060608]

* Body
    13 avril 1834. — Le beagle jette l’ancre à l’embouchure du Santa
 Cruz. Ce fleuve se jette dans la mer à environ 60 milles au sud du port
 Saint-Julien. Pendant son dernier voyage le capitaine Stokes l’avait
 remonté à une distance d’environ 30 milles, mais le manque de
 provisions l’obligea alors à revenir en arrière. On ne connaît de ce
 fleuve que ce qui a été découvert pendant l’excursion dont je viens de
 parler. Le capitaine Fitz-Roy se décide à le remonter aussi loin que le
 temps le lui permettra. Le 18, nous partons dans trois baleinières,
 portant trois semaines de provisions ; notre expédition se compose de
 vingt-cinq hommes, force suffisante pour défier une armée d’Indiens. La
 marée montante nous entraîne rapidement, le temps est beau, aussi
 faisons-nous une longue étape ; nous buvons bientôt l’eau douce du
 fleuve et le soir nous nous trouvons au-dessus du point où se fait
 sentir la marée.

    5 mai. — Nous commençons à redescendre le fleuve avant le lever du
 soleil : cette descente s’effectue avec une grande rapidité ; nous
 faisons ordinairement dix nœuds à l’heure. En un jour, nous avons
 traversé ce qui nous a coûté cinq jours et demi de travail pénible
 quand nous remontions le fleuve. Le 8, nous nous retrouvons à bord du
 beagle après vingt et un jours d’expédition. Tous mes compagnons
 éprouvent un vif désappointement ; quant à moi, j’ai tout lieu de me
 féliciter de ce voyage, car il m’a permis d’observer une section fort
 intéressante de la grande formation tertiaire de la Patagonie.
reyman commented 6 months ago

@reyman

Radio targets work within a single Org file. Why not just do something like this? Calling org-update-radio-target-regexp, "beagle" becomes a radio target link; in the definition, you can have the denote link if you like... Personally to me, this way, you don't need any additional feature, you can still use the denote link to another note, and looks cleaner without links in the body text.

image

* Links
- <<<beagle>>> :: [[denote:20240118T060608]

* Body
    13 avril 1834. — Le beagle jette l’ancre à l’embouchure du Santa
 Cruz. Ce fleuve se jette dans la mer à environ 60 milles au sud du port
 Saint-Julien. Pendant son dernier voyage le capitaine Stokes l’avait
 remonté à une distance d’environ 30 milles, mais le manque de
 provisions l’obligea alors à revenir en arrière. On ne connaît de ce
 fleuve que ce qui a été découvert pendant l’excursion dont je viens de
 parler. Le capitaine Fitz-Roy se décide à le remonter aussi loin que le
 temps le lui permettra. Le 18, nous partons dans trois baleinières,
 portant trois semaines de provisions ; notre expédition se compose de
 vingt-cinq hommes, force suffisante pour défier une armée d’Indiens. La
 marée montante nous entraîne rapidement, le temps est beau, aussi
 faisons-nous une longue étape ; nous buvons bientôt l’eau douce du
 fleuve et le soir nous nous trouvons au-dessus du point où se fait
 sentir la marée.

    5 mai. — Nous commençons à redescendre le fleuve avant le lever du
 soleil : cette descente s’effectue avec une grande rapidité ; nous
 faisons ordinairement dix nœuds à l’heure. En un jour, nous avons
 traversé ce qui nous a coûté cinq jours et demi de travail pénible
 quand nous remontions le fleuve. Le 8, nous nous retrouvons à bord du
 beagle après vingt et un jours d’expédition. Tous mes compagnons
 éprouvent un vif désappointement ; quant à moi, j’ai tout lieu de me
 féliciter de ce voyage, car il m’a permis d’observer une section fort
 intéressante de la grande formation tertiaire de la Patagonie.

Yeah you're right @nobiot, at this scale it works well using your snippet.

But, i think about that all this day, and i need to refine my problem. I see on org mailling list that radio target don't scale well because it maintain a list of regexp that grow with your usage ...

A function that do some sort of "search and replace" in the text based on the content of the description in denote [[link][description]] could be more useful in my case. Advantage of this approach, no need to maintain a list of regex, and link are write in hard in the text. The inverse function could also be useful, removing all links in the text based on description.

protesilaos commented 6 months ago

I see on org mailling list that radio target don't scale well because it maintain a list of regexp that grow with your usage

Indeed. The issue we have here is that radio links are pointers in the current file. There is no mechanism to extend them.

Perhaps you @reyman can use the new feature is denote-org-extras.el that links to a heading inside of the file? I did a video demo of the feature: https://protesilaos.com/codelog/2024-01-20-emacs-denote-link-org-headings/

A function that do some sort of "search and replace" in the text based on the content of the description in denote [[link][description]] could be more useful in my case. Advantage of this approach, no need to maintain a list of regex, and link are write in hard in the text. The inverse function could also be useful, removing all links in the text based on description.

I think I follow you, but just to be sure: can you show how you imagine the file will change? Like have a before and after for comparison?

I do not know if we can do something on this front, because it will not be standard Org. But we may write some snippet in the manual.

reyman commented 6 months ago

I see on org mailling list that radio target don't scale well because it maintain a list of regexp that grow with your usage

Indeed. The issue we have here is that radio links are pointers in the current file. There is no mechanism to extend them.

Perhaps you @reyman can use the new feature is denote-org-extras.el that links to a heading inside of the file? I did a video demo of the feature: https://protesilaos.com/codelog/2024-01-20-emacs-denote-link-org-headings/

Yes ! This is a good proxy in a first approach. I need to look a new time the video to see if i understand well, and after that i will test.

A function that do some sort of "search and replace" in the text based on the content of the description in denote [[link][description]] could be more useful in my case. Advantage of this approach, no need to maintain a list of regex, and link are write in hard in the text. The inverse function could also be useful, removing all links in the text based on description.

I think I follow you, but just to be sure: can you show how you imagine the file will change? Like have a before and after for comparison?

I do not know if we can do something on this front, because it will not be standard Org. But we may write some snippet in the manual.

Before :

13 avril 1834. — Le [[denote:20240118T060608][beagle]] jette l’ancre à l’embouchure du Santa Cruz. Ce fleuve se jette dans la mer à environ 60 milles au sud du port Saint-Julien. Pendant son dernier voyage le capitaine Stokes l’avait remonté à une distance d’environ 30 milles, mais le manque de provisions l’obligea alors à revenir en arrière. On ne connaît de ce fleuve que ce qui a été découvert pendant l’excursion dont je viens de parler. Le capitaine Fitz-Roy se décide à le remonter aussi loin que le temps le lui permettra. Le 18, nous partons dans trois baleinières, portant trois semaines de provisions ; notre expédition se compose de vingt-cinq hommes, force suffisante pour défier une armée d’Indiens. La marée montante nous entraîne rapidement, le temps est beau, aussi faisons-nous une longue étape ; nous buvons bientôt l’eau douce du fleuve et le soir nous nous trouvons au-dessus du point où se fait sentir la marée.

5 mai. — Nous commençons à redescendre le fleuve avant le lever du soleil : cette descente s’effectue avec une grande rapidité ; nous faisons ordinairement dix nœuds à l’heure. En un jour, nous avons traversé ce qui nous a coûté cinq jours et demi de travail pénible quand nous remontions le fleuve. Le 8, nous nous retrouvons à bord du beagle après vingt et un jours d’expédition. Tous mes compagnons éprouvent un vif désappointement ; quant à moi, j’ai tout lieu de me féliciter de ce voyage, car il m’a permis d’observer une section fort intéressante de la grande formation tertiaire de la Patagonie.

Command : M-x org-denote-replace-using-description on [[denote:20240118T060608][beagle]]

After :

13 avril 1834. — Le [[denote:20240118T060608][beagle]] jette l’ancre à l’embouchure du Santa Cruz. Ce fleuve se jette dans la mer à environ 60 milles au sud du port Saint-Julien. Pendant son dernier voyage le capitaine Stokes l’avait remonté à une distance d’environ 30 milles, mais le manque de provisions l’obligea alors à revenir en arrière. On ne connaît de ce fleuve que ce qui a été découvert pendant l’excursion dont je viens de parler. Le capitaine Fitz-Roy se décide à le remonter aussi loin que le temps le lui permettra. Le 18, nous partons dans trois baleinières, portant trois semaines de provisions ; notre expédition se compose de vingt-cinq hommes, force suffisante pour défier une armée d’Indiens. La marée montante nous entraîne rapidement, le temps est beau, aussi faisons-nous une longue étape ; nous buvons bientôt l’eau douce du fleuve et le soir nous nous trouvons au-dessus du point où se fait sentir la marée.

5 mai. — Nous commençons à redescendre le fleuve avant le lever du soleil : cette descente s’effectue avec une grande rapidité ; nous faisons ordinairement dix nœuds à l’heure. En un jour, nous avons traversé ce qui nous a coûté cinq jours et demi de travail pénible quand nous remontions le fleuve. Le 8, nous nous retrouvons à bord du [[denote:20240118T060608][beagle]] après vingt et un jours d’expédition. Tous mes compagnons éprouvent un vif désappointement ; quant à moi, j’ai tout lieu de me féliciter de ce voyage, car il m’a permis d’observer une section fort intéressante de la grande formation tertiaire de la Patagonie.

Command : M-x org-denote-remove-using-description on [[denote:20240118T060608][beagle]]

13 avril 1834. — Le beagle jette l’ancre à l’embouchure du Santa Cruz. Ce fleuve se jette dans la mer à environ 60 milles au sud du port Saint-Julien. Pendant son dernier voyage le capitaine Stokes l’avait remonté à une distance d’environ 30 milles, mais le manque de provisions l’obligea alors à revenir en arrière. On ne connaît de ce fleuve que ce qui a été découvert pendant l’excursion dont je viens de parler. Le capitaine Fitz-Roy se décide à le remonter aussi loin que le temps le lui permettra. Le 18, nous partons dans trois baleinières, portant trois semaines de provisions ; notre expédition se compose de vingt-cinq hommes, force suffisante pour défier une armée d’Indiens. La marée montante nous entraîne rapidement, le temps est beau, aussi faisons-nous une longue étape ; nous buvons bientôt l’eau douce du fleuve et le soir nous nous trouvons au-dessus du point où se fait sentir la marée.

5 mai. — Nous commençons à redescendre le fleuve avant le lever du soleil : cette descente s’effectue avec une grande rapidité ; nous faisons ordinairement dix nœuds à l’heure. En un jour, nous avons traversé ce qui nous a coûté cinq jours et demi de travail pénible quand nous remontions le fleuve. Le 8, nous nous retrouvons à bord du beagle après vingt et un jours d’expédition. Tous mes compagnons éprouvent un vif désappointement ; quant à moi, j’ai tout lieu de me féliciter de ce voyage, car il m’a permis d’observer une section fort intéressante de la grande formation tertiaire de la Patagonie.

That will be an interesting function to simplify the work for wiki creator :)

nobiot commented 6 months ago

@reyman @protesilaos , you two have moved on with an idea, so I won't dwell too long on this issue. But let me part with a couple of notes, which may be relevant with this topic of radio targets and wiki creator.

  1. "Performance issue" with Org's radio targets. I believe the ML thread @reyman refers to is this one. Thanks for noting. I am now trying to contribute. We should be aware of the "scale" here. The issue reported in the thread speaks about roughly 4,000 radio targets. I have created test files with 5000 and 500 radio targets. They work beautifully with 500 of them. I can reproduce the reported error with 5000 targets. For my normal use, 500 (within a single Org file) is more than enough -- for your wiki creator, perhaps it may not be; I am not sure.

  2. Patch proposal. The ML thread has a recent update from Ihor, the maintainer of Org-mode, with a patch. This was on 19 Feb 2024. No news about test results has been sent to the ML yet, but this may lead to removing the error and limit in number of radio targets.

  3. Radio targets across multiple files I am working on a small patch/package to enable radio targets for multiple files. I am trying to refurbish the built-in org-ctag to achieve this. It works fine on my end (though it is cranky if you want to use it at the moment). Together with the patch proposal from Ihor, this may lead to a useful package -- I am considering to have a discussion in the ML to send a patch for upstream Org.

  4. How is this related to Denote and this issue/feature request? I'm not trying to persuade you two to change the course you have discussed above. One thing you may want to consider is this possibility:

- <<<beagle>>> :: [[denote:20240118T060608]]
- <<<Darwin>>> :: [[denote:20240120T060608]]
- <<<term 3>> :: [[denote:ID-for-term-3]]
  ... [more terms]

It would be easy to have Denote code to let radio targets to automatically jump to the note the denote link points to. For the user, the link works as if you go like this:

"beagle" link in the body text -> denote:20240118T060608

when technically the code jumps and hops like this:

"beagle" link in body text -> definition -> denote:20240118T060608.

Just a thought.

reyman commented 6 months ago

@nobiot Thanks for all this hard work :100: :+1: , and for all your packages in general !

Both solution are really interesting for a wiki use case. It's more a matter of taste i suppose, if user prefer denote link written in the text or not. In my use case, i see another disadvantage for the radio target link, in the future we work in team and some people don't use org-mode, and yes, this is a shame :) In my head, denote link seems more easy to transform/maintain in such context, but i'm probably wrong.

nobiot commented 6 months ago

I think you are right about team collaborative editing being a weak spot for Org and, perhaps, Emacs in general.

But if the goal is to work with others who do not use Emacs, I would probably just use Markdown and a [[wiki-link]] syntax straight away.

Edit: Apologies. The last comment about Markdown does not help you achieve what you are pursuing. Please disregard it. Sorry for the noise I caused.

protesilaos commented 4 months ago

I checked again: the radio targets are not easy to extend. We cannot implement this feature right now. Closing, thank you!

reyman commented 4 months ago

I see on org mailling list that radio target don't scale well because it maintain a list of regexp that grow with your usage

Indeed. The issue we have here is that radio links are pointers in the current file. There is no mechanism to extend them.

Perhaps you @reyman can use the new feature is denote-org-extras.el that links to a heading inside of the file? I did a video demo of the feature: https://protesilaos.com/codelog/2024-01-20-emacs-denote-link-org-headings/

A function that do some sort of "search and replace" in the text based on the content of the description in denote [[link][description]] could be more useful in my case. Advantage of this approach, no need to maintain a list of regex, and link are write in hard in the text. The inverse function could also be useful, removing all links in the text based on description.

I think I follow you, but just to be sure: can you show how you imagine the file will change? Like have a before and after for comparison?

I do not know if we can do something on this front, because it will not be standard Org. But we may write some snippet in the manual.

@protesilaos Ok for <<>> but do you think a simple snippet like described in the quoted previous discussion would be feasible ? I could open a new issue if you want.