This PR enables the long-awaited nested-captures.
1. Adds a hook to org-capture-prepare-finalize-hook, which installs org-roam-capture--finalize into org-capture-after-finalize-hook if the capture is an Org-roam capture. This function contains key functionality for Org-roam to Do The Right Thing after specific interactive functions, such as finding the file, or inserting a link.
2. A patch for org-capture-finalize. Specifically, we make org-capture-plist valid during org-capture-finalize.
3. Many hacks that were originally in place are now replaced with nicer alternatives.
Co-authored-by: Leo Vivier <zaephon@gmail.com>
* (feat): Add customize settings to `org-roam-capture-templates`
Declare `org-roam-capture-templates` with `defcustom` and update the
docstring.
Co-authored-by: Leo Vivier <leo.vivier+dev@gmail.com>
New option: `org-roam-capture-function`
Specifies which command is used by org-roam to run the org-capture
process. The default behaviour maintains compatibility with earlier
versions of org-roam. I.E.:
- uses `org-capture`.
- immeadiately chooses the first capture template when
`org-roam-capture-templates` has only one template.
When you've changed `org-roam-capture-function` AND
`org-roam-capture-templates` has multiple templates,
`org-roam-capture-function` is run interactively to
start the org capture process.
Eg. usage: `(setq org-roam-capture-function 'counsel-org-capture)`
Lexically bind org-capture-templates-contexts to nil before calling org-capture
with org-roam-capture-templates. Otherwise, contexts may shadow
org-roam-templates which have same keys as org-capture-templates.
mentioned in #651
Initially we thought that using hash-tables would shave some seconds
because searching for a key is O(1), but when we present completions, we
typically want them sorted, and hash-tables do not support sorted keys.
Co-authored-by: Leo Vivier <leo.vivier+dev@gmail.com>
Tags are used as meta-data for files: they facilitate interactions with notes where titles are insufficient. For example, tags allow for categorization of notes: differentiating between bibliographical and structure notes during interactive commands.
Co-authored-by: Leo Vivier <leo.vivier+dev@gmail.com>
Co-authored-by: N V <44036031+progfolio@users.noreply.github.com>
* (internal): Summarize features
Replace generic package description in features' first line summary.
Co-authored-by: Leo Vivier <leo.vivier+dev@gmail.com>
Allows user to run functions when an `org-roam-capture` is successful. This
might come in handy for moving point after finding the new file, since right
now, it is at `(point-min)`.
Beyond just an extraction, this is also a simplification. It removes two
variables: `org-roam-date-filename-format` and
`org-roam-date-title-format`, in favour of directly specifying them in
the `org-roam-dailies-capture-templates`.
`org-roam--file-for-time` is also vastly simplified to use org-capture's
default time expansion utilities, by setting the capture template's
`:default-time` appropriately.
Instead of using a global variable to check for a existing capture,
leverage the :org-roam plist property of the buffer-local variable
`org-roam-capture-current-plist`.
This prevents a lockout if the capture buffer is killed
This is a hotfix for #369. Currently, calling `org-roam-capture` sets
`org-roam-capture--in-process` to `t`, but cancelling the capture
process does not reset it to `nil`, causing false errors. The whole
nested org-capture processes workaround is brittle, this change moves it
as far back as possible, but the whole thing needs to be redesigned.