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.
My checklist template are usually located in a separate file, and sometimes even
in more than one. Being able to copy those template to point is thus crucial.
Excluding NOTEs as refile targets also excludes them as jump targets for C-u C-c
C-w, which is bad. Better move all NOTEs out of the main task list into a
separate notes.org or something.
This reverts commit 90b6e91051.
NOTEs are meant to hold information for the project at hand, and not to collect
tasks, because NOTEs are meant to live longer than those tasks. Use dedicated
subprojects to group tasks. Task may (and probably should) refer to NOTEs for
keeping long lasting information, though.
This function is referenced in some doc string already, and could as well be
public, so let's make it so. This amounts to removing a dash from it's function
name.
This allows the same copy behavior as before (apart from newly introduced bugs,
that is), but in addition gives the possibility to copy bodies of arbitraty
items that can be choosen interactively. This might come in handy when copying
general checklists from anywhere in the main Org mode file to the current task.
This allows to insert links to items that were recently clocked into. The
selection to those items is done via `org-clock-select-task`, which itself will
display items from `org-clock-history`.
So far, we only considered one link in a headline and replaced it with its
description when linking to it. When there are multiple links, this will fail.
This commit changes this by iterating over all links in the headline, not only
the first one.
So far, when a link is discovered in a headline, we only keep the description of
that link. This will throw away the context of that link, which is
undesirable. So let's keep it.
When inserting links to other Org items or to the currently clocked-in item, the
complete target headline is used as a description in the newly inserted link.
When that target headline is itself a link, the newly inserted link will contain
the complete link as a description, rendering it unreadable and also
malformed (it's not allowed to have two consequtive brackets in the description
of a link). To remedy this, we now explicitly check the target headline for
being a link, and if so, only use the description of it as the description in
the newly inserted link.
When the link to another item is already present in the history of
`org-store-link`, nothing is updated. Inserting the topmost link then results
in a wrong link being inserted.
Not using `org-store-link` at all fixes this problem and also leaves the history
of `org-store-link` untouched. It also simplifies the implementation by not
relying on the complexity of `org-store-link`, but instead just only using
`org-entry-get` and `org-id-get-create`.
The `default-buffer` is apparently not optional when the current buffer is not
associated with a file. If `default-buffer` is missing and the current buffer
is not a file-buffer, e.g., a note buffer, then `org-refile-get-targets` fails.
When finding the location of an Org mode item to link to,
`org-refile-get-location` may return a point even if the target buffer is not
the default buffer. Resolving point in the default buffer thus yields a false
marker and the inserted link is wrong. To remedy this, also consider the file
name returned by `org-refile-get-location` to resolve point in the file buffer
for that file.
`org-refile-get-location` sometimes only returns a point and not a marker. In
that case, manually convert the point to a marker to ensure that calling
functions now where to go to. Additionally, ensure that
`db/org-default-org-file` is opened if not already done so, and error out if the
current buffer is not associated with a file and no default Org file exists.
We are only using the refile mechanism for convenience here, and not for actual
refiling. The refile verification function is thus not relevant here. To take
effect, we also have to ignore the cache, as it may hold precomputed targets
that have used the refile verification function in a previous run.