The original code uses macros that when expanded use a lot memory
and are relatively slow. This removes some of that processing:
- Add a constructor to org-roam-node that does uses parameters
by position instead or by name
- Add the option of using a function to format nodes. The current
code uses a string template. But this template is processes
for every node. Using a function will further improve
performance significantly.
Simplified expected return value user's template function.
As suggested by akashpal-21, the return value of the user's template
function can be simpler.
I have refactored the code such that the function only returns
a string (potentially propertized) with the formatted node.
I have also modified the documentation of
org-roam-node-display-template with an example of the user defined
function.
Acknowledgement: akashpal-21 for the suggestion for improvement
Close: #2511
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.
(kill-whole-line) kills folded text if called from column 1
Make sure to unfold text before calling it --
Prevents data loss if user has decided to extract subtree on a folded org headline.
`=' assumes that both objects being compared are numbers. In some
buffers `outline-level' can return nil, so `=' returns an error. `eq'
does not assume this, but does return t when comparing two numbers.
* (node): new custom `org-roam-ref-prompt-function'
Function for prompting when adding a ref.
* (node): use `org-roam-ref-prompt' in `org-roam-ref-add'
Prompt properly for ref.
* don't complete org-roam nodes in source blocks
This fixes the following situation where
`org-roam-completion-everywhere = t` and you are working with org-babel
blocks in one of your org-roam nodes.
```
```
Before my nodes would be suggested, but after this change only valid
babel headers are suggested as desired.
Previously completions from org-roam nodes would be suggested
* fix lints
Co-authored-by: Jethro Kuan <jethrokuan95@gmail.com>
Without specifying `t`, it is only pushing the PROPERTIES drawer up to
the file level, missing any other "planning information, clocking lines and
any kind of drawer." We want to promote all of this to the file level.
org-roam-node-at-point returned the wrong value if point-min is a
level-1 heading node. We make sure that everytime we go up one
heading, the outline-level changes (reduces by 1) to prevent this error.
* Fix undefined incf.
Calling org-roam-extract-subtree failes with "Symbol’s function definition is void: incf"
org-roam.el includes cl-lib. org-roam--h1-count uses a bare incf call, which is undefined. Fix this by using cl-incf.
* Save buffer before promoting it.
After fixing incf in 8ec2e59e67, org-roam-extract-subtree still fails.
The error is now: org-roam-db--file-hash: Opening input file: No such file or directory,...
The buffer with the newly created content is still unsaved at this time, so save it before calling (org-roam-promote-entire-buffer)
Caveat is we now save the buffer two times, before and after promoting it.
Previously we only updated the database on file save, but we need to
update the file's atime on file access, so we hook into `find-file-hook`
to do so. We only update the file atime if the file exists in the file table.
Special care is taken not to move the point if the original point is no
longer the same (i.e. the user moves the cursor after calling the
capture, but before finalizing it). Fixes#2108.
Previously, the file-path of the new node in `org-roam-extract-subtree'
was incorrect in many circumstances. Expanding w.r.t. the initial
prompt directory (ie, `org-roam-directory') fixes that
Revert to a simplified `org-roam-node-display-template`, because on
non-vertical completion frameworks it looks and behaves strangely. To
restore the original default behaviour, set
`org-roam-node-display-template` in your Emacs configuration as such:
(setq org-roam-node-display-template
(concat "${title:*} "
(propertize "${tags:10}" 'face 'org-tag)))
Emacs commit 3f096eb3405b2fce7c35366eb2dcf025dda55783 introduced
`string-glyph-compose` and `string-glyph-decompose`, autoloading these instead
of the (still existing) `ucs-normalize-NFC-region` and
`ucs-normalize-NFD-region`.
There are three cases:
- Emacs where these transitions have not happened yet (e.g. 27.1):
`ucs-normalize-NFC-region` and `ucs-normalize-NFD-region` are still
autoloaded, aliasing the new names to them will keep them usable
and the code still works.
- Emacs where the new functions are defined (not yet released): the new names
are autoloaded, no aliases are installed and the code still works.
- A (hypothetical?) Emacs where `string-glyph-compose` and
`string-glyph-decompose` are renamed. If `ucs-normalize-NFC-region` and
`ucs-normalize-NFD-region` do not get their autoloaded status back, the
aliasing will happen but the functions not autoloaded and the code will
break in the same way as in #1981