protesilaos / denote

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

Nested dynamic blocks breaks the update functionality #380

Open bryanrinders opened 3 months ago

bryanrinders commented 3 months ago

Hi,

I think the issue is best explained with an example. Let say I have three files:

The problem then is when trying to update the denote-files dblock in the parent file. It will not properly remove all the old contents before inserting the new contents.

The issue is with the function org-prepare-dblock. To remove the contents of the dblock it will simply search for the first #+end, starting the search at the #+begin denote-files, and delete everything in between. However the first #+end in this example is not end of the correct dblock and hence not the entire contents of the denote-files dblock is deleted

protesilaos commented 3 months ago

From: bryanrinders @.***> Date: Sun, 16 Jun 2024 09:12:03 -0700

[... 54 lines elided]

The problem then is when trying to update the denote-files dblock in the parent file. It will not properly remove all the old contents before inserting the new contents.

The issue is with the function org-prepare-dblock. To remove the contents of the dblock it will simply search for the first #+end, starting the search at the #+begin denote-files, and delete everything in between. However the first #+end in this example is not end of the correct dblock and hence not the entire contents of the denote-files dblock is deleted

I am not sure there is something we can do about it in Denote. We would have to refactor the relevant parts in Org, though this sort of work is not trivial.

If there is a solution to this, I am happy to have it in Denote.

-- Protesilaos Stavrou https://protesilaos.com

protesilaos commented 3 months ago

Actually, can you try the key binding C-c C-x C-u? It seems to work on my end.

bryanrinders commented 3 months ago

Actually, can you try the key binding C-c C-x C-u? It seems to work on my end.

I tried this and I still end up with linked file twice in the dblock. I am not sure how this works for you. And just to be clear this also happens when not loading my init file, with emacs -q.

protesilaos commented 3 months ago

I think that key worked on my end. At any rate, this is an Org issue. We will need to check if there is a workaround for it. Perhaps if the outer BEGIN and END are given a unique identity?