mirror of
https://github.com/org-roam/org-roam
synced 2025-08-07 12:47:23 -05:00
Compare commits
38 Commits
Author | SHA1 | Date | |
---|---|---|---|
3782e88d50 | |||
b4f14eebae | |||
cce6a05630 | |||
cc3689f30f | |||
b179a5a1a6 | |||
9172001c11 | |||
c51cadfe25 | |||
f6950a9820 | |||
feb9179c9f | |||
f50d6e7376 | |||
65ea325071 | |||
62d311de22 | |||
c8a360afdd | |||
cebe77135a | |||
25d828c32e | |||
fd97c80a26 | |||
97a342fd3f | |||
d20480bb8d | |||
b163c900b8 | |||
0432b00485 | |||
ccfa97ec3a | |||
86e102d990 | |||
eed1df90f5 | |||
905564a7eb | |||
9f7a4a0b02 | |||
aafe4114c2 | |||
3e2716edf3 | |||
445e3594b2 | |||
6f5d65abd9 | |||
817d8036fb | |||
c17310f0de | |||
bf3ebe2121 | |||
47ad646d51 | |||
6263c3a956 | |||
69742c3d51 | |||
5b15159a2c | |||
c0c240b975 | |||
001de3a874 |
@ -4,6 +4,9 @@
|
||||
(elisp-lint-ignored-validators . ("byte-compile" "package-lint"))
|
||||
(elisp-lint-indent-specs . ((describe . 1)
|
||||
(it . 1)
|
||||
(thread-first . 0)
|
||||
(cl-flet . 1)
|
||||
(cl-flet* . 1)
|
||||
(org-element-map . defun)
|
||||
(org-roam-dolist-with-progress . 2)
|
||||
(org-roam-with-temp-buffer . 1)
|
||||
|
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@ -46,7 +46,7 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Install Eldev
|
||||
run: curl -fsSL https://raw.github.com/doublep/eldev/master/webinstall/github-eldev | sh
|
||||
run: curl -fsSL https://raw.github.com/org-roam/org-roam/master/github-eldev | sh
|
||||
|
||||
- name: Install dependencies
|
||||
run: make prepare
|
||||
|
33
CHANGELOG.md
33
CHANGELOG.md
@ -1,4 +1,37 @@
|
||||
# Changelog
|
||||
## 2.2.1
|
||||
### Breaking
|
||||
- [#2054](https://github.com/org-roam/org-roam/pull/2054) node: simplify default `org-roam-node-display-template`.
|
||||
This was done so completions work fine by default on all completion systems. To restore the tabular vertical completion interface, set this in your configuration:
|
||||
|
||||
```emacs-lisp
|
||||
(setq org-roam-node-display-template
|
||||
(concat "${title:*} "
|
||||
(propertize "${tags:10}" 'face 'org-tag)))
|
||||
```
|
||||
|
||||
### Added
|
||||
- [#2042](https://github.com/org-roam/org-roam/pull/2042) db: add `org-roam-db-extra-links-elements` and `org-roam-db-extra-links-exclude-keys` for fine-grained control over additional link parsing
|
||||
- [#2049](https://github.com/org-roam/org-roam/pull/2049) capture: allow ID to be used as part of `org-roam-capture-templates`
|
||||
- [#2050](https://github.com/org-roam/org-roam/pull/2050) core: add `FILTER-FN` to `org-roam-node-random`
|
||||
- [#2065](https://github.com/org-roam/org-roam/pull/2065) dailies: add `keys` argument to the remaining dailies functions `org-roam-dailies-goto-yesterday`/`-today`/`-tomorrow`/`-date` and `org-roam-dailies-capture-yesterday`/`-tomorrow`/`-date` to give the abilty to get into a capture buffer bypassing the selection screen in all dailies commands. Extension of #2055
|
||||
- [#2079](https://github.com/org-roam/org-roam/pull/2079) capture: ensure that `:ref` info captured in all cases.
|
||||
- [#2121](https://github.com/org-roam/org-roam/pull/2121) buffer: add unique option to `org-roam-backlinks-section`
|
||||
|
||||
### Removed
|
||||
### Fixed
|
||||
- [#2086](https://github.com/org-roam/org-roam/pull/2086) capture: correctly update org-id-locations on capture
|
||||
- [#2082](https://github.com/org-roam/org-roam/pull/2082) buffer: don't destroy window if `org-roam-node-toggle` reuses window
|
||||
- [#2080](https://github.com/org-roam/org-roam/pull/2080) dailies: prevent multiple "dailies/" subdir expansions
|
||||
- [#2055](https://github.com/org-roam/org-roam/pull/2055) dailies: removed stray f require, which was causing require and compilation errors
|
||||
- [#2117](https://github.com/org-roam/org-roam/pull/2117) capture: preserve trailing whitespace content in capture templates
|
||||
|
||||
### Changed
|
||||
- [#2060](https://github.com/org-roam/org-roam/pull/2060) node: added double acute accent normalization for Unicode characters in titles
|
||||
- [#2040](https://github.com/org-roam/org-roam/pull/2040) completions: fix completions display-width for Helm users
|
||||
- [#2025](https://github.com/org-roam/org-roam/pull/2025) chore: removed the dependencies on f.el and s.el
|
||||
- [#2109](https://github.com/org-roam/org-roam/pull/2109) capture: `org-roam-node-insert` places cursor after inserted link where appropriate
|
||||
- [#2123](https://github.com/org-roam/org-roam/pull/2123), [#2124](https://github.com/org-roam/org-roam/pull/2124) buffer: `org-roam-mode-section-functions` renamed to `org-roam-mode-sections`, supports passing args into the section-rendering function
|
||||
|
||||
## 2.2.0
|
||||
### Added
|
||||
|
53
README.md
53
README.md
@ -47,30 +47,6 @@ Stable](https://stable.melpa.org/) using `package.el`:
|
||||
```
|
||||
M-x package-install RET org-roam RET
|
||||
```
|
||||
|
||||
Here's a very basic sample for configuration of `org-roam` using `use-package`:
|
||||
|
||||
```emacs-lisp
|
||||
(use-package org-roam
|
||||
:ensure t
|
||||
:custom
|
||||
(org-roam-directory (file-truename "/path/to/org-files/"))
|
||||
:bind (("C-c n l" . org-roam-buffer-toggle)
|
||||
("C-c n f" . org-roam-node-find)
|
||||
("C-c n g" . org-roam-graph)
|
||||
("C-c n i" . org-roam-node-insert)
|
||||
("C-c n c" . org-roam-capture)
|
||||
;; Dailies
|
||||
("C-c n j" . org-roam-dailies-capture-today))
|
||||
:config
|
||||
(org-roam-db-autosync-mode)
|
||||
;; If using org-roam-protocol
|
||||
(require 'org-roam-protocol))
|
||||
```
|
||||
|
||||
Note that the `file-truename` function is only necessary when you use symbolic
|
||||
link to `org-roam-directory`. Org-roam won't automatically resolve symbolic link
|
||||
to the directory.
|
||||
</details>
|
||||
|
||||
### Using `straight.el`
|
||||
@ -198,6 +174,33 @@ Org-roam also comes with `.texi` files to integrate with Emacs' built-in Info
|
||||
system. Read the manual to find more details for how to install them manually.
|
||||
</details>
|
||||
|
||||
## Configuration
|
||||
|
||||
Here's a very basic sample for configuration of `org-roam` using `use-package`:
|
||||
|
||||
```emacs-lisp
|
||||
(use-package org-roam
|
||||
:ensure t
|
||||
:custom
|
||||
(org-roam-directory (file-truename "/path/to/org-files/"))
|
||||
:bind (("C-c n l" . org-roam-buffer-toggle)
|
||||
("C-c n f" . org-roam-node-find)
|
||||
("C-c n g" . org-roam-graph)
|
||||
("C-c n i" . org-roam-node-insert)
|
||||
("C-c n c" . org-roam-capture)
|
||||
;; Dailies
|
||||
("C-c n j" . org-roam-dailies-capture-today))
|
||||
:config
|
||||
;; If you're using a vertical completion framework, you might want a more informative completion interface
|
||||
(setq org-roam-node-display-template (concat "${title:*} " (propertize "${tags:10}" 'face 'org-tag)))
|
||||
(org-roam-db-autosync-mode)
|
||||
;; If using org-roam-protocol
|
||||
(require 'org-roam-protocol))
|
||||
```
|
||||
|
||||
Note that the `file-truename` function is only necessary when you use symbolic
|
||||
link to `org-roam-directory`. Org-roam won't automatically resolve symbolic link
|
||||
to the directory.
|
||||
## Getting Started
|
||||
|
||||
[David Wilson](https://github.com/daviwil) of [System
|
||||
@ -225,7 +228,7 @@ it has not already been addressed on [GitHub][issues] or on
|
||||
|
||||
- [Jethro Kuan](https://braindump.jethro.dev/)
|
||||
([Source](https://github.com/jethrokuan/braindump/tree/master/org))
|
||||
- [Alexey Shmalko](https://braindump.rasen.dev/)
|
||||
- [Alexey Shmalko](https://www.alexeyshmalko.com/)
|
||||
- [Sidharth Arya](https://sidhartharya.github.io/braindump/index.html)
|
||||
|
||||
## Contributing
|
||||
|
130
doc/org-roam.org
130
doc/org-roam.org
@ -8,13 +8,13 @@
|
||||
#+texinfo_dir_category: Emacs
|
||||
#+texinfo_dir_title: Org-roam: (org-roam).
|
||||
#+texinfo_dir_desc: Roam Research for Emacs.
|
||||
#+subtitle: for version 2.2.0
|
||||
#+subtitle: for version 2.2.1
|
||||
|
||||
#+options: H:4 num:3 toc:nil creator:t ':t
|
||||
#+property: header-args :eval never
|
||||
#+texinfo: @noindent
|
||||
|
||||
This manual is for Org-roam version 2.2.0.
|
||||
This manual is for Org-roam version 2.2.1.
|
||||
|
||||
#+BEGIN_QUOTE
|
||||
Copyright (C) 2020-2021 Jethro Kuan <jethrokuan95@gmail.com>
|
||||
@ -369,7 +369,12 @@ For this tutorial, create an empty directory, and set ~org-roam-directory~:
|
||||
#+END_SRC
|
||||
|
||||
The ~file-truename~ function is only necessary when you use symbolic links
|
||||
inside ~org-roam-directory~: Org-roam does not resolve symbolic links.
|
||||
inside ~org-roam-directory~: Org-roam does not resolve symbolic links. One can
|
||||
however instruct Emacs to always resolve symlinks, at a performance cost:
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(setq find-file-visit-truename t)
|
||||
#+end_src
|
||||
|
||||
Next, we setup Org-roam to run functions on file changes to maintain cache
|
||||
consistency. This is achieved by running ~M-x org-roam-db-autosync-mode~. To
|
||||
@ -413,8 +418,59 @@ brought through the node creation process.
|
||||
One can also conveniently insert links via the completion-at-point functions
|
||||
Org-roam provides (see [[*Completion][Completion]]).
|
||||
|
||||
** Customizing Node Completions
|
||||
|
||||
Node selection is achieved via the ~completing-read~ interface, typically
|
||||
through `org-roam-node-read`. The presentation of these nodes are governed by
|
||||
~org-roam-node-display-template~.
|
||||
|
||||
- Variable: org-roam-node-display-template
|
||||
|
||||
Configures display formatting for Org-roam node.
|
||||
|
||||
Patterns of form "${field-name:length}" are interpolated based
|
||||
on the current node.
|
||||
|
||||
Each "field-name" is replaced with the return value of each
|
||||
corresponding accessor function for org-roam-node, e.g.
|
||||
"${title}" will be interpolated by the result of
|
||||
org-roam-node-title. You can also define custom accessors using
|
||||
cl-defmethod. For example, you can define:
|
||||
|
||||
(cl-defmethod org-roam-node-my-title ((node org-roam-node))
|
||||
(concat "My " (org-roam-node-title node)))
|
||||
|
||||
and then reference it here or in the capture templates as
|
||||
"${my-title}".
|
||||
|
||||
"length" is an optional specifier and declares how many
|
||||
characters can be used to display the value of the corresponding
|
||||
field. If it's not specified, the field will be inserted as is,
|
||||
i.e. it won't be aligned nor trimmed. If it's an integer, the
|
||||
field will be aligned accordingly and all the exceeding
|
||||
characters will be trimmed out. If it's "*", the field will use
|
||||
as many characters as possible and will be aligned accordingly.
|
||||
|
||||
A closure can also be assigned to this variable in which case the
|
||||
closure is evaluated and the return value is used as the
|
||||
template. The closure must evaluate to a valid template string.
|
||||
|
||||
If you're using a vertical completion framework, such as Ivy and Selectrum,
|
||||
Org-roam supports the generation of an aligned, tabular completion interface.
|
||||
For example, to include a column for tags up to 10 character widths wide, one
|
||||
can set ~org-roam-node-display-template~ as such:
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(setq org-roam-node-display-template
|
||||
(concat "${title:*} "
|
||||
(propertize "${tags:10}" 'face 'org-tag)))
|
||||
#+end_src
|
||||
|
||||
* Customizing Node Caching
|
||||
** How to cache
|
||||
:PROPERTIES:
|
||||
:ID: 280bfca8-83f3-4371-bc3a-25478d25129c
|
||||
:END:
|
||||
|
||||
Org-roam uses a sqlite database to perform caching, but there are multiple Emacs
|
||||
libraries that can be used. The default used by Org-roam is ~emacs-sqlite~.
|
||||
@ -485,6 +541,35 @@ all headlines with the ~ATTACH~ tag from the Org-roam database, one can set:
|
||||
(not (member "ATTACH" (org-get-tags)))))
|
||||
#+end_src
|
||||
|
||||
Org-roam relied on the obtained Org AST for the buffer to parse links. However,
|
||||
links appearing in some places (e.g. within property drawers) are not considered
|
||||
by the Org AST to be links. Therefore, Org-roam takes special care of
|
||||
additionally trying to process these links. Use
|
||||
~org-roam-db-extra-links-elements~ to specify which additional Org AST element
|
||||
types to consider.
|
||||
|
||||
- Variable: org-roam-db-extra-links-elements
|
||||
|
||||
The list of Org element types to include for parsing by Org-roam.
|
||||
|
||||
By default, when parsing Org's AST, links within keywords and
|
||||
property drawers are not parsed as links. Sometimes however, it
|
||||
is desirable to parse and cache these links (e.g. hiding links in
|
||||
a property drawer).
|
||||
|
||||
Additionally, one may want to ignore certain keys from being excluded within
|
||||
property drawers. For example, we would not want ~ROAM_REFS~ links to be
|
||||
self-referential. Hence, to exclude specific keys, we use
|
||||
~org-roam-db-extra-links-exclude-keys~.
|
||||
|
||||
- Variable: org-roam-db-extra-links-exclude-keys
|
||||
|
||||
Keys to ignore when mapping over links.
|
||||
|
||||
The car of the association list is the Org element type (e.g. keyword). The
|
||||
cdr is a list of case-insensitive strings to exclude from being treated as
|
||||
links.
|
||||
|
||||
** When to cache
|
||||
|
||||
By default, Org-roam is eager in caching: each time an Org-roam file is modified
|
||||
@ -551,10 +636,10 @@ There are currently 3 provided widget types:
|
||||
- Unlinked references :: View nodes that contain text that match the nodes
|
||||
title/alias but are not linked
|
||||
|
||||
To configure what sections are displayed in the buffer, set ~org-roam-mode-section-functions~.
|
||||
To configure what sections are displayed in the buffer, set ~org-roam-mode-sections.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(setq org-roam-mode-section-functions
|
||||
(setq org-roam-mode-sections
|
||||
(list #'org-roam-backlinks-section
|
||||
#'org-roam-reflinks-section
|
||||
;; #'org-roam-unlinked-references-section
|
||||
@ -563,6 +648,16 @@ To configure what sections are displayed in the buffer, set ~org-roam-mode-secti
|
||||
|
||||
Note that computing unlinked references may be slow, and has not been added in by default.
|
||||
|
||||
For each section function, you can pass args along to modify its behaviour. For
|
||||
example, if you want to render unique sources for backlinks (and also keep
|
||||
rendering reference links), set ~org-roam-mode-sections~ as follows:
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(setq org-roam-mode-sections
|
||||
'((org-roam-backlinks-section :unique t)
|
||||
org-roam-reflinks-section))
|
||||
#+end_src
|
||||
|
||||
** Configuring the Org-roam buffer display
|
||||
|
||||
Org-roam does not control how the pop-up buffer is displayed: this is left to
|
||||
@ -817,7 +912,16 @@ file:
|
||||
#+END_SRC
|
||||
|
||||
We also need to set up ~org-protocol~: the instructions for setting up
|
||||
~org-protocol~ are reproduced below.
|
||||
~org-protocol~ are reproduced here.
|
||||
|
||||
On a high-level, external calls are passed to Emacs via ~emacsclient~.
|
||||
~org-protocol~ intercepts these and runs custom actions based on the protocols
|
||||
registered. Hence, to use ~org-protocol~, once must:
|
||||
|
||||
1. launch the ~emacsclient~ process
|
||||
2. Register ~org-protocol://~ as a valid scheme-handler
|
||||
|
||||
The instructions for the latter for each operating system is detailed below.
|
||||
|
||||
*** Linux
|
||||
For Linux users, create a desktop application in
|
||||
@ -1536,6 +1640,20 @@ to the publishing directory. Example code follows:
|
||||
(kill-buffer (file-name-nondirectory svg))
|
||||
(setq my-publish-time 0)))))
|
||||
#+end_src
|
||||
** I'm seeing this "Selecting deleted buffer" error. What do I do?
|
||||
|
||||
The "selecting deleted buffer" error usually occurs when you don't have a
|
||||
working ~emacsql-sqlite~ executable. Org-roam relies on this executable to
|
||||
function properly, and doesn't catch this error. This issue is most commonly
|
||||
seen on Windows setups. You can browse through the various GitHub issues posted
|
||||
about this [[https://github.com/org-roam/org-roam/issues?q=is%3Aissue+selecting+deleted][here]].
|
||||
|
||||
To fix this, you can try the following:
|
||||
|
||||
1. If on Windows, try replacing your system binary with [[https://github.com/nobiot/emacsql-sqlite.exe][this one]] that has been proven
|
||||
to work
|
||||
2. Use the ~emacsql-sqlite3~ option rather than compiling your own emacsql
|
||||
binary (see [[id:280bfca8-83f3-4371-bc3a-25478d25129c][How to cache]]).
|
||||
|
||||
* Developer's Guide to Org-roam
|
||||
** Org-roam's Design Principle
|
||||
|
@ -31,7 +31,7 @@ General Public License for more details.
|
||||
@finalout
|
||||
@titlepage
|
||||
@title Org-roam User Manual
|
||||
@subtitle for version 2.2.0
|
||||
@subtitle for version 2.2.1
|
||||
@author Jethro Kuan
|
||||
@page
|
||||
@vskip 0pt plus 1filll
|
||||
@ -44,7 +44,7 @@ General Public License for more details.
|
||||
|
||||
@noindent
|
||||
|
||||
This manual is for Org-roam version 2.2.0.
|
||||
This manual is for Org-roam version 2.2.1.
|
||||
|
||||
@quotation
|
||||
Copyright (C) 2020-2021 Jethro Kuan <jethrokuan95@@gmail.com>
|
||||
@ -110,6 +110,7 @@ Getting Started
|
||||
* Links between Nodes::
|
||||
* Setting up Org-roam::
|
||||
* Creating and Linking Nodes::
|
||||
* Customizing Node Completions::
|
||||
|
||||
Customizing Node Caching
|
||||
|
||||
@ -194,6 +195,7 @@ FAQ
|
||||
* How do I migrate from Roam Research?::
|
||||
* How to migrate from Org-roam v1?::
|
||||
* How do I publish my notes with an Internet-friendly graph?::
|
||||
* I'm seeing this ``Selecting deleted buffer'' error. What do I do?: I'm seeing this ``Selecting deleted buffer'' error What do I do?.
|
||||
|
||||
How do I publish my notes with an Internet-friendly graph?
|
||||
|
||||
@ -586,6 +588,7 @@ your Emacs configuration folder like this:
|
||||
* Links between Nodes::
|
||||
* Setting up Org-roam::
|
||||
* Creating and Linking Nodes::
|
||||
* Customizing Node Completions::
|
||||
@end menu
|
||||
|
||||
@node The Org-roam Node
|
||||
@ -652,7 +655,12 @@ For this tutorial, create an empty directory, and set @code{org-roam-directory}:
|
||||
@end lisp
|
||||
|
||||
The @code{file-truename} function is only necessary when you use symbolic links
|
||||
inside @code{org-roam-directory}: Org-roam does not resolve symbolic links.
|
||||
inside @code{org-roam-directory}: Org-roam does not resolve symbolic links. One can
|
||||
however instruct Emacs to always resolve symlinks, at a performance cost:
|
||||
|
||||
@lisp
|
||||
(setq find-file-visit-truename t)
|
||||
@end lisp
|
||||
|
||||
Next, we setup Org-roam to run functions on file changes to maintain cache
|
||||
consistency. This is achieved by running @code{M-x org-roam-db-autosync-mode}. To
|
||||
@ -704,6 +712,56 @@ brought through the node creation process.
|
||||
One can also conveniently insert links via the completion-at-point functions
|
||||
Org-roam provides (see @ref{Completion}).
|
||||
|
||||
@node Customizing Node Completions
|
||||
@section Customizing Node Completions
|
||||
|
||||
Node selection is achieved via the @code{completing-read} interface, typically
|
||||
through `org-roam-node-read`. The presentation of these nodes are governed by
|
||||
@code{org-roam-node-display-template}.
|
||||
|
||||
@defvar org-roam-node-display-template
|
||||
|
||||
Configures display formatting for Org-roam node.
|
||||
|
||||
Patterns of form ``$@{field-name:length@}'' are interpolated based
|
||||
on the current node.
|
||||
|
||||
Each ``field-name'' is replaced with the return value of each
|
||||
corresponding accessor function for org-roam-node, e.g.
|
||||
``$@{title@}'' will be interpolated by the result of
|
||||
org-roam-node-title. You can also define custom accessors using
|
||||
cl-defmethod. For example, you can define:
|
||||
|
||||
(cl-defmethod org-roam-node-my-title ((node org-roam-node))
|
||||
(concat ``My '' (org-roam-node-title node)))
|
||||
|
||||
and then reference it here or in the capture templates as
|
||||
``$@{my-title@}''.
|
||||
|
||||
``length'' is an optional specifier and declares how many
|
||||
characters can be used to display the value of the corresponding
|
||||
field. If it's not specified, the field will be inserted as is,
|
||||
i.e. it won't be aligned nor trimmed. If it's an integer, the
|
||||
field will be aligned accordingly and all the exceeding
|
||||
characters will be trimmed out. If it's ``*'', the field will use
|
||||
as many characters as possible and will be aligned accordingly.
|
||||
|
||||
A closure can also be assigned to this variable in which case the
|
||||
closure is evaluated and the return value is used as the
|
||||
template. The closure must evaluate to a valid template string.
|
||||
@end defvar
|
||||
|
||||
If you're using a vertical completion framework, such as Ivy and Selectrum,
|
||||
Org-roam supports the generation of an aligned, tabular completion interface.
|
||||
For example, to include a column for tags up to 10 character widths wide, one
|
||||
can set @code{org-roam-node-display-template} as such:
|
||||
|
||||
@lisp
|
||||
(setq org-roam-node-display-template
|
||||
(concat "$@{title:*@} "
|
||||
(propertize "$@{tags:10@}" 'face 'org-tag)))
|
||||
@end lisp
|
||||
|
||||
@node Customizing Node Caching
|
||||
@chapter Customizing Node Caching
|
||||
|
||||
@ -786,6 +844,37 @@ all headlines with the @code{ATTACH} tag from the Org-roam database, one can set
|
||||
(not (member "ATTACH" (org-get-tags)))))
|
||||
@end example
|
||||
|
||||
Org-roam relied on the obtained Org AST for the buffer to parse links. However,
|
||||
links appearing in some places (e.g. within property drawers) are not considered
|
||||
by the Org AST to be links. Therefore, Org-roam takes special care of
|
||||
additionally trying to process these links. Use
|
||||
@code{org-roam-db-extra-links-elements} to specify which additional Org AST element
|
||||
types to consider.
|
||||
|
||||
@defvar org-roam-db-extra-links-elements
|
||||
|
||||
The list of Org element types to include for parsing by Org-roam.
|
||||
|
||||
By default, when parsing Org's AST, links within keywords and
|
||||
property drawers are not parsed as links. Sometimes however, it
|
||||
is desirable to parse and cache these links (e.g. hiding links in
|
||||
a property drawer).
|
||||
@end defvar
|
||||
|
||||
Additionally, one may want to ignore certain keys from being excluded within
|
||||
property drawers. For example, we would not want @code{ROAM_REFS} links to be
|
||||
self-referential. Hence, to exclude specific keys, we use
|
||||
@code{org-roam-db-extra-links-exclude-keys}.
|
||||
|
||||
@defvar org-roam-db-extra-links-exclude-keys
|
||||
|
||||
Keys to ignore when mapping over links.
|
||||
|
||||
The car of the association list is the Org element type (e.g. keyword). The
|
||||
cdr is a list of case-insensitive strings to exclude from being treated as
|
||||
links.
|
||||
@end defvar
|
||||
|
||||
@node When to cache
|
||||
@section When to cache
|
||||
|
||||
@ -887,10 +976,10 @@ There are currently 3 provided widget types:
|
||||
title/alias but are not linked
|
||||
@end itemize
|
||||
|
||||
To configure what sections are displayed in the buffer, set @code{org-roam-mode-section-functions}.
|
||||
To configure what sections are displayed in the buffer, set ~org-roam-mode-sections.
|
||||
|
||||
@lisp
|
||||
(setq org-roam-mode-section-functions
|
||||
(setq org-roam-mode-sections
|
||||
(list #'org-roam-backlinks-section
|
||||
#'org-roam-reflinks-section
|
||||
;; #'org-roam-unlinked-references-section
|
||||
@ -899,6 +988,16 @@ To configure what sections are displayed in the buffer, set @code{org-roam-mode-
|
||||
|
||||
Note that computing unlinked references may be slow, and has not been added in by default.
|
||||
|
||||
For each section function, you can pass args along to modify its behaviour. For
|
||||
example, if you want to render unique sources for backlinks (and also keep
|
||||
rendering reference links), set @code{org-roam-mode-sections} as follows:
|
||||
|
||||
@lisp
|
||||
(setq org-roam-mode-sections
|
||||
'((org-roam-backlinks-section :unique t)
|
||||
org-roam-reflinks-section))
|
||||
@end lisp
|
||||
|
||||
@node Configuring the Org-roam buffer display
|
||||
@section Configuring the Org-roam buffer display
|
||||
|
||||
@ -1220,7 +1319,21 @@ file:
|
||||
@end lisp
|
||||
|
||||
We also need to set up @code{org-protocol}: the instructions for setting up
|
||||
@code{org-protocol} are reproduced below.
|
||||
@code{org-protocol} are reproduced here.
|
||||
|
||||
On a high-level, external calls are passed to Emacs via @code{emacsclient}.
|
||||
@code{org-protocol} intercepts these and runs custom actions based on the protocols
|
||||
registered. Hence, to use @code{org-protocol}, once must:
|
||||
|
||||
@itemize
|
||||
@item
|
||||
launch the @code{emacsclient} process
|
||||
|
||||
@item
|
||||
Register @code{org-protocol://} as a valid scheme-handler
|
||||
@end itemize
|
||||
|
||||
The instructions for the latter for each operating system is detailed below.
|
||||
|
||||
@menu
|
||||
* Linux::
|
||||
@ -1935,6 +2048,7 @@ Org-mode, and sync your cards to Anki via @uref{https://github.com/FooSoft/anki-
|
||||
* How do I migrate from Roam Research?::
|
||||
* How to migrate from Org-roam v1?::
|
||||
* How do I publish my notes with an Internet-friendly graph?::
|
||||
* I'm seeing this ``Selecting deleted buffer'' error. What do I do?: I'm seeing this ``Selecting deleted buffer'' error What do I do?.
|
||||
@end menu
|
||||
|
||||
@node How do I have more than one Org-roam directory?
|
||||
@ -2145,6 +2259,27 @@ to the publishing directory. Example code follows:
|
||||
(setq my-publish-time 0)))))
|
||||
@end lisp
|
||||
|
||||
@node I'm seeing this ``Selecting deleted buffer'' error What do I do?
|
||||
@section I'm seeing this ``Selecting deleted buffer'' error. What do I do?
|
||||
|
||||
The ``selecting deleted buffer'' error usually occurs when you don't have a
|
||||
working @code{emacsql-sqlite} executable. Org-roam relies on this executable to
|
||||
function properly, and doesn't catch this error. This issue is most commonly
|
||||
seen on Windows setups. You can browse through the various GitHub issues posted
|
||||
about this @uref{https://github.com/org-roam/org-roam/issues?q=is%3Aissue+selecting+deleted, here}.
|
||||
|
||||
To fix this, you can try the following:
|
||||
|
||||
@itemize
|
||||
@item
|
||||
If on Windows, try replacing your system binary with @uref{https://github.com/nobiot/emacsql-sqlite.exe, this one} that has been proven
|
||||
to work
|
||||
|
||||
@item
|
||||
Use the @code{emacsql-sqlite3} option rather than compiling your own emacsql
|
||||
binary (see @ref{How to cache}).
|
||||
@end itemize
|
||||
|
||||
@node Developer's Guide to Org-roam
|
||||
@chapter Developer's Guide to Org-roam
|
||||
|
||||
|
@ -7,8 +7,8 @@
|
||||
;; Leo Vivier <leo.vivier+dev@gmail.com>
|
||||
;; URL: https://github.com/org-roam/org-roam
|
||||
;; Keywords: org-mode, roam, convenience
|
||||
;; Version: 2.2.0
|
||||
;; Package-Requires: ((emacs "26.1") (dash "2.13") (f "0.17.2") (org-roam "2.1"))
|
||||
;; Version: 2.2.1
|
||||
;; Package-Requires: ((emacs "26.1") (dash "2.13") (org-roam "2.1"))
|
||||
|
||||
;; This file is NOT part of GNU Emacs.
|
||||
|
||||
@ -34,10 +34,9 @@
|
||||
;; each file named after certain date and stored in `org-roam-dailies-directory'.
|
||||
;;
|
||||
;; One can use dailies for various purposes, e.g. journaling, fleeting notes,
|
||||
;; scratch notes and whatever else you can came up with.
|
||||
;; scratch notes or whatever else you can think of.
|
||||
;;
|
||||
;;; Code:
|
||||
(require 'f)
|
||||
(require 'dash)
|
||||
(require 'org-roam)
|
||||
|
||||
@ -140,72 +139,93 @@ In this case, interactive selection will be bypassed."
|
||||
(org-roam-dailies--capture (current-time) goto keys))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-roam-dailies-goto-today ()
|
||||
"Find the daily-note for today, creating it if necessary."
|
||||
(defun org-roam-dailies-goto-today (&optional keys)
|
||||
"Find the daily-note for today, creating it if necessary.
|
||||
|
||||
ELisp programs can set KEYS to a string associated with a template.
|
||||
In this case, interactive selection will be bypassed."
|
||||
(interactive)
|
||||
(org-roam-dailies-capture-today t))
|
||||
(org-roam-dailies-capture-today t keys))
|
||||
|
||||
;;;; Tomorrow
|
||||
;;;###autoload
|
||||
(defun org-roam-dailies-capture-tomorrow (n &optional goto)
|
||||
(defun org-roam-dailies-capture-tomorrow (n &optional goto keys)
|
||||
"Create an entry in the daily-note for tomorrow.
|
||||
|
||||
With numeric argument N, use the daily-note N days in the future.
|
||||
|
||||
With a `C-u' prefix or when GOTO is non-nil, go the note without
|
||||
creating an entry."
|
||||
creating an entry.
|
||||
|
||||
ELisp programs can set KEYS to a string associated with a template.
|
||||
In this case, interactive selection will be bypassed."
|
||||
(interactive "p")
|
||||
(org-roam-dailies--capture (time-add (* n 86400) (current-time)) goto))
|
||||
(org-roam-dailies--capture (time-add (* n 86400) (current-time)) goto keys))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-roam-dailies-goto-tomorrow (n)
|
||||
(defun org-roam-dailies-goto-tomorrow (n &optional keys)
|
||||
"Find the daily-note for tomorrow, creating it if necessary.
|
||||
|
||||
With numeric argument N, use the daily-note N days in the
|
||||
future."
|
||||
future.
|
||||
|
||||
ELisp programs can set KEYS to a string associated with a template.
|
||||
In this case, interactive selection will be bypassed."
|
||||
(interactive "p")
|
||||
(org-roam-dailies-capture-tomorrow n t))
|
||||
(org-roam-dailies-capture-tomorrow n t keys))
|
||||
|
||||
;;;; Yesterday
|
||||
;;;###autoload
|
||||
(defun org-roam-dailies-capture-yesterday (n &optional goto)
|
||||
(defun org-roam-dailies-capture-yesterday (n &optional goto keys)
|
||||
"Create an entry in the daily-note for yesteday.
|
||||
|
||||
With numeric argument N, use the daily-note N days in the past.
|
||||
|
||||
When GOTO is non-nil, go the note without creating an entry."
|
||||
When GOTO is non-nil, go the note without creating an entry.
|
||||
|
||||
ELisp programs can set KEYS to a string associated with a template.
|
||||
In this case, interactive selection will be bypassed."
|
||||
(interactive "p")
|
||||
(org-roam-dailies-capture-tomorrow (- n) goto))
|
||||
(org-roam-dailies-capture-tomorrow (- n) goto keys))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-roam-dailies-goto-yesterday (n)
|
||||
(defun org-roam-dailies-goto-yesterday (n &optional keys)
|
||||
"Find the daily-note for yesterday, creating it if necessary.
|
||||
|
||||
With numeric argument N, use the daily-note N days in the
|
||||
future."
|
||||
future.
|
||||
|
||||
ELisp programs can set KEYS to a string associated with a template.
|
||||
In this case, interactive selection will be bypassed."
|
||||
(interactive "p")
|
||||
(org-roam-dailies-capture-tomorrow (- n) t))
|
||||
(org-roam-dailies-capture-tomorrow (- n) t keys))
|
||||
|
||||
;;;; Date
|
||||
;;;###autoload
|
||||
(defun org-roam-dailies-capture-date (&optional goto prefer-future)
|
||||
(defun org-roam-dailies-capture-date (&optional goto prefer-future keys)
|
||||
"Create an entry in the daily-note for a date using the calendar.
|
||||
Prefer past dates, unless PREFER-FUTURE is non-nil.
|
||||
With a `C-u' prefix or when GOTO is non-nil, go the note without
|
||||
creating an entry."
|
||||
creating an entry.
|
||||
|
||||
ELisp programs can set KEYS to a string associated with a template.
|
||||
In this case, interactive selection will be bypassed."
|
||||
(interactive "P")
|
||||
(let ((time (let ((org-read-date-prefer-future prefer-future))
|
||||
(org-read-date nil t nil (if goto
|
||||
"Find daily-note: "
|
||||
"Capture to daily-note: ")))))
|
||||
(org-roam-dailies--capture time goto)))
|
||||
(org-roam-dailies--capture time goto keys)))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-roam-dailies-goto-date (&optional prefer-future)
|
||||
(defun org-roam-dailies-goto-date (&optional prefer-future keys)
|
||||
"Find the daily-note for a date using the calendar, creating it if necessary.
|
||||
Prefer past dates, unless PREFER-FUTURE is non-nil."
|
||||
Prefer past dates, unless PREFER-FUTURE is non-nil.
|
||||
|
||||
ELisp programs can set KEYS to a string associated with a template.
|
||||
In this case, interactive selection will be bypassed."
|
||||
(interactive)
|
||||
(org-roam-dailies-capture-date t prefer-future))
|
||||
(org-roam-dailies-capture-date t prefer-future keys))
|
||||
|
||||
;;;; Navigation
|
||||
(defun org-roam-dailies-goto-next-note (&optional n)
|
||||
@ -269,7 +289,7 @@ If FILE is not specified, use the current buffer's file-path."
|
||||
(save-match-data
|
||||
(and
|
||||
(org-roam-file-p path)
|
||||
(f-descendant-of-p path directory)))))
|
||||
(org-roam-descendant-of-p path directory)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-roam-dailies-find-directory ()
|
||||
@ -309,7 +329,8 @@ When GOTO is non-nil, go the note without creating an entry.
|
||||
|
||||
ELisp programs can set KEYS to a string associated with a template.
|
||||
In this case, interactive selection will be bypassed."
|
||||
(let ((org-roam-directory (expand-file-name org-roam-dailies-directory org-roam-directory)))
|
||||
(let ((org-roam-directory (expand-file-name org-roam-dailies-directory org-roam-directory))
|
||||
(org-roam-dailies-directory "./"))
|
||||
(org-roam-capture- :goto (when goto '(4))
|
||||
:keys keys
|
||||
:node (org-roam-node-create)
|
||||
|
@ -5,7 +5,7 @@
|
||||
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
||||
;; URL: https://github.com/org-roam/org-roam
|
||||
;; Keywords: org-mode, roam, convenience
|
||||
;; Version: 2.2.0
|
||||
;; Version: 2.2.1
|
||||
;; Package-Requires: ((emacs "26.1") (org "9.4") (org-roam "2.1"))
|
||||
|
||||
;; This file is NOT part of GNU Emacs.
|
||||
@ -266,7 +266,7 @@ Handles both Org-roam nodes, and string nodes (e.g. urls)."
|
||||
(org-roam-quote-string
|
||||
(pcase org-roam-graph-shorten-titles
|
||||
(`truncate (truncate-string-to-width title org-roam-graph-max-title-length nil nil "..."))
|
||||
(`wrap (s-word-wrap org-roam-graph-max-title-length title))
|
||||
(`wrap (org-roam-word-wrap org-roam-graph-max-title-length title))
|
||||
(_ title)))))
|
||||
(setq node-id (org-roam-node-id node)
|
||||
node-properties `(("label" . ,shortened-title)
|
||||
|
@ -5,7 +5,7 @@
|
||||
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
||||
;; URL: https://github.com/org-roam/org-roam
|
||||
;; Keywords: org-mode, roam, convenience
|
||||
;; Version: 2.2.0
|
||||
;; Version: 2.2.1
|
||||
;; Package-Requires: ((emacs "26.1") (org "9.4") (org-roam "2.1"))
|
||||
|
||||
;; This file is NOT part of GNU Emacs.
|
||||
|
@ -4,7 +4,7 @@
|
||||
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
||||
;; URL: https://github.com/org-roam/org-roam
|
||||
;; Keywords: org-mode, roam, convenience
|
||||
;; Version: 2.2.0
|
||||
;; Version: 2.2.1
|
||||
;; Package-Requires: ((emacs "26.1") (org "9.4") (org-roam "2.1"))
|
||||
|
||||
;; This file is NOT part of GNU Emacs.
|
||||
@ -169,25 +169,6 @@ org-protocol://roam-node?node=uuid"
|
||||
(push '("org-roam-node" :protocol "roam-node" :function org-roam-protocol-open-node)
|
||||
org-protocol-protocol-alist)
|
||||
|
||||
;;; Capture implementation
|
||||
(add-hook 'org-roam-capture-preface-hook #'org-roam-protocol--try-capture-to-ref-h)
|
||||
(defun org-roam-protocol--try-capture-to-ref-h ()
|
||||
"Try to capture to an existing node that match the ref."
|
||||
(when-let ((node (and (plist-get org-roam-capture--info :ref)
|
||||
(org-roam-node-from-ref
|
||||
(plist-get org-roam-capture--info :ref)))))
|
||||
(set-buffer (org-capture-target-buffer (org-roam-node-file node)))
|
||||
(goto-char (org-roam-node-point node))
|
||||
(widen)
|
||||
(org-roam-node-id node)))
|
||||
|
||||
(add-hook 'org-roam-capture-new-node-hook #'org-roam-protocol--insert-captured-ref-h)
|
||||
(defun org-roam-protocol--insert-captured-ref-h ()
|
||||
"Insert the ref if any."
|
||||
(when-let ((ref (plist-get org-roam-capture--info :ref)))
|
||||
(org-roam-ref-add ref)))
|
||||
|
||||
|
||||
(provide 'org-roam-protocol)
|
||||
|
||||
;;; org-roam-protocol.el ends here
|
||||
|
11
github-eldev
Executable file
11
github-eldev
Executable file
@ -0,0 +1,11 @@
|
||||
#! /bin/sh
|
||||
set -e
|
||||
|
||||
ELDEV_BIN_DIR=~/.local/bin
|
||||
|
||||
# `$GITHUB_PATH' is a magic file which contents is translated to environment variable `$PATH'.
|
||||
echo "$ELDEV_BIN_DIR" >> $GITHUB_PATH
|
||||
|
||||
mkdir -p $ELDEV_BIN_DIR
|
||||
curl -fsSL https://raw.githubusercontent.com/doublep/eldev/f111d19cda305e5e8fcb70a5675b87173041cb68/bin/eldev > $ELDEV_BIN_DIR/eldev
|
||||
chmod a+x $ELDEV_BIN_DIR/eldev
|
@ -5,8 +5,8 @@
|
||||
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
||||
;; URL: https://github.com/org-roam/org-roam
|
||||
;; Keywords: org-mode, roam, convenience
|
||||
;; Version: 2.2.0
|
||||
;; Package-Requires: ((emacs "26.1") (dash "2.13") (f "0.17.2") (org "9.4") (emacsql "3.0.0") (emacsql-sqlite "1.0.0") (magit-section "3.0.0"))
|
||||
;; Version: 2.2.1
|
||||
;; Package-Requires: ((emacs "26.1") (dash "2.13") (org "9.4") (emacsql "3.0.0") (emacsql-sqlite "1.0.0") (magit-section "3.0.0"))
|
||||
|
||||
;; This file is NOT part of GNU Emacs.
|
||||
|
||||
@ -407,6 +407,8 @@ TEMPLATES is a list of org-roam templates."
|
||||
(mapcar (lambda (template)
|
||||
(org-roam-capture--convert-template template props))
|
||||
(or templates org-roam-capture-templates)))
|
||||
(_ (setf (org-roam-node-id node) (or (org-roam-node-id node)
|
||||
(org-id-new))))
|
||||
(org-roam-capture--node node)
|
||||
(org-roam-capture--info info))
|
||||
(when (and (not keys)
|
||||
@ -503,7 +505,7 @@ Return the ID of the location."
|
||||
(set-buffer (org-capture-target-buffer path))
|
||||
(when new-file-p
|
||||
(org-roam-capture--put :new-file path)
|
||||
(insert (org-roam-capture--fill-template head t)))
|
||||
(insert (org-roam-capture--fill-template head 'ensure-newline)))
|
||||
(widen)
|
||||
(setq p (goto-char (point-min))))
|
||||
(`(file+head+olp ,path ,head ,olp)
|
||||
@ -513,7 +515,7 @@ Return the ID of the location."
|
||||
(widen)
|
||||
(when new-file-p
|
||||
(org-roam-capture--put :new-file path)
|
||||
(insert (org-roam-capture--fill-template head t)))
|
||||
(insert (org-roam-capture--fill-template head 'ensure-newline)))
|
||||
(setq p (point-min))
|
||||
(let ((m (org-roam-capture-find-or-create-olp olp)))
|
||||
(goto-char m)))
|
||||
@ -572,11 +574,11 @@ Return the ID of the location."
|
||||
;; caller.
|
||||
(save-excursion
|
||||
(goto-char p)
|
||||
(when-let* ((node org-roam-capture--node)
|
||||
(id (org-roam-node-id node)))
|
||||
(org-entry-put p "ID" id))
|
||||
(if-let ((id (org-entry-get p "ID")))
|
||||
(setf (org-roam-node-id org-roam-capture--node) id)
|
||||
(org-entry-put p "ID" (org-roam-node-id org-roam-capture--node)))
|
||||
(prog1
|
||||
(org-id-get-create)
|
||||
(org-id-get)
|
||||
(run-hooks 'org-roam-capture-new-node-hook)))))
|
||||
|
||||
(defun org-roam-capture--get-target ()
|
||||
@ -589,8 +591,9 @@ Return the ID of the location."
|
||||
PATH is a string that can optionally contain templated text in
|
||||
it."
|
||||
(or (org-roam-node-file org-roam-capture--node)
|
||||
(thread-first path
|
||||
(org-roam-capture--fill-template t)
|
||||
(thread-first
|
||||
path
|
||||
(org-roam-capture--fill-template)
|
||||
(string-trim)
|
||||
(expand-file-name org-roam-directory))))
|
||||
|
||||
@ -615,7 +618,7 @@ you can catch it with `condition-case'."
|
||||
(org-with-wide-buffer
|
||||
(goto-char start)
|
||||
(dolist (heading olp)
|
||||
(setq heading (org-roam-capture--fill-template heading t))
|
||||
(setq heading (org-roam-capture--fill-template heading))
|
||||
(let ((re (format org-complex-heading-regexp-format
|
||||
(regexp-quote heading)))
|
||||
(cnt 0))
|
||||
@ -677,6 +680,24 @@ the current value of `point'."
|
||||
(goto-char (org-entry-end-position))))))))
|
||||
(point))
|
||||
|
||||
;;; Capture implementation
|
||||
(add-hook 'org-roam-capture-preface-hook #'org-roam-capture--try-capture-to-ref-h)
|
||||
(defun org-roam-capture--try-capture-to-ref-h ()
|
||||
"Try to capture to an existing node that match the ref."
|
||||
(when-let ((node (and (plist-get org-roam-capture--info :ref)
|
||||
(org-roam-node-from-ref
|
||||
(plist-get org-roam-capture--info :ref)))))
|
||||
(set-buffer (org-capture-target-buffer (org-roam-node-file node)))
|
||||
(goto-char (org-roam-node-point node))
|
||||
(widen)
|
||||
(org-roam-node-id node)))
|
||||
|
||||
(add-hook 'org-roam-capture-new-node-hook #'org-roam-capture--insert-captured-ref-h)
|
||||
(defun org-roam-capture--insert-captured-ref-h ()
|
||||
"Insert the ref if any."
|
||||
(when-let ((ref (plist-get org-roam-capture--info :ref)))
|
||||
(org-roam-ref-add ref)))
|
||||
|
||||
;;;; Finalizers
|
||||
(add-hook 'org-capture-prepare-finalize-hook #'org-roam-capture--install-finalize-h)
|
||||
(defun org-roam-capture--install-finalize-h ()
|
||||
@ -689,11 +710,14 @@ the current value of `point'."
|
||||
(when-let ((region (org-roam-capture--get :region)))
|
||||
(org-roam-unshield-region (car region) (cdr region)))
|
||||
(if org-note-abort
|
||||
(when-let ((new-file (org-roam-capture--get :new-file)))
|
||||
(org-roam-message "Deleting file for aborted capture %s" new-file)
|
||||
(when-let ((new-file (org-roam-capture--get :new-file))
|
||||
(_ (yes-or-no-p "Delete file for aborted capture?")))
|
||||
(when (find-buffer-visiting new-file)
|
||||
(kill-buffer (find-buffer-visiting new-file)))
|
||||
(delete-file new-file))
|
||||
(when-let* ((buffer (plist-get org-capture-plist :buffer))
|
||||
(file (buffer-file-name buffer)))
|
||||
(org-id-add-location (org-roam-capture--get :id) file))
|
||||
(when-let* ((finalize (org-roam-capture--get :finalize))
|
||||
(org-roam-finalize-fn (intern (concat "org-roam-capture--finalize-"
|
||||
(symbol-name finalize)))))
|
||||
@ -720,48 +744,53 @@ This function is to be called in the Org-capture finalization process."
|
||||
(delete-region (car region) (cdr region))
|
||||
(set-marker (car region) nil)
|
||||
(set-marker (cdr region) nil))
|
||||
(org-with-point-at mkr
|
||||
(insert (org-link-make-string (concat "id:" (org-roam-capture--get :id))
|
||||
(org-roam-capture--get :link-description)))))))
|
||||
(let* ((id (org-roam-capture--get :id))
|
||||
(description (org-roam-capture--get :link-description))
|
||||
(link (org-link-make-string (concat "id:" id)
|
||||
description)))
|
||||
(if (eq (point) (marker-position mkr))
|
||||
(insert link)
|
||||
(org-with-point-at mkr
|
||||
(insert link)))
|
||||
(run-hook-with-args 'org-roam-post-node-insert-hook
|
||||
id
|
||||
description)))))
|
||||
|
||||
;;;; Processing of the capture templates
|
||||
(defun org-roam-capture--fill-template (template &optional org-capture-p newline)
|
||||
(defun org-roam-capture--fill-template (template &optional ensure-newline)
|
||||
"Expand TEMPLATE and return it.
|
||||
It expands ${var} occurrences in TEMPLATE. When ORG-CAPTURE-P,
|
||||
also run Org-capture's template expansion.
|
||||
If NEWLINE, ensure that the template returned ends with a newline."
|
||||
(setq template (org-roam-format-template
|
||||
template
|
||||
(lambda (key default-val)
|
||||
(let ((fn (intern key))
|
||||
(node-fn (intern (concat "org-roam-node-" key)))
|
||||
(ksym (intern (concat ":" key))))
|
||||
(cond
|
||||
((fboundp fn)
|
||||
(funcall fn org-roam-capture--node))
|
||||
((fboundp node-fn)
|
||||
(funcall node-fn org-roam-capture--node))
|
||||
((plist-get org-roam-capture--info ksym)
|
||||
(plist-get org-roam-capture--info ksym))
|
||||
(t (let ((r (read-from-minibuffer (format "%s: " key) default-val)))
|
||||
(plist-put org-roam-capture--info ksym r)
|
||||
r)))))))
|
||||
;; WARNING:
|
||||
;; `org-capture-fill-template' fills the template, but post-processes whitespace such that the resultant
|
||||
;; template does not start with any whitespace, and only ends with a single newline
|
||||
;;
|
||||
;; In most cases where we rely on `org-capture-fill-template' to populate non-org-capture-related templates,
|
||||
;; (e.g. in OLPs), we strip the final newline, obtaining a template that seems to be string-trimmed.
|
||||
;;
|
||||
;; This means that if the original passed template has newlines, and ORG-CAPTURE-P is true, then the extra
|
||||
;; whitespace specified in the template will be ignored.
|
||||
(when org-capture-p
|
||||
It expands ${var} occurrences in TEMPLATE, and then runs
|
||||
org-capture's template expansion.
|
||||
When ENSURE-NEWLINE, always ensure there's a newline behind."
|
||||
(let ((template-whitespace-content (org-roam-whitespace-content template)))
|
||||
(setq template
|
||||
(replace-regexp-in-string "\n$" "" (org-capture-fill-template template))))
|
||||
(when (and newline
|
||||
(not (string-suffix-p "\n" template)))
|
||||
(setq template (concat template "\n")))
|
||||
template)
|
||||
(org-roam-format-template
|
||||
template
|
||||
(lambda (key default-val)
|
||||
(let ((fn (intern key))
|
||||
(node-fn (intern (concat "org-roam-node-" key)))
|
||||
(ksym (intern (concat ":" key))))
|
||||
(cond
|
||||
((fboundp fn)
|
||||
(funcall fn org-roam-capture--node))
|
||||
((fboundp node-fn)
|
||||
(funcall node-fn org-roam-capture--node))
|
||||
((plist-get org-roam-capture--info ksym)
|
||||
(plist-get org-roam-capture--info ksym))
|
||||
(t (let ((r (read-from-minibuffer (format "%s: " key) default-val)))
|
||||
(plist-put org-roam-capture--info ksym r)
|
||||
r)))))))
|
||||
;; WARNING:
|
||||
;; `org-capture-fill-template' fills the template, but post-processes whitespace such that the resultant
|
||||
;; template does not start with any whitespace, and only ends with a single newline
|
||||
;;
|
||||
;; Instead, we restore the whitespace in the original template.
|
||||
(setq template (replace-regexp-in-string "\n$" "" (org-capture-fill-template template)))
|
||||
(when (and ensure-newline
|
||||
(string-equal template-whitespace-content ""))
|
||||
(setq template-whitespace-content "\n"))
|
||||
(setq template (concat template template-whitespace-content))
|
||||
template))
|
||||
|
||||
(defun org-roam-capture--convert-template (template &optional props)
|
||||
"Convert TEMPLATE from Org-roam syntax to `org-capture-templates' syntax.
|
||||
|
@ -5,7 +5,7 @@
|
||||
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
||||
;; URL: https://github.com/org-roam/org-roam
|
||||
;; Keywords: org-mode, roam, convenience
|
||||
;; Version: 2.2.0
|
||||
;; Version: 2.2.1
|
||||
;; Package-Requires: ((emacs "26.1"))
|
||||
|
||||
;; This file is NOT part of GNU Emacs.
|
||||
@ -229,6 +229,10 @@ nodes." org-id-locations-file)
|
||||
'org-roam-remove-property
|
||||
'org-roam-property-remove "org-roam 2.1")
|
||||
|
||||
(define-obsolete-variable-alias
|
||||
'org-roam-mode-section-functions
|
||||
'org-roam-mode-sections "org-roam 2.2.0")
|
||||
|
||||
;;; Obsolete functions
|
||||
(make-obsolete 'org-roam-get-keyword 'org-collect-keywords "org-roam 2.0")
|
||||
|
||||
|
@ -5,8 +5,8 @@
|
||||
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
||||
;; URL: https://github.com/org-roam/org-roam
|
||||
;; Keywords: org-mode, roam, convenience
|
||||
;; Version: 2.2.0
|
||||
;; Package-Requires: ((emacs "26.1") (dash "2.13") (f "0.17.2") (org "9.4") (emacsql "3.0.0") (emacsql-sqlite "1.0.0") (magit-section "3.0.0"))
|
||||
;; Version: 2.2.1
|
||||
;; Package-Requires: ((emacs "26.1") (dash "2.13") (org "9.4") (emacsql "3.0.0") (emacsql-sqlite "1.0.0") (magit-section "3.0.0"))
|
||||
|
||||
;; This file is NOT part of GNU Emacs.
|
||||
|
||||
@ -98,6 +98,32 @@ slow."
|
||||
:type 'boolean
|
||||
:group 'org-roam)
|
||||
|
||||
(defcustom org-roam-db-extra-links-elements '(node-property keyword)
|
||||
"The list of Org element types to include for parsing by Org-roam.
|
||||
|
||||
By default, when parsing Org's AST, links within keywords and
|
||||
property drawers are not parsed as links. Sometimes however, it
|
||||
is desirable to parse and cache these links (e.g. hiding links in
|
||||
a property drawer)."
|
||||
:package-version '(org-roam . "2.2.0")
|
||||
:group 'org-roam
|
||||
:type '(set (const :tag "keywords" keyword)
|
||||
(const :tag "property drawers" node-property)))
|
||||
|
||||
(defcustom org-roam-db-extra-links-exclude-keys '((node-property . ("ROAM_REFS"))
|
||||
(keyword . ("transclude")))
|
||||
"Keys to ignore when mapping over links.
|
||||
|
||||
The car of the association list is the Org element type (e.g.
|
||||
keyword). The cdr is a list of case-insensitive strings to
|
||||
exclude from being treated as links.
|
||||
|
||||
For example, we use this to prevent self-referential links in
|
||||
ROAM_REFS."
|
||||
:package-version '(org-roam . "2.2.0")
|
||||
:group 'org-roam
|
||||
:type '(alist))
|
||||
|
||||
;;; Variables
|
||||
(defconst org-roam-db-version 18)
|
||||
|
||||
@ -353,15 +379,12 @@ If UPDATE-P is non-nil, first remove the file in the database."
|
||||
;; Links correctly recognized by Org Mode
|
||||
((eq type 'link)
|
||||
(setq link element))
|
||||
;; Prevent self-referencing links in ROAM_REFS
|
||||
((and (eq type 'node-property)
|
||||
(org-roam-string-equal (org-element-property :key element) "ROAM_REFS"))
|
||||
nil)
|
||||
;; Links in property drawers and lines starting with #+. Recall that, as for Org Mode v9.4.4, the
|
||||
;; org-element-type of links within properties drawers is "node-property" and for lines starting with
|
||||
;; #+ is "keyword".
|
||||
((and (or (eq type 'node-property)
|
||||
(eq type 'keyword))
|
||||
((and (member type org-roam-db-extra-links-elements)
|
||||
(not (member-ignore-case (org-element-property :key element)
|
||||
(cdr (assoc type org-roam-db-extra-links-exclude-keys))))
|
||||
(setq bounds (org-in-regexp org-link-any-re))
|
||||
(setq link (buffer-substring-no-properties
|
||||
(car bounds)
|
||||
|
117
org-roam-id.el
Normal file
117
org-roam-id.el
Normal file
@ -0,0 +1,117 @@
|
||||
;;; org-roam-id.el --- ID-related utilities for Org-roam -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright © 2020-2022 Jethro Kuan <jethrokuan95@gmail.com>
|
||||
|
||||
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
||||
;; URL: https://github.com/org-roam/org-roam
|
||||
;; Keywords: org-mode, roam, convenience
|
||||
;; Version: 2.2.1
|
||||
;; Package-Requires: ((emacs "26.1") (dash "2.13") (org "9.4") (magit-section "3.0.0"))
|
||||
|
||||
;; This file is NOT part of GNU Emacs.
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 3, or (at your option)
|
||||
;; any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
;; This module provides ID-related facilities using the Org-roam database.
|
||||
;;
|
||||
;;; Code:
|
||||
(require 'org-id)
|
||||
|
||||
(defun org-roam-id-at-point ()
|
||||
"Return the ID at point, if any.
|
||||
Recursively traverses up the headline tree to find the
|
||||
first encapsulating ID."
|
||||
(org-with-wide-buffer
|
||||
(org-back-to-heading-or-point-min t)
|
||||
(while (and (not (org-roam-db-node-p))
|
||||
(not (bobp)))
|
||||
(org-roam-up-heading-or-point-min))
|
||||
(when (org-roam-db-node-p)
|
||||
(org-id-get))))
|
||||
|
||||
(defun org-roam-id-find (id &optional markerp)
|
||||
"Return the location of the entry with the id ID using the Org-roam db.
|
||||
The return value is a cons cell (file-name . position), or nil
|
||||
if there is no entry with that ID.
|
||||
With optional argument MARKERP, return the position as a new marker."
|
||||
(cond
|
||||
((symbolp id) (setq id (symbol-name id)))
|
||||
((numberp id) (setq id (number-to-string id))))
|
||||
(let ((node (org-roam-populate (org-roam-node-create :id id))))
|
||||
(when-let ((file (org-roam-node-file node)))
|
||||
(if markerp
|
||||
(unwind-protect
|
||||
(let ((buffer (or (find-buffer-visiting file)
|
||||
(find-file-noselect file))))
|
||||
(with-current-buffer buffer
|
||||
(move-marker (make-marker) (org-roam-node-point node) buffer))))
|
||||
(cons (org-roam-node-file node)
|
||||
(org-roam-node-point node))))))
|
||||
|
||||
(defun org-roam-id-open (id _)
|
||||
"Go to the entry with id ID.
|
||||
Like `org-id-open', but additionally uses the Org-roam database."
|
||||
(org-mark-ring-push)
|
||||
(let ((m (or (org-roam-id-find id 'marker)
|
||||
(org-id-find id 'marker)))
|
||||
cmd)
|
||||
(unless m
|
||||
(error "Cannot find entry with ID \"%s\"" id))
|
||||
;; Use a buffer-switching command in analogy to finding files
|
||||
(setq cmd
|
||||
(or
|
||||
(cdr
|
||||
(assq
|
||||
(cdr (assq 'file org-link-frame-setup))
|
||||
'((find-file . switch-to-buffer)
|
||||
(find-file-other-window . switch-to-buffer-other-window)
|
||||
(find-file-other-frame . switch-to-buffer-other-frame))))
|
||||
'switch-to-buffer-other-window))
|
||||
(if (not (equal (current-buffer) (marker-buffer m)))
|
||||
(funcall cmd (marker-buffer m)))
|
||||
(goto-char m)
|
||||
(move-marker m nil)
|
||||
(org-show-context)))
|
||||
|
||||
(org-link-set-parameters "id" :follow #'org-roam-id-open)
|
||||
|
||||
;;;###autoload
|
||||
(defun org-roam-update-org-id-locations (&rest directories)
|
||||
"Scan Org-roam files to update `org-id' related state.
|
||||
This is like `org-id-update-id-locations', but will automatically
|
||||
use the currently bound `org-directory' and `org-roam-directory'
|
||||
along with DIRECTORIES (if any), where the lookup for files in
|
||||
these directories will be always recursive.
|
||||
|
||||
Note: Org-roam doesn't have hard dependency on
|
||||
`org-id-locations-file' to lookup IDs for nodes that are stored
|
||||
in the database, but it still tries to properly integrates with
|
||||
`org-id'. This allows the user to cross-reference IDs outside of
|
||||
the current `org-roam-directory', and also link with \"id:\"
|
||||
links to headings/files within the current `org-roam-directory'
|
||||
that are excluded from identification in Org-roam as
|
||||
`org-roam-node's, e.g. with \"ROAM_EXCLUDE\" property."
|
||||
(interactive)
|
||||
(cl-loop for dir in (cons org-roam-directory directories)
|
||||
for org-roam-directory = dir
|
||||
nconc (org-roam-list-files) into files
|
||||
finally (org-id-update-id-locations files org-roam-verbose)))
|
||||
|
||||
(provide 'org-roam-id)
|
||||
|
||||
;;; org-roam-id.el ends here
|
@ -5,8 +5,8 @@
|
||||
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
||||
;; URL: https://github.com/org-roam/org-roam
|
||||
;; Keywords: org-mode, roam, convenience
|
||||
;; Version: 2.2.0
|
||||
;; Package-Requires: ((emacs "26.1") (dash "2.13") (f "0.17.2") (org "9.4") (emacsql "3.0.0") (emacsql-sqlite "1.0.0") (magit-section "3.0.0"))
|
||||
;; Version: 2.2.1
|
||||
;; Package-Requires: ((emacs "26.1") (dash "2.13") (org "9.4") (emacsql "3.0.0") (emacsql-sqlite "1.0.0") (magit-section "3.0.0"))
|
||||
|
||||
;; This file is NOT part of GNU Emacs.
|
||||
|
||||
|
@ -5,8 +5,8 @@
|
||||
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
||||
;; URL: https://github.com/org-roam/org-roam
|
||||
;; Keywords: org-mode, roam, convenience
|
||||
;; Version: 2.2.0
|
||||
;; Package-Requires: ((emacs "26.1") (dash "2.13") (f "0.17.2") (org "9.4") (emacsql "3.0.0") (emacsql-sqlite "1.0.0") (magit-section "3.0.0"))
|
||||
;; Version: 2.2.1
|
||||
;; Package-Requires: ((emacs "26.1") (dash "2.13") (org "9.4") (emacsql "3.0.0") (emacsql-sqlite "1.0.0") (magit-section "3.0.0"))
|
||||
|
||||
;; This file is NOT part of GNU Emacs.
|
||||
|
||||
@ -39,14 +39,28 @@
|
||||
(defvar org-ref-buffer-hacked)
|
||||
|
||||
;;; Options
|
||||
(defcustom org-roam-mode-section-functions (list #'org-roam-backlinks-section
|
||||
#'org-roam-reflinks-section)
|
||||
"Functions that insert sections in the `org-roam-mode' based buffers.
|
||||
Each function is called with one argument, which is an
|
||||
`org-roam-node' for which the buffer will be constructed for.
|
||||
Normally this node is `org-roam-buffer-current-node'."
|
||||
(defcustom org-roam-mode-sections (list #'org-roam-backlinks-section
|
||||
#'org-roam-reflinks-section)
|
||||
"A list of sections for the `org-roam-mode' based buffers.
|
||||
Each section is a function that is passed the an `org-roam-node'
|
||||
for which the section will be constructed for as the first
|
||||
argument. Normally this node is `org-roam-buffer-current-node'.
|
||||
The function may also accept other optional arguments. Each item
|
||||
in the list is either:
|
||||
|
||||
1. A function, which is called only with the `org-roam-node' as the argument
|
||||
2. A list, containing the function and the optional arguments.
|
||||
|
||||
For example, one can add
|
||||
|
||||
(org-roam-backlinks-section :unique t)
|
||||
|
||||
to the list to pass :unique t to the section-rendering function."
|
||||
:group 'org-roam
|
||||
:type 'hook)
|
||||
:type `(repeat (choice (symbol :tag "Function")
|
||||
(list :tag "Function with arguments"
|
||||
(symbol :tag "Function")
|
||||
(repeat :tag "Arguments" :inline t (sexp :tag "Arg"))))))
|
||||
|
||||
(defcustom org-roam-buffer-postrender-functions (list)
|
||||
"Functions to run after the Org-roam buffer is rendered.
|
||||
@ -168,7 +182,7 @@ This mode is used by special Org-roam buffers, such as persistent
|
||||
`org-roam-buffer' and dedicated Org-roam buffers
|
||||
\(`org-roam-buffer-display-dedicated'), which render the
|
||||
information in a section-like manner (see
|
||||
`org-roam-mode-section-functions'), with which the user can
|
||||
`org-roam-mode-sections'), with which the user can
|
||||
interact with."
|
||||
:group 'org-roam
|
||||
(face-remap-add-relative 'header-line 'org-roam-header-line))
|
||||
@ -228,7 +242,14 @@ buffer."
|
||||
(org-roam-node-title org-roam-buffer-current-node))
|
||||
(magit-insert-section (org-roam)
|
||||
(magit-insert-heading)
|
||||
(run-hook-with-args 'org-roam-mode-section-functions org-roam-buffer-current-node))
|
||||
(dolist (section org-roam-mode-sections)
|
||||
(pcase section
|
||||
((pred functionp)
|
||||
(funcall section org-roam-buffer-current-node))
|
||||
(`(,fn . ,args)
|
||||
(apply fn (cons org-roam-buffer-current-node args)))
|
||||
(_
|
||||
(user-error "Invalid `org-roam-mode-sections' specification")))))
|
||||
(run-hooks 'org-roam-buffer-postrender-functions)
|
||||
(goto-char 0)))
|
||||
|
||||
@ -289,7 +310,7 @@ To toggle its display use `org-roam-buffer-toggle' command.")
|
||||
(pcase (org-roam-buffer--visibility)
|
||||
('visible
|
||||
(progn
|
||||
(delete-window (get-buffer-window org-roam-buffer))
|
||||
(quit-window nil (get-buffer-window org-roam-buffer))
|
||||
(remove-hook 'post-command-hook #'org-roam-buffer--redisplay-h)))
|
||||
((or 'exists 'none)
|
||||
(progn
|
||||
@ -459,14 +480,23 @@ headline, up to the next headline."
|
||||
(org-roam-populate (org-roam-backlink-target-node backlink)))
|
||||
backlink)
|
||||
|
||||
(defun org-roam-backlinks-get (node)
|
||||
"Return the backlinks for NODE."
|
||||
(let ((backlinks (org-roam-db-query
|
||||
[:select [source dest pos properties]
|
||||
:from links
|
||||
:where (= dest $s1)
|
||||
:and (= type "id")]
|
||||
(org-roam-node-id node))))
|
||||
(cl-defun org-roam-backlinks-get (node &key unique)
|
||||
"Return the backlinks for NODE.
|
||||
|
||||
When UNIQUE is nil, show all positions where references are found.
|
||||
When UNIQUE is t, limit to unique sources."
|
||||
(let* ((sql (if unique
|
||||
[:select :distinct [source dest pos properties]
|
||||
:from links
|
||||
:where (= dest $s1)
|
||||
:and (= type "id")
|
||||
:group :by source
|
||||
:having (funcall min pos)]
|
||||
[:select [source dest pos properties]
|
||||
:from links
|
||||
:where (= dest $s1)
|
||||
:and (= type "id")]))
|
||||
(backlinks (org-roam-db-query sql (org-roam-node-id node))))
|
||||
(cl-loop for backlink in backlinks
|
||||
collect (pcase-let ((`(,source-id ,dest-id ,pos ,properties) backlink))
|
||||
(org-roam-populate
|
||||
@ -482,9 +512,12 @@ Sorts by title."
|
||||
(string< (org-roam-node-title (org-roam-backlink-source-node a))
|
||||
(org-roam-node-title (org-roam-backlink-source-node b))))
|
||||
|
||||
(defun org-roam-backlinks-section (node)
|
||||
"The backlinks section for NODE."
|
||||
(when-let ((backlinks (seq-sort #'org-roam-backlinks-sort (org-roam-backlinks-get node))))
|
||||
(cl-defun org-roam-backlinks-section (node &key (unique nil))
|
||||
"The backlinks section for NODE.
|
||||
|
||||
When UNIQUE is nil, show all positions where references are found.
|
||||
When UNIQUE is t, limit to unique sources."
|
||||
(when-let ((backlinks (seq-sort #'org-roam-backlinks-sort (org-roam-backlinks-get node :unique unique))))
|
||||
(magit-insert-section (org-roam-backlinks)
|
||||
(magit-insert-heading "Backlinks:")
|
||||
(dolist (backlink backlinks)
|
||||
@ -643,7 +676,7 @@ References from FILE are excluded."
|
||||
col (string-to-number (match-string 3 line))
|
||||
match (match-string 4 line))
|
||||
(when (and match
|
||||
(not (f-equal-p (org-roam-node-file node) f))
|
||||
(not (file-equal-p (org-roam-node-file node) f))
|
||||
(member (downcase match) (mapcar #'downcase titles)))
|
||||
(magit-insert-section section (org-roam-grep-section)
|
||||
(oset section file f)
|
||||
|
222
org-roam-node.el
222
org-roam-node.el
@ -5,7 +5,7 @@
|
||||
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
||||
;; URL: https://github.com/org-roam/org-roam
|
||||
;; Keywords: org-mode, roam, convenience
|
||||
;; Version: 2.2.0
|
||||
;; Version: 2.2.1
|
||||
;; Package-Requires: ((emacs "26.1") (dash "2.13") (org "9.4") (magit-section "3.0.0"))
|
||||
|
||||
;; This file is NOT part of GNU Emacs.
|
||||
@ -36,8 +36,7 @@
|
||||
|
||||
;;; Options
|
||||
;;;; Completing-read
|
||||
(defcustom org-roam-node-display-template
|
||||
(concat "${title:*} " (propertize "${tags:10}" 'face 'org-tag))
|
||||
(defcustom org-roam-node-display-template "${title}"
|
||||
"Configures display formatting for Org-roam node.
|
||||
Patterns of form \"${field-name:length}\" are interpolated based
|
||||
on the current node.
|
||||
@ -132,7 +131,8 @@ It takes a single argument REF, which is a propertized string."
|
||||
:type 'boolean)
|
||||
|
||||
(defcustom org-roam-extract-new-file-path "%<%Y%m%d%H%M%S>-${slug}.org"
|
||||
"The file path to use when a node is extracted to its own file."
|
||||
"The file path template to use when a node is extracted to its own file.
|
||||
This path is relative to `org-roam-directory'."
|
||||
:group 'org-roam
|
||||
:type 'string)
|
||||
|
||||
@ -175,6 +175,7 @@ It takes a single argument REF, which is a propertized string."
|
||||
776 ; U+0308 COMBINING DIAERESIS
|
||||
777 ; U+0309 COMBINING HOOK ABOVE
|
||||
778 ; U+030A COMBINING RING ABOVE
|
||||
779 ; U+030B COMBINING DOUBLE ACUTE ACCENT
|
||||
780 ; U+030C COMBINING CARON
|
||||
795 ; U+031B COMBINING HORN
|
||||
803 ; U+0323 COMBINING DOT BELOW
|
||||
@ -186,14 +187,12 @@ It takes a single argument REF, which is a propertized string."
|
||||
816 ; U+0330 COMBINING TILDE BELOW
|
||||
817 ; U+0331 COMBINING MACRON BELOW
|
||||
)))
|
||||
(cl-flet* ((nonspacing-mark-p (char)
|
||||
(memq char slug-trim-chars))
|
||||
(strip-nonspacing-marks (s)
|
||||
(string-glyph-compose
|
||||
(apply #'string (seq-remove #'nonspacing-mark-p
|
||||
(string-glyph-decompose s)))))
|
||||
(cl-replace (title pair)
|
||||
(replace-regexp-in-string (car pair) (cdr pair) title)))
|
||||
(cl-flet* ((nonspacing-mark-p (char) (memq char slug-trim-chars))
|
||||
(strip-nonspacing-marks (s) (string-glyph-compose
|
||||
(apply #'string
|
||||
(seq-remove #'nonspacing-mark-p
|
||||
(string-glyph-decompose s)))))
|
||||
(cl-replace (title pair) (replace-regexp-in-string (car pair) (cdr pair) title)))
|
||||
(let* ((pairs `(("[^[:alnum:][:digit:]]" . "_") ;; convert anything not alphanumeric
|
||||
("__*" . "_") ;; remove sequential underscores
|
||||
("^_" . "") ;; remove starting underscore
|
||||
@ -426,19 +425,41 @@ GROUP BY id")))
|
||||
all-titles)))))
|
||||
|
||||
;;;; Finders
|
||||
(defun org-roam-node-find-noselect (node &optional force)
|
||||
"Navigate to the point for NODE, and return the buffer.
|
||||
If NODE is already visited, this won't automatically move the
|
||||
point to the beginning of the NODE, unless FORCE is non-nil."
|
||||
(unless (org-roam-node-file node)
|
||||
(user-error "Node does not have corresponding file"))
|
||||
(let ((buf (find-file-noselect (org-roam-node-file node))))
|
||||
(with-current-buffer buf
|
||||
(when (or force
|
||||
(not (equal (org-roam-node-id node)
|
||||
(org-roam-id-at-point))))
|
||||
(goto-char (org-roam-node-point node))))
|
||||
buf))
|
||||
(defun org-roam-node-marker (node)
|
||||
"Get the marker for NODE."
|
||||
(unwind-protect
|
||||
(let* ((file (org-roam-node-file node))
|
||||
(buffer (or (find-buffer-visiting file)
|
||||
(find-file-noselect file))))
|
||||
(with-current-buffer buffer
|
||||
(move-marker (make-marker) (org-roam-node-point node) buffer)))))
|
||||
|
||||
(defun org-roam-node-open (node &optional cmd force)
|
||||
"Go to the node NODE.
|
||||
CMD is the command used to display the buffer. If not provided,
|
||||
`org-link-frame-setup' is respected. Assumes that the node is
|
||||
fully populated, with file and point. If NODE is already visited,
|
||||
this won't automatically move the point to the beginning of the
|
||||
NODE, unless FORCE is non-nil."
|
||||
(interactive (list (org-roam-node-at-point) current-prefix-arg))
|
||||
(org-mark-ring-push)
|
||||
(let ((m (org-roam-node-marker node))
|
||||
(cmd (or cmd
|
||||
(cdr
|
||||
(assq
|
||||
(cdr (assq 'file org-link-frame-setup))
|
||||
'((find-file . switch-to-buffer)
|
||||
(find-file-other-window . switch-to-buffer-other-window)
|
||||
(find-file-other-frame . switch-to-buffer-other-frame))))
|
||||
'switch-to-buffer-other-window)))
|
||||
(if (not (equal (current-buffer) (marker-buffer m)))
|
||||
(funcall cmd (marker-buffer m)))
|
||||
(when (or force
|
||||
(not (equal (org-roam-node-id node)
|
||||
(org-roam-id-at-point))))
|
||||
(goto-char m))
|
||||
(move-marker m nil))
|
||||
(org-show-context))
|
||||
|
||||
(defun org-roam-node-visit (node &optional other-window force)
|
||||
"From the current buffer, visit NODE. Return the visited buffer.
|
||||
@ -450,13 +471,10 @@ If NODE is already visited, this won't automatically move the
|
||||
point to the beginning of the NODE, unless FORCE is non-nil. In
|
||||
interactive calls FORCE always set to t."
|
||||
(interactive (list (org-roam-node-at-point t) current-prefix-arg t))
|
||||
(let ((buf (org-roam-node-find-noselect node force))
|
||||
(display-buffer-fn (if other-window
|
||||
(org-roam-node-open node (if other-window
|
||||
#'switch-to-buffer-other-window
|
||||
#'pop-to-buffer-same-window)))
|
||||
(funcall display-buffer-fn buf)
|
||||
(when (org-invisible-p) (org-show-context))
|
||||
buf))
|
||||
#'pop-to-buffer-same-window)
|
||||
force))
|
||||
|
||||
;;;###autoload
|
||||
(cl-defun org-roam-node-find (&optional other-window initial-input filter-fn &key templates)
|
||||
@ -477,16 +495,16 @@ The TEMPLATES, if provided, override the list of capture templates (see
|
||||
:props '(:finalize find-file)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-roam-node-random (&optional other-window)
|
||||
(defun org-roam-node-random (&optional other-window filter-fn)
|
||||
"Find and open a random Org-roam node.
|
||||
With prefix argument OTHER-WINDOW, visit the node in another
|
||||
window instead."
|
||||
window instead.
|
||||
FILTER-FN is a function to filter out nodes: it takes an `org-roam-node',
|
||||
and when nil is returned the node will be filtered out."
|
||||
(interactive current-prefix-arg)
|
||||
(let ((random-row (seq-random-elt (org-roam-db-query [:select [id file pos] :from nodes]))))
|
||||
(org-roam-node-visit (org-roam-node-create :id (nth 0 random-row)
|
||||
:file (nth 1 random-row)
|
||||
:point (nth 2 random-row))
|
||||
other-window)))
|
||||
(org-roam-node-visit
|
||||
(cdr (seq-random-elt (org-roam-node-read--completions filter-fn)))
|
||||
other-window))
|
||||
|
||||
;;;; Completing-read interface
|
||||
(defun org-roam-node-read (&optional initial-input filter-fn sort-fn require-match prompt)
|
||||
@ -498,17 +516,7 @@ SORT-FN is a function to sort nodes. See `org-roam-node-read-sort-by-file-mtime'
|
||||
for an example sort function.
|
||||
If REQUIRE-MATCH, the minibuffer prompt will require a match.
|
||||
PROMPT is a string to show at the beginning of the mini-buffer, defaulting to \"Node: \""
|
||||
(let* ((nodes (org-roam-node-read--completions))
|
||||
(nodes (if filter-fn
|
||||
(cl-remove-if-not
|
||||
(lambda (n) (funcall filter-fn (cdr n)))
|
||||
nodes)
|
||||
nodes))
|
||||
(sort-fn (or sort-fn
|
||||
(when org-roam-node-default-sort
|
||||
(intern (concat "org-roam-node-read-sort-by-"
|
||||
(symbol-name org-roam-node-default-sort))))))
|
||||
(_ (when sort-fn (setq nodes (seq-sort sort-fn nodes))))
|
||||
(let* ((nodes (org-roam-node-read--completions filter-fn sort-fn))
|
||||
(prompt (or prompt "Node: "))
|
||||
(node (completing-read
|
||||
prompt
|
||||
@ -529,15 +537,31 @@ PROMPT is a string to show at the beginning of the mini-buffer, defaulting to \"
|
||||
(or (cdr (assoc node nodes))
|
||||
(org-roam-node-create :title node))))
|
||||
|
||||
(defun org-roam-node-read--completions ()
|
||||
(defun org-roam-node-read--completions (&optional filter-fn sort-fn)
|
||||
"Return an alist for node completion.
|
||||
The car is the displayed title or alias for the node, and the cdr
|
||||
is the `org-roam-node'.
|
||||
FILTER-FN is a function to filter out nodes: it takes an `org-roam-node',
|
||||
and when nil is returned the node will be filtered out.
|
||||
SORT-FN is a function to sort nodes. See `org-roam-node-read-sort-by-file-mtime'
|
||||
for an example sort function.
|
||||
The displayed title is formatted according to `org-roam-node-display-template'."
|
||||
(let ((template (org-roam-node--process-display-format org-roam-node-display-template))
|
||||
(nodes (org-roam-node-list)))
|
||||
(mapcar (lambda (node)
|
||||
(org-roam-node-read--to-candidate node template)) nodes)))
|
||||
(let* ((template (org-roam-node--process-display-format org-roam-node-display-template))
|
||||
(nodes (org-roam-node-list))
|
||||
(nodes (mapcar (lambda (node)
|
||||
(org-roam-node-read--to-candidate node template)) nodes))
|
||||
(nodes (if filter-fn
|
||||
(cl-remove-if-not
|
||||
(lambda (n) (funcall filter-fn (cdr n)))
|
||||
nodes)
|
||||
nodes))
|
||||
(sort-fn (or sort-fn
|
||||
(when org-roam-node-default-sort
|
||||
(intern (concat "org-roam-node-read-sort-by-"
|
||||
(symbol-name org-roam-node-default-sort))))))
|
||||
(nodes (if sort-fn (seq-sort sort-fn nodes)
|
||||
nodes)))
|
||||
nodes))
|
||||
|
||||
(defun org-roam-node-read--to-candidate (node template)
|
||||
"Return a minibuffer completion candidate given NODE.
|
||||
@ -545,7 +569,8 @@ TEMPLATE is the processed template used to format the entry."
|
||||
(let ((candidate-main (org-roam-node--format-entry
|
||||
template
|
||||
node
|
||||
(1- (frame-width)))))
|
||||
(1- (if (bufferp (current-buffer))
|
||||
(window-width) (frame-width))))))
|
||||
(cons (propertize candidate-main 'node node) node)))
|
||||
|
||||
(defun org-roam-node--format-entry (template node &optional width)
|
||||
@ -663,9 +688,13 @@ The INFO, if provided, is passed to the underlying `org-roam-capture-'."
|
||||
(delete-region beg end)
|
||||
(set-marker beg nil)
|
||||
(set-marker end nil))
|
||||
(insert (org-link-make-string
|
||||
(concat "id:" (org-roam-node-id node))
|
||||
description)))
|
||||
(let ((id (org-roam-node-id node)))
|
||||
(insert (org-link-make-string
|
||||
(concat "id:" id)
|
||||
description))
|
||||
(run-hook-with-args 'org-roam-post-node-insert-hook
|
||||
id
|
||||
description)))
|
||||
(org-roam-capture-
|
||||
:node node
|
||||
:info info
|
||||
@ -673,31 +702,10 @@ The INFO, if provided, is passed to the underlying `org-roam-capture-'."
|
||||
:props (append
|
||||
(when (and beg end)
|
||||
(list :region (cons beg end)))
|
||||
(list :insert-at (point-marker)
|
||||
:link-description description
|
||||
(list :link-description description
|
||||
:finalize 'insert-link))))))
|
||||
(deactivate-mark)))
|
||||
|
||||
(add-hook 'org-roam-find-file-hook #'org-roam-open-id-with-org-roam-db-h)
|
||||
(defun org-roam-open-id-with-org-roam-db-h ()
|
||||
"Try to open \"id:\" links at point by querying them to the database."
|
||||
(add-hook 'org-open-at-point-functions #'org-roam-open-id-at-point nil t))
|
||||
|
||||
(defun org-roam-open-id-at-point ()
|
||||
"Navigate to \"id:\" link at point using the Org-roam database."
|
||||
(when (org-in-regexp org-link-any-re)
|
||||
(let ((link (match-string 2))
|
||||
id)
|
||||
(when (string-prefix-p "id:" link)
|
||||
(setq id (substring-no-properties link 3))
|
||||
(let ((node (org-roam-populate (org-roam-node-create :id id))))
|
||||
(cond
|
||||
((org-roam-node-file node)
|
||||
(org-mark-ring-push)
|
||||
(org-roam-node-visit node nil 'force)
|
||||
t)
|
||||
(t nil)))))))
|
||||
|
||||
;;;;; [roam:] link
|
||||
(org-link-set-parameters "roam" :follow #'org-roam-link-follow-link)
|
||||
(defun org-roam-link-follow-link (title-or-alias)
|
||||
@ -811,7 +819,8 @@ Any tags declared on #+FILETAGS: are transferred to tags on the new top heading.
|
||||
Any top level properties drawers are incorporated into the new heading."
|
||||
(interactive)
|
||||
(org-with-point-at 1
|
||||
(org-map-entries 'org-do-demote)
|
||||
(org-map-region #'org-do-demote
|
||||
(point-min) (point-max))
|
||||
(insert "* "
|
||||
(org-roam--get-keyword "title")
|
||||
"\n")
|
||||
@ -826,9 +835,11 @@ Converts a file containing a headline node at the top to a file
|
||||
node."
|
||||
(interactive)
|
||||
(org-with-point-at 1
|
||||
(org-map-entries (lambda ()
|
||||
(when (> (org-outline-level) 1)
|
||||
(org-do-promote))))
|
||||
(org-map-region
|
||||
(lambda ()
|
||||
(when (> (org-outline-level) 1)
|
||||
(org-do-promote)))
|
||||
(point-min) (point-max))
|
||||
(let ((title (nth 4 (org-heading-components)))
|
||||
(tags (nth 5 (org-heading-components))))
|
||||
(beginning-of-line)
|
||||
@ -920,8 +931,11 @@ If region is active, then use it instead of the node at point."
|
||||
(t (let ((r (read-from-minibuffer (format "%s: " key) default-val)))
|
||||
(plist-put template-info ksym r)
|
||||
r)))))))
|
||||
(file-path (read-file-name "Extract node to: "
|
||||
(file-name-as-directory org-roam-directory) template nil template)))
|
||||
(file-path
|
||||
(expand-file-name
|
||||
(read-file-name "Extract node to: "
|
||||
(file-name-as-directory org-roam-directory) template nil template)
|
||||
org-roam-directory)))
|
||||
(when (file-exists-p file-path)
|
||||
(user-error "%s exists. Aborting" file-path))
|
||||
(org-cut-subtree)
|
||||
@ -931,42 +945,6 @@ If region is active, then use it instead of the node at point."
|
||||
(org-roam-promote-entire-buffer)
|
||||
(save-buffer)))))
|
||||
|
||||
;;; IDs
|
||||
;;;; Getters
|
||||
(defun org-roam-id-at-point ()
|
||||
"Return the ID at point, if any.
|
||||
Recursively traverses up the headline tree to find the
|
||||
first encapsulating ID."
|
||||
(org-with-wide-buffer
|
||||
(org-back-to-heading-or-point-min t)
|
||||
(while (and (not (org-roam-db-node-p))
|
||||
(not (bobp)))
|
||||
(org-roam-up-heading-or-point-min))
|
||||
(when (org-roam-db-node-p)
|
||||
(org-id-get))))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-roam-update-org-id-locations (&rest directories)
|
||||
"Scan Org-roam files to update `org-id' related state.
|
||||
This is like `org-id-update-id-locations', but will automatically
|
||||
use the currently bound `org-directory' and `org-roam-directory'
|
||||
along with DIRECTORIES (if any), where the lookup for files in
|
||||
these directories will be always recursive.
|
||||
|
||||
Note: Org-roam doesn't have hard dependency on
|
||||
`org-id-locations-file' to lookup IDs for nodes that are stored
|
||||
in the database, but it still tries to properly integrates with
|
||||
`org-id'. This allows the user to cross-reference IDs outside of
|
||||
the current `org-roam-directory', and also link with \"id:\"
|
||||
links to headings/files within the current `org-roam-directory'
|
||||
that are excluded from identification in Org-roam as
|
||||
`org-roam-node's, e.g. with \"ROAM_EXCLUDE\" property."
|
||||
(interactive)
|
||||
(cl-loop for dir in (cons org-roam-directory directories)
|
||||
for org-roam-directory = dir
|
||||
nconc (org-roam-list-files) into files
|
||||
finally (org-id-update-id-locations files org-roam-verbose)))
|
||||
|
||||
;;; Refs
|
||||
;;;; Completing-read interface
|
||||
(defun org-roam-ref-read (&optional initial-input filter-fn)
|
||||
|
@ -5,7 +5,7 @@
|
||||
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
||||
;; URL: https://github.com/org-roam/org-roam
|
||||
;; Keywords: org-mode, roam, convenience
|
||||
;; Version: 2.2.0
|
||||
;; Version: 2.2.1
|
||||
;; Package-Requires: ((emacs "26.1") (dash "2.13") (org "9.4"))
|
||||
|
||||
;; This file is NOT part of GNU Emacs.
|
||||
@ -52,6 +52,16 @@
|
||||
(org-roam-replace-string "\\" "\\\\")
|
||||
(org-roam-replace-string "\"" "\\\"")))
|
||||
|
||||
(defun org-roam-word-wrap (len s)
|
||||
"If S is longer than LEN, wrap the words with newlines."
|
||||
(declare (side-effect-free t))
|
||||
(save-match-data
|
||||
(with-temp-buffer
|
||||
(insert s)
|
||||
(let ((fill-column len))
|
||||
(fill-region (point-min) (point-max)))
|
||||
(buffer-substring (point-min) (point-max)))))
|
||||
|
||||
(defun org-roam-string-equal (s1 s2)
|
||||
"Return t if S1 and S2 are equal.
|
||||
Like `string-equal', but case-insensitive."
|
||||
@ -59,6 +69,15 @@ Like `string-equal', but case-insensitive."
|
||||
(or (string-equal s1 s2)
|
||||
(string-equal (downcase s1) (downcase s2)))))
|
||||
|
||||
(defun org-roam-whitespace-content (s)
|
||||
"Return the whitespace content at the end of S."
|
||||
(with-temp-buffer
|
||||
(let ((c 0))
|
||||
(insert s)
|
||||
(skip-chars-backward " \t\n")
|
||||
(buffer-substring-no-properties
|
||||
(point) (point-max)))))
|
||||
|
||||
(defun org-roam-strip-comments (s)
|
||||
"Strip Org comments from string S."
|
||||
(with-temp-buffer
|
||||
@ -99,6 +118,12 @@ SPEC is a list, as per `dolist'."
|
||||
`(dolist ,spec ,@body)))
|
||||
|
||||
;;; File utilities
|
||||
(defun org-roam-descendant-of-p (a b)
|
||||
"Return t if A is descendant of B."
|
||||
(unless (equal (file-truename a) (file-truename b))
|
||||
(string-prefix-p (replace-regexp-in-string "^\\([A-Za-z]\\):" 'downcase (expand-file-name b) t t)
|
||||
(replace-regexp-in-string "^\\([A-Za-z]\\):" 'downcase (expand-file-name a) t t))))
|
||||
|
||||
(defmacro org-roam-with-file (file keep-buf-p &rest body)
|
||||
"Execute BODY within FILE.
|
||||
If FILE is nil, execute BODY in the current buffer.
|
||||
|
17
org-roam.el
17
org-roam.el
@ -5,8 +5,8 @@
|
||||
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
||||
;; URL: https://github.com/org-roam/org-roam
|
||||
;; Keywords: org-mode, roam, convenience
|
||||
;; Version: 2.2.0
|
||||
;; Package-Requires: ((emacs "26.1") (dash "2.13") (f "0.17.2") (org "9.4") (emacsql "3.0.0") (emacsql-sqlite "1.0.0") (magit-section "3.0.0"))
|
||||
;; Version: 2.2.1
|
||||
;; Package-Requires: ((emacs "26.1") (dash "2.13") (org "9.4") (emacsql "3.0.0") (emacsql-sqlite "1.0.0") (magit-section "3.0.0"))
|
||||
|
||||
;; This file is NOT part of GNU Emacs.
|
||||
|
||||
@ -71,7 +71,6 @@
|
||||
;; majority of them can be found at https://github.com/org-roam and MELPA.
|
||||
;;
|
||||
;;; Code:
|
||||
(require 'f)
|
||||
(require 'dash)
|
||||
|
||||
(require 'rx)
|
||||
@ -123,6 +122,12 @@ All Org files, at any level of nesting, are considered part of the Org-roam."
|
||||
:group 'org-roam
|
||||
:type 'hook)
|
||||
|
||||
(defcustom org-roam-post-node-insert-hook nil
|
||||
"Hook run when an Org-roam node is inserted as an Org link.
|
||||
Each function takes two arguments: the id of the node, and the link description."
|
||||
:group 'org-roam
|
||||
:type 'hook)
|
||||
|
||||
(defcustom org-roam-file-extensions '("org")
|
||||
"List of file extensions to be included by Org-Roam.
|
||||
While a file extension different from \".org\" may be used, the
|
||||
@ -195,7 +200,7 @@ FILE is an Org-roam file if:
|
||||
(member ext org-roam-file-extensions)
|
||||
(not (and org-roam-file-exclude-regexp
|
||||
(string-match-p org-roam-file-exclude-regexp path)))
|
||||
(f-descendant-of-p path (expand-file-name org-roam-directory))))))
|
||||
(org-roam-descendant-of-p path (expand-file-name org-roam-directory))))))
|
||||
|
||||
(defun org-roam-list-files ()
|
||||
"Return a list of all Org-roam files under `org-roam-directory'.
|
||||
@ -260,7 +265,8 @@ If no files are found, an empty list is returned."
|
||||
(shell-command-to-string it)
|
||||
(ansi-color-filter-apply it)
|
||||
(split-string it "\n")
|
||||
(seq-filter #'s-present? it)))
|
||||
(seq-filter (lambda (s)
|
||||
(not (or (null s) (string= "" s)))) it)))
|
||||
|
||||
(defun org-roam--list-files-search-globs (exts)
|
||||
"Given EXTS, return a list of search globs.
|
||||
@ -313,6 +319,7 @@ E.g. (\".org\") => (\"*.org\" \"*.org.gpg\")"
|
||||
(require 'org-roam-utils)
|
||||
(require 'org-roam-db)
|
||||
(require 'org-roam-node)
|
||||
(require 'org-roam-id)
|
||||
(require 'org-roam-capture)
|
||||
(require 'org-roam-mode)
|
||||
(require 'org-roam-migrate))
|
||||
|
51
tests/test-org-roam-capture.el
Normal file
51
tests/test-org-roam-capture.el
Normal file
@ -0,0 +1,51 @@
|
||||
;;; test-org-roam-capture.el --- Tests for Org-roam -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright (C) 2020 Jethro Kuan
|
||||
|
||||
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
||||
;; Package-Requires: ((buttercup))
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
;;; Code:
|
||||
|
||||
(require 'buttercup)
|
||||
(require 'org-roam)
|
||||
|
||||
(describe "org-roam-capture--fill-template"
|
||||
(it "fills template without newline"
|
||||
(expect
|
||||
(org-roam-capture--fill-template "foo")
|
||||
:to-equal "foo"))
|
||||
|
||||
(it "fills template ensuring newline"
|
||||
(expect
|
||||
(org-roam-capture--fill-template "foo" 'ensure-newline)
|
||||
:to-equal "foo\n"))
|
||||
|
||||
(it "fills template with newline"
|
||||
(expect
|
||||
(org-roam-capture--fill-template "foo\n")
|
||||
:to-equal "foo\n"))
|
||||
|
||||
(it "fills template with two newlines"
|
||||
(expect
|
||||
(org-roam-capture--fill-template "foo\n\n")
|
||||
:to-equal "foo\n\n")
|
||||
(expect
|
||||
(org-roam-capture--fill-template "foo\n\t\n")
|
||||
:to-equal "foo\n\t\n")))
|
||||
|
||||
(provide 'test-org-roam-capture)
|
39
tests/test-org-roam-utils.el
Normal file
39
tests/test-org-roam-utils.el
Normal file
@ -0,0 +1,39 @@
|
||||
;;; test-org-roam-utils.el --- Tests for Org-roam -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright (C) 2020 Jethro Kuan
|
||||
|
||||
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
||||
;; Package-Requires: ((buttercup))
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
;;; Code:
|
||||
|
||||
(require 'buttercup)
|
||||
(require 'org-roam)
|
||||
|
||||
(describe "org-roam-whitespace-content"
|
||||
(it "extracts whitespace correctly"
|
||||
(expect
|
||||
(org-roam-whitespace-content "foo")
|
||||
:to-equal "")
|
||||
(expect
|
||||
(org-roam-whitespace-content "foo\n")
|
||||
:to-equal "\n")
|
||||
(expect
|
||||
(org-roam-whitespace-content "foo\n\t\n")
|
||||
:to-equal "\n\t\n")))
|
||||
|
||||
(provide 'test-org-roam-utils)
|
Reference in New Issue
Block a user