Commit Graph

276 Commits

Author SHA1 Message Date
Daniel - 05a126bfed
Introduce dynamic block to show backlinks of Org item at point
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.
2022-05-14 11:43:08 +02:00
Daniel - a36671dc61
Fix minor indentation glitch 2022-05-08 17:04:45 +02:00
Daniel - 9184756c07
Refactor function to return backlinks to item at point
Extract function to return actual list of backlinks, to later use it for
extracting backlinks of item at point and all its parents.
2022-05-05 22:08:02 +02:00
Daniel - 8f18c159d0
Code cosmetics
And not using `nconc`, as I am not quite sure whether it would also affect
`org-agenda-text-search-extra-files`.
2022-04-16 10:19:28 +02:00
Daniel - 341dec6a6a
Simplify code searching for backlinks
Reduce the conditional parts and extract common code.
2022-04-16 10:13:00 +02:00
Daniel - b670ee57f6
Only search Org buffers when querying for backlinks
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.
2022-04-16 10:08:11 +02:00
Daniel - 1d5f318b5b
Add function to return list of Org items linking to item at point
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.
2022-04-16 09:58:46 +02:00
Daniel - fdc32eaa6d
Clear refile cache when updating the headline of an org mode item 2022-04-02 08:56:18 +02:00
Daniel - 4428db4f82
Apply minor cosmetics 2022-03-30 08:44:15 +02:00
Daniel - cfc11ec807
Keep Org links after insertion by default
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.
2022-03-30 08:42:06 +02:00
Daniel - 0db003d442
Try fixing adding note in headline update function
Let's not try to use the Org mode functions to add notes, but instead do it
directly manually.  I hope this works better now …
2022-03-24 20:16:50 +01:00
Daniel - 9d7e88df0e
Ensure functioning of Org Clock hydra even if no task is clocked
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.
2022-02-26 10:16:13 +01:00
Daniel - efb7500202
Add original value as default when changing Org item headlines
This allows to make simple changes to the original headline of an item.
2022-01-08 15:42:40 +01:00
Daniel - d23a8dc817
Fix adding notes when updating headlines
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 :)
2022-01-08 09:11:02 +01:00
Daniel - 407f5d70f2
Add newlines when inserting templates
I find myself inserting these newlines whenever I insert a template, so let's
let them insert them automatically.
2022-01-02 09:31:29 +01:00
Daniel - 5bc7c70882
Add function to copy template of Org Mode item to location at point
This is a convenience function and has been bound to a shortcut for easier
usage.  This function is supposed to be the standard way to copy templates.
2021-12-15 09:43:50 +01:00
Daniel - 80eeca1e44
Add simple function to find template via special property
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.
2021-12-13 21:32:05 +01:00
Daniel - cedaae00e8
Make template copy function more robust
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.
2021-12-13 21:17:18 +01:00
Daniel - 159c8c0eb6
First check for major mode when update Org item headline 2021-11-29 17:39:33 +01:00
Daniel - 5c36dba12c
Make function to update Org item headlines also work in agenda 2021-11-29 17:39:27 +01:00
Daniel - 25a7051c12
Add function to update headline of Org mode item and log note
This allows changing the headline of an item if it's scope changes and record
this change in a note.
2021-11-29 17:16:25 +01:00
Daniel - 0d1fe48e6f
Allow to copy template from outside of current file
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.
2021-10-29 14:35:35 +02:00
Daniel - 747e505fda
Revert "Exclude NOTEs as refile targets"
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.
2021-10-24 12:56:29 +02:00
Daniel - 5b10f83303
Fix typo 2021-10-16 12:27:56 +02:00
Daniel - c17bc4c1ab
Explicitly set frame title when current Org task changes
This should enable new frames to show the correct title, and not just the
default "emacs" string.
2021-10-16 12:21:02 +02:00
Daniel - 90b6e91051
Exclude NOTEs as refile targets
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.
2021-10-16 10:12:51 +02:00
Daniel - 785db3ded8
Fix typo in linking hydra 2021-09-04 16:17:35 +02:00
Daniel - 158601f012
Make custom function to query for locations in Org mode files public
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.
2021-08-08 13:51:52 +02:00
Daniel - ca679b2274
Refactory template copy function into function to copy item bodies
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.
2021-08-08 13:49:07 +02:00
Daniel - 76990dcdf2
Allow fast link creation to items recentely associated with clocking
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`.
2021-07-17 08:47:37 +02:00
Daniel - 0899a9079e
Clean up all links in headline when linking to it
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.
2021-05-12 18:29:34 +02:00
Daniel - 7960f763f4
Keep headline around links when linking to them
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.
2021-05-12 18:20:18 +02:00
Daniel - 268ddeb1aa
Avoid complete links in descriptions when adding links to Org items
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.
2021-05-12 17:47:45 +02:00
Daniel - a0b1f4df0d
Do not use `org-store-link` when inserting links to other items
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`.
2021-04-29 19:52:54 +02:00
Daniel - 56b1de2844
Remove duplication of refile target specification for current buffer 2021-04-16 17:34:40 +02:00
Daniel - 77f2dfc0eb
Fix missing specification of default buffer when inserting links
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.
2021-04-16 17:31:55 +02:00
Daniel - 318f7c8f44
Fix reference to wrong buffer when creating links to other items
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.
2021-04-01 17:02:01 +02:00
Daniel - 8f4fa01304
Remove redundant save of point and mark
`org-with-point-at` will do this already (at least for point).
2021-04-01 16:51:46 +02:00
Daniel - 1916eb6736
Move point when inserting link to other Org mode item
This is the natural flow, as usually one continues writing after the link, not
before it.
2021-04-01 16:51:03 +02:00
Daniel - 96638b09e4
Allow to show backlinks directly from Org agenda buffers
This is more convenient than to first switch to the item in the corrsponding Org
mode buffer and then querying for its backlinks.
2021-03-27 10:39:53 +01:00
Daniel - 732323edfc
Ensure to always return a marker when inserting links to other items
`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.
2021-03-27 10:22:21 +01:00
Daniel - 00ca4c0276
Minorly simplify definition of Org linking hydra
This way, the help buffer of the hydra provides a link to the underlying
function.
2021-03-27 09:48:55 +01:00
Daniel - 22058b1568
Allow adding links to other items without refile verification
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.
2021-03-26 16:47:22 +01:00
Daniel - d6584ef521
Fix signature of frame hook function
This got removed in the last refactoring attempt.
2021-03-26 16:38:17 +01:00
Daniel - d7b2ad0b71
Extend docstring for hydra-org-linking 2021-03-20 20:50:27 +01:00
Daniel - fd14313b9b
Only warn about RESET_CHECK_BOXES if it's really there 2021-03-20 16:33:00 +01:00
Daniel - 7833e28185
Make checkdoc happy about db-org 2021-03-20 16:03:12 +01:00
Daniel - 6e8b878b4d
Warn when using the deprecated RESET_CHECK_BOXES property
I want to use periodic tasks for repeated tasks with check boxes.
2021-03-20 15:57:45 +01:00
Daniel - 78b202aed7
Introduce hydra for managing links between Org mode items
It's easier to use and easier to keep track of what is available.  It also saves
key precious bindings!
2021-03-20 15:45:49 +01:00
Daniel - 77920dd9a2
Move cursor forward when inserting link to current clock 2021-03-20 15:45:15 +01:00