The idea is that those entries represent project notes which should not get
tasks refiled as sub-items (sub-headings to structure these notes are fine,
though, and must be added directly). To connect tasks with project notes, use
links and backlinks instead.
This helps to prevent accidental refiling of tasks under notes and loosing them
there. A drawback is that `C-u org-refile` won't list notes as visiting targets
anymore; for this, use imenu instead.
Mostly making use of pcase-*, but I am not quite sure whether the `(,foo . ,bar)
syntax really helps …
Also adjusted some comments and some formatting.
We are interested in the backlinks so we now put them first. The backlink
targets (i.e., current item or any of its parents) are now grouped after the
priority of the item containing the backlink.
This dynamic block will list all items (including their priority) that link to
the item at point or to any of its parent items. The use case for this is to
have a series of periodic appointments where certain topics should be
discussed (“jour fixe”), and where those topics can be referenced in those
appointments via backlinks. However, simple backlinks to an item on a fixed
date is not sufficient here, as there might not be enough time on that day to
discuss all items. To avoid having to manipulate all backlinks that could not
be discussed, one could simply add a reference to the parent item of all
appointments of the jour fixe series. Using the new dynamic block introduced
here, this item will be on the list of open topics until it's closed.
It does not make sense to look in non-Org buffers for backlinks of items, but
this was indeed what happend until now: the function `db/org-get-location` only
checked whether the current buffer is associated with a file, and if so uses it
for querying the user for an item to select. This does not make sense, as
`db/org-get-location` is supposed to return a mark to an Org item.
This is now fixed by `db/org-get-location` to also check whether the current
buffer is also an Org buffer. It's as simple as that.
This function is not meant for interactive use, but instead should be used in
source blocks such as
```
(db/org-backlinks-to-item-at-point)
```
This will add a table of all items linking to the current item at point, and cut
be used in item templates, for example.
Background: I tried to achive this functionality with `org-ql` directly, but
somehow failed. This function simply encapsulates the corresponding call to
`org-ql-query`, adding the ID property of item at point automatically.
When inserting links multiple times, it's annoying to have to go back to the
original place the link points to and reinsert it into the stored link list.
Using a universal argument to toggle `org-link-keep-stored-after-insertion` is
also not an option, as I keep forgetting to use it.
Instead, by default keep all links after insertion. To be able to handle the
growing list of links, we now provide a function `db/org-clear-stored-links` to
set the list of stored links to the empty list.
It happens sometimes that the clock is not active, in which case hydra tried to
replace strings in `org-clock-current-task`, then a nil value. Fixed this.
I think I just did it wrong, so let's try adding a note by calling
`org-add-note` directly. So far it's working better, but I am not quite sure
whether I really did it right this time. In any way, `org-add-note` keeps track
of all the bookkeeping for taking notes, so my code is simpler now :)
This allows both a more fine-grained and more flexible control over where
templates can be located and which templates are suppoed to be used for the item
at point. This function could also be bound to a custom key binding to make it
easier to invoke.
Instead of going upward from the end, we now just start from the beginning and
skip all drawers we may encounter. This should also allow to copy subtrees in
templates, although adjustments to the headline indentations might be necessary
if the template and point are on different levels.
Using `insert` directly makes use of character conversion and may scramble the
byte when inserting into the buffer (indeed, `insert` does not seem to insert
the byte, but the characters whose code-points is given in the string; same for
`insert-char`).