Figuring out how to indent things and folding and clock updates, etc.
consumes a great deal of time especially considering that files
are (currently) processed for /every single backlink/ even if multiple
backlinks come from the same file.
This dramatically improves the load/refresh time for the org-roam
buffer.
Fix: #2399
To avoid having to create a wrapper function and silence the byte-
compiler for both when using a pre-rename and post-rename Org, keep
it simple and just depend on Org 9.6.
That function was added two years ago and the first release that
provided it was v4.0.0. It automatically picks the best available
back-end, `emacsql-sqlite-builtin' or `emacsql-sqlite-module'.
In v4.0.0 it could also fall back to the legacy `emacsql-sqlite'.
The inferior third-party back-ends are no longer supported.
Emacsql v4.1.0, which will be releases in early December, removes
the legacy `emacsql-sqlite' back-end (which used a custom binary).
This has an effect on find-file-hook for totally unrelated files,
through the callchain of `org-roam-db-autosync--setup-file-h ->
org-roam-file-p -> org-roam-descendant-of-p'.
From an org file, inside a project-el project, (find-file
"some/other/file") will intermittently reproduce this error:
org-roam-descendant-of-p: Wrong type argument: arrayp, nil
If this fix seems inappropriate -- it could amount to surppressing a
valid error in routine calls -- then I would advise throwing an
explicit signal here, or finding a safer way to get the `path` inside
`org-roam-file-p'; the current means:
(or file (buffer-file-name (buffer-base-buffer)))
.. can result in nil, which then bleeds errors into use elsewhere.
for posterity, here is the full calling context I'm referring to, from
`org-roam-file-p'.
(let* ((path (or file (buffer-file-name (buffer-base-buffer))))
(ext (when path (org-roam--file-name-extension path)))
(ext (if (string= ext "gpg")
(org-roam--file-name-extension (file-name-sans-extension path))
ext))
(org-roam-dir-p (org-roam-descendant-of-p path
org-roam-directory))
...
* (fix)capture: fill-template preserve whitespace content
Preserve the whitespace content given in the capture template, by
caching it and then appending it to the output template. For
Org-capture's purposes, we need to separately ensure that a newline is
present. Adds tests to the various helper functions to illustrate changes.
Addresses #2115
* Revert "(fix): `org-roam-descendant-of-p` bug on Windows (#2089)"
This reverts commit 97a342fd3f.
Reason:
It seems that the `file-in-directory-p` function proposed in #2089 is provided only for
*physical directories*, does not work as we would like with *symlinked directories*.
It dereferences all the symlinks in its path, and previously seemed related paths
cease to be such.
Because of this, such notes are ignored and not indexed, although they
were indexed earlier.
On Windows, `file-truename` and `directory-file-name` downcase driver
label: "C:/" => "c:/", while `expand-file-name` keep the case
unchanged. If `org-roam-directory` use upper case driver label, `org-roam-descendant-of-p` will alway return `nil`. Fix by only using `file-truename` in the function.
This commit adds 3 custom variables:
1. org-roam-buffer-postrender-functions
This list of functions are run within the Org-roam buffer after the
Org-roam buffer is rendered. For example, one can produce latex previews
for all content within the Org-roam buffer:
(add-hook
'org-roam-buffer-postrender-functions (lambda () (org--latex-preview-region
(point-min) (point-max))))
2. org-roam-preview-function
This is the function used to extract the content to populate the buffer.
It defaults to `org-roam-preview-default-function`, which extracts all
contents within the headline up to the next headline.
3. org-roam-preview-postprocess-functions
This is a list of functions run to post-process the content retrieved
from org-roam-preview-function. It can be used to strip additional
content from the buffer, or perform sentence-unwrapping.
Org-ref v3 introduced a new citation syntax, and removed some functions
that org-roam had previously relied upon (e.g. for extracting keys from
multi-citations).
This commit introduces support on two fronts:
1. Add `org-roam-org-ref-path-to-keys` which converts a link path to a
list of keys. This supports both Org-ref v2 and v3.
2. Adds support for parsing multi-citations in refs.
The old implementation:
- did not handle duplicate keys well (the function would be applied to each value, but only the first value would be updated with the last value's result)
- was quadratic in the length of the input list (for each key, plist-put would search for the first occurrence of the key by going through all previous elements again)
- copied the input sequence even though this was not really needed
- did not provide a result value that could be useful, thus encouraging imperative programming
- did not need to be a macro, and the macro implementation was evaluating fn multiple times and causing warnings in the native compiler because k and v were not bound.
Some commit in Org 9.5 changed the AST structure, so we our previous
preview content logic was borked and started showing the full contents
of the file. To be forward compatible we change the content preview
logic, and extract everything within the section.
Fixes#1934.
Require optional libraries 'org-ref and 'oc only once per function run:
org-roam-db-update-file and org-roam-db-sync will call these requires at
the top level instead of within the link mapper.
Previously org-roam-set-keyword was unable to handle the syntax of the
:LOGBOOK: drawer. We introduce `org-roam-end-of-meta-data` to move point
over all drawers, allowing us to set the keyword in the right place.
* (fix)org-roam-unlinked-references-section: Use truncate-string-ellipsis
The variable can be set to a unicode ellipsis.
* (fix)org-roam-node-read--format-entry: Fix highlighting for truncation
Fix#1801. The truncated part of the string is made invisible. Matching
on the whole string remains possible.
* (fix)org-roam-format-template: Preserve string properties like format
If the variable value carries properties itself, these properties
take precedence. Display templates can be properties with this change.
(setq org-roam-node-display-template
(concat (propertize "${title:*}" 'face 'font-lock-keyword-face)
" "
(propertize "${tags:10}" 'face 'font-lock-constant-face)))
If org-roam-utils.el is byte-compiled when org-macs is not loaded (`org-with-point-at` macro missing), error can appear about missing `org-with-point-at`.
Output the commit hash when it's available (e.g. when using straight to
install packages). This comes in handy during debugging during error
reporting.
Detangle the codebase and change how dependencies are resolved to
allow the package to better modularize and load itself without
introducing circular dependencies, especially when autoloads involved.
At the current state autoloads from non `org-roam.el` unable to start
loading of the package from their own file. See the following to learn
more about the problem:
https://github.com/org-roam/org-roam/issues/1590#issuecomment-885817825
This is no more than a workaround to bandage a more deeper underlying
problem. Until the more fundamental problem won't be fixed, all autoload
cookies from non "org-roam.el" file will need to manually point to the
main entry point of the package -- "org-roam.el" file, to load it
without causing errors.
Fixes#1590, #1620, #1600 and other similar issues.
Add 2 custom handlers:
1. roam-file?file=path: this simply opens the file at path in Emacs.
2. roam-ref?ref=ref&template=roam-template&title=title&...: attempts to open a roam note with a given ROAM_KEY. If the note doesn't exist, create one. Else, open it.
All org-roam related information will now be stored in the database. Henceforth, the cache needs to be built synchronously once (via `M-x org-roam-build-cache`), which is then incrementally updated.