mirror of
https://github.com/org-roam/org-roam
synced 2025-08-03 12:27:23 -05:00
Compare commits
584 Commits
Author | SHA1 | Date | |
---|---|---|---|
18b75bd03e | |||
ecc3611bec | |||
f754160402 | |||
3a3c4d97d5 | |||
07ec4342aa | |||
096b0c5e30 | |||
32c0f3d2ec | |||
02e35e3b01 | |||
377d39bfff | |||
3d4c93a2a0 | |||
683605c813 | |||
eae1cdc00c | |||
1bbc20cfa8 | |||
de94212cdd | |||
78144d434b | |||
55526a4283 | |||
d2e933cc3e | |||
9405d014af | |||
98434919e0 | |||
7ed513294d | |||
6fe38b959b | |||
44960f189f | |||
fbe3f2909f | |||
f8f3870cf0 | |||
1bdfc25f80 | |||
109917c589 | |||
bc4b7fa409 | |||
f8dd345bd1 | |||
0a7d365e22 | |||
389bf3c7e2 | |||
ca1b02829b | |||
dd7c3fab23 | |||
15c1a46e41 | |||
22c8d1032b | |||
4e0b3fb564 | |||
697c686390 | |||
68dab59a69 | |||
2dc5d6281a | |||
eb9a9e487c | |||
fd23360100 | |||
57f63461cd | |||
d9ba961f96 | |||
169ebe6367 | |||
38b5375354 | |||
aa755a8c77 | |||
49c048a177 | |||
741677869c | |||
9da45b54f3 | |||
1440802b8b | |||
0163461f87 | |||
c866275086 | |||
a37dd6afea | |||
3f31ff2cd9 | |||
20e021fdde | |||
5db30d8fdc | |||
b12bd4ea40 | |||
e6acc40e79 | |||
d53f0e60bf | |||
45aa3e6973 | |||
3c6e1b5194 | |||
be81a3a738 | |||
67b1562582 | |||
05d95abc2e | |||
d465ea0d72 | |||
6b98f4b836 | |||
3664d22fde | |||
f62c00ea73 | |||
597d3c6241 | |||
f43b24a5bf | |||
aa2b670cd7 | |||
9065f6a999 | |||
6c34528837 | |||
bc7a4986d8 | |||
624ac77fe2 | |||
0697f376eb | |||
3615969b35 | |||
f52c3a47d4 | |||
517f18afb4 | |||
b1ebba4b9a | |||
bad71fb928 | |||
bbefa7c174 | |||
1773978dc3 | |||
4cddc21c02 | |||
121d08562d | |||
fbf15fe5f2 | |||
4d697dea8f | |||
e612b3f068 | |||
c9636d6551 | |||
eef1ed2873 | |||
a1710b41b3 | |||
a527560cf4 | |||
628d5dcfbe | |||
516d8dfbf8 | |||
866368bfee | |||
1c831dcd73 | |||
3a2df140cb | |||
de6477be17 | |||
997ddcbf4b | |||
6f233363c8 | |||
09b0d74359 | |||
1b1d2b2b76 | |||
9e4a943d03 | |||
9a6cfe56c4 | |||
45546ff6fa | |||
7a6b885b99 | |||
39bb939dc2 | |||
467b165678 | |||
d641ad4792 | |||
18083cc1ed | |||
5b0078e79d | |||
5a3363ac22 | |||
18aa3ac787 | |||
7a493d8549 | |||
50436a9b1c | |||
2d58651699 | |||
73a04a611a | |||
ca1080b349 | |||
4e5a21d7e3 | |||
fb27fc78bc | |||
a35b0e7c6d | |||
f883c3270f | |||
eec1edf8f5 | |||
3d61a76ecb | |||
49541298ba | |||
490901957e | |||
f681c51630 | |||
ae5a0c15ba | |||
732efc6262 | |||
537f167503 | |||
1ea5b029a5 | |||
486f3cac3d | |||
e62cf7f8aa | |||
a4ab83ea89 | |||
7bb61806ef | |||
6ac3a84057 | |||
47c3b024d7 | |||
e19c3d6273 | |||
6bcf164036 | |||
315e2dc447 | |||
2f77ae709d | |||
e238c6d766 | |||
9b0a45f105 | |||
843eacb80b | |||
6fae3aa74c | |||
d1dd75e3b2 | |||
be828e2c1d | |||
5c7027aece | |||
fb76f81423 | |||
121e969553 | |||
0c0d677631 | |||
dc0357b12e | |||
cbeaa4d92e | |||
302b2e3bc3 | |||
25c41a079a | |||
53dcf687ef | |||
8ad57b1218 | |||
0b964ca428 | |||
643b98eeb3 | |||
b0fd12647b | |||
fde40dc1c4 | |||
96b0a52273 | |||
aa52b65a4a | |||
2a1c73c0a3 | |||
16c7a7bd93 | |||
1b3a0abd36 | |||
06e5814898 | |||
cc2572e48b | |||
05deb64d85 | |||
f10fbad386 | |||
05a9bc44f2 | |||
3fb4e21adf | |||
62bba9755c | |||
78a371cdc4 | |||
15d864a500 | |||
65c0f0dc8c | |||
48e195dd82 | |||
777f6d23ec | |||
8f1cf7b449 | |||
3ce6e299d4 | |||
ecf515f650 | |||
43831c5819 | |||
4d63f99fe8 | |||
57cfb3dbb7 | |||
9c23218553 | |||
7ad32e8395 | |||
d87dd011aa | |||
f2976fa3be | |||
8aa793b021 | |||
be95b42d32 | |||
cff1168ac1 | |||
06d0db736a | |||
fb0662efe7 | |||
9ca5461a2f | |||
33805c3ff5 | |||
3a4ff76508 | |||
bf41352c1c | |||
1b598a4618 | |||
ab34dd138d | |||
b17cc3b1e3 | |||
f9b1e53894 | |||
dbed2bcf5d | |||
060a29c91d | |||
8efec080e0 | |||
61e01430e0 | |||
d70198bba9 | |||
face683e00 | |||
baf0dd9d00 | |||
a9fd6c0fc7 | |||
6502874576 | |||
8401784cd2 | |||
6dc316c450 | |||
48ef3fee11 | |||
16c520068b | |||
b1608bf869 | |||
cc01cf346e | |||
eaf99cba03 | |||
65a2cb6efd | |||
bc12d1cf04 | |||
a86d82b20e | |||
d4c875b53b | |||
2159b6a846 | |||
1db4c22950 | |||
9c0f030ffd | |||
983d7a8798 | |||
910b37268e | |||
d39556a78b | |||
167553b8ee | |||
76affe177a | |||
e96685b1a9 | |||
aef71f1623 | |||
d913447939 | |||
47e83f7d3f | |||
023bcce867 | |||
4f6eb285bf | |||
8c81104816 | |||
7602b8c48d | |||
c6797cbd75 | |||
440461a90b | |||
4d423a916e | |||
b184cdaef0 | |||
b2cc997976 | |||
bc5c41d212 | |||
7c83a84db3 | |||
56c47fbff8 | |||
0d235686f4 | |||
ac2044b84b | |||
cffa0bd201 | |||
bd8b5587f5 | |||
b937bc9655 | |||
a7cf48ea89 | |||
46327991ef | |||
a4da8f32bf | |||
5d483f2d4d | |||
09fd41ce24 | |||
a0c4abf579 | |||
cbf1b585ac | |||
66cd5b6226 | |||
5348654a7e | |||
87d7c07e87 | |||
02fda3adb1 | |||
82bd6c6cda | |||
e8d3516fa8 | |||
0cce9d1165 | |||
7a76f7b476 | |||
ceee2348e0 | |||
32bf91077e | |||
d973e8f6e0 | |||
6759bee56b | |||
ce17e7eecd | |||
369753c98b | |||
93d8c477fe | |||
30d52e5508 | |||
19c5e9b0f3 | |||
3ec2ed8874 | |||
be64f107e9 | |||
64d8ba1900 | |||
2f4034cebc | |||
668f135aa1 | |||
273d0dffa6 | |||
fadb515a87 | |||
2e58d3df19 | |||
c05368a16b | |||
346bbf50a1 | |||
176b2bf19d | |||
ae32c465de | |||
da6af3a468 | |||
cd87cfdd58 | |||
feda1f41e5 | |||
d170c4ac85 | |||
f59c18fda5 | |||
f5257cefa7 | |||
18c0f2da7f | |||
b2aa8bdad0 | |||
925d225f13 | |||
6c89eb82af | |||
8ec4cafa2b | |||
e881ea26b1 | |||
efb592907e | |||
da507a5bee | |||
fc3a03977d | |||
70539c40d2 | |||
fac0465dd8 | |||
6d09323218 | |||
e3ff54616e | |||
d3a920a5b7 | |||
8fff0b86f9 | |||
df174bb52b | |||
cb10b16fc0 | |||
9ff57c8fd1 | |||
a6aabf4038 | |||
f8c8fcee6b | |||
6f0a38e64e | |||
b8b180d60d | |||
fe5566c0dc | |||
cc8a2184b7 | |||
4f0b1b8d43 | |||
0a64a5def4 | |||
2cd993e0a5 | |||
82ac6b6b9c | |||
f6bf9d9401 | |||
38234b491d | |||
4e5b52fbd3 | |||
c33867e6bc | |||
30b2e97426 | |||
9ee591f7a4 | |||
2081e1268a | |||
11aac39a1b | |||
e58ec84b7c | |||
7813b1fe1f | |||
22006be751 | |||
0318983cac | |||
9753ee451f | |||
8c442a72de | |||
0ed9057a87 | |||
5d02e6407b | |||
4fa966d366 | |||
6d03e7626d | |||
c437052b4b | |||
a26c262048 | |||
4f3668a1e3 | |||
09b5357a94 | |||
444eedc799 | |||
da6fdd7542 | |||
f18ecd1fc3 | |||
f206b5bbf9 | |||
30fab7bcc4 | |||
76d2e3f6b4 | |||
8881c9732b | |||
0aa0a7c05a | |||
ea4bfbb55d | |||
0443351800 | |||
6345d0c22e | |||
f2c1500beb | |||
89e9121f26 | |||
c536fd4f2e | |||
20f876aa6b | |||
863ae2427e | |||
379d5e4770 | |||
4d992ce9e3 | |||
1d9968bf69 | |||
650744adc7 | |||
d099f9bef9 | |||
b5f3f04318 | |||
c20c8f9a0a | |||
c24fb51b03 | |||
80390b5a84 | |||
eb7ee0ef6c | |||
fb5beeb14d | |||
10e91a88c1 | |||
4cdab9103f | |||
4ec4e60358 | |||
7a4b15fd36 | |||
f9fea29c44 | |||
569aeb84ed | |||
1574e0d351 | |||
fffef6711f | |||
ef23f507ec | |||
f1dbe3fdf9 | |||
efba3c2bf0 | |||
6770c3eaf5 | |||
b8aa5c1f23 | |||
ca4a7421bc | |||
3348298527 | |||
d77f897400 | |||
9f7ed4353c | |||
d19a711a44 | |||
9766862e84 | |||
aedfca8de2 | |||
21bc220ed3 | |||
d58fc31dfb | |||
64a0bfd168 | |||
3aff6b2be7 | |||
7f56df7f4d | |||
0830da4504 | |||
3a1c826aa0 | |||
1e11a3a16f | |||
e33c3bcb3f | |||
610d4ced85 | |||
2f13d1fe64 | |||
ee28b5e6b1 | |||
79c75ac174 | |||
c59d6c4f7c | |||
220f395c1f | |||
76b2ac3460 | |||
11e0aa4c55 | |||
408e38f8ba | |||
f16de357a6 | |||
abd81918e1 | |||
6a37fff1e6 | |||
527c693f65 | |||
76d419cc89 | |||
3f2f7e3ff7 | |||
fd73da9410 | |||
11902bc790 | |||
185f9877ae | |||
1276e801c0 | |||
04d335cc40 | |||
8b16e5d520 | |||
7ab67436a7 | |||
87403b330c | |||
fae45434b5 | |||
9cf26494e8 | |||
0d5efe1c14 | |||
2eb0aac88a | |||
eca07277ce | |||
48158e67d4 | |||
278e3df95d | |||
48d2c199ac | |||
7f7ba857de | |||
cf368ab4d8 | |||
43dbad1f62 | |||
040913151f | |||
1a964520f2 | |||
39276362d7 | |||
1168c9b6da | |||
92e02b5d14 | |||
26b90b28e3 | |||
f4376f39a9 | |||
898c6c8178 | |||
30599cc3e8 | |||
9d5a34d0f4 | |||
5bf3e596c8 | |||
14f83bdb07 | |||
81e7a5b231 | |||
1756ec6441 | |||
c61f7e20f2 | |||
563252a6f6 | |||
fdaf07da43 | |||
5d25c4552d | |||
c46d153fd3 | |||
0cd4bc05c5 | |||
c5e0c6b9fa | |||
721689d5b5 | |||
d36d3185ae | |||
3ad43b0823 | |||
b2594b84ae | |||
3440e647c0 | |||
1d28b07a7c | |||
195669ad10 | |||
47feff5a8b | |||
7200364d31 | |||
873a314746 | |||
91c905d7e3 | |||
f9a9f15a8b | |||
9ddadc9c25 | |||
d0fab34287 | |||
e3281fc31f | |||
5ee38f2d89 | |||
2e220f511e | |||
1581d875ce | |||
50cc81c76d | |||
f95cea7067 | |||
41a1970c6f | |||
8818f50f41 | |||
ea6bd215fc | |||
a05b1ebcc3 | |||
214f9df844 | |||
4f5a82e291 | |||
4d0b5734c8 | |||
4cd0fe4e41 | |||
1eefc264f5 | |||
525a58dd86 | |||
4a9401dd40 | |||
dd2406ec92 | |||
c4189ffa04 | |||
e3d101f495 | |||
2cced712fa | |||
cce2db8b5a | |||
2147adf95c | |||
d2654f6023 | |||
78b518efd3 | |||
1b5e55b6c4 | |||
4b45f1dbf5 | |||
e0aee184a7 | |||
eae97487dc | |||
f5a9dfab9b | |||
7844827757 | |||
74f12ee8aa | |||
055669817a | |||
1fc08b4428 | |||
cfe3b19a73 | |||
1bc1559743 | |||
265182a698 | |||
4b4ebf76c7 | |||
3bc174a6f0 | |||
8091f4598e | |||
1267a43043 | |||
8ff09b4b6d | |||
2499c7e220 | |||
d816250614 | |||
47763f49fd | |||
9961a22a8c | |||
f390593cfb | |||
59c18c0e8c | |||
3df3b6519c | |||
b47b76aa41 | |||
abb36d11ef | |||
e55a38530d | |||
80bc19cbda | |||
85b3e488b2 | |||
5a9f765a49 | |||
1c7c5b3b9b | |||
4266a81b51 | |||
36940e1eef | |||
176aac67e6 | |||
376ff71616 | |||
232921b9a1 | |||
9e2998c580 | |||
e44b84b791 | |||
5e63bf32ed | |||
e62bda799a | |||
46975107a2 | |||
b388fd3db2 | |||
e0cefa7377 | |||
fca1777648 | |||
1722fae9af | |||
3727f015cd | |||
a85205e7bc | |||
b4927abbd7 | |||
ad5fca5440 | |||
3efe315ff1 | |||
d68d1f8ebb | |||
c70f2d5f54 | |||
d3206b797a | |||
dee540b62f | |||
46fd2a9a68 | |||
c1bfa99ace | |||
9bc80ff9f7 | |||
1912beebc3 | |||
f8f7e6009c | |||
689f559080 | |||
3ca2d9f4ca | |||
cd0850f1c1 | |||
11e15594cc | |||
f6e84caf72 | |||
11d239d661 | |||
7df50c14ec | |||
a723199d68 | |||
1bbfb0cdc9 | |||
69d4f05a13 | |||
4cad2cf6e6 | |||
e698ed7f53 | |||
0132546e56 | |||
a8e2544435 | |||
1ad3539c54 | |||
5b773b687b | |||
08aa5c630d | |||
e05ee1240d | |||
65d99e998c | |||
ea3f5d00a0 | |||
7680663205 | |||
d0819aeffb | |||
bd4b9d41e8 | |||
4142300501 | |||
487025aa2f | |||
bd3c97bb30 | |||
265a3054be | |||
8bb2465e61 | |||
c3a5544da9 | |||
963692f353 | |||
d01f7b2daf | |||
8a99febd0b | |||
b5786edb30 | |||
dce8c47d6e |
12
.dir-locals.el
Normal file
12
.dir-locals.el
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
((emacs-lisp-mode
|
||||||
|
(fill-column . 110)
|
||||||
|
(indent-tabs-mode . nil)
|
||||||
|
(elisp-lint-ignored-validators . ("byte-compile" "package-lint"))
|
||||||
|
(elisp-lint-indent-specs . ((describe . 1)
|
||||||
|
(it . 1)
|
||||||
|
(org-element-map . defun)
|
||||||
|
(org-roam-with-temp-buffer . 1)
|
||||||
|
(org-with-point-at . 1)
|
||||||
|
(magit-insert-section . defun)
|
||||||
|
(magit-section-case . 0)
|
||||||
|
(org-roam-with-file . 2)))))
|
12
.github/FUNDING.yml
vendored
Normal file
12
.github/FUNDING.yml
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# These are supported funding model platforms
|
||||||
|
|
||||||
|
github: [jethrokuan, zaeph]
|
||||||
|
patreon: # Replace with a single Patreon username
|
||||||
|
open_collective: # Replace with a single Open Collective username
|
||||||
|
ko_fi: # Replace with a single Ko-fi username
|
||||||
|
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||||
|
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||||
|
liberapay: # Replace with a single Liberapay username
|
||||||
|
issuehunt: # Replace with a single IssueHunt username
|
||||||
|
otechie: # Replace with a single Otechie username
|
||||||
|
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
23
.github/ISSUE_TEMPLATE/bug_report.md
vendored
23
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@ -1,14 +1,15 @@
|
|||||||
---
|
---
|
||||||
name: Bug Report
|
name: Bug Report
|
||||||
about: Something's not working.
|
about: Something's not working.
|
||||||
title: ''
|
title: ""
|
||||||
labels: ''
|
labels: ""
|
||||||
assignees: 'jethrokuan'
|
assignees: ""
|
||||||
---
|
---
|
||||||
|
|
||||||
### Description
|
### Description
|
||||||
|
|
||||||
#### Steps to Reproduce
|
#### Steps to Reproduce
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
@ -18,13 +19,25 @@ Example:
|
|||||||
...
|
...
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
#### Backtrace
|
||||||
|
<!--
|
||||||
|
Will help us track and understand issues faster.
|
||||||
|
How to provide a backtrace:
|
||||||
|
1. M-x toggle-debug-on-error
|
||||||
|
2. Trigger error. The debugger buffer should pop up.
|
||||||
|
3. Copy the contents of the debugger buffer and paste here
|
||||||
|
-->
|
||||||
|
|
||||||
#### Expected Results
|
#### Expected Results
|
||||||
|
|
||||||
<!-- Example: File A is there -->
|
<!-- Example: File A is there -->
|
||||||
|
|
||||||
#### Actual Results
|
#### Actual Results
|
||||||
|
|
||||||
<!-- Example: File A is missing -->
|
<!-- Example: File A is missing -->
|
||||||
|
|
||||||
### Versions
|
### Environment
|
||||||
- Emacs (`C-h v emacs-version`): vX.X.X
|
|
||||||
|
<!-- Please M-x org-roam-diagnostics and paste results here -->
|
||||||
|
|
||||||
- Org-roam commit: https://github.com/jethrokuan/org-roam/commit/commithashhere
|
- Org-roam commit: https://github.com/jethrokuan/org-roam/commit/commithashhere
|
||||||
|
7
.github/ISSUE_TEMPLATE/feature_request.md
vendored
7
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@ -1,9 +1,9 @@
|
|||||||
---
|
---
|
||||||
name: Feature Request
|
name: Feature Request
|
||||||
about: Create a feature request to improve Org-roam
|
about: Create a feature request to improve Org-roam
|
||||||
title: ''
|
title: ""
|
||||||
labels: 'enhancement'
|
labels: "enhancement"
|
||||||
assignees: 'jethrokuan'
|
assignees: ""
|
||||||
---
|
---
|
||||||
|
|
||||||
### Brief Abstract
|
### Brief Abstract
|
||||||
@ -13,4 +13,5 @@ assignees: 'jethrokuan'
|
|||||||
### Proposed Implementation (if any)
|
### Proposed Implementation (if any)
|
||||||
|
|
||||||
### Please check the following:
|
### Please check the following:
|
||||||
|
|
||||||
- [ ] No similar feature requests
|
- [ ] No similar feature requests
|
||||||
|
31
.github/workflows/docs.yml
vendored
Normal file
31
.github/workflows/docs.yml
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
# * docs.yml --- Build the documentation and publish to Github Pages
|
||||||
|
|
||||||
|
name: "Docs"
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: true
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Install deps
|
||||||
|
run: |
|
||||||
|
sudo apt-get install texinfo
|
||||||
|
|
||||||
|
- name: Build docs
|
||||||
|
continue-on-error: false
|
||||||
|
run: make html
|
||||||
|
|
||||||
|
- name: Deploy 🚀
|
||||||
|
uses: JamesIves/github-pages-deploy-action@releases/v3
|
||||||
|
with:
|
||||||
|
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
||||||
|
BRANCH: gh-pages # The branch the action should deploy to.
|
||||||
|
FOLDER: doc # The folder the action should deploy.
|
||||||
|
CLEAN: true
|
21
.github/workflows/test.yml
vendored
21
.github/workflows/test.yml
vendored
@ -29,15 +29,14 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
- develop
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
matrix:
|
||||||
emacs_version:
|
emacs_version:
|
||||||
|
- 27.1
|
||||||
- snapshot
|
- snapshot
|
||||||
steps:
|
steps:
|
||||||
- uses: purcell/setup-emacs@master
|
- uses: purcell/setup-emacs@master
|
||||||
@ -46,23 +45,17 @@ jobs:
|
|||||||
|
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Initialize sandbox
|
- name: Install Eldev
|
||||||
run: |
|
run: curl -fsSL https://raw.github.com/doublep/eldev/master/webinstall/github-eldev | sh
|
||||||
SANDBOX_DIR=$(mktemp -d) || exit 1
|
|
||||||
echo ::set-env name=SANDBOX_DIR::$SANDBOX_DIR
|
|
||||||
./makem.sh -vv --sandbox $SANDBOX_DIR --install-deps --install-linters
|
|
||||||
|
|
||||||
# The "all" rule is not used, because it treats compilation warnings
|
- name: Install dependencies
|
||||||
# as failures, so linting and testing are run as separate steps.
|
run: make prepare
|
||||||
|
|
||||||
- name: Lint
|
- name: Lint
|
||||||
continue-on-error: true
|
run: make lint
|
||||||
run: ./makem.sh -vv --sandbox $SANDBOX_DIR lint
|
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
if: always() # Run test even if linting fails.
|
run: make test
|
||||||
run: ./makem.sh -vv --sandbox $SANDBOX_DIR test
|
|
||||||
|
|
||||||
# Local Variables:
|
# Local Variables:
|
||||||
# eval: (outline-minor-mode)
|
# eval: (outline-minor-mode)
|
||||||
# End:
|
# End:
|
||||||
|
14
.gitignore
vendored
14
.gitignore
vendored
@ -1,2 +1,16 @@
|
|||||||
/.sandbox/
|
/.sandbox/
|
||||||
**/*.elc
|
**/*.elc
|
||||||
|
/doc/dir
|
||||||
|
/doc/*.info
|
||||||
|
/doc/*.pdf
|
||||||
|
/doc/*.epub
|
||||||
|
/doc/META_INF/
|
||||||
|
/doc/OEBPS/
|
||||||
|
/doc/dir
|
||||||
|
/doc/epub.xml
|
||||||
|
/doc/org-roam/
|
||||||
|
/doc/mimetype
|
||||||
|
/doc/stats/
|
||||||
|
/config.mk
|
||||||
|
/doc/manual.html
|
||||||
|
/.eldev/
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
version: 2
|
|
||||||
mkdocs:
|
|
||||||
configuration: mkdocs.yml
|
|
||||||
formats: all
|
|
||||||
python:
|
|
||||||
version: 3.7
|
|
||||||
install:
|
|
||||||
- requirements: doc/requirements.txt
|
|
8
BACKERS.md
Normal file
8
BACKERS.md
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Backers
|
||||||
|
|
||||||
|
Many thanks to the following backers, your contributions are greatly appreciated!
|
||||||
|
|
||||||
|
- Nathan Tran
|
||||||
|
- Burke Libbey
|
||||||
|
- forkrul
|
||||||
|
- Andreas Stuhlmüller
|
350
CHANGELOG.md
350
CHANGELOG.md
@ -1,5 +1,202 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 1.2.4 (TBD)
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- [#1396](https://github.com/org-roam/org-roam/pull/1396) add option to choose between prepending, appending, and omitting `roam_tags` in file completion
|
||||||
|
- [#1270](https://github.com/org-roam/org-roam/pull/1270) capture: create OLP if it does not exist. Removes need for OLP setup in `:head`.
|
||||||
|
- [#1353](https://github.com/org-roam/org-roam/pull/1353) support file-level property drawers
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- [#1352](https://github.com/org-roam/org-roam/pull/1352) prefer lower-case for roam_tag and roam_alias in interactive commands
|
||||||
|
- [#1513](https://github.com/org-roam/org-roam/pull/1513) replaced hardcoded "svg" with defcustom org-roam-graph-filetype
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- [#1281](https://github.com/org-roam/org-roam/pull/1281) fixed idle-timer not instantiated on `org-roam-mode`
|
||||||
|
- [#1308](https://github.com/org-roam/org-roam/pull/1308) fixed file renames corrupting database
|
||||||
|
- [#1325](https://github.com/org-roam/org-roam/pull/1325) make titles and tags extracted unique per note
|
||||||
|
- [#1327](https://github.com/org-roam/org-roam/pull/1327) preserve existing link description during automatic replacement
|
||||||
|
- [#1346](https://github.com/org-roam/org-roam/pull/1346) prevent malformed path to `org-roam-index-file`
|
||||||
|
- [#1347](https://github.com/org-roam/org-roam/pull/1347) allow use of `%a` element in regular Org-roam captures
|
||||||
|
- [#1352](https://github.com/org-roam/org-roam/pull/1352) fixed org-roam-{tag/alias}-{add/delete} altering the original case of the Org property
|
||||||
|
- [#1374](https://github.com/org-roam/org-roam/pull/1374) fix headline completions erroring out
|
||||||
|
- [#1375](https://github.com/org-roam/org-roam/pull/1375) fix org-roam-protocol to use existing ref file
|
||||||
|
- [#1403](https://github.com/org-roam/org-roam/issues/1403) fixed inconsistency between how we write and read props like alias and tags
|
||||||
|
- [#1409](https://github.com/org-roam/org-roam/issues/1398) prevent inclusion of non-org-roam files in `org-roam-dailies--list-files`
|
||||||
|
|
||||||
|
## 1.2.3 (13-11-2020)
|
||||||
|
|
||||||
|
Primarily a stabilization and bug-fix release.
|
||||||
|
|
||||||
|
Org-roam-dailies has also been revamped to include new features, see [this video](https://www.youtube.com/watch?v=1q9x2aZCJJ4) for a quick overview.
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- [#978](https://github.com/org-roam/org-roam/pull/978) Revamp org-roam-dailies
|
||||||
|
- [#1183](https://github.com/org-roam/org-roam/pull/1183) Interactive functions for managing aliases and tags in Org-roam file, namely `org-roam-alias-add`, `org-roam-alias-delete`, `org-roam-tag-add`, and `org-roam-tag-delete`.
|
||||||
|
- [#1215](https://github.com/org-roam/org-roam/pull/1215) Multiple `ROAM_KEY` keywords can now be specified in one file. This allows bibliographical entries to share the same note file.
|
||||||
|
- [#1238](https://github.com/org-roam/org-roam/pull/1238) Add `org-roam-prefer-id-links` variable to select linking method
|
||||||
|
- [#1239](https://github.com/org-roam/org-roam/pull/1239) Allow `org-roam-protocol` to capture the webpage's selection, and add a toggle for storing the links to the pages
|
||||||
|
- [#1264](https://github.com/org-roam/org-roam/pull/1264) add `org-roam-db-update-method` to control when the cache is rebuilt.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- [#1264](https://github.com/org-roam/org-roam/pull/1264) renamed `org-roam-update-db-idle-seconds` to `org-roam-db-idle-idle-seconds`
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- [#1074](https://github.com/org-roam/org-roam/issues/1074) fix `org-roam--extract-links` to handle content boundaries.
|
||||||
|
- [#1193](https://github.com/org-roam/org-roam/issues/1193) fix `org-roam-db-build-cache` by not killing temporary buffer in `org-roam--extract-links`.
|
||||||
|
- [#1195](https://github.com/org-roam/org-roam/issues/1195) fix ID face showing as invalid if within Org ID files, but not Org-roam's.
|
||||||
|
- [#1199](https://github.com/org-roam/org-roam/issues/1199) make Org-roam link insertions respect `org-roam-link-title-format` everywhere.
|
||||||
|
- [#1201](https://github.com/org-roam/org-roam/issues/1201) fix `org-roam-db-build-cache` failing in scenarios involving duplicate IDs and deleted files.
|
||||||
|
- [#1226](https://github.com/org-roam/org-roam/issues/1226) only update relative path of file links
|
||||||
|
- [#1232](https://github.com/org-roam/org-roam/issues/1232) fix incorrect title extractions from narrowed buffers
|
||||||
|
- [#1233](https://github.com/org-roam/org-roam/issues/1233) fixes bug where descriptive file links become plain links during update for relative paths
|
||||||
|
- [#1252](https://github.com/org-roam/org-roam/issues/1252) respect original link type during automatic replacement
|
||||||
|
|
||||||
|
## 1.2.2 (06-10-2020)
|
||||||
|
|
||||||
|
In this release we support fuzzy links of the form `[[roam:Title]]`, `[[roam:*Headline]]` and `[[roam:Title*Headline]]`. Completion for these fuzzy links is supported via `completion-at-point`.
|
||||||
|
|
||||||
|
Org-roam now does not resolve symlinks. This significantly speeds up cache builds, but may result in some workflows breaking. In particular, Org-roam now cannot figure out if two distinct file paths in the Org-roam directory are the same file, and both files will be processed as if they were different files. This error seems to be unavoidable now that symlinks are not resolved, but this workflow is rare and should not affect most users.
|
||||||
|
|
||||||
|
This change requires you to set `org-roam-directory` to the resolved path of a folder. That is:
|
||||||
|
|
||||||
|
```elisp
|
||||||
|
(setq org-roam-directory (file-truename "/path/to/directory/"))
|
||||||
|
```
|
||||||
|
|
||||||
|
### Breaking Changes
|
||||||
|
|
||||||
|
- [#1164](https://github.com/org-roam/org-roam/pull/1164) Org-roam now stores the database in the user's Emacs directory by default
|
||||||
|
- [#910](https://github.com/org-roam/org-roam/pull/910) Deprecate `company-org-roam`, using `completion-at-point` instead. To use this with company, add the `company-capf` backend instead.
|
||||||
|
- [#1109](https://github.com/org-roam/org-roam/pull/1109) Org-roam now does not resolve symlinks.
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
- [#1163](https://github.com/org-roam/org-roam/pull/1163) Support file-level IDs introduced in Org 9.4
|
||||||
|
- [#1093](https://github.com/org-roam/org-roam/pull/1093) Add `vanilla` org-roam-tag-source to extract buffer Org tags
|
||||||
|
- [#1079](https://github.com/org-roam/org-roam/pull/1079) Add `org-roam-tag-face` to customize appearance of tags in interactive commands
|
||||||
|
- [#1073](https://github.com/org-roam/org-roam/pull/1073) Rename file on title change, when `org-roam-rename-file-on-title-change` is non-nil.
|
||||||
|
- [#1071](https://github.com/org-roam/org-roam/pull/1071) Update link descriptions on title changes, and clean-up rename file advice
|
||||||
|
- [#1061](https://github.com/org-roam/org-roam/pull/1061) Speed up the extraction of file properties, headlines, and titles
|
||||||
|
- [#1046](https://github.com/org-roam/org-roam/pull/1046) New user option to exclude files from Org-roam
|
||||||
|
- [#1032](https://github.com/org-roam/org-roam/pull/1032) File changes are now propagated to the database on idle timer. This prevents large wait times during file saves.
|
||||||
|
- [#974](https://github.com/org-roam/org-roam/pull/974) Protect region targeted by `org-roam-insert`
|
||||||
|
- [#994](https://github.com/org-roam/org-roam/pull/994) Simplify org-roam-store-link
|
||||||
|
- [#1062](https://github.com/org-roam/org-roam/pull/1062) Variable `org-roam-completions-everywhere` allows for completions everywhere from word at point
|
||||||
|
- [#910](https://github.com/org-roam/org-roam/pull/910), [#1105](https://github.com/org-roam/org-roam/pull/1105) Support fuzzy links of the form `[[roam:Title]]`, `[[roam:*Headline]]` and `[[roam:Title*Headline]]`
|
||||||
|
|
||||||
|
### Bugfixes
|
||||||
|
|
||||||
|
- [#1057](https://github.com/org-roam/org-roam/pull/1057) Improve performance of database builds by preventing generation of LaTeX and image previews.
|
||||||
|
- [#1103](https://github.com/org-roam/org-roam/pull/1103) Fix long build-times for Windows on files with URL links
|
||||||
|
|
||||||
|
## 1.2.1 (27-07-2020)
|
||||||
|
|
||||||
|
This release consisted of a big deal of refactoring and bug fixes. Notably, we fixed several catastrophic failures on db builds with bad setups (#854), and modularized tag and title extractions.
|
||||||
|
|
||||||
|
We also added some new features that had been a long time coming:
|
||||||
|
|
||||||
|
1. We made the backlinks more outline-friendly by also showing the outline hierarchy for a backlink (#863)
|
||||||
|
2. We now support nested captures, which is crucial for `org-roam-protocol` (#966)
|
||||||
|
|
||||||
|
### Breaking Changes
|
||||||
|
|
||||||
|
- [#908](https://github.com/org-roam/org-roam/pull/908) Normalized titles in database. May break external packages that rely on unnormalized titles.
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
- [#814](https://github.com/org-roam/org-roam/pull/814) Implement `org-roam-insert-immediate`
|
||||||
|
- [#833](https://github.com/org-roam/org-roam/pull/833) Add customization of file titles with `org-roam-title-to-slug-function`.
|
||||||
|
- [#839](https://github.com/org-roam/org-roam/pull/839) Return selected file from `org-roam-insert`
|
||||||
|
- [#847](https://github.com/org-roam/org-roam/pull/847) Add GC threshold `org-roam-db-gc-threshold` to temporarily change the threshold on expensive operations.
|
||||||
|
- [#847](https://github.com/org-roam/org-roam/pull/847) Use sqlite3 transactions instead of storing the values to be inserted.
|
||||||
|
- [#851](https://github.com/org-roam/org-roam/pull/851) Add `'first-directory'` option for `org-roam-tag-sources`
|
||||||
|
- [#863](https://github.com/org-roam/org-roam/pull/863) Display outline hierarchy in backlinks buffer
|
||||||
|
- [#898](https://github.com/org-roam/org-roam/pull/898) Add `org-roam-random-note` to browse a random note.
|
||||||
|
- [#900](https://github.com/org-roam/org-roam/pull/900) Support and index all valid org links
|
||||||
|
- [#966](https://github.com/org-roam/org-roam/pull/966) Enable nested captures
|
||||||
|
|
||||||
|
### Bugfixes
|
||||||
|
|
||||||
|
- [#854](https://github.com/org-roam/org-roam/pull/854) Warn instead of fail when duplicate refs and IDs exist.
|
||||||
|
- [#857](https://github.com/org-roam/org-roam/pull/857) Fix tag extraction for symlinked directories.
|
||||||
|
- [#894](https://github.com/org-roam/org-roam/pull/894) Perform link fixes on all Org-roam files
|
||||||
|
- [#952](https://github.com/org-roam/org-roam/pull/952) Cache `${foo}` template variables so they do not need to be re-entered twice
|
||||||
|
|
||||||
|
## 1.2.0 (12-06-2020)
|
||||||
|
|
||||||
|
In this release, we improved the linking process by achieving feature parity between links to files and links to headlines. Before, we used the `file:foo::*bar` format to link to the headline `bar` in file `foo`, but this was prone to breakage upon renaming the file or modifying the headline. This is not the case anymore. Now, we use `org-id` to create IDs for those headlines, which are then stored in our database to compute the relationships and jump around. Note that this will work even if you’re not using `org-id` in your global configuration for Org-mode.
|
||||||
|
|
||||||
|
This is a major step forward. Supporting the in-file structure of Org-mode files means that we can interface with many of its core-features like TODOs, properties, priorities, etc. UX will have to be figured out, but this release ushers in a new age in terms of functionalities.
|
||||||
|
|
||||||
|
We also add `org-roam-unlinked-references`, which naively finds text that could be references to the current Org-roam file.
|
||||||
|
|
||||||
|
### Breaking Changes
|
||||||
|
|
||||||
|
- [#701](https://github.com/org-roam/org-roam/pull/701) Use `emacsql-sqlite3` instead of `emacsql-sqlite` for better Windows compatibility. This requires the presence of the standard `sqlite3` binary on your machine.
|
||||||
|
- [#750](https://github.com/org-roam/org-roam/pull/750) Deprecate `org-roam-buffer-no-delete-other-windows` in favour of `org-roam-buffer-window-parameters`.
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
- [#787](https://github.com/org-roam/org-roam/pull/787) Add `org-roam-unlinked-references`
|
||||||
|
- [#783](https://github.com/org-roam/org-roam/pull/783) Add support for headlines
|
||||||
|
- [#757](https://github.com/org-roam/org-roam/pull/757) Roam global properties are now case-insensitive
|
||||||
|
- [#680](https://github.com/org-roam/org-roam/pull/680) , [#703](https://github.com/org-roam/org-roam/pull/703), [#708](https://github.com/org-roam/org-roam/pull/708) Add `org-roam-doctor` checkers for `ROAM_*` properties
|
||||||
|
- [#664](https://github.com/org-roam/org-roam/pull/664) Add support for shelling out to `rg` and `find` in `org-roam--list-files`
|
||||||
|
- [#679](https://github.com/org-roam/org-roam/pull/679), [#683](https://github.com/org-roam/org-roam/pull/683) Building of the graph now happens in a separate process
|
||||||
|
|
||||||
|
### Bugfixes
|
||||||
|
|
||||||
|
- [#714](https://github.com/org-roam/org-roam/pull/714) No longer print citelinks in backlinks buffer if there is no `ROAM_KEY` property or `org-ref` is not installed
|
||||||
|
- [#759](https://github.com/org-roam/org-roam/pull/759), [#760](https://github.com/org-roam/org-roam/pull/760) Tags are only added to the tags table if there are actually tags present
|
||||||
|
- [#700](https://github.com/org-roam/org-roam/pull/700), [#733](https://github.com/org-roam/org-roam/pull/733) Allow symlinks within the `org-roam` directory
|
||||||
|
|
||||||
|
## 1.1.1 (18-05-2020)
|
||||||
|
|
||||||
|
In this release, we added two new features:
|
||||||
|
|
||||||
|
1. `org-roam-doctor`: a linting system that helps you discover possible problems with your Org-roam files. This is in the spirit of keeping notes in top quality.
|
||||||
|
2. A tagging system: one can now use sub-directories, and the `#+roam_tags` key add additional meta data to notes. For more information, see [here](https://www.orgroam.com/manual/Tags.html#Tags).
|
||||||
|
|
||||||
|
As usual, this release comes with a multitude of bug-fixes and refactorings.
|
||||||
|
|
||||||
|
### Breaking Changes
|
||||||
|
|
||||||
|
- [#523](https://github.com/org-roam/org-roam/pull/523) remove `org-roam-completion-fuzzy-match` in favor of using completion mechanism's configuration options directly
|
||||||
|
- [#547](https://github.com/org-roam/org-roam/pull/547) Deprecate `org-roam-db--maybe-update`, in favour of `org-roam-db--update-maybe`
|
||||||
|
- [#604](https://github.com/org-roam/org-roam/pull/604) Deprecate `org-roam-title-include-subdirs`, `org-roam-title-subdir-format` `org-roam-title-subdir-separator`, for a more general tagging system built on subdirectories
|
||||||
|
|
||||||
|
### Bugfixes
|
||||||
|
|
||||||
|
- [#509](https://github.com/org-roam/org-roam/pull/509) fix backup files being tracked in database
|
||||||
|
- [#509](https://github.com/org-roam/org-roam/pull/509) fix external org files being tracked in database
|
||||||
|
- [#537](https://github.com/org-roam/org-roam/pull/537) quote graphviz node and edge configuration options to allow multi-word configurations
|
||||||
|
- [#545](https://github.com/org-roam/org-roam/pull/545) fix `org-roam--extract-links` to ensure that multiple citations (`cite:key1,key2`) are split correctly
|
||||||
|
- [#547](https://github.com/org-roam/org-roam/pull/547) Fix unlinked citations
|
||||||
|
- [#660](https://github.com/org-roam/org-roam/pull/660) fix rename-file advice not working for renaming to directories
|
||||||
|
- [#660](https://github.com/org-roam/org-roam/pull/660) fix links breaking within file on file movement
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
- [#538](https://github.com/org-roam/org-roam/pull/538) Optionally use text in first headline as title
|
||||||
|
- [#553](https://github.com/org-roam/org-roam/pull/553) Add prefix argument to `org-roam-db-build-cache` for forcing rebuilds
|
||||||
|
- [#560](https://github.com/org-roam/org-roam/pull/560) Apply 'error face to distinguish broken links
|
||||||
|
- [#570](https://github.com/org-roam/org-roam/pull/570) Add `org-roam-doctor` to diagnose org-roam files
|
||||||
|
- [#625](https://github.com/org-roam/org-roam/pull/625) Add `org-roam-title-sources` to control how titles are retrieved within notes
|
||||||
|
- [#604](https://github.com/org-roam/org-roam/pull/604) Add a tagging system. `org-roam-tag-sources` controls how tags are retrieved from notes
|
||||||
|
|
||||||
|
### Internal Changes
|
||||||
|
|
||||||
|
- [#547](https://github.com/org-roam/org-roam/pull/547) Added `type` column to the `refs` table
|
||||||
|
- [#606](https://github.com/org-roam/org-roam/pull/606) Added `org-roam-dev.el` for developer coding standards
|
||||||
|
- [#622](https://github.com/org-roam/org-roam/pull/622) Online documentation now points to the Org-based documentation
|
||||||
|
|
||||||
## 1.1.0 (21-04-2020)
|
## 1.1.0 (21-04-2020)
|
||||||
|
|
||||||
To the average user, this release is mainly a bugfix release with additional options to customize. However, the changes made to the source is significant. Most notably, in this release:
|
To the average user, this release is mainly a bugfix release with additional options to customize. However, the changes made to the source is significant. Most notably, in this release:
|
||||||
@ -11,28 +208,32 @@ To the average user, this release is mainly a bugfix release with additional opt
|
|||||||
In the coming months, you can expect work on bigger projects (e.g. revamping the org-roam buffer).
|
In the coming months, you can expect work on bigger projects (e.g. revamping the org-roam buffer).
|
||||||
|
|
||||||
### Breaking Changes
|
### Breaking Changes
|
||||||
* [#385](https://github.com/jethrokuan/org-roam/pull/385) Deprecate `org-roam-graph-node-shape` in favour of `org-roam-graph-node-extra-config`.
|
|
||||||
* [#473](https://github.com/jethrokuan/org-roam/pull/473) Deprecate `org-roam-date-filename-format` and `org-roam-date-title-format`, in favour of `org-roam-dailies-capture-templates`.
|
- [#385](https://github.com/org-roam/org-roam/pull/385) Deprecate `org-roam-graph-node-shape` in favour of `org-roam-graph-node-extra-config`.
|
||||||
|
- [#473](https://github.com/org-roam/org-roam/pull/473) Deprecate `org-roam-date-filename-format` and `org-roam-date-title-format`, in favour of `org-roam-dailies-capture-templates`.
|
||||||
|
|
||||||
### New Features
|
### New Features
|
||||||
* [#350](https://github.com/jethrokuan/org-roam/pull/350) Add `org-roam-db-location` to customize location of org-roam database.
|
|
||||||
* [#359](https://github.com/jethrokuan/org-roam/pull/359) Add `org-roam-verbose` to allow or silence printing of information.
|
- [#350](https://github.com/org-roam/org-roam/pull/350) Add `org-roam-db-location` to customize location of org-roam database.
|
||||||
* [#374](https://github.com/jethrokuan/org-roam/pull/374) Add support for `org-ref` `cite:` links
|
- [#359](https://github.com/org-roam/org-roam/pull/359) Add `org-roam-verbose` to allow or silence printing of information.
|
||||||
* [#380](https://github.com/jethrokuan/org-roam/pull/380) Allow `org-roam-buffer-position` to also be `top` or `bottom`
|
- [#374](https://github.com/org-roam/org-roam/pull/374) Add support for `org-ref` `cite:` links
|
||||||
* [#385](https://github.com/jethrokuan/org-roam/pull/385) Add `org-roam-graph-node-extra-config` to configure Graphviz nodes
|
- [#380](https://github.com/org-roam/org-roam/pull/380) Allow `org-roam-buffer-position` to also be `top` or `bottom`
|
||||||
* [#398](https://github.com/jethrokuan/org-roam/pull/398), [#418](https://github.com/jethrokuan/org-roam/pull/418) Add graph building for connected components
|
- [#385](https://github.com/org-roam/org-roam/pull/385) Add `org-roam-graph-node-extra-config` to configure Graphviz nodes
|
||||||
* [#435](https://github.com/jethrokuan/org-roam/pull/435) Add `org-roam-graph-edge-extra-config` to configure Graphviz edges
|
- [#398](https://github.com/org-roam/org-roam/pull/398), [#418](https://github.com/org-roam/org-roam/pull/418) Add graph building for connected components
|
||||||
* [#439](https://github.com/jethrokuan/org-roam/pull/439) Add support for `org-ref` citations to display as edges in graph. Add `org-roam-graph-edge-cites-extra-config` to configure these edges
|
- [#435](https://github.com/org-roam/org-roam/pull/435) Add `org-roam-graph-edge-extra-config` to configure Graphviz edges
|
||||||
* [#465](https://github.com/jethrokuan/org-roam/pull/465) Add `org-roam-file-extensions` to allow detection of org files with different file extensions
|
- [#439](https://github.com/org-roam/org-roam/pull/439) Add support for `org-ref` citations to display as edges in graph. Add `org-roam-graph-edge-cites-extra-config` to configure these edges
|
||||||
* [#488](https://github.com/jethrokuan/org-roam/pull/488) Allow a function for `org-roam-graph-viewer`
|
- [#465](https://github.com/org-roam/org-roam/pull/465) Add `org-roam-file-extensions` to allow detection of org files with different file extensions
|
||||||
* [#491](https://github.com/jethrokuan/org-roam/pull/491) Use TITLE as description when linking before first heading
|
- [#488](https://github.com/org-roam/org-roam/pull/488) Allow a function for `org-roam-graph-viewer`
|
||||||
|
- [#491](https://github.com/org-roam/org-roam/pull/491) Use TITLE as description when linking before first heading
|
||||||
|
|
||||||
### Bugfixes
|
### Bugfixes
|
||||||
* [#470](https://github.com/jethrokuan/org-roam/pull/470) Add workaround for undocumented `file-truename` behaviour in `org-roam--org-roam-file-p`.
|
|
||||||
|
- [#470](https://github.com/org-roam/org-roam/pull/470) Add workaround for undocumented `file-truename` behaviour in `org-roam--org-roam-file-p`.
|
||||||
|
|
||||||
### Internal Changes
|
### Internal Changes
|
||||||
* [#363](https://github.com/jethrokuan/org-roam/pull/363), [#473](https://github.com/jethrokuan/org-roam/pull/473) Modularize org-roam features.
|
|
||||||
* [#497](https://github.com/jethrokuan/org-roam/pull/497) Simplify `org-roam--list-files` implementation
|
- [#363](https://github.com/org-roam/org-roam/pull/363), [#473](https://github.com/org-roam/org-roam/pull/473) Modularize org-roam features.
|
||||||
|
- [#497](https://github.com/org-roam/org-roam/pull/497) Simplify `org-roam--list-files` implementation
|
||||||
|
|
||||||
## 1.0.0 (23-03-2020)
|
## 1.0.0 (23-03-2020)
|
||||||
|
|
||||||
@ -40,16 +241,18 @@ Org-roam is now on MELPA! We have squashed most of the bugs, and Org-roam has
|
|||||||
been stable for the most part.
|
been stable for the most part.
|
||||||
|
|
||||||
### New Features
|
### New Features
|
||||||
* [#269](https://github.com/jethrokuan/org-roam/pull/269) Add `org-roam-graphviz-extra-options`
|
|
||||||
* [#257](https://github.com/jethrokuan/org-roam/pull/257) Add a company-backend `company-org-roam`
|
- [#269](https://github.com/org-roam/org-roam/pull/269) Add `org-roam-graphviz-extra-options`
|
||||||
* [#284](https://github.com/jethrokuan/org-roam/pull/284), [#289](https://github.com/jethrokuan/org-roam/pull/289) Configurable `org-roam-completion-system` with options `'default`, `'ido`, `'ivy` and `'helm`
|
- [#257](https://github.com/org-roam/org-roam/pull/257) Add a company-backend `company-org-roam`
|
||||||
* [#289](https://github.com/jethrokuan/org-roam/pull/289) Add customizable `org-roam-fuzzy-match` to allow fuzzy-matching of candidates
|
- [#284](https://github.com/org-roam/org-roam/pull/284), [#289](https://github.com/org-roam/org-roam/pull/289) Configurable `org-roam-completion-system` with options `'default`, `'ido`, `'ivy` and `'helm`
|
||||||
* [#290](https://github.com/jethrokuan/org-roam/pull/290) Add `org-roam-date-title-format` and `org-roam-date-filename-format` for customizing Org-roam's date files
|
- [#289](https://github.com/org-roam/org-roam/pull/289) Add customizable `org-roam-fuzzy-match` to allow fuzzy-matching of candidates
|
||||||
* [#296](https://github.com/jethrokuan/org-roam/pull/296) Allow multiple exclusion matchers in `org-roam-graph-exclude-matcher`
|
- [#290](https://github.com/org-roam/org-roam/pull/290) Add `org-roam-date-title-format` and `org-roam-date-filename-format` for customizing Org-roam's date files
|
||||||
|
- [#296](https://github.com/org-roam/org-roam/pull/296) Allow multiple exclusion matchers in `org-roam-graph-exclude-matcher`
|
||||||
|
|
||||||
### Bugfixes
|
### Bugfixes
|
||||||
* [#293](https://github.com/jethrokuan/org-roam/pull/293) Fix capture templates not working as expected for `org-roam-find-file`
|
|
||||||
* [#275](https://github.com/jethrokuan/org-roam/pull/275) Fix database rebuild when `org-roam-directory` is set locally
|
- [#293](https://github.com/org-roam/org-roam/pull/293) Fix capture templates not working as expected for `org-roam-find-file`
|
||||||
|
- [#275](https://github.com/org-roam/org-roam/pull/275) Fix database rebuild when `org-roam-directory` is set locally
|
||||||
|
|
||||||
## 1.0.0-rc1 (06-03-2020)
|
## 1.0.0-rc1 (06-03-2020)
|
||||||
|
|
||||||
@ -59,82 +262,95 @@ backing storage has been changed to a SQLite database, and a
|
|||||||
templating system using `org-capture` is introduced.
|
templating system using `org-capture` is introduced.
|
||||||
|
|
||||||
### Breaking Changes
|
### Breaking Changes
|
||||||
* [#200](https://github.com/jethrokuan/org-roam/pull/200) Move Org-roam cache into a SQLite database.
|
|
||||||
* [#203](https://github.com/jethrokuan/org-roam/pull/203) Roam protocol is deprecated, in favour of extending org-roam-protocol.
|
- [#200](https://github.com/org-roam/org-roam/pull/200) Move Org-roam cache into a SQLite database.
|
||||||
|
- [#203](https://github.com/org-roam/org-roam/pull/203) Roam protocol is deprecated, in favour of extending org-roam-protocol.
|
||||||
|
|
||||||
### New Features
|
### New Features
|
||||||
* [#182](https://github.com/jethrokuan/org-roam/pull/182) Support file name aliases via `#+ROAM_ALIAS`.
|
|
||||||
* [#216](https://github.com/jethrokuan/org-roam/pull/216) Adds templating functionality by extending org-capture.
|
- [#182](https://github.com/org-roam/org-roam/pull/182) Support file name aliases via `#+ROAM_ALIAS`.
|
||||||
* [#232](https://github.com/jethrokuan/org-roam/pull/232) Adds a prefix key to `org-roam-show-graph`, to generate graph without opening it.
|
- [#216](https://github.com/org-roam/org-roam/pull/216) Adds templating functionality by extending org-capture.
|
||||||
* [#233](https://github.com/jethrokuan/org-roam/pull/233) Adds `org-roam-graph-exclude-matcher`, which allows exclusion of nodes from graph.
|
- [#232](https://github.com/org-roam/org-roam/pull/232) Adds a prefix key to `org-roam-show-graph`, to generate graph without opening it.
|
||||||
* [#247](https://github.com/jethrokuan/org-roam/pull/247) Add `org-roam-backlink` face, which allows customizing backlinks appearance
|
- [#233](https://github.com/org-roam/org-roam/pull/233) Adds `org-roam-graph-exclude-matcher`, which allows exclusion of nodes from graph.
|
||||||
* [#259](https://github.com/jethrokuan/org-roam/pull/259) Add optional initial-prompt to `org-roam-find-file`
|
- [#247](https://github.com/org-roam/org-roam/pull/247) Add `org-roam-backlink` face, which allows customizing backlinks appearance
|
||||||
|
- [#259](https://github.com/org-roam/org-roam/pull/259) Add optional initial-prompt to `org-roam-find-file`
|
||||||
|
|
||||||
### Bugfixes
|
### Bugfixes
|
||||||
* [#207](https://github.com/jethrokuan/org-roam/pull/207), [#221](https://github.com/jethrokuan/org-roam/pull/221) small bugfixes to Org-roam graph generation
|
|
||||||
* [#230](https://github.com/jethrokuan/org-roam/pull/230) remove nonspacing marks from filenames, to prevent cross-platform errors
|
- [#207](https://github.com/org-roam/org-roam/pull/207), [#221](https://github.com/org-roam/org-roam/pull/221) small bugfixes to Org-roam graph generation
|
||||||
|
- [#230](https://github.com/org-roam/org-roam/pull/230) remove nonspacing marks from filenames, to prevent cross-platform errors
|
||||||
|
|
||||||
### New Contributors
|
### New Contributors
|
||||||
* [@acowley][https://github.com/acowley]
|
|
||||||
* [@teesloane][https://github.com/teesloane]
|
- [@acowley][https://github.com/acowley]
|
||||||
|
- [@teesloane][https://github.com/teesloane]
|
||||||
|
|
||||||
## 0.1.2 (2020-02-21)
|
## 0.1.2 (2020-02-21)
|
||||||
|
|
||||||
### Breaking Changes
|
### Breaking Changes
|
||||||
* [#143](https://github.com/jethrokuan/org-roam/pull/143) `org-roam-mode` is now a global mode. The installation instructions have changed accordingly.
|
|
||||||
* [#103](https://github.com/jethrokuan/org-roam/pull/103) Change `org-roam-file-format` to a function: `org-roam-file-name-function` to allow more flexible file name customizaton. Also changes `org-roam-use-timestamp-as-filename` to `org-roam-filename-noconfirm` to better describe what it does.
|
- [#143](https://github.com/org-roam/org-roam/pull/143) `org-roam-mode` is now a global mode. The installation instructions have changed accordingly.
|
||||||
|
- [#103](https://github.com/org-roam/org-roam/pull/103) Change `org-roam-file-format` to a function: `org-roam-file-name-function` to allow more flexible file name customizaton. Also changes `org-roam-use-timestamp-as-filename` to `org-roam-filename-noconfirm` to better describe what it does.
|
||||||
|
|
||||||
### New Features
|
### New Features
|
||||||
* [#145](https://github.com/jethrokuan/org-roam/pull/145) `org-roam-show-graph`: Fallback to Emacs SVG viewer
|
|
||||||
* [#141](https://github.com/jethrokuan/org-roam/pull/141) add variable `org-roam-new-file-directory` for new Org-roam files
|
- [#145](https://github.com/org-roam/org-roam/pull/145) `org-roam-show-graph`: Fallback to Emacs SVG viewer
|
||||||
* [#138](https://github.com/jethrokuan/org-roam/pull/138) add `org-roam-switch-to-buffer`
|
- [#141](https://github.com/org-roam/org-roam/pull/141) add variable `org-roam-new-file-directory` for new Org-roam files
|
||||||
* [#124](https://github.com/jethrokuan/org-roam/pull/124), [#141](https://github.com/jethrokuan/org-roam/pull/141) Maintain cache consistency on file rename and delete
|
- [#138](https://github.com/org-roam/org-roam/pull/138) add `org-roam-switch-to-buffer`
|
||||||
* [#87](https://github.com/jethrokuan/org-roam/pull/87), [#90](https://github.com/jethrokuan/org-roam/pull/90) Support encrypted Org files
|
- [#124](https://github.com/org-roam/org-roam/pull/124), [#141](https://github.com/org-roam/org-roam/pull/141) Maintain cache consistency on file rename and delete
|
||||||
* [#110](https://github.com/jethrokuan/org-roam/pull/110) Add prefix to `org-roam-insert`, for inserting titles down-cased
|
- [#87](https://github.com/org-roam/org-roam/pull/87), [#90](https://github.com/org-roam/org-roam/pull/90) Support encrypted Org files
|
||||||
* [#99](https://github.com/jethrokuan/org-roam/pull/99) Add keybinding so that `<return>` or `mouse-1` in the backlinks buffer visits the source file of the backlink at point
|
- [#110](https://github.com/org-roam/org-roam/pull/110) Add prefix to `org-roam-insert`, for inserting titles down-cased
|
||||||
|
- [#99](https://github.com/org-roam/org-roam/pull/99) Add keybinding so that `<return>` or `mouse-1` in the backlinks buffer visits the source file of the backlink at point
|
||||||
|
|
||||||
### Changes
|
### Changes
|
||||||
|
|
||||||
* [#108](https://github.com/jethrokuan/org-roam/pull/108) Locally overwrite the link following behaviour in the org-roam-buffer to open files in the same window `org-roam` was called from
|
- [#108](https://github.com/org-roam/org-roam/pull/108) Locally overwrite the link following behaviour in the org-roam-buffer to open files in the same window `org-roam` was called from
|
||||||
|
|
||||||
### Bugfixes
|
### Bugfixes
|
||||||
* [#86](https://github.com/jethrokuan/org-roam/pull/86) Fix `org-roam--parse-content` incorrect `:to` computation for nested files
|
|
||||||
* [#98](https://github.com/jethrokuan/org-roam/pull/98) Fix `org-roam--find-file` picking up temporary files
|
- [#86](https://github.com/org-roam/org-roam/pull/86) Fix `org-roam--parse-content` incorrect `:to` computation for nested files
|
||||||
* [#136](https://github.com/jethrokuan/org-roam/pull/136) Misc bugfixes
|
- [#98](https://github.com/org-roam/org-roam/pull/98) Fix `org-roam--find-file` picking up temporary files
|
||||||
|
- [#136](https://github.com/org-roam/org-roam/pull/136) Misc bugfixes
|
||||||
|
|
||||||
### Internal
|
### Internal
|
||||||
* [#122](https://github.com/jethrokuan/org-roam/pull/122), [#128](https://github.com/jethrokuan/org-roam/pull/128) Improve performance of post-command-hook
|
|
||||||
* [#92](https://github.com/jethrokuan/org-roam/pull/92), [#105](https://github.com/jethrokuan/org-roam/pull/105) Add tests for core functionality
|
- [#122](https://github.com/org-roam/org-roam/pull/122), [#128](https://github.com/org-roam/org-roam/pull/128) Improve performance of post-command-hook
|
||||||
|
- [#92](https://github.com/org-roam/org-roam/pull/92), [#105](https://github.com/org-roam/org-roam/pull/105) Add tests for core functionality
|
||||||
|
|
||||||
### New Contributors
|
### New Contributors
|
||||||
* [@frigge](https://github.com/frigge)
|
|
||||||
* [@juergenhoetzel](https://github.com/juergenhoetzel)
|
- [@frigge](https://github.com/frigge)
|
||||||
* [@chip2n](https://github.com/chip2n)
|
- [@juergenhoetzel](https://github.com/juergenhoetzel)
|
||||||
* [@l3kn](https://github.com/l3kn)
|
- [@chip2n](https://github.com/chip2n)
|
||||||
* [@jdormit](https://github.com/jdormit)
|
- [@l3kn](https://github.com/l3kn)
|
||||||
* [@herbertjones](https://github.com/herbertjones)
|
- [@jdormit](https://github.com/jdormit)
|
||||||
* [@CeleritasCelery](https://github.com/CeleritasCelery)
|
- [@herbertjones](https://github.com/herbertjones)
|
||||||
* [@daniel-koudouna](https://github.com/daniel-koudouna)
|
- [@CeleritasCelery](https://github.com/CeleritasCelery)
|
||||||
|
- [@daniel-koudouna](https://github.com/daniel-koudouna)
|
||||||
|
|
||||||
## 0.1.1 (2020-02-15)
|
## 0.1.1 (2020-02-15)
|
||||||
|
|
||||||
Mostly a documentation/cleanup release.
|
Mostly a documentation/cleanup release.
|
||||||
|
|
||||||
### New Features
|
### New Features
|
||||||
* [#62](https://github.com/jethrokuan/org-roam/pull/62) Add the options `org-roam-use-timestamps-as-filename` and `org-roam-file-format`, more in documentation.
|
|
||||||
|
- [#62](https://github.com/org-roam/org-roam/pull/62) Add the options `org-roam-use-timestamps-as-filename` and `org-roam-file-format`, more in documentation.
|
||||||
|
|
||||||
### Breaking Changes
|
### Breaking Changes
|
||||||
* [#62](https://github.com/jethrokuan/org-roam/pull/62) The ID (file-name) workflow is no longer first-class, but a fallback when titles don't exist.
|
|
||||||
|
- [#62](https://github.com/org-roam/org-roam/pull/62) The ID (file-name) workflow is no longer first-class, but a fallback when titles don't exist.
|
||||||
|
|
||||||
### Changes
|
### Changes
|
||||||
* [#66](https://github.com/jethrokuan/org-roam/pull/66), [#68](https://github.com/jethrokuan/org-roam/pull/68): Improved the quality of the package in preparation of submission to MELPA
|
|
||||||
* [#73](https://github.com/jethrokuan/org-roam/pull/73): Added CI to the project via Github Issues (Thanks [@alphapapa](https://github.com/alphapapa/) for scripts and setup)
|
- [#66](https://github.com/org-roam/org-roam/pull/66), [#68](https://github.com/org-roam/org-roam/pull/68): Improved the quality of the package in preparation of submission to MELPA
|
||||||
* [#69](https://github.com/jethrokuan/org-roam/pull/69), [#72](https://github.com/jethrokuan/org-roam/pull/72), [#75](https://github.com/jethrokuan/org-roam/pull/75): Major cleanup and de-duplication of code
|
- [#73](https://github.com/org-roam/org-roam/pull/73): Added CI to the project via Github Issues (Thanks [@alphapapa](https://github.com/alphapapa/) for scripts and setup)
|
||||||
|
- [#69](https://github.com/org-roam/org-roam/pull/69), [#72](https://github.com/org-roam/org-roam/pull/72), [#75](https://github.com/org-roam/org-roam/pull/75): Major cleanup and de-duplication of code
|
||||||
|
|
||||||
### Bugfixes
|
### Bugfixes
|
||||||
* [#67](https://github.com/jethrokuan/org-roam/pull/67): Fixed `org-roam--make-file` not creating files with extensions
|
|
||||||
* [#71](https://github.com/jethrokuan/org-roam/pull/71), [#78](https://github.com/jethrokuan/org-roam/pull/78): Fixed `org-roam-insert` not inserting correct paths
|
- [#67](https://github.com/org-roam/org-roam/pull/67): Fixed `org-roam--make-file` not creating files with extensions
|
||||||
* [#82](https://github.com/jethrokuan/org-roam/pull/82): Fixed nested Org-roam files not being detected as part of Org-roam
|
- [#71](https://github.com/org-roam/org-roam/pull/71), [#78](https://github.com/org-roam/org-roam/pull/78): Fixed `org-roam-insert` not inserting correct paths
|
||||||
|
- [#82](https://github.com/org-roam/org-roam/pull/82): Fixed nested Org-roam files not being detected as part of Org-roam
|
||||||
|
|
||||||
<!-- Local Variables: -->
|
<!-- Local Variables: -->
|
||||||
<!-- eval: (auto-fill-mode -1) -->
|
<!-- eval: (auto-fill-mode -1) -->
|
||||||
|
29
Eldev
Normal file
29
Eldev
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
; -*- mode: emacs-lisp; lexical-binding: t; no-byte-compile: t -*-
|
||||||
|
|
||||||
|
;; explicitly set main file
|
||||||
|
(setf eldev-project-main-file "org-roam.el")
|
||||||
|
|
||||||
|
(eldev-use-package-archive 'gnu)
|
||||||
|
(eldev-use-package-archive 'melpa-unstable)
|
||||||
|
|
||||||
|
;; allow to load test helpers
|
||||||
|
(eldev-add-loading-roots 'test "test/utils")
|
||||||
|
|
||||||
|
;; Tell checkdoc not to demand two spaces after a period.
|
||||||
|
(setq sentence-end-double-space nil)
|
||||||
|
|
||||||
|
(setf eldev-lint-default '(elisp))
|
||||||
|
(setf eldev-standard-excludes `(:or ,eldev-standard-excludes "org-roam-macs.el"))
|
||||||
|
|
||||||
|
(with-eval-after-load 'elisp-lint
|
||||||
|
;; We will byte-compile with Eldev.
|
||||||
|
(setf elisp-lint-ignored-validators '("package-lint" "fill-column")
|
||||||
|
enable-local-variables :all))
|
||||||
|
|
||||||
|
;; Teach linter how to properly indent emacsql vectors
|
||||||
|
(eldev-add-extra-dependencies 'lint 'emacsql)
|
||||||
|
(add-hook 'eldev-lint-hook
|
||||||
|
(lambda ()
|
||||||
|
(eldev-load-project-dependencies 'lint nil t)
|
||||||
|
(require 'emacsql)
|
||||||
|
(call-interactively #'emacsql-fix-vector-indentation)))
|
69
Makefile
69
Makefile
@ -1,56 +1,29 @@
|
|||||||
# * makem.sh/Makefile --- Script to aid building and testing Emacs Lisp packages
|
.PHONY: clean
|
||||||
|
clean:
|
||||||
|
eldev clean all
|
||||||
|
|
||||||
# This Makefile is from the makem.sh repo: <https://github.com/alphapapa/makem.sh>.
|
.PHONY: prepare
|
||||||
|
prepare:
|
||||||
|
eldev -C --unstable -p -dtT prepare
|
||||||
|
|
||||||
# * Arguments
|
.PHONY: lint
|
||||||
|
lint:
|
||||||
|
eldev -C --unstable -T lint
|
||||||
|
|
||||||
# For consistency, we use only var=val options, not hyphen-prefixed options.
|
.PHONY: test
|
||||||
|
test:
|
||||||
|
eldev -C --unstable -T test
|
||||||
|
|
||||||
# NOTE: I don't like duplicating the arguments here and in makem.sh,
|
docs:
|
||||||
# but I haven't been able to find a way to pass arguments which
|
make -C doc all
|
||||||
# conflict with Make's own arguments through Make to the script.
|
|
||||||
# Using -- doesn't seem to do it.
|
|
||||||
|
|
||||||
ifdef install-deps
|
html:
|
||||||
INSTALL_DEPS = "--install-deps"
|
make -C doc html-dir
|
||||||
endif
|
|
||||||
ifdef install-linters
|
|
||||||
INSTALL_LINTERS = "--install-linters"
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifdef sandbox
|
install: install-docs
|
||||||
ifeq ($(sandbox), t)
|
|
||||||
SANDBOX = --sandbox
|
|
||||||
else
|
|
||||||
SANDBOX = --sandbox $(sandbox)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifdef debug
|
install-docs: docs
|
||||||
DEBUG = "--debug"
|
make -C doc install-docs
|
||||||
endif
|
|
||||||
|
|
||||||
# ** Verbosity
|
install-info: info
|
||||||
|
make -C doc install-info
|
||||||
# Since the "-v" in "make -v" gets intercepted by Make itself, we have
|
|
||||||
# to use a variable.
|
|
||||||
|
|
||||||
verbose = $(v)
|
|
||||||
|
|
||||||
ifneq (,$(findstring vv,$(verbose)))
|
|
||||||
VERBOSE = "-vv"
|
|
||||||
else ifneq (,$(findstring v,$(verbose)))
|
|
||||||
VERBOSE = "-v"
|
|
||||||
endif
|
|
||||||
|
|
||||||
# * Rules
|
|
||||||
|
|
||||||
# TODO: Handle cases in which "test" or "tests" are called and a
|
|
||||||
# directory by that name exists, which can confuse Make.
|
|
||||||
|
|
||||||
%:
|
|
||||||
@./makem.sh $(DEBUG) $(VERBOSE) $(SANDBOX) $(INSTALL_DEPS) $(INSTALL_LINTERS) $(@)
|
|
||||||
|
|
||||||
.DEFAULT: init
|
|
||||||
init:
|
|
||||||
@./makem.sh $(DEBUG) $(VERBOSE) $(SANDBOX) $(INSTALL_DEPS) $(INSTALL_LINTERS)
|
|
||||||
|
108
README.md
108
README.md
@ -1,43 +1,35 @@
|
|||||||
[![License GPL 3][badge-license]](http://www.gnu.org/licenses/gpl-3.0.txt)
|
# Org-roam [![GitHub Release][release-badge]][release] [![MELPA][melpa-badge]][melpa] [![License GPL 3][gpl3-badge]][gpl3]
|
||||||
[](https://org-roam.readthedocs.io/en/latest/?badge=latest)
|
|
||||||
[](https://img.shields.io/github/v/release/jethrokuan/org-roam)
|
|
||||||
[](https://melpa.org/#/org-roam)
|
|
||||||
|
|
||||||
## Synopsis
|
<img src="https://www.orgroam.com/img/logo.svg" align="right" alt="Org-roam Logo" width="240">
|
||||||
|
|
||||||
Org-roam is a [Roam][roamresearch] replica built on top of the
|
Org-roam is a plain-text knowledge management system. It brings some of
|
||||||
all-powerful [Org-mode][org].
|
[Roam's][roamresearch] more powerful features into the [Org-mode][org]
|
||||||
|
ecosystem.
|
||||||
|
|
||||||
Org-roam is a solution for effortless non-hierarchical note-taking
|
Org-roam borrows principles from the Zettelkasten method, providing a solution
|
||||||
with Org-mode. With Org-roam, notes flow naturally, making note-taking
|
for non-hierarchical note-taking. It should also work as a plug-and-play
|
||||||
fun and easy. Org-roam should also work as a plug-and-play solution
|
solution for anyone already using Org-mode for their personal wiki.
|
||||||
for anyone already using Org-mode for their personal wiki.
|
|
||||||
|
|
||||||
Org-roam aims to implement the core features of Roam, leveraging the
|
- **Private and Secure**: Edit your personal wiki completely offline, entirely
|
||||||
mature ecosystem around Org-mode where possible. Eventually, we hope
|
in your control. Encrypt your notes with GPG. Take lasting notes in
|
||||||
to further introduce features enabled by the Emacs ecosystem.
|
plain-text.
|
||||||
|
- **Networked Thought**: Connect notes and thoughts together with ease using
|
||||||
|
backlinks. Discover surprising and previously unseen connections in your notes
|
||||||
|
with the built-in graph visualization.
|
||||||
|
- **Extensible and Powerful**: Leverage Emacs' fantastic text-editing interface,
|
||||||
|
and the mature Emacs and Org-mode ecosystem of packages.
|
||||||
|
- **Free and Open Source**: Org-roam is licensed under the GNU General Public
|
||||||
|
License version 3 or later.
|
||||||
|
|
||||||
[@technovangelist](https://github.com/technovangelist/) has produced a video
|
<p align="center">
|
||||||
describing Org-roam and the concepts behind it:
|
<img src="https://www.orgroam.com/img/screenshot.png" alt="Org-roam Screenshot" width="738">
|
||||||
|
</p>
|
||||||
[](http://www.youtube.com/watch?v=Lg61ocfxk3c "Making Connections in your Notes")
|
|
||||||
|
|
||||||
As of February 2020, it is in a very early stage of development.
|
|
||||||
|
|
||||||
Important links:
|
|
||||||
|
|
||||||
- **[Documentation][docs]**
|
- **[Documentation][docs]**
|
||||||
- **[Org-roam Slack][slack]**
|
- **[Discourse][discourse]**
|
||||||
|
- **[Slack][slack]**
|
||||||
## A Preview
|
- **[Frequently Asked Questions][faq]**
|
||||||
|
- **[Changelog](CHANGELOG.md)**
|
||||||
Here's a screenshot of `org-roam`. The `org-roam` buffer shows
|
|
||||||
backlinks for the active org buffer in the left window, as well as the
|
|
||||||
surrounding content in the backlink file. The database is built once,
|
|
||||||
and updated incrementally. The graph is generated from the link
|
|
||||||
structure, and can be used to navigate to the respective files.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
@ -47,34 +39,50 @@ You can install `org-roam` using `package.el`:
|
|||||||
M-x package-install RET org-roam RET
|
M-x package-install RET org-roam RET
|
||||||
```
|
```
|
||||||
|
|
||||||
Here's a sample configuration with using `use-package`:
|
Here's a sample configuration with `use-package`:
|
||||||
|
|
||||||
```emacs-lisp
|
```emacs-lisp
|
||||||
(use-package org-roam
|
(use-package org-roam
|
||||||
|
:ensure t
|
||||||
:hook
|
:hook
|
||||||
(after-init . org-roam-mode)
|
(after-init . org-roam-mode)
|
||||||
:custom
|
:custom
|
||||||
(org-roam-directory "/path/to/org-files/")
|
(org-roam-directory (file-truename "/path/to/org-files/"))
|
||||||
:bind (:map org-roam-mode-map
|
:bind (:map org-roam-mode-map
|
||||||
(("C-c n l" . org-roam)
|
(("C-c n l" . org-roam)
|
||||||
("C-c n f" . org-roam-find-file)
|
("C-c n f" . org-roam-find-file)
|
||||||
("C-c n g" . org-roam-show-graph))
|
("C-c n g" . org-roam-graph))
|
||||||
:map org-mode-map
|
:map org-mode-map
|
||||||
(("C-c n i" . org-roam-insert))))
|
(("C-c n i" . org-roam-insert))))
|
||||||
```
|
```
|
||||||
|
|
||||||
For more detailed installation and configuration instructions (including for
|
The `file-truename` function is only necessary when you use symbolic links
|
||||||
Doom and Spacemacs users), please see [the
|
inside `org-roam-directory`: Org-roam does not resolve symbolic links.
|
||||||
documentation](https://org-roam.readthedocs.io/en/master/installation/).
|
|
||||||
|
Org-roam requires sqlite to function. Org-roam optionally uses Graphviz for
|
||||||
|
graph-related functionality. It is recommended to install PCRE-enabled ripgrep
|
||||||
|
for better performance and extended functionality.
|
||||||
|
|
||||||
|
## Getting Help
|
||||||
|
|
||||||
|
Before creating a new topic/issue, please be mindful of our time and ensure that
|
||||||
|
it has not already been addressed on [GitHub][issues] or on
|
||||||
|
[Discourse][discourse].
|
||||||
|
|
||||||
|
- If you are new to Emacs and have problem setting up Org-roam, please ask your
|
||||||
|
question on [Slack, channel #how-do-i][slack].
|
||||||
|
- For quick questions, please ask them on [Slack, channel
|
||||||
|
#troubleshooting][slack].
|
||||||
|
- If something is not working as it should, or if you would like to suggest a
|
||||||
|
new feature, please [create a new issue][issues].
|
||||||
|
- If you have questions about your workflow with the slip-box method, please
|
||||||
|
find a relevant topic on [Discourse][discourse], or create a new one.
|
||||||
|
|
||||||
## Knowledge Bases using Org-roam
|
## Knowledge Bases using Org-roam
|
||||||
|
|
||||||
- [Jethro Kuan](https://braindump.jethro.dev/)
|
- [Jethro Kuan](https://braindump.jethro.dev/)
|
||||||
([Source](https://github.com/jethrokuan/braindump/tree/master/org))
|
([Source](https://github.com/jethrokuan/braindump/tree/master/org))
|
||||||
|
- [Alexey Shmalko](https://braindump.rasen.dev/)
|
||||||
## Changelog
|
|
||||||
|
|
||||||
A changelog is being maintained [here](CHANGELOG.md)
|
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
@ -85,10 +93,18 @@ request. Please also see [CONTRIBUTING.md](.github/CONTRIBUTING.md).
|
|||||||
## License
|
## License
|
||||||
|
|
||||||
Copyright © Jethro Kuan and contributors. Distributed under the GNU
|
Copyright © Jethro Kuan and contributors. Distributed under the GNU
|
||||||
General Public License, Version 3
|
General Public License, Version 3.
|
||||||
|
|
||||||
[roamresearch]: https://www.roamresearch.com/
|
[roamresearch]: https://www.roamresearch.com/
|
||||||
[org]: https://orgmode.org/
|
[org]: https://orgmode.org/
|
||||||
[badge-license]: https://img.shields.io/badge/license-GPL_3-green.svg
|
[gpl3-badge]: https://img.shields.io/badge/license-GPL_3-green.svg
|
||||||
[docs]: https://org-roam.readthedocs.io/
|
[gpl3]: http://www.gnu.org/licenses/gpl-3.0.txt
|
||||||
|
[melpa-badge]: https://melpa.org/packages/org-roam-badge.svg
|
||||||
|
[melpa]: https://melpa.org/#/org-roam
|
||||||
|
[release-badge]: https://img.shields.io/github/v/release/org-roam/org-roam
|
||||||
|
[release]: https://github.com/org-roam/org-roam/releases
|
||||||
|
[docs]: https://www.orgroam.com/manual.html
|
||||||
|
[discourse]: https://org-roam.discourse.group/
|
||||||
[slack]: https://join.slack.com/t/orgroam/shared_invite/zt-deoqamys-043YQ~s5Tay3iJ5QRI~Lxg
|
[slack]: https://join.slack.com/t/orgroam/shared_invite/zt-deoqamys-043YQ~s5Tay3iJ5QRI~Lxg
|
||||||
|
[issues]: https://github.com/org-roam/org-roam/issues
|
||||||
|
[faq]: https://www.orgroam.com/manual.html#FAQ
|
||||||
|
106
default.mk
Normal file
106
default.mk
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
TOP := $(dir $(lastword $(MAKEFILE_LIST)))
|
||||||
|
|
||||||
|
## User options ######################################################
|
||||||
|
#
|
||||||
|
# You can override these settings in "config.mk" or on the command
|
||||||
|
# line.
|
||||||
|
#
|
||||||
|
# You might also want to set LOAD_PATH. If you do, then it must
|
||||||
|
# contain "-L .".
|
||||||
|
#
|
||||||
|
# If you don't do so, then the default is set in the "Load-Path"
|
||||||
|
# section below. The default assumes that all dependencies are
|
||||||
|
# installed either at "../<DEPENDENCY>", or when using package.el
|
||||||
|
# at "ELPA_DIR/<DEPENDENCY>-<HIGHEST-VERSION>".
|
||||||
|
|
||||||
|
sharedir ?= $(HOME)/.local/share
|
||||||
|
lispdir ?= $(sharedir)/emacs/site-lisp/org-roam
|
||||||
|
infodir ?= $(sharedir)/info
|
||||||
|
docdir ?= $(sharedir)/doc/org-roam
|
||||||
|
statsdir ?= $(TOP)/doc/stats
|
||||||
|
|
||||||
|
CP ?= install -p -m 644
|
||||||
|
MKDIR ?= install -p -m 755 -d
|
||||||
|
RMDIR ?= rm -rf
|
||||||
|
TAR ?= tar
|
||||||
|
SED ?= sed
|
||||||
|
|
||||||
|
EMACSBIN ?= emacs
|
||||||
|
BATCH = $(EMACSBIN) -Q --batch $(LOAD_PATH)
|
||||||
|
|
||||||
|
INSTALL_INFO ?= $(shell command -v ginstall-info || printf install-info)
|
||||||
|
MAKEINFO ?= makeinfo
|
||||||
|
MANUAL_HTML_ARGS ?= --css-ref /assets/page.css
|
||||||
|
|
||||||
|
## Files #############################################################
|
||||||
|
|
||||||
|
PKG = org-roam
|
||||||
|
PACKAGES = org-roam
|
||||||
|
|
||||||
|
TEXIPAGES = $(addsuffix .texi,$(PACKAGES))
|
||||||
|
INFOPAGES = $(addsuffix .info,$(PACKAGES))
|
||||||
|
HTMLFILES = $(addsuffix .html,$(PACKAGES))
|
||||||
|
HTMLDIRS = $(PACKAGES)
|
||||||
|
PDFFILES = $(addsuffix .pdf,$(PACKAGES))
|
||||||
|
EPUBFILES = $(addsuffix .epub,$(PACKAGES))
|
||||||
|
|
||||||
|
ELS = org-roam-buffer.el
|
||||||
|
ELS += org-roam-capture.el
|
||||||
|
ELS += org-roam-compat.el
|
||||||
|
ELS += org-roam-completion.el
|
||||||
|
ELS += org-roam-dailies.el
|
||||||
|
ELS += org-roam-db.el
|
||||||
|
ELS += org-roam.el
|
||||||
|
ELS += org-roam-graph.el
|
||||||
|
ELS += org-roam-macs.el
|
||||||
|
ELS += org-roam-protocol.el
|
||||||
|
ELCS = $(ELS:.el=.elc)
|
||||||
|
ELMS = org-roam.el $(filter-out $(addsuffix .el,$(PACKAGES)),$(ELS))
|
||||||
|
ELGS = org-roam-autoloads.el org-roam-version.el
|
||||||
|
|
||||||
|
## Versions ##########################################################
|
||||||
|
|
||||||
|
VERSION ?= $(shell test -e $(TOP).git && git describe --tags --abbrev=0 | cut -c2-)
|
||||||
|
|
||||||
|
EMACS_VERSION = 26.1
|
||||||
|
|
||||||
|
EMACSOLD := $(shell $(BATCH) --eval \
|
||||||
|
"(and (version< emacs-version \"$(EMACS_VERSION)\") (princ \"true\"))")
|
||||||
|
ifeq "$(EMACSOLD)" "true"
|
||||||
|
$(error At least version $(EMACS_VERSION) of Emacs is required)
|
||||||
|
endif
|
||||||
|
|
||||||
|
## Load-Path #########################################################
|
||||||
|
|
||||||
|
ifndef LOAD_PATH
|
||||||
|
|
||||||
|
ELPA_DIR ?= $(HOME)/.emacs.d/elpa
|
||||||
|
|
||||||
|
SYSTYPE := $(shell $(EMACSBIN) -Q --batch --eval "(princ system-type)")
|
||||||
|
ifeq ($(SYSTYPE), windows-nt)
|
||||||
|
CYGPATH := $(shell cygpath --version 2>/dev/null)
|
||||||
|
endif
|
||||||
|
|
||||||
|
LOAD_PATH = -L $(TOP)
|
||||||
|
|
||||||
|
# When making changes here, then don't forget to adjust "Makefile",
|
||||||
|
# ".travis.yml", ".github/ISSUE_TEMPLATE/bug_report.md",
|
||||||
|
# `magit-emacs-Q-command' and the "Installing from the Git Repository"
|
||||||
|
# info node accordingly. Also don't forget to "rgrep \b<pkg>\b".
|
||||||
|
|
||||||
|
endif # ifndef LOAD_PATH
|
||||||
|
|
||||||
|
ifndef ORG_LOAD_PATH
|
||||||
|
ORG_LOAD_PATH = $(LOAD_PATH)
|
||||||
|
ORG_LOAD_PATH += -L $(TOP)../ox-texinfo-plus
|
||||||
|
ORG_LOAD_PATH += -L $(TOP)../org-mode/contrib/lisp
|
||||||
|
ORG_LOAD_PATH += -L $(TOP)../org-mode/lisp
|
||||||
|
endif
|
||||||
|
|
||||||
|
## Publish ###########################################################
|
||||||
|
|
||||||
|
PUBLISH_TARGETS ?= html html-dir pdf epub
|
||||||
|
|
||||||
|
DOCBOOK_XSL ?= /usr/share/xml/docbook/stylesheet/docbook-xsl/epub/docbook.xsl
|
||||||
|
|
||||||
|
EPUBTRASH = epub.xml META-INF OEBPS
|
0
doc/.nojekyll
Normal file
0
doc/.nojekyll
Normal file
37
doc/AUTHORS.md
Normal file
37
doc/AUTHORS.md
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
Authors
|
||||||
|
=======
|
||||||
|
|
||||||
|
The following people have contributed to Org-Roam.
|
||||||
|
|
||||||
|
Names below are sorted alphabetically.
|
||||||
|
|
||||||
|
Author
|
||||||
|
------
|
||||||
|
|
||||||
|
- Jethro Kuan <jethrokuan95@gmail.com>
|
||||||
|
|
||||||
|
Maintainers
|
||||||
|
----------
|
||||||
|
|
||||||
|
- Jethro Kuan <jethrokuan95@gmail.com>
|
||||||
|
- Leo Vivier <leo.vivier+dev@gmail.com>
|
||||||
|
|
||||||
|
Contributors
|
||||||
|
------------
|
||||||
|
|
||||||
|
- Alexey Shmalko <rasen.dubi@gmail.com>
|
||||||
|
- James Ravn <james@r-vn.org>
|
||||||
|
- Jethro Kuan <jethrokuan95@gmail.com>
|
||||||
|
- Johann Klähn <johann@jklaehn.de>
|
||||||
|
- Josh English <josh@joshenglish.com>
|
||||||
|
- Jürgen Hötzel <juergen@archlinux.org>
|
||||||
|
- Langston Barrett <langston.barrett@gmail.com>
|
||||||
|
- Leo Vivier <leo.vivier+dev@gmail.com>
|
||||||
|
- Michael Glaesemann <grzm@seespotcode.net>
|
||||||
|
- Michael Herold <github@michaeljherold.com>
|
||||||
|
- Noboru <noboru.ota@gmail.com>
|
||||||
|
- N V <44036031+progfolio@users.noreply.github.com>
|
||||||
|
- Rafael Accácio Nogueira <raccacio@poli.ufrj.br>
|
||||||
|
- Roland Coeurjoly <rolandcoeurjoly@gmail.com>
|
||||||
|
- Sayan <dit7ya@users.noreply.github.com>
|
||||||
|
- Tim Quelch <tim@tquelch.com>
|
127
doc/Makefile
Normal file
127
doc/Makefile
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
-include ../config.mk
|
||||||
|
include ../default.mk
|
||||||
|
|
||||||
|
###################################################################
|
||||||
|
MANUAL_HTML_ARGS = --css-ref assets/page.css
|
||||||
|
|
||||||
|
.PHONY: texi install clean AUTHORS.md stats
|
||||||
|
|
||||||
|
all: info
|
||||||
|
|
||||||
|
## Build #############################################################
|
||||||
|
|
||||||
|
info: $(INFOPAGES) dir
|
||||||
|
html: $(HTMLFILES)
|
||||||
|
pdf: $(PDFFILES)
|
||||||
|
epub: $(EPUBFILES)
|
||||||
|
|
||||||
|
%.info: %.texi
|
||||||
|
@printf "Generating $@\n"
|
||||||
|
@$(MAKEINFO) --no-split $< -o $@
|
||||||
|
|
||||||
|
dir: org-roam.info
|
||||||
|
@printf "Generating dir\n"
|
||||||
|
@echo $^ | xargs -n 1 $(INSTALL_INFO) --dir=$@
|
||||||
|
|
||||||
|
%.html: %.texi
|
||||||
|
@printf "Generating $@\n"
|
||||||
|
@$(MAKEINFO) --html --no-split $(MANUAL_HTML_ARGS) $<
|
||||||
|
|
||||||
|
html-dir:
|
||||||
|
@$(MAKEINFO) --html --no-split $(MANUAL_HTML_ARGS) org-roam.texi
|
||||||
|
mv org-roam.html manual.html
|
||||||
|
|
||||||
|
%.pdf: %.texi
|
||||||
|
@printf "Generating $@\n"
|
||||||
|
@texi2pdf --clean $< > /dev/null
|
||||||
|
|
||||||
|
%.epub: %.texi
|
||||||
|
@printf "Generating $@\n"
|
||||||
|
@$(MAKEINFO) --docbook $< -o epub.xml
|
||||||
|
@xsltproc $(DOCBOOK_XSL) epub.xml 2> /dev/null
|
||||||
|
@echo "application/epub+zip" > mimetype
|
||||||
|
@zip -X --quiet --recurse-paths -0 $@ mimetype
|
||||||
|
@zip -X --quiet --recurse-paths -9 --no-dir-entries $@ META-INF OEBPS
|
||||||
|
@$(RMDIR) $(EPUBTRASH)
|
||||||
|
|
||||||
|
## Install ###########################################################
|
||||||
|
|
||||||
|
install: install-info install-docs
|
||||||
|
|
||||||
|
install-docs: install-info
|
||||||
|
@$(MKDIR) $(DESTDIR)$(docdir)
|
||||||
|
$(CP) AUTHORS.md $(DESTDIR)$(docdir)
|
||||||
|
|
||||||
|
install-info: info
|
||||||
|
@$(MKDIR) $(DESTDIR)$(infodir)
|
||||||
|
$(CP) $(INFOPAGES) $(DESTDIR)$(infodir)
|
||||||
|
|
||||||
|
## Clean #############################################################
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@printf "Cleaning doc/*...\n"
|
||||||
|
@$(RMDIR) dir $(INFOPAGES) $(HTMLFILES) $(HTMLDIRS) $(PDFFILES)
|
||||||
|
@$(RMDIR) $(EPUBFILES) $(EPUBTRASH)
|
||||||
|
|
||||||
|
## Release management ################################################
|
||||||
|
|
||||||
|
ORG_ARGS = --batch -Q $(ORG_LOAD_PATH)
|
||||||
|
ORG_ARGS += -l ox-extra -l ox-texinfo+
|
||||||
|
ORG_ARGS += --eval "(or (require 'org-man nil t) (require 'ol-man))"
|
||||||
|
ORG_EVAL = --eval "(ox-extras-activate '(ignore-headlines))"
|
||||||
|
ORG_EVAL += --eval "(setq indent-tabs-mode nil)"
|
||||||
|
ORG_EVAL += --eval "(setq org-src-preserve-indentation nil)"
|
||||||
|
ORG_EVAL += --funcall org-texinfo-export-to-texinfo
|
||||||
|
|
||||||
|
# This target first bumps version strings in the Org source. The
|
||||||
|
# necessary tools might be missing so other targets do not depend
|
||||||
|
# on this target and it has to be run explicitly when appropriate.
|
||||||
|
#
|
||||||
|
# AMEND=t make texi Update manual to be amended to HEAD.
|
||||||
|
# VERSION=N make texi Update manual for release.
|
||||||
|
#
|
||||||
|
texi:
|
||||||
|
@$(EMACSBIN) $(ORG_ARGS) $(PKG).org $(ORG_EVAL)
|
||||||
|
@printf "\n" >> $(PKG).texi
|
||||||
|
@rm -f $(PKG).texi~
|
||||||
|
|
||||||
|
stats:
|
||||||
|
@printf "Generating statistics\n"
|
||||||
|
@gitstats -c style=/assets/stats.css -c max_authors=999 $(TOP) $(statsdir)
|
||||||
|
|
||||||
|
authors: AUTHORS.md
|
||||||
|
|
||||||
|
AUTHORS.md:
|
||||||
|
@printf "Generating AUTHORS.md..."
|
||||||
|
@test -e $(TOP).git \
|
||||||
|
&& (printf "$$AUTHORS_HEADER\n" > $@ \
|
||||||
|
&& git log --pretty=format:'- %aN <%aE>' | sort -u >> $@ \
|
||||||
|
&& printf "done\n" ; ) \
|
||||||
|
|| printf "FAILED (non-fatal)\n"
|
||||||
|
|
||||||
|
# Templates ##########################################################
|
||||||
|
|
||||||
|
define AUTHORS_HEADER
|
||||||
|
Authors
|
||||||
|
=======
|
||||||
|
|
||||||
|
The following people have contributed to Org-Roam.
|
||||||
|
|
||||||
|
Names below are sorted alphabetically.
|
||||||
|
|
||||||
|
Author
|
||||||
|
------
|
||||||
|
|
||||||
|
- Jethro Kuan <jethrokuan95@gmail.com>
|
||||||
|
|
||||||
|
Maintainers
|
||||||
|
----------
|
||||||
|
|
||||||
|
- Jethro Kuan <jethrokuan95@gmail.com>
|
||||||
|
- Leo Vivier <leo.vivier+dev@gmail.com>
|
||||||
|
|
||||||
|
Contributors
|
||||||
|
------------
|
||||||
|
|
||||||
|
endef
|
||||||
|
export AUTHORS_HEADER
|
@ -1,41 +0,0 @@
|
|||||||
The bulk of Org-roam's functionality is built on top of vanilla
|
|
||||||
Org-mode. However, to support additional functionality, Org-roam adds
|
|
||||||
several Org-roam-specific keywords. These functionality are not
|
|
||||||
crucial to effective use of Org-roam.
|
|
||||||
|
|
||||||
## File Aliases
|
|
||||||
|
|
||||||
Suppose you want a note to be referred to by different names (e.g.
|
|
||||||
"World War 2", "WWII"). You may specify such aliases using the
|
|
||||||
`#+ROAM_ALIAS` attribute:
|
|
||||||
|
|
||||||
```org
|
|
||||||
#+TITLE: World War 2
|
|
||||||
#+ROAM_ALIAS: "WWII" "World War II"
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## File Refs
|
|
||||||
|
|
||||||
Refs are unique identifiers for files. Each note can only have 1 ref.
|
|
||||||
For example, a note for a website may contain a ref:
|
|
||||||
|
|
||||||
```org
|
|
||||||
#+TITLE: Google
|
|
||||||
#+ROAM_KEY: https://www.google.com/
|
|
||||||
```
|
|
||||||
|
|
||||||
These keys come in useful for when taking website notes, using the
|
|
||||||
`roam-ref` protocol (see [Roam Protocol](roam_protocol.md)).
|
|
||||||
|
|
||||||
Alternatively, add a ref for notes for a specific paper, using its
|
|
||||||
[org-ref](https://github.com/jkitchin/org-ref) citation key:
|
|
||||||
|
|
||||||
```org
|
|
||||||
#+TITLE: Neural Ordinary Differential Equations
|
|
||||||
#+ROAM_KEY: cite:chen18_neural_ordin_differ_equat
|
|
||||||
```
|
|
||||||
|
|
||||||
The backlinks buffer will show any cites of this key: e.g.
|
|
||||||
|
|
||||||

|
|
68
doc/assets/page.css
Normal file
68
doc/assets/page.css
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
:root {
|
||||||
|
--border: #526980;
|
||||||
|
--code: #007;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
margin: 5ex 10ex;
|
||||||
|
max-width: 80ex;
|
||||||
|
line-height: 1.5;
|
||||||
|
font-family: sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1, h2, h3 {
|
||||||
|
font-weight: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
pre, code {
|
||||||
|
font-family: x, monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
pre {
|
||||||
|
padding: 1ex;
|
||||||
|
background: #eee;
|
||||||
|
border: solid 1px #ddd;
|
||||||
|
min-width: 0;
|
||||||
|
font-size: 80%;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
code {
|
||||||
|
color: var(--code);
|
||||||
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
border-collapse: collapse;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
pre.menu-comment {
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
font-family: sans-serif;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
font-size: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
thead {
|
||||||
|
border-bottom: 1px solid var(--border);
|
||||||
|
}
|
||||||
|
|
||||||
|
tfoot {
|
||||||
|
border-top: 1px solid var(--border);
|
||||||
|
}
|
||||||
|
|
||||||
|
blockquote {
|
||||||
|
margin-left: 1rem;
|
||||||
|
font-style: italic;
|
||||||
|
font-family: serif;
|
||||||
|
border-left: 3px solid;
|
||||||
|
border-left-color: currentcolor;
|
||||||
|
border-color: var(--text-color);
|
||||||
|
padding-left: 1em;
|
||||||
|
}
|
@ -1,11 +0,0 @@
|
|||||||
---
|
|
||||||
title: "Comparing Org-roam With Other Packages"
|
|
||||||
metaTitle: "Comparing Org-roam With Other Packages"
|
|
||||||
metaDescription: "Comparing Org-roam With Other Packages"
|
|
||||||
---
|
|
||||||
|
|
||||||
# Org-brain
|
|
||||||
|
|
||||||
# Zetteldeft
|
|
||||||
|
|
||||||
# Org-zettelkasten
|
|
@ -1,142 +0,0 @@
|
|||||||
The number of configuration options is deliberately kept small, to
|
|
||||||
keep the Org-roam codebase manageable. However, we attempt to
|
|
||||||
accommodate as many usage styles as possible.
|
|
||||||
|
|
||||||
All of Org-roam's customization options can be viewed via `M-x
|
|
||||||
customize-group org-roam`.
|
|
||||||
|
|
||||||
## Setting the Org-roam Directory
|
|
||||||
|
|
||||||
Set `org-roam-directory` to the folder containing all your Org files:
|
|
||||||
|
|
||||||
```emacs-lisp
|
|
||||||
(setq org-roam-directory "/path/to/org/")
|
|
||||||
```
|
|
||||||
|
|
||||||
Every Org file, at any level of nesting, within `/path/to/org/` is
|
|
||||||
considered part of the Org-roam ecosystem.
|
|
||||||
|
|
||||||
### Having More Than One Org-roam Directory
|
|
||||||
|
|
||||||
Emacs supports directory-local variables, allowing the value of
|
|
||||||
`org-roam-directory` to be different in different directories. It does
|
|
||||||
this by checking for a file named `.dir-locals.el`.
|
|
||||||
|
|
||||||
To add support for multiple directories, override the
|
|
||||||
`org-roam-directory` variable using directory-local variables. This is
|
|
||||||
what `.dir-locals.el` may contain:
|
|
||||||
|
|
||||||
```emacs-lisp
|
|
||||||
((nil . ((org-roam-directory . "/path/to/here/"))))
|
|
||||||
```
|
|
||||||
|
|
||||||
All files within that directory will be treated as their own separate
|
|
||||||
set of Org-roam files. Remember to run `org-roam-db-build-cache` from a
|
|
||||||
file within that directory, at least once.
|
|
||||||
|
|
||||||
## Org-roam Buffer
|
|
||||||
|
|
||||||
The Org-roam buffer defaults to popping up from the right. You may
|
|
||||||
choose to set it to pop up from the left with `(setq
|
|
||||||
org-roam-buffer-position 'left)`.
|
|
||||||
|
|
||||||
The Org-roam buffer name can also be renamed: e.g. `(setq
|
|
||||||
org-roam-buffer "*my-buffer-name*")`.
|
|
||||||
|
|
||||||
The Org-roam buffer width is adjustable via `org-roam-buffer-width`.
|
|
||||||
The value of `org-roam-buffer-width` set as a percentage of the total
|
|
||||||
frame width. For example:
|
|
||||||
|
|
||||||
```emacs-lisp
|
|
||||||
(setq org-roam-buffer-width 0.4)
|
|
||||||
```
|
|
||||||
|
|
||||||
Will result in the Org-roam buffer taking up 40% of the screen width.
|
|
||||||
|
|
||||||
You can change backlinks appearance in the buffer by customizing
|
|
||||||
`org-roam-backlink` face (`M-x customize-face org-roam-backlink`).
|
|
||||||
|
|
||||||
## Org-roam Links
|
|
||||||
|
|
||||||
By default, links are inserted with the title as the link description.
|
|
||||||
This can make them hard to distinguish from external links. You may
|
|
||||||
choose add special indicators for Org-roam links by tweaking
|
|
||||||
`org-roam-link-title-format`, for example:
|
|
||||||
|
|
||||||
```emacs-lisp
|
|
||||||
(setq org-roam-link-title-format "R:%s")
|
|
||||||
```
|
|
||||||
|
|
||||||
If your version of Org is at least `9.2`, you may also choose to
|
|
||||||
simply style the link differently, by customizing `org-roam-link` face
|
|
||||||
(`M-x customize-face org-roam-link`).
|
|
||||||
|
|
||||||
## Org-roam Files
|
|
||||||
|
|
||||||
Org-roam files are created and prefilled using Org-roam's templating
|
|
||||||
system. The templating system is customizable, and the system is
|
|
||||||
described in detail in the [Org-roam Template](templating.md) page.
|
|
||||||
|
|
||||||
### Encryption
|
|
||||||
|
|
||||||
Encryption (via GPG) can be enabled for all new files by setting
|
|
||||||
`org-roam-encrypt-files` to `t`. When enabled, new files are created
|
|
||||||
with the `.org.gpg` extension and decryption are handled automatically
|
|
||||||
by EasyPG.
|
|
||||||
|
|
||||||
Note that Emacs will prompt for a password for encrypted files during
|
|
||||||
cache updates if it requires reading the encrypted file. To reduce the
|
|
||||||
number of password prompts, you may wish to cache the password.
|
|
||||||
|
|
||||||
## Org-roam Graph Viewer
|
|
||||||
|
|
||||||
Org-roam generates an SVG image using
|
|
||||||
[Graphviz](https://graphviz.org/). To setup graph navigation, see the
|
|
||||||
[Graph Setup](graph_setup.md) page.
|
|
||||||
|
|
||||||
Org-roam tries its best to locate the Graphviz executable from your
|
|
||||||
`PATH`, but if it fails to do so, you may set it manually:
|
|
||||||
|
|
||||||
```
|
|
||||||
(setq org-roam-graph-executable "/path/to/dot")
|
|
||||||
```
|
|
||||||
|
|
||||||
You may also choose to use `neato` in place of `dot`, which generates a more compact graph layout.
|
|
||||||
|
|
||||||
```
|
|
||||||
(setq org-roam-graph-executable "/path/to/neato")
|
|
||||||
(setq org-roam-graph-extra-config '(("overlap" . "false")))
|
|
||||||
```
|
|
||||||
|
|
||||||
Org-roam also attempts to use Firefox (located on `PATH`) to view the
|
|
||||||
SVG, you may choose to set it to any compatible program:
|
|
||||||
|
|
||||||
```
|
|
||||||
(setq org-roam-graph-viewer "/path/to/image-viewer")
|
|
||||||
```
|
|
||||||
|
|
||||||
### Excluding Nodes and Edges
|
|
||||||
One may want to exclude certain files to declutter the graph. You can do so by setting `org-roam-graph-exclude-matcher`.
|
|
||||||
|
|
||||||
```
|
|
||||||
(setq org-roam-graph-exclude-matcher '("private" "dailies"))
|
|
||||||
```
|
|
||||||
|
|
||||||
This setting excludes all files whose path contain "private" or "dailies".
|
|
||||||
|
|
||||||
## Org-roam Completion System
|
|
||||||
|
|
||||||
Org-roam offers completion when choosing note titles etc.
|
|
||||||
The completion system is configurable. The default setting,
|
|
||||||
|
|
||||||
```
|
|
||||||
(setq org-roam-completion-system 'default)
|
|
||||||
```
|
|
||||||
|
|
||||||
uses Emacs' standard `completing-read`. If you prefer [Helm](https://emacs-helm.github.io/helm/), use
|
|
||||||
|
|
||||||
```
|
|
||||||
(setq org-roam-completion-system 'helm)
|
|
||||||
```
|
|
||||||
|
|
||||||
Other options included `'ido`, and `'ivy'`.
|
|
85
doc/css/styles.css
Normal file
85
doc/css/styles.css
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
body {
|
||||||
|
margin: 20px;
|
||||||
|
background: #303030;
|
||||||
|
color: #f5f5f5;
|
||||||
|
font-size: 1.6rem;
|
||||||
|
font-weight: 300;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container {
|
||||||
|
max-width: 800px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav {
|
||||||
|
margin-top: 5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-item a {
|
||||||
|
/* color: #797979; */
|
||||||
|
color: #bebebe;
|
||||||
|
text-decoration: none;
|
||||||
|
font-family: "Consolas", "Monaco", "Menlo", monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-item a:hover {
|
||||||
|
cursor: pointer;
|
||||||
|
/* color: #4d4a4a; */
|
||||||
|
color: #dcdcdc;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero {
|
||||||
|
color: #f5f5f5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero div {
|
||||||
|
margin-bottom: 5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero h3 {
|
||||||
|
/* font-family: "Edelsans", sans-serif; */
|
||||||
|
font-size: 5rem;
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero h5 {
|
||||||
|
margin-top: 1rem;
|
||||||
|
margin-bottom: 0;
|
||||||
|
/* font-weight: 200; */
|
||||||
|
font-weight: 250;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid-demo-col {
|
||||||
|
background: #e4e4e4;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: #cd86ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover {
|
||||||
|
color: #dbb9f3;
|
||||||
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer-links {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
color: #f5f5f5;
|
||||||
|
text-decoration: none;
|
||||||
|
font-weight: 250;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header {
|
||||||
|
font-weight: 200;
|
||||||
|
}
|
||||||
|
|
||||||
|
#footer {
|
||||||
|
margin-bottom: 3rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
#footer h5 {
|
||||||
|
margin-bottom: 1.5rem;
|
||||||
|
}
|
134
doc/ecosystem.md
134
doc/ecosystem.md
@ -1,134 +0,0 @@
|
|||||||
A number of packages work well combined with Org-Roam:
|
|
||||||
|
|
||||||
## Deft
|
|
||||||
|
|
||||||
[Deft][deft] provides a nice interface for browsing and filtering
|
|
||||||
org-roam notes.
|
|
||||||
|
|
||||||
```emacs-lisp
|
|
||||||
(use-package deft
|
|
||||||
:after org
|
|
||||||
:bind
|
|
||||||
("C-c n d" . deft)
|
|
||||||
:custom
|
|
||||||
(deft-recursive t)
|
|
||||||
(deft-use-filter-string-for-filename t)
|
|
||||||
(deft-default-extension "org")
|
|
||||||
(deft-directory "/path/to/org-roam-files/"))
|
|
||||||
```
|
|
||||||
|
|
||||||
If the title of the Org file is not the first line, you might not get
|
|
||||||
nice titles. You may choose to patch this to use `org-roam`'s
|
|
||||||
functionality. Here I'm using [el-patch](https://github.com/raxod502/el-patch):
|
|
||||||
|
|
||||||
```emacs-lisp
|
|
||||||
(use-package el-patch
|
|
||||||
:straight (:host github
|
|
||||||
:repo "raxod502/el-patch"
|
|
||||||
:branch "develop"))
|
|
||||||
|
|
||||||
(eval-when-compile
|
|
||||||
(require 'el-patch))
|
|
||||||
|
|
||||||
(use-package deft
|
|
||||||
;; same as above...
|
|
||||||
:config/el-patch
|
|
||||||
(defun deft-parse-title (file contents)
|
|
||||||
"Parse the given FILE and CONTENTS and determine the title.
|
|
||||||
If `deft-use-filename-as-title' is nil, the title is taken to
|
|
||||||
be the first non-empty line of the FILE. Else the base name of the FILE is
|
|
||||||
used as title."
|
|
||||||
(el-patch-swap (if deft-use-filename-as-title
|
|
||||||
(deft-base-filename file)
|
|
||||||
(let ((begin (string-match "^.+$" contents)))
|
|
||||||
(if begin
|
|
||||||
(funcall deft-parse-title-function
|
|
||||||
(substring contents begin (match-end 0))))))
|
|
||||||
(org-roam--get-title-or-slug file))))
|
|
||||||
```
|
|
||||||
|
|
||||||
The Deft interface can slow down quickly when the number of files get
|
|
||||||
huge. [Notdeft][notdeft] is a fork of Deft that uses an external
|
|
||||||
search engine and indexer.
|
|
||||||
|
|
||||||
## Org-journal
|
|
||||||
|
|
||||||
[Org-journal](https://github.com/bastibe/org-journal) is a more powerful
|
|
||||||
alternative to the simple function `org-roam-dailies-today`. It provides better
|
|
||||||
journaling capabilities, and a nice calendar interface to see all dated entries.
|
|
||||||
|
|
||||||
```emacs-lisp
|
|
||||||
(use-package org-journal
|
|
||||||
:bind
|
|
||||||
("C-c n j" . org-journal-new-entry)
|
|
||||||
:custom
|
|
||||||
(org-journal-date-prefix "#+TITLE: ")
|
|
||||||
(org-journal-file-format "%Y-%m-%d.org")
|
|
||||||
(org-journal-dir "/path/to/org-roam-files/")
|
|
||||||
(org-journal-date-format "%A, %d %B %Y"))
|
|
||||||
```
|
|
||||||
|
|
||||||
## Note-taking Add-ons
|
|
||||||
|
|
||||||
These are some plugins that make note-taking in Org-mode more
|
|
||||||
enjoyable.
|
|
||||||
|
|
||||||
### Org-download
|
|
||||||
|
|
||||||
[Org-download][org-download] lets you screenshot and yank images from
|
|
||||||
the web into your notes:
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
```emacs-lisp
|
|
||||||
(use-package org-download
|
|
||||||
:after org
|
|
||||||
:bind
|
|
||||||
(:map org-mode-map
|
|
||||||
(("s-Y" . org-download-screenshot)
|
|
||||||
("s-y" . org-download-yank))))
|
|
||||||
```
|
|
||||||
|
|
||||||
### mathpix.el
|
|
||||||
|
|
||||||
[mathpix.el][mathpix-el] uses [Mathpix's](https://mathpix.com/) API to convert clips into
|
|
||||||
latex equations:
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
```emacs-lisp
|
|
||||||
(use-package mathpix.el
|
|
||||||
:straight (:host github :repo "jethrokuan/mathpix.el")
|
|
||||||
:custom ((mathpix-app-id "app-id")
|
|
||||||
(mathpix-app-key "app-key"))
|
|
||||||
:bind
|
|
||||||
("C-x m" . mathpix-screenshot))
|
|
||||||
```
|
|
||||||
|
|
||||||
### Org-noter / Interleave
|
|
||||||
|
|
||||||
[Org-noter][org-noter] and [Interleave][interleave] are both projects
|
|
||||||
that allow synchronised annotation of documents (PDF, EPUB etc.)
|
|
||||||
within Org-mode.
|
|
||||||
|
|
||||||
### Org-ref
|
|
||||||
|
|
||||||
[Org-ref][org-ref] does citation and bibliography management in
|
|
||||||
Org-mode, and a great tool for scientific notes.
|
|
||||||
|
|
||||||
### Spaced Repetition
|
|
||||||
|
|
||||||
[Org-fc][org-fc] is a spaced repetition system that scales well with a
|
|
||||||
large number of files. Other alternatives include
|
|
||||||
[org-drill][org-drill], and [pamparam][pamparam].
|
|
||||||
|
|
||||||
[deft]: https://jblevins.org/projects/deft/
|
|
||||||
[notdeft]: https://github.com/hasu/notdeft
|
|
||||||
[org-download]: https://github.com/abo-abo/org-download
|
|
||||||
[mathpix-el]: https://github.com/jethrokuan/mathpix.el
|
|
||||||
[org-noter]: https://github.com/weirdNox/org-noter
|
|
||||||
[interleave]: https://github.com/rudolfochrist/interleave
|
|
||||||
[org-ref]: https://github.com/jkitchin/org-ref
|
|
||||||
[org-fc]: https://github.com/l3kn/org-fc/
|
|
||||||
[org-drill]: https://orgmode.org/worg/org-contrib/org-drill.html
|
|
||||||
[pamparam]: https://github.com/abo-abo/pamparam
|
|
15
doc/htmlxref.cnf
Normal file
15
doc/htmlxref.cnf
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# https://www.gnu.org/software/texinfo/manual/texinfo/html_node/HTML-Xref-Configuration.html
|
||||||
|
|
||||||
|
EMACS = https://www.gnu.org/software/emacs/manual
|
||||||
|
|
||||||
|
auth mono ${EMACS}/html_mono/auth.html
|
||||||
|
auth node ${EMACS}/html_node/auth/
|
||||||
|
|
||||||
|
ediff mono ${EMACS}/html_mono/ediff.html
|
||||||
|
ediff node ${EMACS}/html_node/ediff/
|
||||||
|
|
||||||
|
elisp mono ${EMACS}/html_mono/elisp.html
|
||||||
|
elisp node ${EMACS}/html_node/elisp/
|
||||||
|
|
||||||
|
emacs mono ${EMACS}/html_mono/emacs.html
|
||||||
|
emacs node ${EMACS}/html_node/emacs/
|
BIN
doc/images/org-roam-bibtex.gif
Normal file
BIN
doc/images/org-roam-bibtex.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 MiB |
BIN
doc/img/logo.png
Normal file
BIN
doc/img/logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 85 KiB |
572
doc/img/logo.svg
Normal file
572
doc/img/logo.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 42 KiB |
BIN
doc/img/screenshot.png
Normal file
BIN
doc/img/screenshot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 272 KiB |
168
doc/index.html
Normal file
168
doc/index.html
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<meta name="description" content="An Effortless PKM System." />
|
||||||
|
<meta name="author" content="Org-roam Contributors" />
|
||||||
|
|
||||||
|
<title>Org-roam</title>
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="https://unpkg.com/wingcss" />
|
||||||
|
<link rel="stylesheet" type="text/css" href="./css/styles.css" />
|
||||||
|
|
||||||
|
<script src="https://code.iconify.design/1/1.0.6/iconify.min.js"></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<section class="hero container center text-center">
|
||||||
|
<div>
|
||||||
|
<img src="./img/logo.png" alt="Org-roam Logo" height="200" />
|
||||||
|
<h3>Org-roam</h3>
|
||||||
|
<h5>A plain-text personal knowledge management system.</h5>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="container center">
|
||||||
|
<div>
|
||||||
|
<img src="./img/screenshot.png" alt="screenshot" />
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section id="features" class="container center">
|
||||||
|
<div>
|
||||||
|
<h3 class="header">FEATURES</h3>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<h5 class="left">
|
||||||
|
<iconify-icon data-icon="fxemoji:lock"></iconify-icon>
|
||||||
|
Private and Secure
|
||||||
|
</h5>
|
||||||
|
<p class="content">
|
||||||
|
Edit your personal wiki completely offline, entirely in your
|
||||||
|
control. Encrypt your notes with GPG. Take lasting notes in
|
||||||
|
plain-text.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<h5 class="left">
|
||||||
|
<iconify-icon data-icon="flat-color-icons:link"></iconify-icon>
|
||||||
|
Make Connections
|
||||||
|
</h5>
|
||||||
|
<p class="content">
|
||||||
|
Connect notes and thoughts together with ease using backlinks.
|
||||||
|
Discover surprising and previously unseen connections in your
|
||||||
|
notes with the built-in graph visualization.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<h5 class="left">
|
||||||
|
<iconify-icon data-icon="twemoji:puzzle-piece"></iconify-icon>
|
||||||
|
Extensible and Powerful
|
||||||
|
</h5>
|
||||||
|
<p class="content">
|
||||||
|
Leverage Emacs' fantastic text-editing interface, and the mature
|
||||||
|
Emacs and Org-mode ecosystem of packages.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<h5 class="left">
|
||||||
|
<iconify-icon data-icon="logos:git-icon"></iconify-icon>
|
||||||
|
Free and Open Source
|
||||||
|
</h5>
|
||||||
|
<p class="content">
|
||||||
|
Org-roam is licensed under the GNU General Public License version
|
||||||
|
3 or later. You are free to extend its functionality and
|
||||||
|
contribute back. Find
|
||||||
|
us <a href="https://github.com/org-roam/org-roam">here</a>.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section id="links" class="container">
|
||||||
|
<div>
|
||||||
|
<h3 class="header">LINKS</h3> New to Emacs and Org-mode, and trying to
|
||||||
|
find your way around? Org-roam has an inclusive community of users
|
||||||
|
passionate about Personal Knowledge Management -- we're happy to help!
|
||||||
|
You can find us on Discourse and Slack.
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>Read our documentation within Emacs, or on the <a href="https://www.orgroam.com/manual.html">Online Manual</a></li>
|
||||||
|
<li>Participate in our forum discussions on <a href="https://org-roam.discourse.group">Discourse</a></li>
|
||||||
|
<li>Chat with us on <a href="https://join.slack.com/t/orgroam/shared_invite/zt-deoqamys-043YQ~s5Tay3iJ5QRI~Lxg">Slack</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section id="footer" class="row container">
|
||||||
|
<div class="col">
|
||||||
|
<div class="row">
|
||||||
|
<h5 class="header">Ecosystem</h5>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<a
|
||||||
|
class="content footer-links"
|
||||||
|
href="https://github.com/org-roam/org-roam-bibtex"
|
||||||
|
>org-roam-bibtex</a
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<a
|
||||||
|
class="content footer-links"
|
||||||
|
href="https://github.com/org-roam/org-roam-server"
|
||||||
|
>org-roam-server</a
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col">
|
||||||
|
<div class="row">
|
||||||
|
<h5 class="header">Resources</h5>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<a
|
||||||
|
class="content footer-links"
|
||||||
|
href="https://github.com/org-roam/org-roam/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc"
|
||||||
|
>Open Issues</a
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<a
|
||||||
|
class="content footer-links"
|
||||||
|
href="https://github.com/org-roam/org-roam/releases"
|
||||||
|
>Releases</a
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col">
|
||||||
|
<div class="row">
|
||||||
|
<h5 class="header">Connect</h5>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<a
|
||||||
|
class="content footer-links"
|
||||||
|
href="https://join.slack.com/t/orgroam/shared_invite/zt-deoqamys-043YQ~s5Tay3iJ5QRI~Lxg"
|
||||||
|
>Slack</a
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<a
|
||||||
|
class="content footer-links"
|
||||||
|
href="https://org-roam.discourse.group/"
|
||||||
|
>Discourse</a
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</body>
|
||||||
|
</html>
|
62
doc/index.md
62
doc/index.md
@ -1,62 +0,0 @@
|
|||||||
![org-roam][org-roam-intro-image]
|
|
||||||
|
|
||||||
## What is Org-roam?
|
|
||||||
|
|
||||||
Org-roam is a [Roam][roamresearch] replica built around the
|
|
||||||
all-powerful [Org-mode][org].
|
|
||||||
|
|
||||||
Org-roam is a solution for effortless non-hierarchical note-taking
|
|
||||||
with Org-mode. With Org-roam, notes flow naturally, making note-taking
|
|
||||||
fun and easy. Org-roam should also work as a plug-and-play solution
|
|
||||||
for anyone already using Org-mode for their personal wiki.
|
|
||||||
|
|
||||||
To understand more about Roam, a collection of links are available in
|
|
||||||
[the appendix](notetaking_workflow.md).
|
|
||||||
|
|
||||||
Org-roam aims to implement the core features of Roam, leveraging the
|
|
||||||
mature ecosystem around Org-mode where possible. Eventually, we hope
|
|
||||||
to further introduce features enabled by the Emacs ecosystem.
|
|
||||||
|
|
||||||
## Why use Org-roam?
|
|
||||||
|
|
||||||
##### Private and Secure
|
|
||||||
|
|
||||||
Edit your personal wiki completely offline, entirely in your control.
|
|
||||||
Encrypt your notes with GPG.
|
|
||||||
|
|
||||||
##### Longevity
|
|
||||||
|
|
||||||
Unlike web solutions like Roam research, the notes are first and
|
|
||||||
foremost plain Org-mode files -- Org-roam simply builds up an
|
|
||||||
auxilliary database to give the personal wiki superpowers. Having your
|
|
||||||
notes in plain-text is crucial for the longevity of your wiki. Never
|
|
||||||
have to worry about proprietary web solutions being taken down. Edit
|
|
||||||
your plain-text notes in notepad if all other editors cease to exist.
|
|
||||||
|
|
||||||
##### Free and Open-source
|
|
||||||
|
|
||||||
Org-roam is free and open-source, which means that if you feel unhappy
|
|
||||||
with any part of Org-roam, you may choose to extend Org-roam, or open
|
|
||||||
a PR.
|
|
||||||
|
|
||||||
##### Leverage the Org-mode Ecosystem
|
|
||||||
|
|
||||||
Over the years, Emacs and Org-mode has developed into a mature system
|
|
||||||
for plain-text organization. Building upon Org-mode already puts
|
|
||||||
Org-roam light-years ahead of many other solutions.
|
|
||||||
|
|
||||||
Emacs is also a fantastic interface for editing text, and we can
|
|
||||||
inherit many of the powerful text-navigation and editing packages
|
|
||||||
available to Emacs.
|
|
||||||
|
|
||||||
There are several packages that are similar to Org-roam, see the
|
|
||||||
[Comparison](comparison.md) page for a detailed comparison.
|
|
||||||
|
|
||||||
## Project Status
|
|
||||||
|
|
||||||
As of March 2020, most of the core functionality and interfaces have
|
|
||||||
stabilized, and a stable release is near.
|
|
||||||
|
|
||||||
[org-roam-intro-image]: images/org-roam-intro.png
|
|
||||||
[roamresearch]: https://www.roamresearch.com/
|
|
||||||
[org]: https://orgmode.org/
|
|
@ -1,195 +0,0 @@
|
|||||||
## Basic Install and Configuration
|
|
||||||
|
|
||||||
Org-roam is now available on MELPA, so you can install it via the following
|
|
||||||
command:
|
|
||||||
|
|
||||||
```
|
|
||||||
M-x package-install RET org-roam RET
|
|
||||||
```
|
|
||||||
|
|
||||||
Alternatively, you may use package managers such as [straight][straight] or
|
|
||||||
[quelpa][quelpa] to install the package.
|
|
||||||
|
|
||||||
The recommended method of configuration is to use [use-package][use-package].
|
|
||||||
|
|
||||||
```emacs-lisp
|
|
||||||
(use-package org-roam
|
|
||||||
:hook
|
|
||||||
(after-init . org-roam-mode)
|
|
||||||
:custom
|
|
||||||
(org-roam-directory "/path/to/org-files/")
|
|
||||||
:bind (:map org-roam-mode-map
|
|
||||||
(("C-c n l" . org-roam)
|
|
||||||
("C-c n f" . org-roam-find-file)
|
|
||||||
("C-c n b" . org-roam-switch-to-buffer)
|
|
||||||
("C-c n g" . org-roam-graph))
|
|
||||||
:map org-mode-map
|
|
||||||
(("C-c n i" . org-roam-insert))))
|
|
||||||
```
|
|
||||||
|
|
||||||
Or without `use-package`:
|
|
||||||
|
|
||||||
```emacs-lisp
|
|
||||||
(require 'org-roam)
|
|
||||||
(define-key org-roam-mode-map (kbd "C-c n l") #'org-roam)
|
|
||||||
(define-key org-roam-mode-map (kbd "C-c n f") #'org-roam-find-file)
|
|
||||||
(define-key org-roam-mode-map (kbd "C-c n b") #'org-roam-switch-to-buffer)
|
|
||||||
(define-key org-roam-mode-map (kbd "C-c n g") #'org-roam-graph)
|
|
||||||
(define-key org-mode-map (kbd "C-c n i") #'org-roam-insert)
|
|
||||||
(org-roam-mode +1)
|
|
||||||
```
|
|
||||||
|
|
||||||
The [Configuration](configuration.md) page details some of the common
|
|
||||||
configuration options available.
|
|
||||||
|
|
||||||
### Completion
|
|
||||||
|
|
||||||
Link auto-completion is offered via
|
|
||||||
[company-org-roam](https://github.com/jethrokuan/company-org-roam/), refer to
|
|
||||||
the documentation there for further details.
|
|
||||||
|
|
||||||
## Spacemacs
|
|
||||||
|
|
||||||
If you are using Spacemacs, install org-roam by creating a simple layer that
|
|
||||||
wraps Org-roam. Paste the following into a new file
|
|
||||||
`~/.emacs.d/private/org-roam/packages.el`.
|
|
||||||
|
|
||||||
```emacs-lisp
|
|
||||||
(defconst org-roam-packages
|
|
||||||
'(org-roam))
|
|
||||||
|
|
||||||
(defun org-roam/init-org-roam ()
|
|
||||||
(use-package org-roam
|
|
||||||
:hook
|
|
||||||
(after-init . org-roam-mode)
|
|
||||||
:custom
|
|
||||||
(org-roam-directory "/path/to/org-files/")
|
|
||||||
:init
|
|
||||||
(progn
|
|
||||||
(spacemacs/declare-prefix "ar" "org-roam")
|
|
||||||
(spacemacs/set-leader-keys
|
|
||||||
"arl" 'org-roam
|
|
||||||
"art" 'org-roam-dailies-today
|
|
||||||
"arf" 'org-roam-find-file
|
|
||||||
"arg" 'org-roam-graph)
|
|
||||||
|
|
||||||
(spacemacs/declare-prefix-for-mode 'org-mode "mr" "org-roam")
|
|
||||||
(spacemacs/set-leader-keys-for-major-mode 'org-mode
|
|
||||||
"rl" 'org-roam
|
|
||||||
"rt" 'org-roam-dailies-today
|
|
||||||
"rb" 'org-roam-switch-to-buffer
|
|
||||||
"rf" 'org-roam-find-file
|
|
||||||
"ri" 'org-roam-insert
|
|
||||||
"rg" 'org-roam-graph))))
|
|
||||||
```
|
|
||||||
|
|
||||||
Next, append `org-roam` to the `dotspacemacs-configuration-layers`
|
|
||||||
list in your `.spacemacs` configuration file. Reload (`SPC f e R`) or
|
|
||||||
restart Emacs to load `org-roam`. It's functions are available under
|
|
||||||
the prefix `SPC a r` and `, r` when visiting an org-mode buffer.
|
|
||||||
|
|
||||||
If you also have the ranger layer installed, the prefix 'ar' conflict
|
|
||||||
with that of the ranger layer. You might want to change it to 'aor'
|
|
||||||
(also change the 'ar' to 'aor' in the other key-binding declarations)
|
|
||||||
|
|
||||||
## Doom Emacs
|
|
||||||
|
|
||||||
[Doom Emacs][doom] has a `+roam` flag on its `org` module for easy
|
|
||||||
installation and configuration. Simply add the flag to the `org` section
|
|
||||||
of your `~/.doom.d/init.el` and run `~/.emacs.d/bin/doom sync`.
|
|
||||||
|
|
||||||
[use-package]: https://github.com/jwiegley/use-package
|
|
||||||
[straight]: https://github.com/raxod502/straight.el
|
|
||||||
[quelpa]: https://github.com/quelpa/quelpa
|
|
||||||
[doom]: https://github.com/hlissner/doom-emacs
|
|
||||||
[doom-getting-started]: https://github.com/hlissner/doom-emacs/blob/develop/docs/getting_started.org#configuring-packages
|
|
||||||
|
|
||||||
## Windows
|
|
||||||
|
|
||||||
On Windows, if you follow the installation instructions above, you will likely get the error message: **"No EmacSQL SQLite binary available, aborting"**, and `org-roam` won't start properly.
|
|
||||||
|
|
||||||
You need to do some additional steps to get `org-roam` to work.
|
|
||||||
|
|
||||||
Essentially, you will need to have a binary file for `emacsql-sqlite` so that your Emacs can work with `sqlite` database -- `org-roam` uses it to track backlinks. The following options have been reported to work by Windows users in the community.
|
|
||||||
|
|
||||||
Option 1. **Windows Subsystem for Linux (WSL)**
|
|
||||||
: This option lets you use Linux on your Windows machine. It's Linux, so you don't need to do anything specific for Windows.
|
|
||||||
|
|
||||||
Option 2. **mingw-x64**
|
|
||||||
: Use mingw-x64. You would spend a bit of time to download it, and get familiar with how it works. You should be able to use Linux tools within your Windows [more contribution welcome].
|
|
||||||
|
|
||||||
Option 3. **scoop**
|
|
||||||
: Use [scoop](https://scoop.sh/) to install a couple of software tools (make and gcc) and manually compile a binary (`.exe`) file yourself. Find a short step-by-step guide below.
|
|
||||||
|
|
||||||
Option 4. **emacsql-sqlite3**
|
|
||||||
: Use another Emacs package called [`emacsql-sqlite3`](https://github.com/cireu/emacsql-sqlite3). You can download an [official binary](https://sqlite.org/download.html) for `sqlite3`. `emacsql-sqlite3` lets you use it. For this option to work, you need to adjust the `org-roam` source code, and get your modified version to work in your Emacs environment. Find a suggestion below.
|
|
||||||
|
|
||||||
### scoop
|
|
||||||
**Step 1.** In PowerShell, install `scoop` ([instruction here](https://scoop.sh/)).
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
iwr -useb get.scoop.sh | iex
|
|
||||||
```
|
|
||||||
|
|
||||||
**Step 2.** In PowerShell, install `make` and `gcc` via scoop
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
scoop install make gcc
|
|
||||||
```
|
|
||||||
|
|
||||||
**Step 3.** In Emacs, install the `emacsql-sqlite` package for your Emacs if it is not done yet.
|
|
||||||
|
|
||||||
**Step 4.** In PowerShell, move to the directory where `emacsql.c` is stored.
|
|
||||||
|
|
||||||
With MELPA, it is likely to be under your ELPA folder:
|
|
||||||
|
|
||||||
```
|
|
||||||
~\AppData\Roaming\.emacs.d\elpa\emacsql-sqlite-20190727.1710\sqlite
|
|
||||||
```
|
|
||||||
|
|
||||||
With Doom Emacs, it should be under your `.emacs\.local`:
|
|
||||||
|
|
||||||
```
|
|
||||||
~\.emacs.d\.local\straight\build\emacsql-sqlite\sqlite
|
|
||||||
```
|
|
||||||
|
|
||||||
Check the files via `dir` command. You should see these files:
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
Mode LastWriteTime Length Name
|
|
||||||
---- ------------- ------ ----
|
|
||||||
-a---- 22/03/2020 12:10 PM 5170 emacsql.c
|
|
||||||
-a---- 22/03/2020 12:10 PM 439 Makefile
|
|
||||||
-a---- 22/03/2020 12:10 PM 7516138 sqlite3.c
|
|
||||||
-a---- 22/03/2020 12:10 PM 526684 sqlite3.h
|
|
||||||
```
|
|
||||||
|
|
||||||
**Step 5.** Compile the `.exe` file with `make`
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
make emacsql-sqlite CC=gcc LDLIBS=
|
|
||||||
```
|
|
||||||
|
|
||||||
You will see the process triggered with lots of text automatically scrolling down; it may take a couple of minutes for compilation to finish.
|
|
||||||
|
|
||||||
Once compilation is done, check that `emacsql-sqlite.exe` has been added to the directory.
|
|
||||||
|
|
||||||
**Step 6.** Relaunch Emacs, use `org-roam`
|
|
||||||
|
|
||||||
When you start `org-roam` (e.g. via `org-roam-mode`), now you should no longer see the "No EmacSQL SQLite binary available, aborting" error. You are good to go.
|
|
||||||
|
|
||||||
|
|
||||||
### emacsql-sqlite3
|
|
||||||
|
|
||||||
1. In Emacs, install the `emacsql-sqlite3` package
|
|
||||||
|
|
||||||
2. Using your text editor, etc. modify `org-roam-db.el`:
|
|
||||||
|
|
||||||
1. Replace `(require 'emacsql-sqlite)` with `(require 'emacsql-sqlite3)`
|
|
||||||
|
|
||||||
2. Comment/deactivate the complete `(defconst org-roam-db--sqlite-available-p ... )`
|
|
||||||
|
|
||||||
3. In `(defun org-roam-db ...`, replace `emacsql-sqlite`
|
|
||||||
with `emacsql-sqlite3`
|
|
||||||
|
|
||||||
3. If you compile `.el` files, ensure to replace `org-roam-db.elc` with the new source you modified.
|
|
@ -1,24 +0,0 @@
|
|||||||
## Recommended Books
|
|
||||||
- [How to Take Smart Notes][1]
|
|
||||||
|
|
||||||
## Articles
|
|
||||||
- [How to Take Smart Notes in Org-mode - Jethro Kuan][7]
|
|
||||||
- [The Zettelkasten Method - LessWrong 2.0][3]
|
|
||||||
- [Building a second brain in Roam][4]
|
|
||||||
- [Roam: Why I Love It and How I Use It][5]
|
|
||||||
- [Adam Keesling's Twitter Thread][6]
|
|
||||||
|
|
||||||
## Threads
|
|
||||||
- [Ask HN: How to Take Good Notes][8]
|
|
||||||
|
|
||||||
## What to Do With Your Notes
|
|
||||||
- [How to Use Roam to Outline a New Article in Under 20 Minutes][2]
|
|
||||||
|
|
||||||
[1]: https://www.goodreads.com/book/show/34507927-how-to-take-smart-notes?ac=1&from_search=true&qid=6L8iEE1FIA&rank=1
|
|
||||||
[2]: https://www.youtube.com/watch?v=RvWic15iXjk
|
|
||||||
[3]: https://www.lesswrong.com/posts/NfdHG6oHBJ8Qxc26s/the-zettelkasten-method-1
|
|
||||||
[4]: https://reddit.com/r/RoamResearch/comments/eho7de/building_a_second_brain_in_roamand_why_you_might
|
|
||||||
[5]: https://www.nateliason.com/blog/roam
|
|
||||||
[6]: https://twitter.com/adam_keesling/status/1196864424725774336?s=20
|
|
||||||
[7]: https://blog.jethro.dev/posts/how_to_take_smart_notes_org/
|
|
||||||
[8]: https://news.ycombinator.com/item?id=22473209
|
|
1747
doc/org-roam.org
Normal file
1747
doc/org-roam.org
Normal file
File diff suppressed because it is too large
Load Diff
2172
doc/org-roam.texi
Normal file
2172
doc/org-roam.texi
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,61 +0,0 @@
|
|||||||
While exporting your documents to another format such as HTML -- whether using Org's in-built export or ox-hugo -- you can add a backlinks section which would display the backlinks to the current file. This is done via org-export's preprocessing hooks. See more at [Advanced Export Configuration (The Org Manual)](https://orgmode.org/manual/Advanced-Export-Configuration.html#Advanced-Export-Configuration).
|
|
||||||
|
|
||||||
Following are two different configs that might be suitable for different use-cases. Add one of these snippets in your Emacs init file.
|
|
||||||
|
|
||||||
### Only Backlinks
|
|
||||||
|
|
||||||
This will display only the backlinks and not the contents.
|
|
||||||
|
|
||||||
```emacs-lisp
|
|
||||||
(defun my/org-roam--backlinks-list (file)
|
|
||||||
(if (org-roam--org-roam-file-p file)
|
|
||||||
(--reduce-from
|
|
||||||
(concat acc (format "- [[file:%s][%s]]\n"
|
|
||||||
(file-relative-name (car it) org-roam-directory)
|
|
||||||
(org-roam--get-title-or-slug (car it))))
|
|
||||||
"" (org-roam-db-query [:select [from] :from links :where (= to $s1)] file))
|
|
||||||
""))
|
|
||||||
|
|
||||||
(defun my/org-export-preprocessor (backend)
|
|
||||||
(let ((links (my/org-roam--backlinks-list (buffer-file-name))))
|
|
||||||
(unless (string= links "")
|
|
||||||
(save-excursion
|
|
||||||
(goto-char (point-max))
|
|
||||||
(insert (concat "\n* Backlinks\n") links)))))
|
|
||||||
|
|
||||||
(add-hook 'org-export-before-processing-hook 'my/org-export-preprocessor)
|
|
||||||
```
|
|
||||||
|
|
||||||
### Backlinks and Contents
|
|
||||||
|
|
||||||
This would insert both backlinks and the contents, just like the org-roam buffer. This might be especially useful if you host a web version of your personal knowledgebase and want to browse the files along with the backlinks from mobile devices.
|
|
||||||
|
|
||||||
```emacs-lisp
|
|
||||||
(defun my/org-roam--backlinks-list-with-content (file)
|
|
||||||
(with-temp-buffer
|
|
||||||
(if-let* ((backlinks (org-roam--get-backlinks file))
|
|
||||||
(grouped-backlinks (--group-by (nth 0 it) backlinks)))
|
|
||||||
(progn
|
|
||||||
(insert (format "\n\n* %d Backlinks\n"
|
|
||||||
(length backlinks)))
|
|
||||||
(dolist (group grouped-backlinks)
|
|
||||||
(let ((file-from (car group))
|
|
||||||
(bls (cdr group)))
|
|
||||||
(insert (format "** [[file:%s][%s]]\n"
|
|
||||||
file-from
|
|
||||||
(org-roam--get-title-or-slug file-from)))
|
|
||||||
(dolist (backlink bls)
|
|
||||||
(pcase-let ((`(,file-from _ ,props) backlink))
|
|
||||||
(insert (s-trim (s-replace "\n" " " (plist-get props :content))))
|
|
||||||
(insert "\n\n")))))))
|
|
||||||
(buffer-string)))
|
|
||||||
|
|
||||||
(defun my/org-export-preprocessor (backend)
|
|
||||||
(let ((links (my/org-roam--backlinks-list-with-content (buffer-file-name))))
|
|
||||||
(unless (string= links "")
|
|
||||||
(save-excursion
|
|
||||||
(goto-char (point-max))
|
|
||||||
(insert (concat "\n* Backlinks\n") links)))))
|
|
||||||
|
|
||||||
(add-hook 'org-export-before-processing-hook 'my/org-export-preprocessor)
|
|
||||||
```
|
|
@ -1,2 +0,0 @@
|
|||||||
mkdocs-material==4.6.2
|
|
||||||
pymdown-extensions==6.3
|
|
@ -1,161 +0,0 @@
|
|||||||
## What is Roam protocol?
|
|
||||||
|
|
||||||
Org-roam extending `org-protocol` with 2 protocols: the `roam-file`
|
|
||||||
and `roam-ref` protocol.
|
|
||||||
|
|
||||||
## The `roam-file` protocol
|
|
||||||
|
|
||||||
This is a simple protocol that opens the path specified by the `file`
|
|
||||||
key (e.g. `org-protocol://roam-file?file=/tmp/file.org`). This is used
|
|
||||||
in the generated graph.
|
|
||||||
|
|
||||||
## The `roam-ref` Protocol
|
|
||||||
|
|
||||||
This protocol finds or creates a new note with a given `ROAM_KEY` (see
|
|
||||||
[Anatomy](anatomy.md)):
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
To use this, create a Firefox bookmarklet as follows:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
javascript:location.href =
|
|
||||||
'org-protocol:/roam-ref?template=r&ref='
|
|
||||||
+ encodeURIComponent(location.href)
|
|
||||||
+ '&title='
|
|
||||||
+ encodeURIComponent(document.title)
|
|
||||||
```
|
|
||||||
|
|
||||||
where `template` is the template key for a template in
|
|
||||||
`org-roam-capture-ref-templates`. More documentation on the templating
|
|
||||||
system can be found [here](templating.md).
|
|
||||||
|
|
||||||
These templates should contain a `#+ROAM_KEY: ${ref}` in it.
|
|
||||||
|
|
||||||
## Setting up Org-roam protocol
|
|
||||||
|
|
||||||
To enable org-roam's protocol extensions, you have to add the
|
|
||||||
following to your init file:
|
|
||||||
|
|
||||||
```emacs-lisp
|
|
||||||
(require 'org-roam-protocol)
|
|
||||||
```
|
|
||||||
|
|
||||||
The instructions for setting up `org-protocol` can be found
|
|
||||||
[here][org-protocol-inst], but they are reproduced below.
|
|
||||||
|
|
||||||
We will also need to create a desktop application for `emacsclient`.
|
|
||||||
The instructions for various platforms are shown below:
|
|
||||||
|
|
||||||
## Linux
|
|
||||||
|
|
||||||
Create a desktop application. I place mine in
|
|
||||||
`~/.local/share/applications/org-protocol.desktop`:
|
|
||||||
|
|
||||||
```
|
|
||||||
[Desktop Entry]
|
|
||||||
Name=Org-Protocol
|
|
||||||
Exec=emacsclient %u
|
|
||||||
Icon=emacs-icon
|
|
||||||
Type=Application
|
|
||||||
Terminal=false
|
|
||||||
MimeType=x-scheme-handler/org-protocol
|
|
||||||
```
|
|
||||||
|
|
||||||
Associate `org-protocol://` links with the desktop application by
|
|
||||||
running in your shell:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
xdg-mime default org-protocol.desktop x-scheme-handler/org-protocol
|
|
||||||
```
|
|
||||||
|
|
||||||
To disable the "confirm" prompt in Chrome, you can also make Chrome
|
|
||||||
show a checkbox to tick, so that the `Org-Protocol Client` app will be used
|
|
||||||
without confirmation. To do this, run in a shell:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
sudo mkdir -p /etc/opt/chrome/policies/managed/
|
|
||||||
sudo tee /etc/opt/chrome/policies/managed/external_protocol_dialog.json >/dev/null <<'EOF'
|
|
||||||
{
|
|
||||||
"ExternalProtocolDialogShowAlwaysOpenCheckbox": true
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
sudo chmod 644 /etc/opt/chrome/policies/managed/external_protocol_dialog.json
|
|
||||||
```
|
|
||||||
|
|
||||||
and then restart Chrome (for example, by navigating to <chrome://restart>) to
|
|
||||||
make the new policy take effect.
|
|
||||||
|
|
||||||
See [here](https://www.chromium.org/administrators/linux-quick-start)
|
|
||||||
for more info on the `/etc/opt/chrome/policies/managed` directory and
|
|
||||||
[here](https://cloud.google.com/docs/chrome-enterprise/policies/?policy=ExternalProtocolDialogShowAlwaysOpenCheckbox)
|
|
||||||
for information on the `ExternalProtocolDialogShowAlwaysOpenCheckbox`
|
|
||||||
policy.
|
|
||||||
|
|
||||||
|
|
||||||
## Mac OS
|
|
||||||
|
|
||||||
One solution is to use
|
|
||||||
[Platypus](https://github.com/sveinbjornt/Platypus). Here are the
|
|
||||||
instructions for setting up with Platypus and Chrome:
|
|
||||||
|
|
||||||
1. Install and launch Platypus (with [Homebrew](https://brew.sh/)):
|
|
||||||
|
|
||||||
```sh
|
|
||||||
brew cask install platypus
|
|
||||||
```
|
|
||||||
2. Create a script `launch_emacs.sh`:
|
|
||||||
|
|
||||||
```
|
|
||||||
#!/usr/bin/env bash
|
|
||||||
/usr/local/bin/emacsclient --no-wait $1
|
|
||||||
```
|
|
||||||
|
|
||||||
3. Create a Platypus app with the following settings:
|
|
||||||
|
|
||||||
```
|
|
||||||
| Setting | Value |
|
|
||||||
|--------------------------------+---------------------------|
|
|
||||||
| App Name | "OrgProtocol" |
|
|
||||||
| Script Type | "env" · "/usr/bin/env" |
|
|
||||||
| Script Path | "path/to/launch-emacs.sh" |
|
|
||||||
| Interface | None |
|
|
||||||
| Accept dropped items | true |
|
|
||||||
| Remain running after execution | false |
|
|
||||||
```
|
|
||||||
|
|
||||||
Inside `Settings`:
|
|
||||||
|
|
||||||
```
|
|
||||||
| Setting | Value |
|
|
||||||
|--------------------------------+----------------|
|
|
||||||
| Accept dropped files | true |
|
|
||||||
| Register as URI scheme handler | true |
|
|
||||||
| Protocol | "org-protocol" |
|
|
||||||
```
|
|
||||||
|
|
||||||
To disable the "confirm" prompt in Chrome, you can also make Chrome
|
|
||||||
show a checkbox to tick, so that the `OrgProtocol` app will be used
|
|
||||||
without confirmation. To do this, run in a shell:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
defaults write com.google.Chrome ExternalProtocolDialogShowAlwaysOpenCheckbox -bool true
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
##### Note for Emacs Mac Port
|
|
||||||
|
|
||||||
If you're using [Emacs Mac Port](https://github.com/railwaycat/homebrew-emacsmacport), it
|
|
||||||
registered its `Emacs.app` as the default handler for the URL scheme
|
|
||||||
`org-protocol`. We have to make our `OrgProtocol.app` the default
|
|
||||||
handler instead (replace `org.yourusername.OrgProtocol` with your app
|
|
||||||
identifier):
|
|
||||||
|
|
||||||
```
|
|
||||||
$ defaults write com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers -array-add \
|
|
||||||
'{"LSHandlerPreferredVersions" = { "LSHandlerRoleAll" = "-"; }; LSHandlerRoleAll = "org.yourusername.OrgProtocol"; LSHandlerURLScheme = "org-protocol";}'
|
|
||||||
```
|
|
||||||
|
|
||||||
Then restart your computer.
|
|
||||||
|
|
||||||
[org-protocol-inst]: https://orgmode.org/worg/org-contrib/org-protocol.html
|
|
@ -1,119 +0,0 @@
|
|||||||
Rather than creating blank files on `org-roam-insert` and
|
|
||||||
`org-roam-find-file`, it is may be desirable to prefill the file with
|
|
||||||
content. This may include:
|
|
||||||
|
|
||||||
- Time of creation
|
|
||||||
- File it was created from
|
|
||||||
- Clipboard content
|
|
||||||
- Any other data you may want to input manually
|
|
||||||
|
|
||||||
This requires a complex template insertion system, but fortunately,
|
|
||||||
Org ships with a powerful one: `org-capture`. However, org-capture was
|
|
||||||
not designed for such use. Org-roam abuses `org-capture` to some
|
|
||||||
extent, extending its syntax. To first understand how org-roam's
|
|
||||||
templating system works, it may be useful to look into org-capture.
|
|
||||||
|
|
||||||
## Org-roam Templates
|
|
||||||
|
|
||||||
The org-roam capture template extends org-capture's template with 2
|
|
||||||
additional properties:
|
|
||||||
|
|
||||||
1. `:file-name`: This is the file name template used when a new note
|
|
||||||
is created.
|
|
||||||
2. `:head`: This is the template that is inserted on initial note
|
|
||||||
creation.
|
|
||||||
|
|
||||||
### Org-roam Template Expansion
|
|
||||||
|
|
||||||
Org-roam's template definitions also extend org-capture's template
|
|
||||||
syntax, to allow prefilling of strings. In many scenarios,
|
|
||||||
`org-roam--capture` is passed a mapping between variables and strings.
|
|
||||||
For example, during `org-roam-insert`, a title is prompted for. If the
|
|
||||||
title doesn't already exist, we would like to create a new file,
|
|
||||||
without prompting for the title again.
|
|
||||||
|
|
||||||
Variables passed are expanded with the `${var}` syntax. For example,
|
|
||||||
during `org-roam-insert`, `${title}` is prefilled for expansion. Any
|
|
||||||
variables that do not contain strings, are prompted for values using
|
|
||||||
`completing-read`.
|
|
||||||
|
|
||||||
After doing this expansion, the org-capture's template expansion
|
|
||||||
system is used to fill up the rest of the template. You may read up
|
|
||||||
more on this on [org-capture's documentation
|
|
||||||
page](https://orgmode.org/manual/Template-expansion.html#Template-expansion).
|
|
||||||
|
|
||||||
For example, take the template: `"%<%Y%m%d%H%M%S>-${title}"`, with the title
|
|
||||||
`"Foo"`. The template is first expanded into `%<%Y%m%d%H%M%S>-Foo`. Then
|
|
||||||
org-capture expands `%<%Y%m%d%H%M%S>` with timestamp: e.g.
|
|
||||||
`20200213032037-Foo`.
|
|
||||||
|
|
||||||
All of the flexibility afforded by emacs and org-mode are
|
|
||||||
available. For example, if you want to encode a UTC timestamp in the
|
|
||||||
filename, you can take advantage of org-mode's `%(EXP)` template
|
|
||||||
expansion to call `format-time-string` directly to provide its third
|
|
||||||
argument to specify UTC.
|
|
||||||
|
|
||||||
``` emacs-lisp
|
|
||||||
("d" "default" plain (function org-roam--capture-get-point)
|
|
||||||
"%?"
|
|
||||||
:file-name "%(format-time-string \"%Y-%m-%d--%H-%M-%SZ--${slug}\" (current-time) t)"
|
|
||||||
:head "#+TITLE: ${title}\n"
|
|
||||||
:unnarrowed t)
|
|
||||||
```
|
|
||||||
|
|
||||||
Similarly, if you want to change how titles are transformed into
|
|
||||||
slugs, you can override `org-roam--title-to-slug`. For example, to use
|
|
||||||
hyphens instead of underscores:
|
|
||||||
|
|
||||||
|
|
||||||
``` emacs-lisp
|
|
||||||
(defun org-roam--title-to-slug (title)
|
|
||||||
"Convert TITLE to a filename-suitable slug. Uses hyphens rather than underscores."
|
|
||||||
(cl-flet* ((nonspacing-mark-p (char)
|
|
||||||
(eq 'Mn (get-char-code-property char 'general-category)))
|
|
||||||
(strip-nonspacing-marks (s)
|
|
||||||
(apply #'string (seq-remove #'nonspacing-mark-p
|
|
||||||
(ucs-normalize-NFD-string 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
|
|
||||||
("-$" . ""))) ;; remove ending underscore
|
|
||||||
(slug (-reduce-from #'cl-replace (strip-nonspacing-marks title) pairs)))
|
|
||||||
(s-downcase slug))))
|
|
||||||
```
|
|
||||||
|
|
||||||
This templating system is used throughout org-roam templates.
|
|
||||||
|
|
||||||
### Template examples
|
|
||||||
|
|
||||||
Here I walkthrough the default template, reproduced below.
|
|
||||||
|
|
||||||
```
|
|
||||||
("d" "default" plain (function org-roam--capture-get-point)
|
|
||||||
"%?"
|
|
||||||
:file-name "%<%Y%m%d%H%M%S>-${slug}"
|
|
||||||
:head "#+TITLE: ${title}\n"
|
|
||||||
:unnarrowed t)
|
|
||||||
```
|
|
||||||
|
|
||||||
1. The template has short key `"d"`. If you have only one template,
|
|
||||||
org-roam automatically chooses this template for you.
|
|
||||||
2. The template is given a description of `"default"`.
|
|
||||||
3. `plain` text is inserted. Other options include Org headings via
|
|
||||||
`entry`.
|
|
||||||
4. `(function org-roam--capture-get-point)` should not be changed.
|
|
||||||
5. `"%?"` is the template inserted on each call to `org-roam--capture`.
|
|
||||||
This template means don't insert any content, but place the cursor
|
|
||||||
here.
|
|
||||||
6. `:file-name` is the file-name template for a new note, if it
|
|
||||||
doesn't yet exist. This creates a file at path that looks like
|
|
||||||
`/path/to/org-roam-directory/20200213032037-foo.org`.
|
|
||||||
7. `:head` contains the initial template to be inserted (once only),
|
|
||||||
at the beginning of the file. Here, the title global attribute is
|
|
||||||
inserted.
|
|
||||||
8. `:unnarrowed t` tells org-capture to show the contents for the
|
|
||||||
whole file, rather than narrowing to just the entry.
|
|
||||||
|
|
||||||
Other options you may want to learn about include `:immediate-finish`.
|
|
70
doc/tour.md
70
doc/tour.md
@ -1,70 +0,0 @@
|
|||||||
Org-roam was built to support a workflow that was not possible with
|
|
||||||
vanilla Org-mode. This flow is modelled after the [Zettelkasten
|
|
||||||
method][zettelkasten], and many of [Roam Research][roam]'s workflows.
|
|
||||||
It is crucial to understand that Org-roam does not auto-magically make
|
|
||||||
note-taking better -- it's changing the note-taking workflow that
|
|
||||||
does.
|
|
||||||
|
|
||||||
To understand more about the methods and madness, the [Note-Taking
|
|
||||||
Workflow][appendix:ntw] page contains a page of useful references. The
|
|
||||||
author has also written [a post][jethro-blog-post] about how he uses
|
|
||||||
Org-roam.
|
|
||||||
|
|
||||||
## Activating Org-roam
|
|
||||||
|
|
||||||
Org-roam's entry point is the global minor `org-roam-mode`. This sets
|
|
||||||
up Emacs with several hooks, for keeping the org-roam cache
|
|
||||||
consistently updated, as well as showing the backlinks buffer.
|
|
||||||
|
|
||||||
The cache is a sqlite database named `org-roam.db`, which resides at
|
|
||||||
the root of the `org-roam-directory`. Activating `org-roam-mode`
|
|
||||||
builds the cache, which may take a while the first time, but is
|
|
||||||
generally instantaneous in subsequent runs. To build the cache
|
|
||||||
manually again, run `M-x org-roam-db-build-cache`.
|
|
||||||
|
|
||||||
## Finding a Note
|
|
||||||
|
|
||||||
`org-roam-find-file` shows the list of titles for notes that reside in
|
|
||||||
`org-roam-directory`. Selecting a note title will bring you to the
|
|
||||||
corresponding note. Entering a title of a note that does not yet exist
|
|
||||||
will create a new note with that title.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Note that in the above image, the [ivy](https://github.com/abo-abo/swiper)
|
|
||||||
completion frontend is used. The default frontend has some usability issues with
|
|
||||||
non-matching candidates (e.g. when you want to enter a title of a new note,
|
|
||||||
there is no completion candidate), so either `ivy` or `helm` is recommended.
|
|
||||||
|
|
||||||
## Inserting Links
|
|
||||||
|
|
||||||
`org-roam-insert` insert links to existing (or new) notes. Entering a
|
|
||||||
non-existent title will also create a new note with that title.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Good usage of Org-roam requires liberally linking files. This allows
|
|
||||||
the build-up of a dense knowledge graph.
|
|
||||||
|
|
||||||
## The Org-roam Buffer
|
|
||||||
|
|
||||||
The Org-roam buffer is often displayed in the side window. It shows
|
|
||||||
backlinks for the currently active Org-roam note, along with some
|
|
||||||
surrounding context.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## Exporting the Graph
|
|
||||||
|
|
||||||
Org-roam also uses Graphviz to generate a graph, with notes as nodes,
|
|
||||||
and links between them as edges. The generated graph can be used to
|
|
||||||
navigate to the files, but this requires some additional setup
|
|
||||||
described in the [Roam Protocol][appendix:roam-protocol] page.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
[zettelkasten]: https://zettelkasten.de/
|
|
||||||
[appendix:ntw]: notetaking_workflow.md
|
|
||||||
[appendix:roam-protocol]: roam_protocol.md
|
|
||||||
[roam]: https://www.roamresearch.com/
|
|
||||||
[jethro-blog-post]: https://blog.jethro.dev/posts/how_to_take_smart_notes_org/
|
|
40
mkdocs.yml
40
mkdocs.yml
@ -1,40 +0,0 @@
|
|||||||
site_name: "Org-roam"
|
|
||||||
repo_url: https://github.com/jethrokuan/org-roam/
|
|
||||||
edit_uri: edit/master/doc/
|
|
||||||
copyright: "Copyright (C) 2020 Jethro Kuan and contributors"
|
|
||||||
docs_dir: doc
|
|
||||||
extra:
|
|
||||||
social:
|
|
||||||
- type: 'slack'
|
|
||||||
link: 'https://join.slack.com/t/orgroam/shared_invite/zt-clh0g0tx-j8xg1kVxnrWdKt16gmSGPQ'
|
|
||||||
nav:
|
|
||||||
- Home: index.md
|
|
||||||
- A Tour of Org-roam: tour.md
|
|
||||||
- Installation: installation.md
|
|
||||||
- Configuration: configuration.md
|
|
||||||
- Anatomy of an Org-roam file: anatomy.md
|
|
||||||
- The Templating System: templating.md
|
|
||||||
- Ecosystem: ecosystem.md
|
|
||||||
- Similar Packages: comparison.md
|
|
||||||
- "Appendix: Note-taking Workflow": notetaking_workflow.md
|
|
||||||
- "Appendix: Roam Protocol": roam_protocol.md
|
|
||||||
- "Appendix: Org Export": org_export.md
|
|
||||||
markdown_extensions:
|
|
||||||
- admonition
|
|
||||||
- pymdownx.betterem:
|
|
||||||
smart_enable: all
|
|
||||||
- pymdownx.caret
|
|
||||||
- pymdownx.critic
|
|
||||||
- pymdownx.details
|
|
||||||
- pymdownx.mark
|
|
||||||
- pymdownx.smartsymbols
|
|
||||||
- pymdownx.superfences
|
|
||||||
- pymdownx.tasklist:
|
|
||||||
custom_checkbox: true
|
|
||||||
- pymdownx.tilde
|
|
||||||
|
|
||||||
theme:
|
|
||||||
name: 'material'
|
|
||||||
palette:
|
|
||||||
primary: 'deep purple'
|
|
||||||
accent: 'deep purple'
|
|
@ -1,260 +0,0 @@
|
|||||||
;;; org-roam-buffer.el --- Roam Research replica with Org-mode -*- coding: utf-8; lexical-binding: t -*-
|
|
||||||
|
|
||||||
;; Copyright © 2020 Jethro Kuan <jethrokuan95@gmail.com>
|
|
||||||
|
|
||||||
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
|
||||||
;; URL: https://github.com/jethrokuan/org-roam
|
|
||||||
;; Keywords: org-mode, roam, convenience
|
|
||||||
;; Version: 1.1.0
|
|
||||||
;; Package-Requires: ((emacs "26.1") (dash "2.13") (f "0.17.2") (s "1.12.0") (org "9.3") (emacsql "3.0.0") (emacsql-sqlite "1.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 library provides the org-roam-buffer functionality for org-roam
|
|
||||||
;;; Code:
|
|
||||||
;;;; Library Requires
|
|
||||||
(eval-when-compile (require 'subr-x))
|
|
||||||
(require 'cl-lib)
|
|
||||||
(require 'dash)
|
|
||||||
(require 's)
|
|
||||||
|
|
||||||
(defvar org-roam-directory)
|
|
||||||
(defvar org-link-frame-setup)
|
|
||||||
(defvar org-return-follows-link)
|
|
||||||
(defvar org-roam-backlinks-mode)
|
|
||||||
(defvar org-roam-last-window)
|
|
||||||
(declare-function org-roam-db--ensure-built "org-roam-db")
|
|
||||||
(declare-function org-roam--extract-ref "org-roam")
|
|
||||||
(declare-function org-roam--get-title-or-slug "org-roam")
|
|
||||||
(declare-function org-roam--get-backlinks "org-roam")
|
|
||||||
(declare-function org-roam-backlinks-mode "org-roam")
|
|
||||||
|
|
||||||
(defcustom org-roam-buffer-position 'right
|
|
||||||
"Position of `org-roam' buffer.
|
|
||||||
Valid values are
|
|
||||||
* left,
|
|
||||||
* right,
|
|
||||||
* top,
|
|
||||||
* bottom."
|
|
||||||
:type '(choice (const left)
|
|
||||||
(const right)
|
|
||||||
(const top)
|
|
||||||
(const bottom))
|
|
||||||
:group 'org-roam)
|
|
||||||
|
|
||||||
(defcustom org-roam-buffer-width 0.33
|
|
||||||
"Width of `org-roam' buffer.
|
|
||||||
Has an effect if and only if `org-roam-buffer-position' is `left' or `right'."
|
|
||||||
:type 'number
|
|
||||||
:group 'org-roam)
|
|
||||||
|
|
||||||
(defcustom org-roam-buffer-height 0.27
|
|
||||||
"Height of `org-roam' buffer.
|
|
||||||
Has an effect if and only if `org-roam-buffer-position' is `top' or `bottom'."
|
|
||||||
:type 'number
|
|
||||||
:group 'org-roam)
|
|
||||||
|
|
||||||
|
|
||||||
(defcustom org-roam-buffer "*org-roam*"
|
|
||||||
"Org-roam buffer name."
|
|
||||||
:type 'string
|
|
||||||
:group 'org-roam)
|
|
||||||
|
|
||||||
(defcustom org-roam-buffer-prepare-hook '(org-roam-buffer--insert-title
|
|
||||||
org-roam-buffer--insert-backlinks
|
|
||||||
org-roam-buffer--insert-citelinks)
|
|
||||||
"Hook run in the `org-roam-buffer' before it is displayed."
|
|
||||||
:type 'hook
|
|
||||||
:group 'org-roam)
|
|
||||||
|
|
||||||
(defcustom org-roam-buffer-no-delete-other-windows nil
|
|
||||||
"The `no-delete-other-windows' parameter of the `org-roam-buffer' window.
|
|
||||||
When non-nil, the window will not be closed when deleting other windows."
|
|
||||||
:type 'boolean
|
|
||||||
:group 'org-roam)
|
|
||||||
|
|
||||||
(defvar org-roam-buffer--current nil
|
|
||||||
"Currently displayed file in `org-roam' buffer.")
|
|
||||||
|
|
||||||
(defun org-roam-buffer--insert-title ()
|
|
||||||
"Insert the org-roam-buffer title."
|
|
||||||
(insert (propertize (org-roam--get-title-or-slug
|
|
||||||
(buffer-file-name org-roam-buffer--current))
|
|
||||||
'font-lock-face
|
|
||||||
'org-document-title)))
|
|
||||||
|
|
||||||
(defun org-roam-buffer--insert-citelinks ()
|
|
||||||
"Insert citation backlinks for the current buffer."
|
|
||||||
(if-let* ((roam-key (with-temp-buffer
|
|
||||||
(insert-buffer-substring org-roam-buffer--current)
|
|
||||||
(org-roam--extract-ref)))
|
|
||||||
(key-backlinks (org-roam--get-backlinks (s-chop-prefix "cite:" roam-key)))
|
|
||||||
(grouped-backlinks (--group-by (nth 0 it) key-backlinks)))
|
|
||||||
(progn
|
|
||||||
(insert (format "\n\n* %d Cite backlinks\n"
|
|
||||||
(length key-backlinks)))
|
|
||||||
(dolist (group grouped-backlinks)
|
|
||||||
(let ((file-from (car group))
|
|
||||||
(bls (cdr group)))
|
|
||||||
(insert (format "** [[file:%s][%s]]\n"
|
|
||||||
file-from
|
|
||||||
(org-roam--get-title-or-slug file-from)))
|
|
||||||
(dolist (backlink bls)
|
|
||||||
(pcase-let ((`(,file-from _ ,props) backlink))
|
|
||||||
(insert (propertize
|
|
||||||
(s-trim (s-replace "\n" " "
|
|
||||||
(plist-get props :content)))
|
|
||||||
'help-echo "mouse-1: visit backlinked note"
|
|
||||||
'file-from file-from
|
|
||||||
'file-from-point (plist-get props :point)))
|
|
||||||
(insert "\n\n"))))))
|
|
||||||
(insert "\n\n* No cite backlinks!")))
|
|
||||||
|
|
||||||
(defun org-roam-buffer--insert-backlinks ()
|
|
||||||
"Insert the org-roam-buffer backlinks string for the current buffer."
|
|
||||||
(if-let* ((file-path (buffer-file-name org-roam-buffer--current))
|
|
||||||
(backlinks (org-roam--get-backlinks file-path))
|
|
||||||
(grouped-backlinks (--group-by (nth 0 it) backlinks)))
|
|
||||||
(progn
|
|
||||||
(insert (format "\n\n* %d Backlinks\n"
|
|
||||||
(length backlinks)))
|
|
||||||
(dolist (group grouped-backlinks)
|
|
||||||
(let ((file-from (car group))
|
|
||||||
(bls (cdr group)))
|
|
||||||
(insert (format "** [[file:%s][%s]]\n"
|
|
||||||
file-from
|
|
||||||
(org-roam--get-title-or-slug file-from)))
|
|
||||||
(dolist (backlink bls)
|
|
||||||
(pcase-let ((`(,file-from _ ,props) backlink))
|
|
||||||
(insert (propertize
|
|
||||||
(s-trim (s-replace "\n" " "
|
|
||||||
(plist-get props :content)))
|
|
||||||
'help-echo "mouse-1: visit backlinked note"
|
|
||||||
'file-from file-from
|
|
||||||
'file-from-point (plist-get props :point)))
|
|
||||||
(insert "\n\n"))))))
|
|
||||||
(insert "\n\n* No backlinks!")))
|
|
||||||
|
|
||||||
(defun org-roam-buffer-update ()
|
|
||||||
"Update the `org-roam-buffer'."
|
|
||||||
(org-roam-db--ensure-built)
|
|
||||||
(let* ((source-org-roam-directory org-roam-directory))
|
|
||||||
(with-current-buffer org-roam-buffer
|
|
||||||
;; When dir-locals.el is used to override org-roam-directory,
|
|
||||||
;; org-roam-buffer should have a different local org-roam-directory and
|
|
||||||
;; default-directory, as relative links are relative from the overridden
|
|
||||||
;; org-roam-directory.
|
|
||||||
(setq-local org-roam-directory source-org-roam-directory)
|
|
||||||
(setq-local default-directory source-org-roam-directory)
|
|
||||||
;; Locally overwrite the file opening function to re-use the
|
|
||||||
;; last window org-roam was called from
|
|
||||||
(setq-local org-link-frame-setup
|
|
||||||
(cons '(file . org-roam--find-file) org-link-frame-setup))
|
|
||||||
(let ((inhibit-read-only t))
|
|
||||||
(erase-buffer)
|
|
||||||
(unless (eq major-mode 'org-mode)
|
|
||||||
(org-mode))
|
|
||||||
(unless org-roam-backlinks-mode
|
|
||||||
(org-roam-backlinks-mode))
|
|
||||||
(make-local-variable 'org-return-follows-link)
|
|
||||||
(setq org-return-follows-link t)
|
|
||||||
(run-hooks 'org-roam-buffer-prepare-hook)
|
|
||||||
(read-only-mode 1)))))
|
|
||||||
|
|
||||||
(cl-defun org-roam-buffer--update-maybe (&key redisplay)
|
|
||||||
"Reconstructs `org-roam-buffer'.
|
|
||||||
This needs to be quick or infrequent, because this is run at
|
|
||||||
`post-command-hook'. If REDISPLAY, force an update of
|
|
||||||
`org-roam-buffer'."
|
|
||||||
(let ((buffer (window-buffer)))
|
|
||||||
(when (and (or redisplay
|
|
||||||
(not (eq org-roam-buffer--current buffer)))
|
|
||||||
(eq 'visible (org-roam-buffer--visibility))
|
|
||||||
(buffer-local-value 'buffer-file-truename buffer))
|
|
||||||
(setq org-roam-buffer--current buffer)
|
|
||||||
(org-roam-buffer-update))))
|
|
||||||
|
|
||||||
;;;; Toggling the org-roam buffer
|
|
||||||
(define-inline org-roam-buffer--visibility ()
|
|
||||||
"Return whether the current visibility state of the org-roam buffer.
|
|
||||||
Valid states are 'visible, 'exists and 'none."
|
|
||||||
(declare (side-effect-free t))
|
|
||||||
(inline-quote
|
|
||||||
(cond
|
|
||||||
((get-buffer-window org-roam-buffer) 'visible)
|
|
||||||
((get-buffer org-roam-buffer) 'exists)
|
|
||||||
(t 'none))))
|
|
||||||
|
|
||||||
(defun org-roam-buffer--set-width (width)
|
|
||||||
"Set the width of `org-roam-buffer' to `WIDTH'."
|
|
||||||
(unless (one-window-p)
|
|
||||||
(let ((window-size-fixed)
|
|
||||||
(w (max width window-min-width)))
|
|
||||||
(cond
|
|
||||||
((> (window-width) w)
|
|
||||||
(shrink-window-horizontally (- (window-width) w)))
|
|
||||||
((< (window-width) w)
|
|
||||||
(enlarge-window-horizontally (- w (window-width))))))))
|
|
||||||
|
|
||||||
(defun org-roam-buffer--set-height (height)
|
|
||||||
"Set the height of `org-roam-buffer' to `HEIGHT'."
|
|
||||||
(unless (one-window-p)
|
|
||||||
(let ((window-size-fixed)
|
|
||||||
(h (max height window-min-height)))
|
|
||||||
(cond
|
|
||||||
((> (window-height) h)
|
|
||||||
(shrink-window (- (window-height) h)))
|
|
||||||
((< (window-height) h)
|
|
||||||
(enlarge-window (- h (window-height))))))))
|
|
||||||
|
|
||||||
(defun org-roam-buffer--get-create ()
|
|
||||||
"Set up the `org-roam' buffer at `org-roam-buffer-position'."
|
|
||||||
(let ((window (get-buffer-window))
|
|
||||||
(position
|
|
||||||
(if (member org-roam-buffer-position '(right left top bottom))
|
|
||||||
org-roam-buffer-position
|
|
||||||
(let ((text-quoting-style 'grave))
|
|
||||||
(lwarn '(org-roam) :error
|
|
||||||
"Invalid org-roam-buffer-position: %s. Defaulting to \\='right"
|
|
||||||
org-roam-buffer-position))
|
|
||||||
'right)))
|
|
||||||
(-> (get-buffer-create org-roam-buffer)
|
|
||||||
(display-buffer-in-side-window
|
|
||||||
`((side . ,position)
|
|
||||||
(window-parameters . ((no-delete-other-windows . ,org-roam-buffer-no-delete-other-windows)))))
|
|
||||||
(select-window))
|
|
||||||
(pcase position
|
|
||||||
((or 'right 'left)
|
|
||||||
(org-roam-buffer--set-width (round (* (frame-width) org-roam-buffer-width))))
|
|
||||||
((or 'top 'bottom)
|
|
||||||
(org-roam-buffer--set-height (round (* (frame-height) org-roam-buffer-height)))))
|
|
||||||
(select-window window)))
|
|
||||||
|
|
||||||
(defun org-roam-buffer-toggle-display ()
|
|
||||||
"Toggle display of the `org-roam-buffer'."
|
|
||||||
(interactive)
|
|
||||||
(setq org-roam-last-window (get-buffer-window))
|
|
||||||
(pcase (org-roam-buffer--visibility)
|
|
||||||
('visible (delete-window (get-buffer-window org-roam-buffer)))
|
|
||||||
((or 'exists 'none) (org-roam-buffer--get-create))))
|
|
||||||
|
|
||||||
(provide 'org-roam-buffer)
|
|
||||||
|
|
||||||
;;; org-roam-buffer.el ends here
|
|
File diff suppressed because it is too large
Load Diff
@ -1,12 +1,12 @@
|
|||||||
;;; org-roam-compat.el --- Compatibility Code -*- coding: utf-8; lexical-binding: t -*-
|
;;; org-roam-compat.el --- Compatibility Code -*- coding: utf-8; lexical-binding: t; -*-
|
||||||
|
|
||||||
;; Copyright © 2020 Jethro Kuan <jethrokuan95@gmail.com>
|
;; Copyright © 2020 Jethro Kuan <jethrokuan95@gmail.com>
|
||||||
|
|
||||||
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
||||||
;; URL: https://github.com/jethrokuan/org-roam
|
;; URL: https://github.com/org-roam/org-roam
|
||||||
;; Keywords: org-mode, roam, convenience
|
;; Keywords: org-mode, roam, convenience
|
||||||
;; Version: 1.1.0
|
;; Version: 2.0.0
|
||||||
;; Package-Requires: ((emacs "26.1") (dash "2.13") (f "0.17.2") (s "1.12.0") (org "9.3") (emacsql "3.0.0") (emacsql-sqlite "1.0.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 "2.90.1"))
|
||||||
|
|
||||||
;; This file is NOT part of GNU Emacs.
|
;; This file is NOT part of GNU Emacs.
|
||||||
|
|
||||||
@ -34,62 +34,7 @@
|
|||||||
;;;; Library Requires
|
;;;; Library Requires
|
||||||
|
|
||||||
;;; Obsolete aliases (remove after next major release)
|
;;; Obsolete aliases (remove after next major release)
|
||||||
;;;; Functions
|
;;; Obsolete functions
|
||||||
(define-obsolete-function-alias 'org-roam--capture-get-point 'org-roam-capture--get-point
|
|
||||||
"org-roam 1.0.0")
|
|
||||||
(define-obsolete-function-alias 'org-roam-build-cache 'org-roam-db-build-cache
|
|
||||||
"org-roam 1.0.0")
|
|
||||||
(define-obsolete-function-alias 'org-roam-sql 'org-roam-db-query
|
|
||||||
"org-roam 1.0.0")
|
|
||||||
(define-obsolete-function-alias 'org-roam--get-db 'org-roam-db--get
|
|
||||||
"org-roam 1.0.0")
|
|
||||||
(define-obsolete-function-alias 'org-roam--db-clear 'org-roam-db--clear
|
|
||||||
"org-roam 1.0.0")
|
|
||||||
(define-obsolete-function-alias 'org-roam-show-graph 'org-roam-graph-show
|
|
||||||
"org-roam 1.0.0")
|
|
||||||
(define-obsolete-function-alias 'org-roam--maybe-update-buffer
|
|
||||||
'org-roam-buffer--update-maybe "org-roam 1.0.0")
|
|
||||||
(define-obsolete-function-alias 'org-roam--current-visibility
|
|
||||||
'org-roam-buffer--visibility "org-roam 1.0.0")
|
|
||||||
(define-obsolete-function-alias 'org-roam-update 'org-roam-buffer-update
|
|
||||||
"org-roam 1.0.0")
|
|
||||||
(define-obsolete-function-alias 'org-roam--set-width 'org-roam-buffer--set-width
|
|
||||||
"org-roam 1.0.0")
|
|
||||||
(define-obsolete-function-alias 'org-roam--set-height 'org-roam-buffer--set-height
|
|
||||||
"org-roam 1.0.0")
|
|
||||||
(define-obsolete-function-alias 'org-roam--set-up-buffer 'org-roam-buffer--get-create
|
|
||||||
"org-roam 1.0.0")
|
|
||||||
(define-obsolete-function-alias 'org-roam-today 'org-roam-dailies-today
|
|
||||||
"org-roam 1.0.0")
|
|
||||||
(define-obsolete-function-alias 'org-roam-tomorrow 'org-roam-dailies-tomorrow
|
|
||||||
"org-roam 1.0.0")
|
|
||||||
(define-obsolete-function-alias 'org-roam-yesterday 'org-roam-dailies-yesterday
|
|
||||||
"org-roam 1.0.0")
|
|
||||||
(define-obsolete-function-alias 'org-roam-date 'org-roam-dailies-date
|
|
||||||
"org-roam 1.0.0")
|
|
||||||
(define-obsolete-function-alias 'org-roam-graph-show 'org-roam-graph
|
|
||||||
"org-roam 1.0.0")
|
|
||||||
(define-obsolete-function-alias 'org-roam-graph-build 'org-roam-graph
|
|
||||||
"org-roam 1.0.0")
|
|
||||||
|
|
||||||
;;;; Variables
|
|
||||||
(define-obsolete-variable-alias 'org-roam-graphviz-extra-options
|
|
||||||
'org-roam-graph-extra-config "org-roam 1.0.0")
|
|
||||||
(define-obsolete-variable-alias 'org-roam-grapher-extra-options
|
|
||||||
'org-roam-graph-extra-config "org-roam 1.0.0")
|
|
||||||
(make-obsolete-variable 'org-roam-graph-node-shape 'org-roam-graph-node-extra-config "org-roam 1.0.0")
|
|
||||||
(defcustom org-roam-graph-node-shape "ellipse"
|
|
||||||
"Shape of graph nodes."
|
|
||||||
:type 'string
|
|
||||||
:group 'org-roam)
|
|
||||||
(define-obsolete-variable-alias 'org-roam--db-connection
|
|
||||||
'org-roam-db--connection "org-roam 1.0.0")
|
|
||||||
(define-obsolete-variable-alias 'org-roam--current-buffer
|
|
||||||
'org-roam-buffer--current "org-roam 1.0.0")
|
|
||||||
(define-obsolete-variable-alias 'org-roam-date-title-format
|
|
||||||
'org-roam-dailies-capture-templates "org-roam 1.0.0")
|
|
||||||
(define-obsolete-variable-alias 'org-roam-date-filename-format
|
|
||||||
'org-roam-dailies-capture-templates "org-roam 1.0.0")
|
|
||||||
|
|
||||||
(provide 'org-roam-compat)
|
(provide 'org-roam-compat)
|
||||||
|
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
;;; org-roam-completion.el --- Roam Research replica with Org-mode -*- coding: utf-8; lexical-binding: t -*-
|
;;; org-roam-completion.el --- Completion features -*- coding: utf-8; lexical-binding: t; -*-
|
||||||
|
|
||||||
;; Copyright © 2020 Jethro Kuan <jethrokuan95@gmail.com>
|
;; Copyright © 2020 Jethro Kuan <jethrokuan95@gmail.com>
|
||||||
|
|
||||||
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
||||||
;; URL: https://github.com/jethrokuan/org-roam
|
;; URL: https://github.com/org-roam/org-roam
|
||||||
;; Keywords: org-mode, roam, convenience
|
;; Keywords: org-mode, roam, convenience
|
||||||
;; Version: 1.1.0
|
;; Version: 2.0.0
|
||||||
;; Package-Requires: ((emacs "26.1") (dash "2.13") (f "0.17.2") (s "1.12.0") (org "9.3") (emacsql "3.0.0") (emacsql-sqlite "1.0.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 "2.90.1"))
|
||||||
|
|
||||||
;; This file is NOT part of GNU Emacs.
|
;; This file is NOT part of GNU Emacs.
|
||||||
|
|
||||||
;; This program is free software; you can redistribute it and/or modify
|
;; This program is free software; you can redistribute it and/or modify
|
||||||
@ -27,92 +26,107 @@
|
|||||||
|
|
||||||
;;; Commentary:
|
;;; Commentary:
|
||||||
;;
|
;;
|
||||||
;; This library provides completion for org-roam.
|
;; This library provides completion-at-point functions for Org-roam.
|
||||||
|
;;
|
||||||
|
;; The two main functions provided to capf are:
|
||||||
|
;;
|
||||||
|
;; `org-roam-complete-link-at-point' provides completions to nodes
|
||||||
|
;; within link brackets
|
||||||
|
;;
|
||||||
|
;; `org-roam-complete-everywhere' provides completions for nodes everywhere,
|
||||||
|
;; matching the symbol at point
|
||||||
|
;;
|
||||||
;;; Code:
|
;;; Code:
|
||||||
;;;; Library Requires
|
|
||||||
(require 'cl-lib)
|
(require 'cl-lib)
|
||||||
(require 's)
|
(require 'org-element)
|
||||||
|
|
||||||
(defvar helm-pattern)
|
(declare-function org-roam--get-titles "org-roam")
|
||||||
(declare-function helm "ext:helm")
|
|
||||||
(declare-function helm-make-source "ext:helm-source" (name class &rest args) t)
|
|
||||||
|
|
||||||
(defcustom org-roam-completion-system 'default
|
(defcustom org-roam-completion-ignore-case t
|
||||||
"The completion system to be used by `org-roam'."
|
"Whether to ignore case in Org-roam `completion-at-point' completions."
|
||||||
:type '(radio
|
:group 'org-roam
|
||||||
(const :tag "Default" default)
|
:type 'boolean)
|
||||||
(const :tag "Ido" ido)
|
|
||||||
(const :tag "Ivy" ivy)
|
|
||||||
(const :tag "Helm" helm)
|
|
||||||
(function :tag "Custom function"))
|
|
||||||
:group 'org-roam)
|
|
||||||
|
|
||||||
(defcustom org-roam-completion-fuzzy-match nil
|
(defcustom org-roam-completion-everywhere nil
|
||||||
"Whether to fuzzy match Org-roam's completion candidates."
|
"When non-nil, provide link completion matching outside of Org links."
|
||||||
:type 'boolean
|
:group 'org-roam
|
||||||
:group 'org-roam)
|
:type 'boolean)
|
||||||
|
|
||||||
(defun org-roam-completion--helm-candidate-transformer (candidates _source)
|
(defvar org-roam-completion-functions (list #'org-roam-complete-link-at-point
|
||||||
"Transforms CANDIDATES for Helm-based completing read.
|
#'org-roam-complete-everywhere)
|
||||||
SOURCE is not used."
|
"List of functions to be used with `completion-at-point' for Org-roam.")
|
||||||
(let ((prefix (propertize "[?] "
|
|
||||||
'face 'helm-ff-prefix)))
|
|
||||||
(cons (propertize helm-pattern
|
|
||||||
'display (concat prefix helm-pattern))
|
|
||||||
candidates)))
|
|
||||||
|
|
||||||
(cl-defun org-roam-completion--completing-read (prompt choices &key
|
(defun org-roam-complete-everywhere ()
|
||||||
require-match initial-input
|
"Provides completions for links for any word at point.
|
||||||
action)
|
This is a `completion-at-point' function, and is active when
|
||||||
"Present a PROMPT with CHOICES and optional INITIAL-INPUT.
|
`org-roam-completion-everywhere' is non-nil."
|
||||||
If REQUIRE-MATCH is t, the user must select one of the CHOICES.
|
(let ((end (point))
|
||||||
Return user choice."
|
(start (point))
|
||||||
(let (res)
|
(exit-fn (lambda (&rest _) nil))
|
||||||
(setq res
|
collection)
|
||||||
(cond
|
(when (and org-roam-completion-everywhere
|
||||||
((eq org-roam-completion-system 'ido)
|
(thing-at-point 'word)
|
||||||
(let ((candidates (mapcar #'car choices)))
|
(not (save-match-data (org-in-regexp org-link-any-re))))
|
||||||
(ido-completing-read prompt candidates nil require-match initial-input)))
|
(let ((bounds (bounds-of-thing-at-point 'word)))
|
||||||
((eq org-roam-completion-system 'default)
|
(setq start (car bounds)
|
||||||
(completing-read prompt choices nil require-match initial-input))
|
end (cdr bounds)
|
||||||
((eq org-roam-completion-system 'ivy)
|
collection #'org-roam--get-titles
|
||||||
(if (fboundp 'ivy-read)
|
exit-fn (lambda (str _status)
|
||||||
(ivy-read prompt choices
|
(delete-char (- (length str)))
|
||||||
:initial-input initial-input
|
(insert "[[roam:" str "]]")))))
|
||||||
:require-match require-match
|
(when collection
|
||||||
:action (prog1 action
|
(let ((prefix (buffer-substring-no-properties start end)))
|
||||||
(setq action nil))
|
(list start end
|
||||||
:caller 'org-roam--completing-read
|
(if (functionp collection)
|
||||||
:re-builder (if org-roam-completion-fuzzy-match 'ivy--regex-fuzzy
|
(completion-table-case-fold
|
||||||
'regexp-quote))
|
(completion-table-dynamic
|
||||||
(user-error "Please install ivy from \
|
(lambda (_)
|
||||||
https://github.com/abo-abo/swiper")))
|
(cl-remove-if (apply-partially #'string= prefix)
|
||||||
((eq org-roam-completion-system 'helm)
|
(funcall collection))))
|
||||||
(unless (and (fboundp 'helm)
|
(not org-roam-completion-ignore-case))
|
||||||
(fboundp 'helm-make-source))
|
collection)
|
||||||
(user-error "Please install helm from \
|
:exit-function exit-fn)))))
|
||||||
https://github.com/emacs-helm/helm"))
|
|
||||||
(let ((source (helm-make-source prompt 'helm-source-sync
|
(defun org-roam-complete-link-at-point ()
|
||||||
:candidates (mapcar #'car choices)
|
"Do appropriate completion for the link at point."
|
||||||
:filtered-candidate-transformer
|
(let ((end (point))
|
||||||
(and (not require-match)
|
(start (point))
|
||||||
#'org-roam-completion--helm-candidate-transformer)
|
collection link-type)
|
||||||
:fuzzy-match org-roam-completion-fuzzy-match))
|
(when (org-in-regexp org-link-bracket-re 1)
|
||||||
(buf (concat "*org-roam "
|
(setq start (match-beginning 1)
|
||||||
(s-downcase (s-chop-suffix ":" (s-trim prompt)))
|
end (match-end 1))
|
||||||
"*")))
|
(let ((context (org-element-context)))
|
||||||
(or (helm :sources source
|
(pcase (org-element-lineage context '(link) t)
|
||||||
:action (if action
|
(`nil nil)
|
||||||
(prog1 action
|
(link
|
||||||
(setq action nil))
|
(setq link-type (org-element-property :type link))
|
||||||
#'identity)
|
(when (member link-type '("roam" "fuzzy"))
|
||||||
:prompt prompt
|
(when (string= link-type "roam") (setq start (+ start (length "roam:"))))
|
||||||
:input initial-input
|
(setq collection #'org-roam--get-titles))))))
|
||||||
:buffer buf)
|
(when collection
|
||||||
(keyboard-quit))))))
|
(let ((prefix (buffer-substring-no-properties start end)))
|
||||||
(if action
|
(list start end
|
||||||
(funcall action res)
|
(if (functionp collection)
|
||||||
res)))
|
(completion-table-case-fold
|
||||||
|
(completion-table-dynamic
|
||||||
|
(lambda (_)
|
||||||
|
(cl-remove-if (apply-partially #'string= prefix)
|
||||||
|
(funcall collection))))
|
||||||
|
(not org-roam-completion-ignore-case))
|
||||||
|
collection)
|
||||||
|
:exit-function
|
||||||
|
(lambda (str &rest _)
|
||||||
|
(delete-char (- 0 (length str)))
|
||||||
|
(insert (concat (unless (string= link-type "roam") "roam:")
|
||||||
|
str))
|
||||||
|
(forward-char 2)))))))
|
||||||
|
|
||||||
|
(defun org-roam--register-completion-functions ()
|
||||||
|
"."
|
||||||
|
(dolist (fn org-roam-completion-functions)
|
||||||
|
(add-hook 'completion-at-point-functions fn nil t)))
|
||||||
|
|
||||||
|
(add-hook 'org-roam-find-file-hook #'org-roam--register-completion-functions)
|
||||||
|
|
||||||
(provide 'org-roam-completion)
|
(provide 'org-roam-completion)
|
||||||
|
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
;;; org-roam-dialies.el --- Roam Research replica with Org-mode -*- coding: utf-8; lexical-binding: t -*-
|
;;; org-roam-dailies.el --- Daily-notes for Org-roam -*- coding: utf-8; lexical-binding: t; -*-
|
||||||
;;;
|
;;;
|
||||||
;; Copyright © 2020 Jethro Kuan <jethrokuan95@gmail.com>
|
;; Copyright © 2020 Jethro Kuan <jethrokuan95@gmail.com>
|
||||||
|
;; Copyright © 2020 Leo Vivier <leo.vivier+dev@gmail.com>
|
||||||
|
|
||||||
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
||||||
;; URL: https://github.com/jethrokuan/org-roam
|
;; Leo Vivier <leo.vivier+dev@gmail.com>
|
||||||
|
;; URL: https://github.com/org-roam/org-roam
|
||||||
;; Keywords: org-mode, roam, convenience
|
;; Keywords: org-mode, roam, convenience
|
||||||
;; Version: 1.1.0
|
;; Version: 2.0.0
|
||||||
;; Package-Requires: ((emacs "26.1") (dash "2.13") (f "0.17.2") (s "1.12.0") (org "9.3") (emacsql "3.0.0") (emacsql-sqlite "1.0.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 "2.90.1"))
|
||||||
|
|
||||||
;; This file is NOT part of GNU Emacs.
|
;; This file is NOT part of GNU Emacs.
|
||||||
|
|
||||||
@ -27,55 +29,319 @@
|
|||||||
|
|
||||||
;;; Commentary:
|
;;; Commentary:
|
||||||
;;
|
;;
|
||||||
;; This library provides functionality for creating daily notes. This is a
|
;; This library provides functionality for creating daily-notes. This is a
|
||||||
;; concept borrowed from Roam Research.
|
;; concept borrowed from Roam Research.
|
||||||
;;
|
;;
|
||||||
;;; Code:
|
;;; Code:
|
||||||
;;; Library Requires
|
;;; Library Requires
|
||||||
(require 'org-capture)
|
(require 'org-capture)
|
||||||
(require 'org-roam-capture)
|
(require 'org-roam-capture)
|
||||||
|
(require 'f)
|
||||||
|
|
||||||
(defvar org-roam-dailies-capture-templates
|
;;;; Declarations
|
||||||
'(("d" "daily" plain (function org-roam-capture--get-point)
|
(defvar org-roam-directory)
|
||||||
""
|
(defvar org-roam-file-extensions)
|
||||||
:immediate-finish t
|
(declare-function org-roam--org-file-p "org-roam")
|
||||||
:file-name "%<%Y-%m-%d>"
|
|
||||||
:head "#+TITLE: %<%Y-%m-%d>"))
|
|
||||||
"Capture templates for daily notes in Org-roam.")
|
|
||||||
|
|
||||||
;; Declarations
|
;;;; Faces
|
||||||
(declare-function org-roam--file-path-from-id "org-roam")
|
(defface org-roam-dailies-calendar-note
|
||||||
|
'((t :inherit (org-link) :underline nil))
|
||||||
|
"Face for dates with a daily-note in the calendar."
|
||||||
|
:group 'org-roam-faces)
|
||||||
|
|
||||||
(defun org-roam-dailies--file-for-time (time)
|
;;;; Customizable variables
|
||||||
"Create and find file for TIME."
|
(defcustom org-roam-dailies-directory "daily/"
|
||||||
(let ((org-roam-capture-templates org-roam-dailies-capture-templates)
|
"Path to daily-notes."
|
||||||
(org-roam-capture--info (list (cons 'time time)))
|
:group 'org-roam
|
||||||
(org-roam-capture--context 'dailies))
|
:type 'string)
|
||||||
(add-hook 'org-capture-after-finalize-hook #'org-roam-capture--find-file-h)
|
|
||||||
(org-roam--capture)))
|
|
||||||
|
|
||||||
(defun org-roam-dailies-today ()
|
(defcustom org-roam-dailies-find-file-hook nil
|
||||||
"Create and find the daily note for today."
|
"Hook that is run right after navigating to a daily-note."
|
||||||
|
:group 'org-roam
|
||||||
|
:type 'hook)
|
||||||
|
|
||||||
|
(defcustom org-roam-dailies-capture-templates
|
||||||
|
`(("d" "default" entry
|
||||||
|
"* %?"
|
||||||
|
:if-new (file+head ,(expand-file-name "%<%Y-%m-%d>.org" org-roam-dailies-directory)
|
||||||
|
"#+title: %<%Y-%m-%d>\n")))
|
||||||
|
"Capture templates for daily-notes in Org-roam.
|
||||||
|
See `org-roam-capture-templates' for the template documentation."
|
||||||
|
:group 'org-roam
|
||||||
|
:type '(repeat
|
||||||
|
(choice (list :tag "Multikey description"
|
||||||
|
(string :tag "Keys ")
|
||||||
|
(string :tag "Description"))
|
||||||
|
(list :tag "Template entry"
|
||||||
|
(string :tag "Keys ")
|
||||||
|
(string :tag "Description ")
|
||||||
|
(choice :tag "Capture Type " :value entry
|
||||||
|
(const :tag "Org entry" entry)
|
||||||
|
(const :tag "Plain list item" item)
|
||||||
|
(const :tag "Checkbox item" checkitem)
|
||||||
|
(const :tag "Plain text" plain)
|
||||||
|
(const :tag "Table line" table-line))
|
||||||
|
(choice :tag "Template "
|
||||||
|
(string)
|
||||||
|
(list :tag "File"
|
||||||
|
(const :format "" file)
|
||||||
|
(file :tag "Template file"))
|
||||||
|
(list :tag "Function"
|
||||||
|
(const :format "" function)
|
||||||
|
(function :tag "Template function")))
|
||||||
|
(plist :inline t
|
||||||
|
;; Give the most common options as checkboxes
|
||||||
|
:options (((const :format "%v " :if-new)
|
||||||
|
(choice :tag "Node location"
|
||||||
|
(list :tag "File"
|
||||||
|
(const :format "" file)
|
||||||
|
(string :tag " File"))
|
||||||
|
(list :tag "File & Head Content"
|
||||||
|
(const :format "" file+head)
|
||||||
|
(string :tag " File")
|
||||||
|
(string :tag " Head Content"))
|
||||||
|
(list :tag "File & Outline path"
|
||||||
|
(const :format "" file+olp)
|
||||||
|
(string :tag " File")
|
||||||
|
(list :tag "Outline path"
|
||||||
|
(repeat string :tag "Headline")))
|
||||||
|
(list :tag "File & Head Content & Outline path"
|
||||||
|
(const :format "" file+head+olp)
|
||||||
|
(string :tag " File")
|
||||||
|
(string :tag " Head Content")
|
||||||
|
(list :tag "Outline path"
|
||||||
|
(repeat string :tag "Headline")))))
|
||||||
|
((const :format "%v " :prepend) (const t))
|
||||||
|
((const :format "%v " :immediate-finish) (const t))
|
||||||
|
((const :format "%v " :jump-to-captured) (const t))
|
||||||
|
((const :format "%v " :empty-lines) (const 1))
|
||||||
|
((const :format "%v " :empty-lines-before) (const 1))
|
||||||
|
((const :format "%v " :empty-lines-after) (const 1))
|
||||||
|
((const :format "%v " :clock-in) (const t))
|
||||||
|
((const :format "%v " :clock-keep) (const t))
|
||||||
|
((const :format "%v " :clock-resume) (const t))
|
||||||
|
((const :format "%v " :time-prompt) (const t))
|
||||||
|
((const :format "%v " :tree-type) (const week))
|
||||||
|
((const :format "%v " :unnarrowed) (const t))
|
||||||
|
((const :format "%v " :table-line-pos) (string))
|
||||||
|
((const :format "%v " :kill-buffer) (const t))))))))
|
||||||
|
|
||||||
|
;;;; Utilities
|
||||||
|
(defun org-roam-dailies-directory--get-absolute-path ()
|
||||||
|
"Get absolute path to `org-roam-dailies-directory'."
|
||||||
|
(expand-file-name org-roam-dailies-directory org-roam-directory))
|
||||||
|
|
||||||
|
(defun org-roam-dailies-find-directory ()
|
||||||
|
"Find and open `org-roam-dailies-directory'."
|
||||||
(interactive)
|
(interactive)
|
||||||
(org-roam-dailies--file-for-time (current-time)))
|
(find-file (org-roam-dailies-directory--get-absolute-path)))
|
||||||
|
|
||||||
(defun org-roam-dailies-tomorrow (n)
|
(defun org-roam-dailies--daily-note-p (&optional file)
|
||||||
"Create and find the daily note for tomorrow.
|
"Return t if FILE is an Org-roam daily-note, nil otherwise.
|
||||||
With numeric argument N, use N days in the future."
|
|
||||||
(interactive "p")
|
|
||||||
(org-roam-dailies--file-for-time (time-add (* n 86400) (current-time))))
|
|
||||||
|
|
||||||
(defun org-roam-dailies-yesterday (n)
|
If FILE is not specified, use the current buffer's file-path."
|
||||||
"Create and find the file for yesterday.
|
(when-let ((path (or file
|
||||||
With numeric argument N, use N days in the past."
|
(buffer-base-buffer (buffer-file-name))))
|
||||||
(interactive "p")
|
(directory (org-roam-dailies-directory--get-absolute-path)))
|
||||||
(org-roam-tomorrow (- n)))
|
(setq path (expand-file-name path))
|
||||||
|
(save-match-data
|
||||||
|
(and
|
||||||
|
(org-roam--org-file-p path)
|
||||||
|
(f-descendant-of-p path directory)))))
|
||||||
|
|
||||||
(defun org-roam-dailies-date ()
|
(defun org-roam-dailies--capture (time &optional goto)
|
||||||
"Create the file for any date using the calendar interface."
|
"Capture an entry in a daily-note for TIME, creating it if necessary.
|
||||||
|
|
||||||
|
When GOTO is non-nil, go the note without creating an entry."
|
||||||
|
(org-roam-capture- :goto (when goto '(4))
|
||||||
|
:node (org-roam-node-create)
|
||||||
|
:templates org-roam-dailies-capture-templates
|
||||||
|
:props (list :default-time time)))
|
||||||
|
|
||||||
|
;;;; Commands
|
||||||
|
;;; Today
|
||||||
|
(defun org-roam-dailies-capture-today (&optional goto)
|
||||||
|
"Create an entry in the daily-note for today.
|
||||||
|
|
||||||
|
When GOTO is non-nil, go the note without creating an entry."
|
||||||
|
(interactive "P")
|
||||||
|
(org-roam-dailies--capture (current-time) goto)
|
||||||
|
(when goto
|
||||||
|
(run-hooks 'org-roam-dailies-find-file-hook)))
|
||||||
|
|
||||||
|
(defun org-roam-dailies-find-today ()
|
||||||
|
"Find the daily-note for today, creating it if necessary."
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((time (org-read-date nil 'to-time nil "Date: ")))
|
(org-roam-dailies-capture-today t))
|
||||||
(org-roam-dailies--file-for-time time)))
|
|
||||||
|
;;; Tomorrow
|
||||||
|
(defun org-roam-dailies-capture-tomorrow (n &optional goto)
|
||||||
|
"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."
|
||||||
|
(interactive "p")
|
||||||
|
(org-roam-dailies--capture (time-add (* n 86400) (current-time)) goto))
|
||||||
|
|
||||||
|
(defun org-roam-dailies-find-tomorrow (n)
|
||||||
|
"Find the daily-note for tomorrow, creating it if necessary.
|
||||||
|
|
||||||
|
With numeric argument N, use the daily-note N days in the
|
||||||
|
future."
|
||||||
|
(interactive "p")
|
||||||
|
(org-roam-dailies-capture-tomorrow n t))
|
||||||
|
|
||||||
|
;;; Yesterday
|
||||||
|
(defun org-roam-dailies-capture-yesterday (n &optional goto)
|
||||||
|
"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."
|
||||||
|
(interactive "p")
|
||||||
|
(org-roam-dailies-capture-tomorrow (- n) goto))
|
||||||
|
|
||||||
|
(defun org-roam-dailies-find-yesterday (n)
|
||||||
|
"Find the daily-note for yesterday, creating it if necessary.
|
||||||
|
|
||||||
|
With numeric argument N, use the daily-note N days in the
|
||||||
|
future."
|
||||||
|
(interactive "p")
|
||||||
|
(org-roam-dailies-capture-tomorrow (- n) t))
|
||||||
|
|
||||||
|
;;; Calendar
|
||||||
|
(defvar org-roam-dailies-calendar-hook (list 'org-roam-dailies-calendar-mark-entries)
|
||||||
|
"Hooks to run when showing the `org-roam-dailies-calendar'.")
|
||||||
|
|
||||||
|
(defun org-roam-dailies-calendar--install-hook ()
|
||||||
|
"Install Org-roam-dailies hooks to calendar."
|
||||||
|
(add-hook 'calendar-today-visible-hook #'org-roam-dailies-calendar--run-hook)
|
||||||
|
(add-hook 'calendar-today-invisible-hook #'org-roam-dailies-calendar--run-hook))
|
||||||
|
|
||||||
|
(defun org-roam-dailies-calendar--run-hook ()
|
||||||
|
"Run Org-roam-dailies hooks to calendar."
|
||||||
|
(run-hooks 'org-roam-dailies-calendar-hook)
|
||||||
|
(remove-hook 'calendar-today-visible-hook #'org-roam-dailies-calendar--run-hook)
|
||||||
|
(remove-hook 'calendar-today-invisible-hook #'org-roam-dailies-calendar--run-hook))
|
||||||
|
|
||||||
|
(defun org-roam-dailies-calendar--file-to-date (&optional file)
|
||||||
|
"Convert FILE to date.
|
||||||
|
|
||||||
|
Return (MONTH DAY YEAR)."
|
||||||
|
(let ((file (or file
|
||||||
|
(buffer-base-buffer (buffer-file-name)))))
|
||||||
|
(cl-destructuring-bind (_ _ _ d m y _ _ _)
|
||||||
|
(org-parse-time-string
|
||||||
|
(file-name-sans-extension
|
||||||
|
(file-name-nondirectory file)))
|
||||||
|
(list m d y))))
|
||||||
|
|
||||||
|
(defun org-roam-dailies-calendar--date-to-time (date)
|
||||||
|
"Convert DATE as returned from the calendar (MONTH DAY YEAR) to a time."
|
||||||
|
(encode-time 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date)))
|
||||||
|
|
||||||
|
(defun org-roam-dailies-calendar-mark-entries ()
|
||||||
|
"Mark days in the calendar for which a daily-note is present."
|
||||||
|
(when (file-exists-p (org-roam-dailies-directory--get-absolute-path))
|
||||||
|
(dolist (date (mapcar #'org-roam-dailies-calendar--file-to-date
|
||||||
|
(org-roam-dailies--list-files)))
|
||||||
|
(when (calendar-date-is-visible-p date)
|
||||||
|
(calendar-mark-visible-date date 'org-roam-dailies-calendar-note)))))
|
||||||
|
|
||||||
|
;;; Date
|
||||||
|
(defun org-roam-dailies-capture-date (&optional goto prefer-future)
|
||||||
|
"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."
|
||||||
|
(interactive "P")
|
||||||
|
(org-roam-dailies-calendar--install-hook)
|
||||||
|
(let* ((time-str (let ((org-read-date-prefer-future prefer-future))
|
||||||
|
(org-read-date nil nil nil (if goto
|
||||||
|
"Find daily-note: "
|
||||||
|
"Capture to daily-note: "))))
|
||||||
|
(time (org-read-date nil t time-str)))
|
||||||
|
(org-roam-dailies--capture time goto)
|
||||||
|
(when goto
|
||||||
|
(run-hooks 'org-roam-dailies-find-file-hook))))
|
||||||
|
|
||||||
|
(defun org-roam-dailies-find-date (&optional prefer-future)
|
||||||
|
"Find the daily-note for a date using the calendar, creating it if necessary.
|
||||||
|
Prefer past dates, unless PREFER-FUTURE is non-nil."
|
||||||
|
(interactive)
|
||||||
|
(org-roam-dailies-capture-date t prefer-future))
|
||||||
|
|
||||||
|
;;; Navigation
|
||||||
|
(defun org-roam-dailies--list-files (&rest extra-files)
|
||||||
|
"List all files in `org-roam-dailies-directory'.
|
||||||
|
EXTRA-FILES can be used to append extra files to the list."
|
||||||
|
(let ((dir (org-roam-dailies-directory--get-absolute-path))
|
||||||
|
(regexp (rx-to-string `(and "." (or ,@org-roam-file-extensions)))))
|
||||||
|
(append (--remove (let ((file (file-name-nondirectory it)))
|
||||||
|
(when (or (auto-save-file-name-p file)
|
||||||
|
(backup-file-name-p file)
|
||||||
|
(string-match "^\\." file))
|
||||||
|
it))
|
||||||
|
(directory-files-recursively dir regexp))
|
||||||
|
extra-files)))
|
||||||
|
|
||||||
|
(defun org-roam-dailies-find-next-note (&optional n)
|
||||||
|
"Find next daily-note.
|
||||||
|
|
||||||
|
With numeric argument N, find note N days in the future. If N is
|
||||||
|
negative, find note N days in the past."
|
||||||
|
(interactive "p")
|
||||||
|
(unless (org-roam-dailies--daily-note-p)
|
||||||
|
(user-error "Not in a daily-note"))
|
||||||
|
(setq n (or n 1))
|
||||||
|
(let* ((dailies (org-roam-dailies--list-files))
|
||||||
|
(position
|
||||||
|
(cl-position-if (lambda (candidate)
|
||||||
|
(string= (buffer-file-name (buffer-base-buffer)) candidate))
|
||||||
|
dailies))
|
||||||
|
note)
|
||||||
|
(unless position
|
||||||
|
(user-error "Can't find current note file - have you saved it yet?"))
|
||||||
|
(pcase n
|
||||||
|
((pred (natnump))
|
||||||
|
(when (eq position (- (length dailies) 1))
|
||||||
|
(user-error "Already at newest note")))
|
||||||
|
((pred (integerp))
|
||||||
|
(when (eq position 0)
|
||||||
|
(user-error "Already at oldest note"))))
|
||||||
|
(setq note (nth (+ position n) dailies))
|
||||||
|
(find-file note)
|
||||||
|
(run-hooks 'org-roam-dailies-find-file-hook)))
|
||||||
|
|
||||||
|
(defun org-roam-dailies-find-previous-note (&optional n)
|
||||||
|
"Find previous daily-note.
|
||||||
|
|
||||||
|
With numeric argument N, find note N days in the past. If N is
|
||||||
|
negative, find note N days in the future."
|
||||||
|
(interactive "p")
|
||||||
|
(let ((n (if n (- n) -1)))
|
||||||
|
(org-roam-dailies-find-next-note n)))
|
||||||
|
|
||||||
|
;;;; Bindings
|
||||||
|
(defvar org-roam-dailies-map (make-sparse-keymap)
|
||||||
|
"Keymap for `org-roam-dailies'.")
|
||||||
|
|
||||||
|
(define-prefix-command 'org-roam-dailies-map)
|
||||||
|
|
||||||
|
(define-key org-roam-dailies-map (kbd "d") #'org-roam-dailies-find-today)
|
||||||
|
(define-key org-roam-dailies-map (kbd "y") #'org-roam-dailies-find-yesterday)
|
||||||
|
(define-key org-roam-dailies-map (kbd "t") #'org-roam-dailies-find-tomorrow)
|
||||||
|
(define-key org-roam-dailies-map (kbd "n") #'org-roam-dailies-capture-today)
|
||||||
|
(define-key org-roam-dailies-map (kbd "f") #'org-roam-dailies-find-next-note)
|
||||||
|
(define-key org-roam-dailies-map (kbd "b") #'org-roam-dailies-find-previous-note)
|
||||||
|
(define-key org-roam-dailies-map (kbd "c") #'org-roam-dailies-find-date)
|
||||||
|
(define-key org-roam-dailies-map (kbd "v") #'org-roam-dailies-capture-date)
|
||||||
|
(define-key org-roam-dailies-map (kbd ".") #'org-roam-dailies-find-directory)
|
||||||
|
|
||||||
(provide 'org-roam-dailies)
|
(provide 'org-roam-dailies)
|
||||||
|
|
||||||
;;; org-roam-dailies.el ends here
|
;;; org-roam-dailies.el ends here
|
||||||
|
580
org-roam-db.el
580
org-roam-db.el
@ -1,12 +1,12 @@
|
|||||||
;;; org-roam-db.el --- Roam Research replica with Org-mode -*- coding: utf-8; lexical-binding: t -*-
|
;;; org-roam-db.el --- Org-roam database API -*- coding: utf-8; lexical-binding: t; -*-
|
||||||
|
|
||||||
;; Copyright © 2020 Jethro Kuan <jethrokuan95@gmail.com>
|
;; Copyright © 2020 Jethro Kuan <jethrokuan95@gmail.com>
|
||||||
|
|
||||||
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
||||||
;; URL: https://github.com/jethrokuan/org-roam
|
;; URL: https://github.com/org-roam/org-roam
|
||||||
;; Keywords: org-mode, roam, convenience
|
;; Keywords: org-mode, roam, convenience
|
||||||
;; Version: 1.1.0
|
;; Version: 2.0.0
|
||||||
;; Package-Requires: ((emacs "26.1") (dash "2.13") (f "0.17.2") (s "1.12.0") (org "9.3") (emacsql "3.0.0") (emacsql-sqlite "1.0.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 "2.90.1"))
|
||||||
|
|
||||||
;; This file is NOT part of GNU Emacs.
|
;; This file is NOT part of GNU Emacs.
|
||||||
|
|
||||||
@ -27,27 +27,36 @@
|
|||||||
|
|
||||||
;;; Commentary:
|
;;; Commentary:
|
||||||
;;
|
;;
|
||||||
;; This library is provides the underlying database api to org-roam
|
;; This library provides the underlying database api to org-roam.
|
||||||
;;
|
;;
|
||||||
;;; Code:
|
;;; Code:
|
||||||
;;;; Library Requires
|
;;;; Library Requires
|
||||||
(eval-when-compile (require 'subr-x))
|
(eval-when-compile (require 'subr-x))
|
||||||
(require 'emacsql)
|
(require 'emacsql)
|
||||||
(require 'emacsql-sqlite)
|
(require 'emacsql-sqlite)
|
||||||
(require 'org-roam-macs)
|
(require 'seq)
|
||||||
|
|
||||||
|
(eval-and-compile
|
||||||
|
(require 'org-roam-macs)
|
||||||
|
;; For `org-with-wide-buffer'
|
||||||
|
(require 'org-macs))
|
||||||
|
(require 'org)
|
||||||
|
(require 'ol)
|
||||||
|
(require 'org-roam-utils)
|
||||||
|
|
||||||
|
(defvar org-roam-find-file-hook)
|
||||||
(defvar org-roam-directory)
|
(defvar org-roam-directory)
|
||||||
(defvar org-roam-verbose)
|
(defvar org-roam-verbose)
|
||||||
|
(defvar org-agenda-files)
|
||||||
|
|
||||||
(declare-function org-roam--extract-titles "org-roam")
|
(declare-function org-roam-id-at-point "org-roam")
|
||||||
(declare-function org-roam--extract-ref "org-roam")
|
(declare-function org-roam--org-roam-file-p "org-roam")
|
||||||
(declare-function org-roam--extract-links "org-roam")
|
(declare-function org-roam--list-all-files "org-roam")
|
||||||
(declare-function org-roam--list-files "org-roam")
|
(declare-function org-roam-node-at-point "org-roam")
|
||||||
(declare-function org-roam-buffer--update-maybe "org-roam-buffer")
|
|
||||||
|
|
||||||
;;;; Options
|
;;;; Options
|
||||||
(defcustom org-roam-db-location nil
|
(defcustom org-roam-db-location (expand-file-name "org-roam.db" user-emacs-directory)
|
||||||
"Location of the Org-roam database.
|
"The full path to file where the Org-roam database is stored.
|
||||||
If this is non-nil, the Org-roam sqlite database is saved here.
|
If this is non-nil, the Org-roam sqlite database is saved here.
|
||||||
|
|
||||||
It is the user's responsibility to set this correctly, especially
|
It is the user's responsibility to set this correctly, especially
|
||||||
@ -55,8 +64,23 @@ when used with multiple Org-roam instances."
|
|||||||
:type 'string
|
:type 'string
|
||||||
:group 'org-roam)
|
:group 'org-roam)
|
||||||
|
|
||||||
(defconst org-roam-db--version 2)
|
(defcustom org-roam-db-gc-threshold gc-cons-threshold
|
||||||
(defconst org-roam-db--sqlite-available-p
|
"The value to temporarily set the `gc-cons-threshold' threshold to.
|
||||||
|
During large, heavy operations like `org-roam-db-sync',
|
||||||
|
many GC operations happen because of the large number of
|
||||||
|
temporary structures generated (e.g. parsed ASTs). Temporarily
|
||||||
|
increasing `gc-cons-threshold' will help reduce the number of GC
|
||||||
|
operations, at the cost of temporary memory usage.
|
||||||
|
|
||||||
|
This defaults to the original value of `gc-cons-threshold', but
|
||||||
|
tweaking this number may lead to better overall performance. For
|
||||||
|
example, to reduce the number of GCs, one may set it to a large
|
||||||
|
value like `most-positive-fixnum'."
|
||||||
|
:type 'int
|
||||||
|
:group 'org-roam)
|
||||||
|
|
||||||
|
(defconst org-roam-db--version 15)
|
||||||
|
(defconst org-roam--sqlite-available-p
|
||||||
(with-demoted-errors "Org-roam initialization: %S"
|
(with-demoted-errors "Org-roam initialization: %S"
|
||||||
(emacsql-sqlite-ensure-binary)
|
(emacsql-sqlite-ensure-binary)
|
||||||
t))
|
t))
|
||||||
@ -65,15 +89,10 @@ when used with multiple Org-roam instances."
|
|||||||
"Database connection to Org-roam database.")
|
"Database connection to Org-roam database.")
|
||||||
|
|
||||||
;;;; Core Functions
|
;;;; Core Functions
|
||||||
(defun org-roam-db--get ()
|
|
||||||
"Return the sqlite db file."
|
|
||||||
(interactive "P")
|
|
||||||
(or org-roam-db-location
|
|
||||||
(expand-file-name "org-roam.db" org-roam-directory)))
|
|
||||||
|
|
||||||
(defun org-roam-db--get-connection ()
|
(defun org-roam-db--get-connection ()
|
||||||
"Return the database connection, if any."
|
"Return the database connection, if any."
|
||||||
(gethash (file-truename org-roam-directory)
|
(gethash (expand-file-name org-roam-directory)
|
||||||
org-roam-db--connection))
|
org-roam-db--connection))
|
||||||
|
|
||||||
(defun org-roam-db ()
|
(defun org-roam-db ()
|
||||||
@ -82,18 +101,17 @@ Initializes and stores the database, and the database connection.
|
|||||||
Performs a database upgrade when required."
|
Performs a database upgrade when required."
|
||||||
(unless (and (org-roam-db--get-connection)
|
(unless (and (org-roam-db--get-connection)
|
||||||
(emacsql-live-p (org-roam-db--get-connection)))
|
(emacsql-live-p (org-roam-db--get-connection)))
|
||||||
(let* ((db-file (org-roam-db--get))
|
(let ((init-db (not (file-exists-p org-roam-db-location))))
|
||||||
(init-db (not (file-exists-p db-file))))
|
(make-directory (file-name-directory org-roam-db-location) t)
|
||||||
(make-directory (file-name-directory db-file) t)
|
(let ((conn (emacsql-sqlite org-roam-db-location)))
|
||||||
(let ((conn (emacsql-sqlite db-file)))
|
|
||||||
(set-process-query-on-exit-flag (emacsql-process conn) nil)
|
(set-process-query-on-exit-flag (emacsql-process conn) nil)
|
||||||
(puthash (file-truename org-roam-directory)
|
(puthash (expand-file-name org-roam-directory)
|
||||||
conn
|
conn
|
||||||
org-roam-db--connection)
|
org-roam-db--connection)
|
||||||
(when init-db
|
(when init-db
|
||||||
(org-roam-db--init conn))
|
(org-roam-db--init conn))
|
||||||
(let* ((version (caar (emacsql conn "PRAGMA user_version")))
|
(let* ((version (caar (emacsql conn "PRAGMA user_version")))
|
||||||
(version (org-roam-db--maybe-update conn version)))
|
(version (org-roam-db--upgrade-maybe conn version)))
|
||||||
(cond
|
(cond
|
||||||
((> version org-roam-db--version)
|
((> version org-roam-db--version)
|
||||||
(emacsql-close conn)
|
(emacsql-close conn)
|
||||||
@ -118,40 +136,71 @@ SQL can be either the emacsql vector representation, or a string."
|
|||||||
(defconst org-roam-db--table-schemata
|
(defconst org-roam-db--table-schemata
|
||||||
'((files
|
'((files
|
||||||
[(file :unique :primary-key)
|
[(file :unique :primary-key)
|
||||||
(hash :not-null)
|
(hash :not-null)])
|
||||||
(last-modified :not-null)])
|
|
||||||
|
|
||||||
(links
|
(nodes
|
||||||
[(from :not-null)
|
([(id :not-null :primary-key)
|
||||||
(to :not-null)
|
(file :not-null)
|
||||||
(type :not-null)
|
(level :not-null)
|
||||||
(properties :not-null)])
|
(pos :not-null)
|
||||||
|
todo
|
||||||
|
priority
|
||||||
|
(scheduled text)
|
||||||
|
(deadline text)
|
||||||
|
title
|
||||||
|
properties
|
||||||
|
olp]
|
||||||
|
(:foreign-key [file] :references files [file] :on-delete :cascade)))
|
||||||
|
|
||||||
(titles
|
(aliases
|
||||||
[(file :not-null)
|
([(node-id :not-null)
|
||||||
titles])
|
alias]
|
||||||
|
(:foreign-key [node-id] :references nodes [id] :on-delete :cascade)))
|
||||||
|
|
||||||
(refs
|
(refs
|
||||||
[(ref :unique :not-null)
|
([(node-id :not-null)
|
||||||
(file :not-null)])))
|
(ref :not-null)
|
||||||
|
(type :not-null)]
|
||||||
|
(:foreign-key [node-id] :references nodes [id] :on-delete :cascade)))
|
||||||
|
|
||||||
|
(tags
|
||||||
|
([(node-id :not-null)
|
||||||
|
tag]
|
||||||
|
(:foreign-key [node-id] :references nodes [id] :on-delete :cascade)))
|
||||||
|
|
||||||
|
(links
|
||||||
|
([(pos :not-null)
|
||||||
|
(source :not-null)
|
||||||
|
(dest :not-null)
|
||||||
|
(type :not-null)
|
||||||
|
(properties :not-null)]
|
||||||
|
(:foreign-key [source] :references nodes [id] :on-delete :cascade)))))
|
||||||
|
|
||||||
|
(defconst org-roam-db--table-indices
|
||||||
|
'((alias-node-id aliases [node-id])
|
||||||
|
(refs-node-id refs [node-id])
|
||||||
|
(tags-node-id tags [node-id])))
|
||||||
|
|
||||||
(defun org-roam-db--init (db)
|
(defun org-roam-db--init (db)
|
||||||
"Initialize database DB with the correct schema and user version."
|
"Initialize database DB with the correct schema and user version."
|
||||||
(emacsql-with-transaction db
|
(emacsql-with-transaction db
|
||||||
(pcase-dolist (`(,table . ,schema) org-roam-db--table-schemata)
|
(emacsql db "PRAGMA foreign_keys = ON")
|
||||||
|
(pcase-dolist (`(,table ,schema) org-roam-db--table-schemata)
|
||||||
(emacsql db [:create-table $i1 $S2] table schema))
|
(emacsql db [:create-table $i1 $S2] table schema))
|
||||||
|
(pcase-dolist (`(,index-name ,table ,columns) org-roam-db--table-indices)
|
||||||
|
(emacsql db [:create-index $i1 :on $i2 $S3] index-name table columns))
|
||||||
(emacsql db (format "PRAGMA user_version = %s" org-roam-db--version))))
|
(emacsql db (format "PRAGMA user_version = %s" org-roam-db--version))))
|
||||||
|
|
||||||
(defun org-roam-db--maybe-update (db version)
|
(defun org-roam-db--upgrade-maybe (db version)
|
||||||
"Upgrades the database schema for DB, if VERSION is old."
|
"Upgrades the database schema for DB, if VERSION is old."
|
||||||
(emacsql-with-transaction db
|
(emacsql-with-transaction db
|
||||||
'ignore
|
'ignore
|
||||||
(when (= version 1)
|
(if (< version org-roam-db--version)
|
||||||
(progn
|
(progn
|
||||||
(warn "No good way to perform a DB upgrade, rebuilding from scratch...")
|
(org-roam-message (format "Upgrading the Org-roam database from version %d to version %d"
|
||||||
(delete-file (org-roam-db--get))
|
version org-roam-db--version))
|
||||||
(org-roam-db-build-cache)))
|
(org-roam-db-sync t))))
|
||||||
version))
|
version)
|
||||||
|
|
||||||
(defun org-roam-db--close (&optional db)
|
(defun org-roam-db--close (&optional db)
|
||||||
"Closes the database connection for database DB.
|
"Closes the database connection for database DB.
|
||||||
@ -168,241 +217,274 @@ the current `org-roam-directory'."
|
|||||||
(org-roam-db--close conn)))
|
(org-roam-db--close conn)))
|
||||||
|
|
||||||
;;;; Database API
|
;;;; Database API
|
||||||
;;;;; Initialization
|
|
||||||
(defun org-roam-db--initialized-p ()
|
|
||||||
"Whether the cache has been initialized."
|
|
||||||
(and (file-exists-p (org-roam-db--get))
|
|
||||||
(> (caar (org-roam-db-query [:select (funcall count) :from titles]))
|
|
||||||
0)))
|
|
||||||
|
|
||||||
(defun org-roam-db--ensure-built ()
|
|
||||||
"Ensures that Org-roam cache is built."
|
|
||||||
(unless (org-roam-db--initialized-p)
|
|
||||||
(error "[Org-roam] your cache isn't built yet! Please run org-roam-db-build-cache")))
|
|
||||||
|
|
||||||
;;;;; Clearing
|
;;;;; Clearing
|
||||||
(defun org-roam-db--clear ()
|
(defun org-roam-db-clear-all ()
|
||||||
"Clears all entries in the caches."
|
"Clears all entries in the Org-roam cache."
|
||||||
(interactive)
|
(interactive)
|
||||||
(when (file-exists-p (org-roam-db--get))
|
(when (file-exists-p org-roam-db-location)
|
||||||
(org-roam-db-query [:delete :from files])
|
(dolist (table (mapcar #'car org-roam-db--table-schemata))
|
||||||
(org-roam-db-query [:delete :from titles])
|
(org-roam-db-query `[:delete :from ,table]))))
|
||||||
(org-roam-db-query [:delete :from links])
|
|
||||||
(org-roam-db-query [:delete :from refs])))
|
|
||||||
|
|
||||||
|
(defun org-roam-db-clear-file (&optional file)
|
||||||
(defun org-roam-db--clear-file (&optional filepath)
|
"Remove any related links to the FILE.
|
||||||
"Remove any related links to the file at FILEPATH.
|
This is equivalent to removing the node from the graph.
|
||||||
This is equivalent to removing the node from the graph."
|
If FILE is nil, clear the current buffer."
|
||||||
(let* ((path (or filepath
|
(setq file (or file (buffer-file-name (buffer-base-buffer))))
|
||||||
(buffer-file-name)))
|
|
||||||
(file (file-truename path)))
|
|
||||||
(org-roam-db-query [:delete :from files
|
(org-roam-db-query [:delete :from files
|
||||||
:where (= file $s1)]
|
:where (= file $s1)]
|
||||||
file)
|
file))
|
||||||
(org-roam-db-query [:delete :from links
|
|
||||||
:where (= from $s1)]
|
|
||||||
file)
|
|
||||||
(org-roam-db-query [:delete :from titles
|
|
||||||
:where (= file $s1)]
|
|
||||||
file)
|
|
||||||
(org-roam-db-query [:delete :from refs
|
|
||||||
:where (= file $s1)]
|
|
||||||
file)))
|
|
||||||
|
|
||||||
;;;;; Insertion
|
;;;;; Updating tables
|
||||||
(defun org-roam-db--insert-links (links)
|
(defun org-roam-db-insert-file ()
|
||||||
"Insert LINKS into the Org-roam cache."
|
"Update the files table for the current buffer.
|
||||||
|
If UPDATE-P is non-nil, first remove the file in the database."
|
||||||
|
(let* ((file (buffer-file-name))
|
||||||
|
(hash (org-roam-db--file-hash)))
|
||||||
(org-roam-db-query
|
(org-roam-db-query
|
||||||
[:insert :into links
|
[:insert :into files
|
||||||
:values $v1]
|
:values $v1]
|
||||||
links))
|
(list (vector file hash)))))
|
||||||
|
|
||||||
(defun org-roam-db--insert-titles (file titles)
|
(defun org-roam-db-get-scheduled-time ()
|
||||||
"Insert TITLES for a FILE into the Org-roam cache."
|
"Return the scheduled time at point in ISO8601 format."
|
||||||
|
(when-let ((time (org-get-scheduled-time (point))))
|
||||||
|
(org-format-time-string "%FT%T%z" time)))
|
||||||
|
|
||||||
|
(defun org-roam-db-get-deadline-time ()
|
||||||
|
"Return the deadline time at point in ISO8601 format."
|
||||||
|
(when-let ((time (org-get-deadline-time (point))))
|
||||||
|
(org-format-time-string "%FT%T%z" time)))
|
||||||
|
|
||||||
|
(defun org-roam-db-map-headlines (fns)
|
||||||
|
"Run FNS over all headlines in the current buffer."
|
||||||
|
(org-with-point-at 1
|
||||||
|
(org-map-entries
|
||||||
|
(lambda ()
|
||||||
|
(dolist (fn fns)
|
||||||
|
(funcall fn))))))
|
||||||
|
|
||||||
|
(defun org-roam-db-map-links (fns)
|
||||||
|
"Run FNS over all links in the current buffer."
|
||||||
|
(org-with-point-at 1
|
||||||
|
(org-element-map (org-element-parse-buffer) 'link
|
||||||
|
(lambda (link)
|
||||||
|
(dolist (fn fns)
|
||||||
|
(funcall fn link))))))
|
||||||
|
|
||||||
|
(defun org-roam-db-insert-file-node ()
|
||||||
|
"Insert the file-level node into the Org-roam cache."
|
||||||
|
(org-with-point-at 1
|
||||||
|
(when (= (org-outline-level) 0)
|
||||||
|
(when-let ((id (org-id-get)))
|
||||||
|
(let* ((file (buffer-file-name (buffer-base-buffer)))
|
||||||
|
(title (org-link-display-format
|
||||||
|
(or (cadr (assoc "TITLE" (org-collect-keywords '("title"))
|
||||||
|
#'string-equal))
|
||||||
|
(file-relative-name file org-roam-directory))))
|
||||||
|
(pos (point))
|
||||||
|
(todo nil)
|
||||||
|
(priority nil)
|
||||||
|
(scheduled nil)
|
||||||
|
(deadline nil)
|
||||||
|
(level 0)
|
||||||
|
(aliases (org-entry-get (point) "ROAM_ALIASES"))
|
||||||
|
(tags org-file-tags)
|
||||||
|
(refs (org-entry-get (point) "ROAM_REFS"))
|
||||||
|
(properties (org-entry-properties))
|
||||||
|
(olp (org-get-outline-path)))
|
||||||
(org-roam-db-query
|
(org-roam-db-query
|
||||||
[:insert :into titles
|
[:insert :into nodes
|
||||||
:values $v1]
|
:values $v1]
|
||||||
(list (vector file titles))))
|
(vector id file level pos todo priority
|
||||||
|
scheduled deadline title properties olp))
|
||||||
(defun org-roam-db--insert-ref (file ref)
|
(when tags
|
||||||
"Insert REF for FILE into the Org-roam cache."
|
(org-roam-db-query
|
||||||
|
[:insert :into tags
|
||||||
|
:values $v1]
|
||||||
|
(mapcar (lambda (tag)
|
||||||
|
(vector id (substring-no-properties tag)))
|
||||||
|
tags)))
|
||||||
|
(when aliases
|
||||||
|
(org-roam-db-query
|
||||||
|
[:insert :into aliases
|
||||||
|
:values $v1]
|
||||||
|
(mapcar (lambda (alias)
|
||||||
|
(vector id alias))
|
||||||
|
(split-string-and-unquote aliases))))
|
||||||
|
(when refs
|
||||||
|
(setq refs (split-string-and-unquote refs))
|
||||||
|
(let (rows)
|
||||||
|
(dolist (ref refs)
|
||||||
|
(if (string-match org-link-plain-re ref)
|
||||||
|
(progn
|
||||||
|
(push (vector id (match-string 2 ref)
|
||||||
|
(match-string 1 ref)) rows))
|
||||||
|
(lwarn '(org-roam) :warning
|
||||||
|
"%s:%s\tInvalid ref %s, skipping..."
|
||||||
|
(buffer-file-name) (point) ref)))
|
||||||
|
(when rows
|
||||||
(org-roam-db-query
|
(org-roam-db-query
|
||||||
[:insert :into refs
|
[:insert :into refs
|
||||||
:values $v1]
|
:values $v1]
|
||||||
(list (vector ref file))))
|
rows)))))))))
|
||||||
|
|
||||||
|
(defun org-roam-db-insert-node-data ()
|
||||||
|
"Insert node data for headline at point into the Org-roam cache."
|
||||||
|
(when-let ((id (org-id-get)))
|
||||||
|
(let* ((file (buffer-file-name (buffer-base-buffer)))
|
||||||
|
(heading-components (org-heading-components))
|
||||||
|
(pos (point))
|
||||||
|
(todo (nth 2 heading-components))
|
||||||
|
(priority (nth 3 heading-components))
|
||||||
|
(level (nth 1 heading-components))
|
||||||
|
(scheduled (org-roam-db-get-scheduled-time))
|
||||||
|
(deadline (org-roam-db-get-deadline-time))
|
||||||
|
(title (org-link-display-format (nth 4 heading-components)))
|
||||||
|
(properties (org-entry-properties))
|
||||||
|
(olp (org-get-outline-path)))
|
||||||
|
(org-roam-db-query
|
||||||
|
[:insert :into nodes
|
||||||
|
:values $v1]
|
||||||
|
(vector id file level pos todo priority
|
||||||
|
scheduled deadline title properties olp)))))
|
||||||
|
|
||||||
|
(defun org-roam-db-insert-aliases ()
|
||||||
|
"Insert aliases for node at point into Org-roam cache."
|
||||||
|
(when-let ((file (buffer-file-name (buffer-base-buffer)))
|
||||||
|
(node-id (org-id-get))
|
||||||
|
(aliases (org-entry-get (point) "ROAM_ALIASES")))
|
||||||
|
(org-roam-db-query [:insert :into aliases
|
||||||
|
:values $v1]
|
||||||
|
(mapcar (lambda (alias)
|
||||||
|
(vector file node-id alias))
|
||||||
|
(split-string-and-unquote aliases)))))
|
||||||
|
|
||||||
|
(defun org-roam-db-insert-tags ()
|
||||||
|
"Insert tags for node at point into Org-roam cache."
|
||||||
|
(when-let ((node-id (org-id-get))
|
||||||
|
(tags (org-get-tags)))
|
||||||
|
(org-roam-db-query [:insert :into tags
|
||||||
|
:values $v1]
|
||||||
|
(mapcar (lambda (tag)
|
||||||
|
(vector node-id (substring-no-properties tag))) tags))))
|
||||||
|
|
||||||
|
(defun org-roam-db-insert-refs ()
|
||||||
|
"Insert refs for node at point into Org-roam cache."
|
||||||
|
(when-let* ((node-id (org-id-get))
|
||||||
|
(refs (org-entry-get (point) "ROAM_REFS"))
|
||||||
|
(refs (split-string-and-unquote refs)))
|
||||||
|
(let (rows)
|
||||||
|
(dolist (ref refs)
|
||||||
|
(save-match-data
|
||||||
|
(if (string-match org-link-plain-re ref)
|
||||||
|
(progn
|
||||||
|
(push (vector node-id (match-string 2 ref) (match-string 1 ref)) rows))
|
||||||
|
(lwarn '(org-roam) :warning
|
||||||
|
"%s:%s\tInvalid ref %s, skipping..." (buffer-file-name) (point) ref))))
|
||||||
|
(org-roam-db-query [:insert :into refs
|
||||||
|
:values $v1]
|
||||||
|
rows))))
|
||||||
|
|
||||||
|
(defun org-roam-db-insert-link (link)
|
||||||
|
"Insert link data for LINK at current point into the Org-roam cache."
|
||||||
|
(save-excursion
|
||||||
|
(goto-char (org-element-property :begin link))
|
||||||
|
(let ((type (org-element-property :type link))
|
||||||
|
(dest (org-element-property :path link))
|
||||||
|
(properties (list :outline (org-get-outline-path)))
|
||||||
|
(source (org-roam-id-at-point)))
|
||||||
|
(when source
|
||||||
|
(org-roam-db-query
|
||||||
|
[:insert :into links
|
||||||
|
:values $v1]
|
||||||
|
(vector (point) source dest type properties))))))
|
||||||
|
|
||||||
;;;;; Fetching
|
;;;;; Fetching
|
||||||
(defun org-roam-db--get-current-files ()
|
(defun org-roam-db--get-current-files ()
|
||||||
"Return a hash-table of file to the hash of its file contents."
|
"Return a hash-table of file to the hash of its file contents."
|
||||||
(let* ((current-files (org-roam-db-query [:select * :from files]))
|
(let ((current-files (org-roam-db-query [:select [file hash] :from files]))
|
||||||
(ht (make-hash-table :test #'equal)))
|
(ht (make-hash-table :test #'equal)))
|
||||||
(dolist (row current-files)
|
(dolist (row current-files)
|
||||||
(puthash (car row) (cadr row) ht))
|
(puthash (car row) (cadr row) ht))
|
||||||
ht))
|
ht))
|
||||||
|
|
||||||
(defun org-roam-db--get-titles (file)
|
(defun org-roam-db--file-hash (&optional file-path)
|
||||||
"Return the titles of FILE from the cache."
|
"Compute the hash of FILE-PATH, a file or current buffer."
|
||||||
(caar (org-roam-db-query [:select [titles] :from titles
|
(if file-path
|
||||||
:where (= file $s1)]
|
(with-temp-buffer
|
||||||
file
|
(set-buffer-multibyte nil)
|
||||||
:limit 1)))
|
(insert-file-contents-literally file-path)
|
||||||
|
(secure-hash 'sha1 (current-buffer)))
|
||||||
(defun org-roam-db--connected-component (file)
|
(org-with-wide-buffer
|
||||||
"Return all files reachable from/connected to FILE, including the file itself.
|
(secure-hash 'sha1 (current-buffer)))))
|
||||||
If the file does not have any connections, nil is returned."
|
|
||||||
(let* ((query "WITH RECURSIVE
|
|
||||||
links_of(file, link) AS
|
|
||||||
(WITH roamlinks AS (SELECT * FROM links WHERE \"type\" = '\"roam\"'),
|
|
||||||
citelinks AS (SELECT * FROM links
|
|
||||||
JOIN refs ON links.\"to\" = refs.\"ref\"
|
|
||||||
AND links.\"type\" = '\"cite\"')
|
|
||||||
SELECT \"from\", \"to\" FROM roamlinks UNION
|
|
||||||
SELECT \"to\", \"from\" FROM roamlinks UNION
|
|
||||||
SELECT \"file\", \"from\" FROM citelinks UNION
|
|
||||||
SELECT \"from\", \"file\" FROM citelinks),
|
|
||||||
connected_component(file) AS
|
|
||||||
(SELECT link FROM links_of WHERE file = $s1
|
|
||||||
UNION
|
|
||||||
SELECT link FROM links_of JOIN connected_component USING(file))
|
|
||||||
SELECT * FROM connected_component;")
|
|
||||||
(files (mapcar 'car-safe (emacsql (org-roam-db) query file))))
|
|
||||||
files))
|
|
||||||
|
|
||||||
(defun org-roam-db--links-with-max-distance (file max-distance)
|
|
||||||
"Return all files reachable from/connected to FILE in at most MAX-DISTANCE steps,
|
|
||||||
including the file itself. If the file does not have any connections, nil is returned."
|
|
||||||
(let* ((query "WITH RECURSIVE
|
|
||||||
links_of(file, link) AS
|
|
||||||
(WITH roamlinks AS (SELECT * FROM links WHERE \"type\" = '\"roam\"'),
|
|
||||||
citelinks AS (SELECT * FROM links
|
|
||||||
JOIN refs ON links.\"to\" = refs.\"ref\"
|
|
||||||
AND links.\"type\" = '\"cite\"')
|
|
||||||
SELECT \"from\", \"to\" FROM roamlinks UNION
|
|
||||||
SELECT \"to\", \"from\" FROM roamlinks UNION
|
|
||||||
SELECT \"file\", \"from\" FROM citelinks UNION
|
|
||||||
SELECT \"from\", \"file\" FROM citelinks),
|
|
||||||
-- Links are traversed in a breadth-first search. In order to calculate the
|
|
||||||
-- distance of nodes and to avoid following cyclic links, the visited nodes
|
|
||||||
-- are tracked in 'trace'.
|
|
||||||
connected_component(file, trace) AS
|
|
||||||
(VALUES($s1, json_array($s1))
|
|
||||||
UNION
|
|
||||||
SELECT lo.link, json_insert(cc.trace, '$[' || json_array_length(cc.trace) || ']', lo.link) FROM
|
|
||||||
connected_component AS cc JOIN links_of AS lo USING(file)
|
|
||||||
WHERE (
|
|
||||||
-- Avoid cycles by only visiting each file once.
|
|
||||||
(SELECT count(*) FROM json_each(cc.trace) WHERE json_each.value == lo.link) == 0
|
|
||||||
-- Note: BFS is cut off early here.
|
|
||||||
AND json_array_length(cc.trace) < ($s2 + 1)))
|
|
||||||
SELECT DISTINCT file, min(json_array_length(trace)) AS distance
|
|
||||||
FROM connected_component GROUP BY file ORDER BY distance;")
|
|
||||||
;; In principle the distance would be available in the second column.
|
|
||||||
(files (mapcar 'car-safe (emacsql (org-roam-db) query file max-distance))))
|
|
||||||
files))
|
|
||||||
|
|
||||||
;;;;; Updating
|
;;;;; Updating
|
||||||
(defun org-roam-db--update-titles ()
|
(defun org-roam-db-sync (&optional force)
|
||||||
"Update the title of the current buffer into the cache."
|
"Synchronize the cache state with the current Org files on-disk.
|
||||||
(let ((file (file-truename (buffer-file-name))))
|
If FORCE, force a rebuild of the cache from scratch."
|
||||||
(org-roam-db-query [:delete :from titles
|
(interactive "P")
|
||||||
:where (= file $s1)]
|
(when force (delete-file org-roam-db-location))
|
||||||
file)
|
|
||||||
(org-roam-db--insert-titles file (org-roam--extract-titles))))
|
|
||||||
|
|
||||||
(defun org-roam-db--update-refs ()
|
|
||||||
"Update the ref of the current buffer into the cache."
|
|
||||||
(let ((file (file-truename (buffer-file-name))))
|
|
||||||
(org-roam-db-query [:delete :from refs
|
|
||||||
:where (= file $s1)]
|
|
||||||
file)
|
|
||||||
(when-let ((ref (org-roam--extract-ref)))
|
|
||||||
(org-roam-db--insert-ref file ref))))
|
|
||||||
|
|
||||||
(defun org-roam-db--update-cache-links ()
|
|
||||||
"Update the file links of the current buffer in the cache."
|
|
||||||
(let ((file (file-truename (buffer-file-name))))
|
|
||||||
(org-roam-db-query [:delete :from links
|
|
||||||
:where (= from $s1)]
|
|
||||||
file)
|
|
||||||
(when-let ((links (org-roam--extract-links)))
|
|
||||||
(org-roam-db--insert-links links))))
|
|
||||||
|
|
||||||
(defun org-roam-db--update-file (&optional file-path)
|
|
||||||
"Update Org-roam cache for FILE-PATH."
|
|
||||||
(let (buf)
|
|
||||||
(if file-path
|
|
||||||
(setq buf (find-file-noselect file-path))
|
|
||||||
(setq buf (current-buffer)))
|
|
||||||
(with-current-buffer buf
|
|
||||||
(save-excursion
|
|
||||||
(org-roam-db--update-titles)
|
|
||||||
(org-roam-db--update-refs)
|
|
||||||
(org-roam-db--update-cache-links)
|
|
||||||
(org-roam-buffer--update-maybe :redisplay t)))))
|
|
||||||
|
|
||||||
;;;;; org-roam-db-build-cache
|
|
||||||
(defun org-roam-db-build-cache ()
|
|
||||||
"Build the cache for `org-roam-directory'."
|
|
||||||
(interactive)
|
|
||||||
(org-roam-db--close) ;; Force a reconnect
|
(org-roam-db--close) ;; Force a reconnect
|
||||||
(org-roam-db) ;; To initialize the database, no-op if already initialized
|
(org-roam-db) ;; To initialize the database, no-op if already initialized
|
||||||
(let* ((org-roam-files (org-roam--list-files org-roam-directory))
|
(let* ((gc-cons-threshold org-roam-db-gc-threshold)
|
||||||
|
(org-agenda-files nil)
|
||||||
|
(org-roam-files (org-roam--list-all-files))
|
||||||
(current-files (org-roam-db--get-current-files))
|
(current-files (org-roam-db--get-current-files))
|
||||||
(time (current-time))
|
(modified-files nil))
|
||||||
all-files all-links all-titles all-refs)
|
|
||||||
(dolist (file org-roam-files)
|
(dolist (file org-roam-files)
|
||||||
(org-roam--with-temp-buffer
|
(let ((contents-hash (org-roam-db--file-hash file)))
|
||||||
(insert-file-contents file)
|
|
||||||
(let ((contents-hash (secure-hash 'sha1 (current-buffer))))
|
|
||||||
(unless (string= (gethash file current-files)
|
(unless (string= (gethash file current-files)
|
||||||
contents-hash)
|
contents-hash)
|
||||||
(org-roam-db--clear-file file)
|
(push file modified-files)))
|
||||||
(setq all-files
|
(remhash file current-files))
|
||||||
(cons (vector file contents-hash time) all-files))
|
(emacsql-with-transaction (org-roam-db)
|
||||||
(when-let (links (org-roam--extract-links file))
|
(if (fboundp 'dolist-with-progress-reporter)
|
||||||
(setq all-links (append links all-links)))
|
(dolist-with-progress-reporter (file (hash-table-keys current-files))
|
||||||
(let ((titles (org-roam--extract-titles)))
|
"Clearing removed files..."
|
||||||
(setq all-titles (cons (vector file titles) all-titles)))
|
(org-roam-db-clear-file file))
|
||||||
(when-let ((ref (org-roam--extract-ref)))
|
|
||||||
(setq all-refs (cons (vector ref file) all-refs))))
|
|
||||||
(remhash file current-files))))
|
|
||||||
(dolist (file (hash-table-keys current-files))
|
(dolist (file (hash-table-keys current-files))
|
||||||
;; These files are no longer around, remove from cache...
|
(org-roam-db-clear-file file)))
|
||||||
(org-roam-db--clear-file file))
|
(if (fboundp 'dolist-with-progress-reporter)
|
||||||
(when all-files
|
(dolist-with-progress-reporter (file modified-files)
|
||||||
(org-roam-db-query
|
"Processing modified files..."
|
||||||
[:insert :into files
|
(org-roam-db-update-file file))
|
||||||
:values $v1]
|
(dolist (file modified-files)
|
||||||
all-files))
|
(org-roam-db-update-file file))))))
|
||||||
(when all-links
|
|
||||||
(org-roam-db-query
|
(defun org-roam-db-update-file (&optional file-path)
|
||||||
[:insert :into links
|
"Update Org-roam cache for FILE-PATH.
|
||||||
:values $v1]
|
If the file does not exist anymore, remove it from the cache.
|
||||||
all-links))
|
If the file exists, update the cache with information."
|
||||||
(when all-titles
|
(setq file-path (or file-path (buffer-file-name (buffer-base-buffer))))
|
||||||
(org-roam-db-query
|
(let ((content-hash (org-roam-db--file-hash file-path))
|
||||||
[:insert :into titles
|
(db-hash (caar (org-roam-db-query [:select hash :from files
|
||||||
:values $v1]
|
:where (= file $s1)] file-path))))
|
||||||
all-titles))
|
(unless (string= content-hash db-hash)
|
||||||
(when all-refs
|
(org-roam-with-file file-path nil
|
||||||
(org-roam-db-query
|
(save-excursion
|
||||||
[:insert :into refs
|
(org-set-regexps-and-options 'tags-only)
|
||||||
:values $v1]
|
(org-roam-db-clear-file)
|
||||||
all-refs))
|
(org-roam-db-insert-file)
|
||||||
(let ((stats (list :files (length all-files)
|
(org-roam-db-insert-file-node)
|
||||||
:links (length all-links)
|
(org-roam-db-map-headlines
|
||||||
:titles (length all-titles)
|
(list #'org-roam-db-insert-node-data
|
||||||
:refs (length all-refs)
|
#'org-roam-db-insert-aliases
|
||||||
:deleted (length (hash-table-keys current-files)))))
|
#'org-roam-db-insert-tags
|
||||||
(when org-roam-verbose
|
#'org-roam-db-insert-refs))
|
||||||
(message "files: %s, links: %s, titles: %s, refs: %s, deleted: %s"
|
(org-roam-db-map-links
|
||||||
(plist-get stats :files)
|
(list #'org-roam-db-insert-link)))))))
|
||||||
(plist-get stats :links)
|
|
||||||
(plist-get stats :titles)
|
(defun org-roam-db--update-on-save-h ()
|
||||||
(plist-get stats :refs)
|
"."
|
||||||
(plist-get stats :deleted)))
|
(add-hook 'after-save-hook #'org-roam-db-update-file nil t))
|
||||||
stats)))
|
|
||||||
|
(add-to-list 'org-roam-find-file-hook #'org-roam-db--update-on-save-h)
|
||||||
|
|
||||||
|
;; Diagnostic Interactives
|
||||||
|
(defun org-roam-db-diagnose-node ()
|
||||||
|
"Print information about node at point."
|
||||||
|
(interactive)
|
||||||
|
(prin1 (org-roam-node-at-point)))
|
||||||
|
|
||||||
(provide 'org-roam-db)
|
(provide 'org-roam-db)
|
||||||
|
|
||||||
|
222
org-roam-doctor.el
Normal file
222
org-roam-doctor.el
Normal file
@ -0,0 +1,222 @@
|
|||||||
|
;;; org-roam-doctor.el --- Linter for Org-roam files -*- coding: utf-8; lexical-binding: t; -*-
|
||||||
|
;;
|
||||||
|
;; Copyright © 2020 Jethro Kuan <jethrokuan95@gmail.com>
|
||||||
|
|
||||||
|
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
||||||
|
;; URL: https://github.com/jethrokuan/org-roam
|
||||||
|
;; Keywords: org-mode, roam, convenience
|
||||||
|
;; Version: 2.0.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 "2.90.1"))
|
||||||
|
|
||||||
|
;; 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 library provides `org-roam-doctor', a utility for diagnosing and fixing
|
||||||
|
;; Org-roam files. Running `org-roam-doctor' launches a list of checks defined
|
||||||
|
;; by `org-roam-doctor--checkers'. Every checker is an instance of
|
||||||
|
;; `org-roam-doctor-checker'.
|
||||||
|
;;
|
||||||
|
;; Each checker is given the Org parse tree (AST), and is expected to return a
|
||||||
|
;; list of errors. The checker can also provide "actions" for auto-fixing errors
|
||||||
|
;; (see `org-roam-doctor--remove-link' for an example).
|
||||||
|
;;
|
||||||
|
;; The UX experience is inspired by both org-lint and checkdoc, and their code
|
||||||
|
;; is heavily referenced.
|
||||||
|
;;
|
||||||
|
;;; Code:
|
||||||
|
;; Library Requires
|
||||||
|
(require 'cl-lib)
|
||||||
|
(require 'org)
|
||||||
|
(require 'org-element)
|
||||||
|
(require 'dash)
|
||||||
|
(eval-when-compile
|
||||||
|
(require 'org-roam-macs))
|
||||||
|
(require 'org-roam)
|
||||||
|
|
||||||
|
(defvar org-roam-mode-map)
|
||||||
|
|
||||||
|
(declare-function org-roam--get-roam-buffers "org-roam")
|
||||||
|
(declare-function org-roam--list-all-files "org-roam")
|
||||||
|
(declare-function org-roam--org-roam-file-p "org-roam")
|
||||||
|
|
||||||
|
(defvar org-roam-verbose)
|
||||||
|
|
||||||
|
(defcustom org-roam-doctor-inhibit-startup t
|
||||||
|
"Inhibit `org-mode' startup when processing files with `org-doctor'.
|
||||||
|
When non-nil, images and LaTeX preview will not be generated,
|
||||||
|
tables will not be aligned, and headlines will not respect
|
||||||
|
startup visability. This significantly improves performance when
|
||||||
|
processing multiple files"
|
||||||
|
:type 'boolean
|
||||||
|
:group 'org-roam)
|
||||||
|
|
||||||
|
(cl-defstruct (org-roam-doctor-checker (:copier nil))
|
||||||
|
(name 'missing-checker-name)
|
||||||
|
(description "")
|
||||||
|
(actions nil))
|
||||||
|
|
||||||
|
(defconst org-roam-doctor--checkers
|
||||||
|
(list
|
||||||
|
(make-org-roam-doctor-checker
|
||||||
|
:name 'org-roam-doctor-broken-links
|
||||||
|
:description "Fix broken links."
|
||||||
|
:actions '(("d" . ("Unlink" . org-roam-doctor--remove-link))
|
||||||
|
("r" . ("Replace link" . org-roam-doctor--replace-link))))))
|
||||||
|
|
||||||
|
(defun org-roam-doctor-broken-links (ast)
|
||||||
|
"Checker for detecting broken links.
|
||||||
|
AST is the org-element parse tree."
|
||||||
|
(let (reports)
|
||||||
|
(org-element-map ast 'link
|
||||||
|
(lambda (l)
|
||||||
|
(when (equal "id" (org-element-property :type l))
|
||||||
|
(let ((id (org-element-property :path l)))
|
||||||
|
(unless (org-id-find id)
|
||||||
|
(push `(,(org-element-property :begin l)
|
||||||
|
,(format "Broken id link \"%s\"" id))
|
||||||
|
reports))))))
|
||||||
|
reports))
|
||||||
|
|
||||||
|
(defun org-roam-doctor--check (buffer checkers)
|
||||||
|
"Check BUFFER for errors.
|
||||||
|
CHECKERS is the list of checkers used."
|
||||||
|
(with-current-buffer buffer
|
||||||
|
(save-excursion
|
||||||
|
(goto-char (point-min))
|
||||||
|
(let* ((ast (org-element-parse-buffer))
|
||||||
|
(errors (sort (cl-mapcan
|
||||||
|
(lambda (c)
|
||||||
|
(mapcar
|
||||||
|
(lambda (report)
|
||||||
|
(list (set-marker (make-marker) (car report))
|
||||||
|
(nth 1 report) c))
|
||||||
|
(save-excursion
|
||||||
|
(funcall
|
||||||
|
(org-roam-doctor-checker-name c)
|
||||||
|
ast))))
|
||||||
|
checkers)
|
||||||
|
#'car-less-than-car)))
|
||||||
|
(dolist (e errors)
|
||||||
|
(pcase-let ((`(,m ,msg ,checker) e))
|
||||||
|
(switch-to-buffer buffer)
|
||||||
|
(goto-char m)
|
||||||
|
(org-reveal)
|
||||||
|
(undo-boundary)
|
||||||
|
(org-roam-doctor--resolve msg checker)
|
||||||
|
(set-marker m nil)))
|
||||||
|
errors))))
|
||||||
|
|
||||||
|
;;; Actions
|
||||||
|
(defun org-roam-doctor--recursive-edit ()
|
||||||
|
"Launch into a recursive edit."
|
||||||
|
(message "When you're done editing press C-M-c to continue.")
|
||||||
|
(recursive-edit))
|
||||||
|
|
||||||
|
(defun org-roam-doctor--skip ()
|
||||||
|
"Skip the current error."
|
||||||
|
(org-roam-message "Skipping..."))
|
||||||
|
|
||||||
|
(defun org-roam-doctor--replace-link ()
|
||||||
|
"Replace the current link with a new link."
|
||||||
|
(save-match-data
|
||||||
|
(unless (org-in-regexp org-link-bracket-re 1)
|
||||||
|
(user-error "No link at point"))
|
||||||
|
(let ((orig (buffer-string))
|
||||||
|
(p (point)))
|
||||||
|
(condition-case nil
|
||||||
|
(save-excursion
|
||||||
|
(replace-match "")
|
||||||
|
(org-roam-node-insert))
|
||||||
|
(quit (progn
|
||||||
|
(replace-buffer-contents orig)
|
||||||
|
(goto-char p)))))))
|
||||||
|
|
||||||
|
(defun org-roam-doctor--remove-link ()
|
||||||
|
"Unlink the text at point."
|
||||||
|
(unless (org-in-regexp org-link-bracket-re 1)
|
||||||
|
(user-error "No link at point"))
|
||||||
|
(save-excursion
|
||||||
|
(let ((label (if (match-end 2)
|
||||||
|
(match-string-no-properties 2)
|
||||||
|
(org-link-unescape (match-string-no-properties 1)))))
|
||||||
|
(delete-region (match-beginning 0) (match-end 0))
|
||||||
|
(insert label))))
|
||||||
|
|
||||||
|
(defun org-roam-doctor--resolve (msg checker)
|
||||||
|
"Resolve an error.
|
||||||
|
MSG is the error that was found, which is displayed in a help buffer.
|
||||||
|
CHECKER is a `org-roam-doctor' checker instance."
|
||||||
|
(let ((actions (org-roam-doctor-checker-actions checker))
|
||||||
|
c)
|
||||||
|
(push '("e" . ("Edit" . org-roam-doctor--recursive-edit)) actions)
|
||||||
|
(push '("s" . ("Skip" . org-roam-doctor--skip)) actions)
|
||||||
|
(with-output-to-temp-buffer "*Org-roam-doctor Help*"
|
||||||
|
(mapc #'princ
|
||||||
|
(list "Error message:\n " msg "\n\n"))
|
||||||
|
(dolist (action actions)
|
||||||
|
(princ (format "[%s]: %s\n"
|
||||||
|
(car action)
|
||||||
|
(cadr action))))
|
||||||
|
(princ "\n\n"))
|
||||||
|
(shrink-window-if-larger-than-buffer
|
||||||
|
(get-buffer-window "*Org-roam-doctor Help*"))
|
||||||
|
(message "Press key for command:")
|
||||||
|
(unwind-protect
|
||||||
|
(progn
|
||||||
|
(cl-loop
|
||||||
|
do (setq c (char-to-string (read-char-exclusive)))
|
||||||
|
until (assoc c actions)
|
||||||
|
do (message "Please enter a valid key for command:"))
|
||||||
|
(funcall (cddr (assoc c actions)))
|
||||||
|
(redisplay))
|
||||||
|
(when (get-buffer-window "*Org-roam-doctor Help*")
|
||||||
|
(delete-window (get-buffer-window "*Org-roam-doctor Help*"))
|
||||||
|
(kill-buffer "*Org-roam-doctor Help*")))))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun org-roam-doctor (&optional checkall)
|
||||||
|
"Perform a check on the current buffer to ensure cleanliness.
|
||||||
|
If CHECKALL, run the check for all Org-roam files."
|
||||||
|
(interactive "P")
|
||||||
|
(let ((files (if checkall
|
||||||
|
(org-roam--list-all-files)
|
||||||
|
(unless (org-roam--org-roam-file-p)
|
||||||
|
(user-error "Not in an org-roam file"))
|
||||||
|
`(,(buffer-file-name)))))
|
||||||
|
(org-roam-doctor-start files org-roam-doctor--checkers)))
|
||||||
|
|
||||||
|
(defun org-roam-doctor-start (files checkers)
|
||||||
|
"Lint FILES using CHECKERS."
|
||||||
|
(save-window-excursion
|
||||||
|
(let ((existing-buffers (org-roam--get-roam-buffers))
|
||||||
|
(org-inhibit-startup org-roam-doctor-inhibit-startup))
|
||||||
|
(org-id-update-id-locations)
|
||||||
|
(dolist (f files)
|
||||||
|
(let ((buf (find-file-noselect f)))
|
||||||
|
(org-roam-doctor--check buf checkers)
|
||||||
|
(unless (memq buf existing-buffers)
|
||||||
|
(with-current-buffer buf
|
||||||
|
(save-buffer))
|
||||||
|
(kill-buffer buf))))))
|
||||||
|
(org-roam-message "Linting completed."))
|
||||||
|
|
||||||
|
(provide 'org-roam-doctor)
|
||||||
|
|
||||||
|
;;; org-roam-doctor.el ends here
|
@ -1,268 +0,0 @@
|
|||||||
;;; org-roam-graph.el --- Roam Research replica with Org-mode -*- coding: utf-8; lexical-binding: t -*-
|
|
||||||
|
|
||||||
;; Copyright © 2020 Jethro Kuan <jethrokuan95@gmail.com>
|
|
||||||
|
|
||||||
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
|
||||||
;; URL: https://github.com/jethrokuan/org-roam
|
|
||||||
;; Keywords: org-mode, roam, convenience
|
|
||||||
;; Version: 1.1.0
|
|
||||||
;; Package-Requires: ((emacs "26.1") (dash "2.13") (f "0.17.2") (s "1.12.0") (org "9.3") (emacsql "3.0.0") (emacsql-sqlite "1.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 library provides graphing functionality for org-roam.
|
|
||||||
;;
|
|
||||||
;;; Code:
|
|
||||||
(require 'xml) ;xml-escape-string
|
|
||||||
(require 's) ;s-truncate, s-replace
|
|
||||||
(require 'org-roam-macs)
|
|
||||||
(require 'org-roam-db)
|
|
||||||
|
|
||||||
;;;; Declarations
|
|
||||||
(defvar org-roam-directory)
|
|
||||||
(declare-function org-roam--org-roam-file-p "org-roam")
|
|
||||||
(declare-function org-roam--path-to-slug "org-roam")
|
|
||||||
|
|
||||||
;;;; Options
|
|
||||||
(defcustom org-roam-graph-viewer (executable-find "firefox")
|
|
||||||
"Method to view the org-roam graph.
|
|
||||||
It may be one of the following:
|
|
||||||
- a string representing the path to the executable for viewing the graph.
|
|
||||||
- a function accepting a single argument: the graph file path.
|
|
||||||
- nil uses `view-file' to view the graph."
|
|
||||||
:type '(choice
|
|
||||||
(string :tag "Path to executable")
|
|
||||||
(function :tag "Function to display graph" eww-open-file)
|
|
||||||
(const :tag "view-file"))
|
|
||||||
:group 'org-roam)
|
|
||||||
|
|
||||||
(defcustom org-roam-graph-executable (executable-find "dot")
|
|
||||||
"Path to graphing executable."
|
|
||||||
:type 'string
|
|
||||||
:group 'org-roam)
|
|
||||||
|
|
||||||
(defcustom org-roam-graph-extra-config nil
|
|
||||||
"Extra options passed to graphviz.
|
|
||||||
Example:
|
|
||||||
'((\"rankdir\" . \"LR\"))"
|
|
||||||
:type '(alist)
|
|
||||||
:group 'org-roam)
|
|
||||||
|
|
||||||
(defcustom org-roam-graph-node-extra-config nil
|
|
||||||
"Extra options for graphviz nodes.
|
|
||||||
Example:
|
|
||||||
'((\"color\" . \"skyblue\"))"
|
|
||||||
:type '(alist)
|
|
||||||
:group 'org-roam)
|
|
||||||
|
|
||||||
(defcustom org-roam-graph-edge-extra-config nil
|
|
||||||
"Extra options for graphviz edges.
|
|
||||||
Example:
|
|
||||||
'((\"dir\" . \"back\"))"
|
|
||||||
:type '(alist)
|
|
||||||
:group 'org-roam)
|
|
||||||
|
|
||||||
(defcustom org-roam-graph-edge-cites-extra-config '(("color" . "red"))
|
|
||||||
"Extra options for graphviz edges for citation links.
|
|
||||||
Example:
|
|
||||||
'((\"dir\" . \"back\"))"
|
|
||||||
:type '(alist)
|
|
||||||
:group 'org-roam)
|
|
||||||
|
|
||||||
(defcustom org-roam-graph-max-title-length 100
|
|
||||||
"Maximum length of titles in graph nodes."
|
|
||||||
:type 'number
|
|
||||||
:group 'org-roam)
|
|
||||||
|
|
||||||
(defcustom org-roam-graph-exclude-matcher nil
|
|
||||||
"Matcher for excluding nodes from the generated graph.
|
|
||||||
Any nodes and links for file paths matching this string is
|
|
||||||
excluded from the graph.
|
|
||||||
|
|
||||||
If value is a string, the string is the only matcher.
|
|
||||||
|
|
||||||
If value is a list, all file paths matching any of the strings
|
|
||||||
are excluded."
|
|
||||||
:type '(choice
|
|
||||||
(string :tag "Matcher")
|
|
||||||
(list :tag "Matchers"))
|
|
||||||
:group 'org-roam)
|
|
||||||
|
|
||||||
;;;; Functions
|
|
||||||
(defun org-roam-graph--expand-matcher (col &optional negate where)
|
|
||||||
"Return the exclusion regexp from `org-roam-graph-exclude-matcher'.
|
|
||||||
COL is the symbol to be matched against. if NEGATE, add :not to sql query.
|
|
||||||
set WHERE to true if WHERE query already exists."
|
|
||||||
(let ((matchers (pcase org-roam-graph-exclude-matcher
|
|
||||||
('nil nil)
|
|
||||||
((pred stringp) `(,(concat "%" org-roam-graph-exclude-matcher "%")))
|
|
||||||
((pred listp) (mapcar (lambda (m)
|
|
||||||
(concat "%" m "%"))
|
|
||||||
org-roam-graph-exclude-matcher))
|
|
||||||
(_ (error "Invalid org-roam-graph-exclude-matcher"))))
|
|
||||||
res)
|
|
||||||
(dolist (match matchers)
|
|
||||||
(if where
|
|
||||||
(push :and res)
|
|
||||||
(push :where res)
|
|
||||||
(setq where t))
|
|
||||||
(push col res)
|
|
||||||
(when negate
|
|
||||||
(push :not res))
|
|
||||||
(push :like res)
|
|
||||||
(push match res))
|
|
||||||
(nreverse res)))
|
|
||||||
|
|
||||||
(defun org-roam-graph--dot-option (option &optional wrap-key wrap-val)
|
|
||||||
"Return dot string of form KEY=VAL for OPTION cons.
|
|
||||||
If WRAP-KEY is non-nil it wraps the KEY.
|
|
||||||
If WRAP-VAL is non-nil it wraps the VAL."
|
|
||||||
(concat wrap-key (car option) wrap-key
|
|
||||||
"="
|
|
||||||
wrap-val (cdr option) wrap-val))
|
|
||||||
|
|
||||||
(defun org-roam-graph--dot (node-query)
|
|
||||||
"Build the graphviz dot string for NODE-QUERY.
|
|
||||||
The Org-roam database titles table is read, to obtain the list of titles.
|
|
||||||
The links table is then read to obtain all directed links, and formatted
|
|
||||||
into a digraph."
|
|
||||||
(org-roam-db--ensure-built)
|
|
||||||
(org-roam--with-temp-buffer
|
|
||||||
(let* ((nodes (org-roam-db-query node-query))
|
|
||||||
(edges-query
|
|
||||||
`[:with selected :as [:select [file] :from ,node-query]
|
|
||||||
:select :distinct [to from] :from links
|
|
||||||
:where (and (in to selected) (in from selected))])
|
|
||||||
(edges-cites-query
|
|
||||||
`[:with selected :as [:select [file] :from ,node-query]
|
|
||||||
:select :distinct [file from]
|
|
||||||
:from links :inner :join refs :on (and (= links:to refs:ref)
|
|
||||||
(= links:type "cite"))
|
|
||||||
:where (and (in file selected) (in from selected))])
|
|
||||||
(edges (org-roam-db-query edges-query))
|
|
||||||
(edges-cites (org-roam-db-query edges-cites-query)))
|
|
||||||
(insert "digraph \"org-roam\" {\n")
|
|
||||||
(dolist (option org-roam-graph-extra-config)
|
|
||||||
(insert (org-roam-graph--dot-option option) ";\n"))
|
|
||||||
(dolist (attribute '("node" "edge"))
|
|
||||||
(insert (format " %s [%s];\n" attribute
|
|
||||||
(mapconcat #'org-roam-graph--dot-option
|
|
||||||
(symbol-value
|
|
||||||
(intern (concat "org-roam-graph-" attribute "-extra-config")))
|
|
||||||
","))))
|
|
||||||
(dolist (node nodes)
|
|
||||||
(let* ((file (xml-escape-string (car node)))
|
|
||||||
(title (or (caadr node)
|
|
||||||
(org-roam--path-to-slug file)))
|
|
||||||
(shortened-title (s-truncate org-roam-graph-max-title-length title))
|
|
||||||
(node-properties
|
|
||||||
`(("label" . ,(s-replace "\"" "\\\"" shortened-title))
|
|
||||||
("URL" . ,(concat "org-protocol://roam-file?file=" (url-hexify-string file)))
|
|
||||||
("tooltip" . ,(xml-escape-string title)))))
|
|
||||||
(insert
|
|
||||||
(format " \"%s\" [%s];\n" file
|
|
||||||
(mapconcat (lambda (n)
|
|
||||||
(org-roam-graph--dot-option n nil "\""))
|
|
||||||
node-properties ",")))))
|
|
||||||
(dolist (edge edges)
|
|
||||||
(insert (apply #'format `(" \"%s\" -> \"%s\";\n"
|
|
||||||
,@(mapcar #'xml-escape-string edge)))))
|
|
||||||
(insert (format " edge [%s];\n"
|
|
||||||
(mapconcat #'org-roam-graph--dot-option
|
|
||||||
org-roam-graph-edge-cites-extra-config ",")))
|
|
||||||
(dolist (edge edges-cites)
|
|
||||||
(insert (apply #'format `(" \"%s\" -> \"%s\";\n"
|
|
||||||
,@(mapcar #'xml-escape-string edge)))))
|
|
||||||
(insert "}")
|
|
||||||
(buffer-string))))
|
|
||||||
|
|
||||||
(defun org-roam-graph--build (&optional node-query)
|
|
||||||
"Generate a graph showing the relations between nodes in NODE-QUERY."
|
|
||||||
(unless org-roam-graph-executable
|
|
||||||
(user-error "Can't find %s executable. Please check if it is in your path"
|
|
||||||
org-roam-graph-executable))
|
|
||||||
(let* ((node-query (or node-query
|
|
||||||
`[:select [file titles]
|
|
||||||
:from titles
|
|
||||||
,@(org-roam-graph--expand-matcher 'file t)]))
|
|
||||||
(graph (org-roam-graph--dot node-query))
|
|
||||||
(temp-dot (make-temp-file "graph." nil ".dot" graph))
|
|
||||||
(temp-graph (make-temp-file "graph." nil ".svg")))
|
|
||||||
(call-process org-roam-graph-executable nil 0 nil
|
|
||||||
temp-dot "-Tsvg" "-o" temp-graph)
|
|
||||||
temp-graph))
|
|
||||||
|
|
||||||
(defun org-roam-graph--open (file)
|
|
||||||
"Open FILE using `org-roam-graph-viewer' with `view-file' as a fallback."
|
|
||||||
(pcase org-roam-graph-viewer
|
|
||||||
((pred stringp)
|
|
||||||
(if (executable-find org-roam-graph-viewer)
|
|
||||||
(condition-case err
|
|
||||||
(call-process org-roam-graph-viewer nil 0 nil file)
|
|
||||||
((error (user-error "Failed to open org-roam graph: %s" err))))
|
|
||||||
(user-error "Executable not found: \"%s\"" org-roam-graph-viewer)))
|
|
||||||
((pred functionp) (funcall org-roam-graph-viewer file))
|
|
||||||
('nil (view-file file))
|
|
||||||
(_ (signal 'wrong-type-argument `((functionp stringp null) ,org-roam-graph-viewer)))))
|
|
||||||
|
|
||||||
(defun org-roam-graph--build-connected-component (file &optional max-distance)
|
|
||||||
"Build a graph of nodes connected to FILE.
|
|
||||||
If MAX-DISTANCE is non-nil, limit nodes to MAX-DISTANCE steps."
|
|
||||||
(let* ((file (file-truename file))
|
|
||||||
(files (or (if (and max-distance (>= max-distance 0))
|
|
||||||
(org-roam-db--links-with-max-distance file max-distance)
|
|
||||||
(org-roam-db--connected-component file))
|
|
||||||
(list file)))
|
|
||||||
(query `[:select [file titles]
|
|
||||||
:from titles
|
|
||||||
:where (in file [,@files])]))
|
|
||||||
(org-roam-graph--build query)))
|
|
||||||
|
|
||||||
;;;; Commands
|
|
||||||
;;;###autoload
|
|
||||||
(defun org-roam-graph (&optional arg file node-query)
|
|
||||||
"Build and possibly display a graph for FILE from NODE-QUERY.
|
|
||||||
If FILE is nil, default to current buffer's file name.
|
|
||||||
ARG may be any of the following values:
|
|
||||||
- nil show the graph.
|
|
||||||
- `\\[universal-argument]' show the graph for FILE.
|
|
||||||
- `\\[universal-argument]' N show the graph for FILE limiting nodes to N steps.
|
|
||||||
- `\\[universal-argument] \\[universal-argument]' build the graph.
|
|
||||||
- `\\[universal-argument]' - build the graph for FILE.
|
|
||||||
- `\\[universal-argument]' -N build the graph for FILE limiting nodes to N steps."
|
|
||||||
(interactive "P")
|
|
||||||
(let ((file (or file (buffer-file-name))))
|
|
||||||
(unless file
|
|
||||||
(user-error "Cannot build graph for nil file. Is current buffer visiting a file?"))
|
|
||||||
(unless (org-roam--org-roam-file-p file)
|
|
||||||
(user-error "\"%s\" is not an org-roam file" file))
|
|
||||||
(pcase arg
|
|
||||||
('nil (org-roam-graph--open (org-roam-graph--build node-query)))
|
|
||||||
('(4) (org-roam-graph--open (org-roam-graph--build-connected-component file)))
|
|
||||||
((pred integerp) (let ((graph (org-roam-graph--build-connected-component (buffer-file-name) (abs arg))))
|
|
||||||
(when (>= arg 0)
|
|
||||||
(org-roam-graph--open graph))))
|
|
||||||
('(16) (org-roam-graph--build node-query))
|
|
||||||
('- (org-roam-graph--build-connected-component file))
|
|
||||||
(_ (user-error "Unrecognized ARG: %s" arg)))))
|
|
||||||
|
|
||||||
(provide 'org-roam-graph)
|
|
||||||
|
|
||||||
;;; org-roam-graph.el ends here
|
|
@ -1,12 +1,12 @@
|
|||||||
;;; org-roam-macs.el --- Roam Research replica with Org-mode -*- coding: utf-8; lexical-binding: t -*-
|
;;; org-roam-macs.el --- Macros/utility functions -*- coding: utf-8; lexical-binding: t; -*-
|
||||||
|
|
||||||
;; Copyright © 2020 Jethro Kuan <jethrokuan95@gmail.com>
|
;; Copyright © 2020 Jethro Kuan <jethrokuan95@gmail.com>
|
||||||
|
|
||||||
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
||||||
;; URL: https://github.com/jethrokuan/org-roam
|
;; URL: https://github.com/org-roam/org-roam
|
||||||
;; Keywords: org-mode, roam, convenience
|
;; Keywords: org-mode, roam, convenience
|
||||||
;; Version: 1.1.0
|
;; Version: 2.0.0
|
||||||
;; Package-Requires: ((emacs "26.1") (dash "2.13") (f "0.17.2") (s "1.12.0") (org "9.3") (emacsql "3.0.0") (emacsql-sqlite "1.0.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 "2.90.1"))
|
||||||
|
|
||||||
;; This file is NOT part of GNU Emacs.
|
;; This file is NOT part of GNU Emacs.
|
||||||
|
|
||||||
@ -27,20 +27,62 @@
|
|||||||
|
|
||||||
;;; Commentary:
|
;;; Commentary:
|
||||||
;;
|
;;
|
||||||
;; This library implements macros used throughout org-roam
|
;; This library implements macros used throughout org-roam.
|
||||||
;;
|
|
||||||
;;
|
;;
|
||||||
;;; Code:
|
;;; Code:
|
||||||
;;;; Library Requires
|
(defmacro org-roam-plist-map! (fn plist)
|
||||||
|
"Map FN over PLIST, modifying it in-place."
|
||||||
|
(declare (indent 1))
|
||||||
|
(let ((plist-var (make-symbol "plist"))
|
||||||
|
(k (make-symbol "k"))
|
||||||
|
(v (make-symbol "v")))
|
||||||
|
`(let ((,plist-var (copy-sequence ,plist)))
|
||||||
|
(while ,plist-var
|
||||||
|
(setq ,k (pop ,plist-var))
|
||||||
|
(setq ,v (pop ,plist-var))
|
||||||
|
(setq ,plist (plist-put ,plist ,k (funcall ,fn ,k ,v)))))))
|
||||||
|
|
||||||
(defmacro org-roam--with-temp-buffer (&rest body)
|
(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.
|
||||||
|
Kills the buffer if KEEP-BUF-P is nil, and FILE is not yet visited."
|
||||||
|
(declare (indent 2) (debug t))
|
||||||
|
`(let* (new-buf
|
||||||
|
(auto-mode-alist nil)
|
||||||
|
(buf (or (and (not ,file)
|
||||||
|
(current-buffer)) ;If FILE is nil, use current buffer
|
||||||
|
(find-buffer-visiting ,file) ; If FILE is already visited, find buffer
|
||||||
|
(progn
|
||||||
|
(setq new-buf t)
|
||||||
|
(find-file-noselect ,file)))) ; Else, visit FILE and return buffer
|
||||||
|
res)
|
||||||
|
(with-current-buffer buf
|
||||||
|
(unless (equal major-mode 'org-mode)
|
||||||
|
(delay-mode-hooks
|
||||||
|
(let ((org-inhibit-startup t)
|
||||||
|
(org-agenda-files nil))
|
||||||
|
(org-mode))))
|
||||||
|
(setq res (progn ,@body))
|
||||||
|
(unless (and new-buf (not ,keep-buf-p))
|
||||||
|
(save-buffer)))
|
||||||
|
(if (and new-buf (not ,keep-buf-p))
|
||||||
|
(when (find-buffer-visiting ,file)
|
||||||
|
(kill-buffer (find-buffer-visiting ,file))))
|
||||||
|
res))
|
||||||
|
|
||||||
|
(defmacro org-roam-with-temp-buffer (file &rest body)
|
||||||
"Execute BODY within a temp buffer.
|
"Execute BODY within a temp buffer.
|
||||||
Like `with-temp-buffer', but propagates `org-roam-directory'."
|
Like `with-temp-buffer', but propagates `org-roam-directory'.
|
||||||
(declare (indent 0) (debug t))
|
If FILE, set `default-directory' to FILE's directory and insert its contents."
|
||||||
|
(declare (indent 1) (debug t))
|
||||||
(let ((current-org-roam-directory (make-symbol "current-org-roam-directory")))
|
(let ((current-org-roam-directory (make-symbol "current-org-roam-directory")))
|
||||||
`(let ((,current-org-roam-directory org-roam-directory))
|
`(let ((,current-org-roam-directory org-roam-directory))
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
(let ((org-roam-directory ,current-org-roam-directory))
|
(let ((org-roam-directory ,current-org-roam-directory))
|
||||||
|
(delay-mode-hooks (org-mode))
|
||||||
|
(when ,file
|
||||||
|
(insert-file-contents ,file)
|
||||||
|
(setq-local default-directory (file-name-directory ,file)))
|
||||||
,@body)))))
|
,@body)))))
|
||||||
|
|
||||||
(provide 'org-roam-macs)
|
(provide 'org-roam-macs)
|
||||||
|
458
org-roam-mode.el
Normal file
458
org-roam-mode.el
Normal file
@ -0,0 +1,458 @@
|
|||||||
|
;;; org-roam-mode.el --- create and refresh Org-roam buffers -*- lexical-binding: t -*-
|
||||||
|
;; Copyright © 2020 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.0.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 "2.90.1"))
|
||||||
|
|
||||||
|
;; 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 library implements the abstract major-mode `org-roam-mode', from which
|
||||||
|
;; almost all other Org-roam major-modes derive.
|
||||||
|
;;
|
||||||
|
;;; Code:
|
||||||
|
(require 'magit-section)
|
||||||
|
|
||||||
|
(require 'org-roam-utils)
|
||||||
|
|
||||||
|
(defvar org-roam-directory)
|
||||||
|
(defvar org-roam-find-file-hook)
|
||||||
|
|
||||||
|
(declare-function org-roam--org-file-p "org-roam")
|
||||||
|
(declare-function org-roam-node-at-point "org-roam")
|
||||||
|
|
||||||
|
;;; Faces
|
||||||
|
(defface org-roam-header-line
|
||||||
|
`((((class color) (background light))
|
||||||
|
,@(and (>= emacs-major-version 27) '(:extend t))
|
||||||
|
:foreground "DarkGoldenrod4"
|
||||||
|
:weight bold)
|
||||||
|
(((class color) (background dark))
|
||||||
|
,@(and (>= emacs-major-version 27) '(:extend t))
|
||||||
|
:foreground "LightGoldenrod2"
|
||||||
|
:weight bold))
|
||||||
|
"Face for the `header-line' in some Org-roam modes."
|
||||||
|
:group 'org-roam-faces)
|
||||||
|
|
||||||
|
(defface org-roam-title
|
||||||
|
'((t :weight bold))
|
||||||
|
"Face for Org-roam titles."
|
||||||
|
:group 'org-roam-faces)
|
||||||
|
|
||||||
|
(defface org-roam-olp
|
||||||
|
'((((class color) (background light)) :foreground "grey60")
|
||||||
|
(((class color) (background dark)) :foreground "grey40"))
|
||||||
|
"Face for the OLP of the node."
|
||||||
|
:group 'org-roam-faces)
|
||||||
|
|
||||||
|
(defface org-roam-preview-heading
|
||||||
|
`((((class color) (background light))
|
||||||
|
,@(and (>= emacs-major-version 27) '(:extend t))
|
||||||
|
:background "grey80"
|
||||||
|
:foreground "grey30")
|
||||||
|
(((class color) (background dark))
|
||||||
|
,@(and (>= emacs-major-version 27) '(:extend t))
|
||||||
|
:background "grey25"
|
||||||
|
:foreground "grey70"))
|
||||||
|
"Face for preview headings."
|
||||||
|
:group 'org-roam-faces)
|
||||||
|
|
||||||
|
(defface org-roam-preview-heading-highlight
|
||||||
|
`((((class color) (background light))
|
||||||
|
,@(and (>= emacs-major-version 27) '(:extend t))
|
||||||
|
:background "grey75"
|
||||||
|
:foreground "grey30")
|
||||||
|
(((class color) (background dark))
|
||||||
|
,@(and (>= emacs-major-version 27) '(:extend t))
|
||||||
|
:background "grey35"
|
||||||
|
:foreground "grey70"))
|
||||||
|
"Face for current preview headings."
|
||||||
|
:group 'org-roam-faces)
|
||||||
|
|
||||||
|
(defface org-roam-preview-heading-selection
|
||||||
|
`((((class color) (background light))
|
||||||
|
,@(and (>= emacs-major-version 27) '(:extend t))
|
||||||
|
:inherit org-roam-preview-heading-highlight
|
||||||
|
:foreground "salmon4")
|
||||||
|
(((class color) (background dark))
|
||||||
|
,@(and (>= emacs-major-version 27) '(:extend t))
|
||||||
|
:inherit org-roam-preview-heading-highlight
|
||||||
|
:foreground "LightSalmon3"))
|
||||||
|
"Face for selected preview headings."
|
||||||
|
:group 'org-roam-faces)
|
||||||
|
|
||||||
|
(defface org-roam-preview-region
|
||||||
|
`((t :inherit bold
|
||||||
|
,@(and (>= emacs-major-version 27)
|
||||||
|
(list :extend (ignore-errors (face-attribute 'region :extend))))))
|
||||||
|
"Face used by `org-roam-highlight-preview-region-using-face'.
|
||||||
|
|
||||||
|
This face is overlaid over text that uses other hunk faces,
|
||||||
|
and those normally set the foreground and background colors.
|
||||||
|
The `:foreground' and especially the `:background' properties
|
||||||
|
should be avoided here. Setting the latter would cause the
|
||||||
|
loss of information. Good properties to set here are `:weight'
|
||||||
|
and `:slant'."
|
||||||
|
:group 'org-roam-faces)
|
||||||
|
|
||||||
|
(defface org-roam-dim
|
||||||
|
'((((class color) (background light)) :foreground "grey60")
|
||||||
|
(((class color) (background dark)) :foreground "grey40"))
|
||||||
|
"Face for the dimmer part of the widgets."
|
||||||
|
:group 'org-roam-faces)
|
||||||
|
|
||||||
|
;;; Variables
|
||||||
|
(defvar org-roam-current-node nil
|
||||||
|
"The current node at point.")
|
||||||
|
|
||||||
|
(defcustom org-roam-mode-section-functions (list #'org-roam-backlinks-section
|
||||||
|
#'org-roam-reflinks-section)
|
||||||
|
"Functions which insert sections of the `org-roam-buffer'.
|
||||||
|
Each function is called with one argument, which is the current org-roam node at point."
|
||||||
|
:group 'org-roam
|
||||||
|
:type 'hook)
|
||||||
|
|
||||||
|
;;; The mode
|
||||||
|
(defvar org-roam-mode-map
|
||||||
|
(let ((map (make-sparse-keymap)))
|
||||||
|
(set-keymap-parent map magit-section-mode-map)
|
||||||
|
(define-key map [C-return] 'org-roam-visit-thing)
|
||||||
|
(define-key map (kbd "C-m") 'org-roam-visit-thing)
|
||||||
|
(define-key map [remap revert-buffer] 'org-roam-buffer-render)
|
||||||
|
map)
|
||||||
|
"Parent keymap for all keymaps of modes derived from `org-roam-mode'.")
|
||||||
|
|
||||||
|
(define-derived-mode org-roam-mode magit-section-mode "Org-roam"
|
||||||
|
"Major mode for Org-roam's buffer."
|
||||||
|
:group 'org-roam
|
||||||
|
(face-remap-add-relative 'header-line 'org-roam-header-line))
|
||||||
|
|
||||||
|
;;; Key functions
|
||||||
|
(defun org-roam-visit-thing ()
|
||||||
|
"This is a placeholder command.
|
||||||
|
Where applicable, section-specific keymaps bind another command
|
||||||
|
which visits the thing at point."
|
||||||
|
(interactive)
|
||||||
|
(user-error "There is no thing at point that could be visited"))
|
||||||
|
|
||||||
|
(defun org-roam-buffer-render ()
|
||||||
|
"Render the current node at point."
|
||||||
|
(interactive)
|
||||||
|
(when (derived-mode-p 'org-roam-mode)
|
||||||
|
(let ((inhibit-read-only t))
|
||||||
|
(erase-buffer)
|
||||||
|
(org-roam-set-header-line-format (org-roam-node-title org-roam-current-node))
|
||||||
|
(magit-insert-section (org-roam)
|
||||||
|
(magit-insert-heading)
|
||||||
|
(run-hook-with-args 'org-roam-mode-section-functions org-roam-current-node)))))
|
||||||
|
|
||||||
|
(defun org-roam-buffer ()
|
||||||
|
"Launch an Org-roam buffer for the current node at point."
|
||||||
|
(interactive)
|
||||||
|
(if-let ((node (org-roam-node-at-point)))
|
||||||
|
(progn
|
||||||
|
(let ((buffer (get-buffer-create
|
||||||
|
(concat "org-roam: "
|
||||||
|
(file-relative-name (buffer-file-name) org-roam-directory)))))
|
||||||
|
(with-current-buffer buffer
|
||||||
|
(org-roam-mode)
|
||||||
|
(setq-local org-roam-current-node node)
|
||||||
|
(org-roam-buffer-render))
|
||||||
|
(switch-to-buffer-other-window buffer)))
|
||||||
|
(user-error "No node at point")))
|
||||||
|
|
||||||
|
;;; Persistent buffer
|
||||||
|
(defvar org-roam-buffer "*org-roam*"
|
||||||
|
"The persistent Org-roam buffer name.")
|
||||||
|
|
||||||
|
(defun org-roam-buffer--post-command-h ()
|
||||||
|
"Reconstructs the Org-roam buffer.
|
||||||
|
This needs to be quick or infrequent, because this is run at
|
||||||
|
`post-command-hook'. If REDISPLAY, force an update of
|
||||||
|
the Org-roam buffer."
|
||||||
|
(when (get-buffer-window org-roam-buffer)
|
||||||
|
(when-let ((node (org-roam-node-at-point)))
|
||||||
|
(unless (equal node org-roam-current-node)
|
||||||
|
(setq org-roam-current-node node)
|
||||||
|
(org-roam-buffer-persistent-redisplay)))))
|
||||||
|
|
||||||
|
(define-inline org-roam-buffer--visibility ()
|
||||||
|
"Return whether the current visibility state of the org-roam buffer.
|
||||||
|
Valid states are 'visible, 'exists and 'none."
|
||||||
|
(declare (side-effect-free t))
|
||||||
|
(inline-quote
|
||||||
|
(cond
|
||||||
|
((get-buffer-window org-roam-buffer) 'visible)
|
||||||
|
((get-buffer org-roam-buffer) 'exists)
|
||||||
|
(t 'none))))
|
||||||
|
|
||||||
|
(defun org-roam-buffer-toggle ()
|
||||||
|
"Toggle display of the Org-roam buffer."
|
||||||
|
(interactive)
|
||||||
|
(pcase (org-roam-buffer--visibility)
|
||||||
|
('visible
|
||||||
|
(progn
|
||||||
|
(delete-window (get-buffer-window org-roam-buffer))
|
||||||
|
(remove-hook 'post-command-hook #'org-roam-buffer--post-command-h)))
|
||||||
|
((or 'exists 'none)
|
||||||
|
(progn
|
||||||
|
(display-buffer (get-buffer-create org-roam-buffer))
|
||||||
|
(setq org-roam-current-node (org-roam-node-at-point))
|
||||||
|
(org-roam-buffer-persistent-redisplay)))))
|
||||||
|
|
||||||
|
(defun org-roam-buffer-persistent-redisplay ()
|
||||||
|
"Recompute contents of the persistent Org-roam buffer.
|
||||||
|
Has no effect when `org-roam-current-node' is nil."
|
||||||
|
(when org-roam-current-node
|
||||||
|
(with-current-buffer (get-buffer-create org-roam-buffer)
|
||||||
|
(let ((inhibit-read-only t))
|
||||||
|
(erase-buffer)
|
||||||
|
(org-roam-mode)
|
||||||
|
(org-roam-set-header-line-format (org-roam-node-title org-roam-current-node))
|
||||||
|
(magit-insert-section (org-roam)
|
||||||
|
(magit-insert-heading)
|
||||||
|
(dolist (fn org-roam-mode-section-functions)
|
||||||
|
(funcall fn org-roam-current-node)))))))
|
||||||
|
|
||||||
|
(defun org-roam-buffer--redisplay ()
|
||||||
|
"."
|
||||||
|
(add-hook 'post-command-hook #'org-roam-buffer--post-command-h nil t))
|
||||||
|
|
||||||
|
(add-hook 'org-roam-find-file-hook #'org-roam-buffer--redisplay)
|
||||||
|
|
||||||
|
;;; Sections
|
||||||
|
;;;; Backlinks
|
||||||
|
(cl-defstruct (org-roam-backlink (:constructor org-roam-backlink-create)
|
||||||
|
(:copier nil))
|
||||||
|
source-node target-node
|
||||||
|
point properties)
|
||||||
|
|
||||||
|
(cl-defmethod org-roam-populate ((backlink org-roam-backlink))
|
||||||
|
"Populate BACKLINK from database."
|
||||||
|
(setf (org-roam-backlink-source-node backlink)
|
||||||
|
(org-roam-populate (org-roam-backlink-source-node backlink))
|
||||||
|
(org-roam-backlink-target-node backlink)
|
||||||
|
(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-loop for backlink in backlinks
|
||||||
|
collect (pcase-let ((`(,source-id ,dest-id ,pos ,properties) backlink))
|
||||||
|
(org-roam-populate
|
||||||
|
(org-roam-backlink-create
|
||||||
|
:source-node (org-roam-node-create :id source-id)
|
||||||
|
:target-node (org-roam-node-create :id dest-id)
|
||||||
|
:point pos
|
||||||
|
:properties properties))))))
|
||||||
|
|
||||||
|
(defun org-roam-backlinks-sort (a b)
|
||||||
|
"Default sorting function for backlinks A and B.
|
||||||
|
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))))
|
||||||
|
(magit-insert-section (org-roam-backlinks)
|
||||||
|
(magit-insert-heading "Backlinks:")
|
||||||
|
(dolist (backlink backlinks)
|
||||||
|
(org-roam-node-insert-section
|
||||||
|
:source-node (org-roam-backlink-source-node backlink)
|
||||||
|
:point (org-roam-backlink-point backlink)
|
||||||
|
:properties (org-roam-backlink-properties backlink)))
|
||||||
|
(insert ?\n))))
|
||||||
|
|
||||||
|
;;;; Reflinks
|
||||||
|
(cl-defstruct (org-roam-reflink (:constructor org-roam-reflink-create)
|
||||||
|
(:copier nil))
|
||||||
|
source-node ref
|
||||||
|
point properties)
|
||||||
|
|
||||||
|
(cl-defmethod org-roam-populate ((reflink org-roam-reflink))
|
||||||
|
"Populate REFLINK from database."
|
||||||
|
(setf (org-roam-reflink-source-node reflink)
|
||||||
|
(org-roam-populate (org-roam-reflink-source-node reflink)))
|
||||||
|
reflink)
|
||||||
|
|
||||||
|
(defun org-roam-reflinks-get (node)
|
||||||
|
"Return the reflinks for NODE."
|
||||||
|
(let ((refs (org-roam-db-query [:select [ref] :from refs
|
||||||
|
:where (= node-id $s1)]
|
||||||
|
(org-roam-node-id node)))
|
||||||
|
links)
|
||||||
|
(pcase-dolist (`(,ref) refs)
|
||||||
|
(pcase-dolist (`(,source-id ,pos ,properties) (org-roam-db-query
|
||||||
|
[:select [source pos properties]
|
||||||
|
:from links
|
||||||
|
:where (= dest $s1)]
|
||||||
|
ref))
|
||||||
|
(push (org-roam-populate
|
||||||
|
(org-roam-reflink-create
|
||||||
|
:source-node (org-roam-node-create :id source-id)
|
||||||
|
:ref ref
|
||||||
|
:point pos
|
||||||
|
:properties properties)) links)))
|
||||||
|
links))
|
||||||
|
|
||||||
|
(defun org-roam-reflinks-sort (a b)
|
||||||
|
"Default sorting function for reflinks A and B.
|
||||||
|
Sorts by title."
|
||||||
|
(string< (org-roam-node-title (org-roam-reflink-source-node a))
|
||||||
|
(org-roam-node-title (org-roam-reflink-source-node b))))
|
||||||
|
|
||||||
|
(defun org-roam-reflinks-section (node)
|
||||||
|
"The reflinks section for NODE."
|
||||||
|
(when (org-roam-node-refs node)
|
||||||
|
(let* ((reflinks (seq-sort #'org-roam-reflinks-sort (org-roam-reflinks-get node))))
|
||||||
|
(magit-insert-section (org-roam-reflinks)
|
||||||
|
(magit-insert-heading "Reflinks:")
|
||||||
|
(dolist (reflink reflinks)
|
||||||
|
(org-roam-node-insert-section
|
||||||
|
:source-node (org-roam-reflink-source-node reflink)
|
||||||
|
:point (org-roam-reflink-point reflink)
|
||||||
|
:properties (org-roam-reflink-properties reflink)))
|
||||||
|
(insert ?\n)))))
|
||||||
|
|
||||||
|
;;;; Unlinked references
|
||||||
|
(defvar org-roam-grep-map
|
||||||
|
(let ((map (make-sparse-keymap)))
|
||||||
|
(set-keymap-parent map org-roam-mode-map)
|
||||||
|
(define-key map [remap org-roam-visit-thing] 'org-roam-file-visit)
|
||||||
|
map)
|
||||||
|
"Keymap for Org-roam grep result sections.")
|
||||||
|
|
||||||
|
(defclass org-roam-grep-section (magit-section)
|
||||||
|
((keymap :initform org-roam-grep-map)
|
||||||
|
(file :initform nil)
|
||||||
|
(row :initform nil)
|
||||||
|
(col :initform nil)))
|
||||||
|
|
||||||
|
(defun org-roam-file-at-point (&optional assert)
|
||||||
|
"Return the file at point.
|
||||||
|
If ASSERT, throw an error."
|
||||||
|
(if-let ((file (magit-section-case
|
||||||
|
(org-roam-node-section (org-roam-node-file (oref it node)))
|
||||||
|
(org-roam-grep-section (oref it file))
|
||||||
|
(org-roam-preview-section (oref it file)))))
|
||||||
|
file
|
||||||
|
(when assert
|
||||||
|
(user-error "No file at point"))))
|
||||||
|
|
||||||
|
(defun org-roam-file-visit (file &optional other-window row col)
|
||||||
|
"Visits FILE.
|
||||||
|
With a prefix argument OTHER-WINDOW, display the buffer in
|
||||||
|
another window instead.
|
||||||
|
If ROW, move to the row, and if COL move to the COL."
|
||||||
|
(interactive (list (org-roam-file-at-point t)
|
||||||
|
current-prefix-arg
|
||||||
|
(oref (magit-current-section) row)
|
||||||
|
(oref (magit-current-section) col)))
|
||||||
|
(let ((buf (find-file-noselect file)))
|
||||||
|
(with-current-buffer buf
|
||||||
|
(widen)
|
||||||
|
(goto-char (point-min))
|
||||||
|
(when row
|
||||||
|
(forward-line (1- row)))
|
||||||
|
(when col
|
||||||
|
(forward-char (1- col))))
|
||||||
|
(funcall (if other-window
|
||||||
|
#'switch-to-buffer-other-window
|
||||||
|
#'pop-to-buffer-same-window) buf)))
|
||||||
|
|
||||||
|
(defvar org-roam-unlinked-references-result-re
|
||||||
|
(rx (group (one-or-more anything))
|
||||||
|
":"
|
||||||
|
(group (one-or-more digit))
|
||||||
|
":"
|
||||||
|
(group (one-or-more digit))
|
||||||
|
":"
|
||||||
|
(group (zero-or-more anything)))
|
||||||
|
"Regex for the return result of a ripgrep query.")
|
||||||
|
|
||||||
|
(defun org-roam-unlinked-references-preview-line (file row)
|
||||||
|
"Return the preview line from FILE.
|
||||||
|
This is the ROW within FILE."
|
||||||
|
(with-temp-buffer
|
||||||
|
(insert-file-contents-literally file)
|
||||||
|
(forward-line (1- row))
|
||||||
|
(buffer-substring-no-properties
|
||||||
|
(save-excursion
|
||||||
|
(beginning-of-line)
|
||||||
|
(point))
|
||||||
|
(save-excursion
|
||||||
|
(end-of-line)
|
||||||
|
(point)))))
|
||||||
|
|
||||||
|
(defun org-roam-unlinked-references-section (node)
|
||||||
|
"The unlinked references section for NODE.
|
||||||
|
References from FILE are excluded."
|
||||||
|
(when (and (executable-find "rg")
|
||||||
|
(not (string-match "PCRE2 is not available"
|
||||||
|
(shell-command-to-string "rg --pcre2-version"))))
|
||||||
|
(let* ((titles (cons (org-roam-node-title node)
|
||||||
|
(org-roam-node-aliases node)))
|
||||||
|
(rg-command (concat "rg -o --vimgrep -P -i "
|
||||||
|
(mapconcat (lambda (glob) (concat "-g " glob))
|
||||||
|
(org-roam--list-files-search-globs org-roam-file-extensions)
|
||||||
|
" ")
|
||||||
|
(format " '\\[([^[]]++|(?R))*\\]%s' "
|
||||||
|
(mapconcat (lambda (title)
|
||||||
|
(format "|(\\b%s\\b)" (shell-quote-argument title)))
|
||||||
|
titles ""))
|
||||||
|
org-roam-directory))
|
||||||
|
(results (split-string (shell-command-to-string rg-command) "\n"))
|
||||||
|
f row col match)
|
||||||
|
(magit-insert-section (unlinked-references)
|
||||||
|
(magit-insert-heading "Unlinked References:")
|
||||||
|
(dolist (line results)
|
||||||
|
(save-match-data
|
||||||
|
(when (string-match org-roam-unlinked-references-result-re line)
|
||||||
|
(setq f (match-string 1 line)
|
||||||
|
row (string-to-number (match-string 2 line))
|
||||||
|
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))
|
||||||
|
(member (downcase match) (mapcar #'downcase titles)))
|
||||||
|
(magit-insert-section section (org-roam-grep-section)
|
||||||
|
(oset section file f)
|
||||||
|
(oset section row row)
|
||||||
|
(oset section col col)
|
||||||
|
(insert (propertize (format "%s:%s:%s"
|
||||||
|
(truncate-string-to-width (file-name-base f) 15 nil nil "...")
|
||||||
|
row col) 'font-lock-face 'org-roam-dim)
|
||||||
|
" "
|
||||||
|
(org-roam-fontify-like-in-org-mode
|
||||||
|
(org-roam-unlinked-references-preview-line f row))
|
||||||
|
"\n"))))))
|
||||||
|
(insert ?\n)))))
|
||||||
|
|
||||||
|
(provide 'org-roam-mode)
|
||||||
|
;;; org-roam-mode.el ends here
|
@ -1,11 +1,11 @@
|
|||||||
;;; org-roam-protocol.el --- Protocol handler for roam:// links -*- coding: utf-8; lexical-binding: t -*-
|
;;; org-roam-protocol.el --- Protocol handler for roam:// links -*- coding: utf-8; lexical-binding: t; -*-
|
||||||
|
|
||||||
;; Copyright © 2020 Jethro Kuan <jethrokuan95@gmail.com>
|
;; Copyright © 2020 Jethro Kuan <jethrokuan95@gmail.com>
|
||||||
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
||||||
;; URL: https://github.com/jethrokuan/org-roam
|
;; URL: https://github.com/org-roam/org-roam
|
||||||
;; Keywords: org-mode, roam, convenience
|
;; Keywords: org-mode, roam, convenience
|
||||||
;; Version: 1.1.0
|
;; Version: 2.0.0
|
||||||
;; Package-Requires: ((emacs "26.1") (org "9.3"))
|
;; 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 "2.90.1"))
|
||||||
|
|
||||||
;; This file is NOT part of GNU Emacs.
|
;; This file is NOT part of GNU Emacs.
|
||||||
|
|
||||||
@ -37,6 +37,14 @@
|
|||||||
;;; Code:
|
;;; Code:
|
||||||
(require 'org-protocol)
|
(require 'org-protocol)
|
||||||
(require 'org-roam)
|
(require 'org-roam)
|
||||||
|
(eval-when-compile
|
||||||
|
(require 'org-roam-macs))
|
||||||
|
(require 'ol) ;; for org-link-decode
|
||||||
|
|
||||||
|
(defcustom org-roam-protocol-store-links nil
|
||||||
|
"Whether to store links when capturing websites with `org-roam-protocol'."
|
||||||
|
:type 'boolean
|
||||||
|
:group 'org-roam)
|
||||||
|
|
||||||
;;;; Functions
|
;;;; Functions
|
||||||
(defun org-roam-protocol-open-ref (info)
|
(defun org-roam-protocol-open-ref (info)
|
||||||
@ -45,25 +53,34 @@
|
|||||||
It opens or creates a note with the given ref.
|
It opens or creates a note with the given ref.
|
||||||
|
|
||||||
javascript:location.href = \\='org-protocol://roam-ref?template=r&ref=\\='+ \\
|
javascript:location.href = \\='org-protocol://roam-ref?template=r&ref=\\='+ \\
|
||||||
encodeURIComponent(location.href) + \\='&title=\\=' \\
|
encodeURIComponent(location.href) + \\='&title=\\=' + \\
|
||||||
encodeURIComponent(document.title) + \\='&body=\\=' + \\
|
encodeURIComponent(document.title) + \\='&body=\\=' + \\
|
||||||
encodeURIComponent(window.getSelection())"
|
encodeURIComponent(window.getSelection())"
|
||||||
(when-let* ((alist (org-roam--plist-to-alist info))
|
(unless (plist-get info :ref)
|
||||||
(decoded-alist (mapcar (lambda (k.v)
|
(user-error "No ref key provided"))
|
||||||
(let ((key (car k.v))
|
(org-roam-plist-map! (lambda (k v)
|
||||||
(val (cdr k.v)))
|
(org-link-decode
|
||||||
(cons key (org-link-decode val)))) alist)))
|
(if (equal k :ref)
|
||||||
(unless (assoc 'ref decoded-alist)
|
(org-protocol-sanitize-uri v)
|
||||||
(error "No ref key provided"))
|
v))) info)
|
||||||
(when-let ((title (cdr (assoc 'title decoded-alist))))
|
(when org-roam-protocol-store-links
|
||||||
(push (cons 'slug (org-roam--title-to-slug title)) decoded-alist))
|
(push (list (plist-get info :ref)
|
||||||
(let* ((org-roam-capture-templates org-roam-capture-ref-templates)
|
(plist-get info :title)) org-stored-links))
|
||||||
(org-roam-capture--context 'ref)
|
(org-link-store-props :type (and (string-match org-link-plain-re
|
||||||
(org-roam-capture--info decoded-alist)
|
(plist-get info :ref))
|
||||||
(template (cdr (assoc 'template decoded-alist))))
|
(match-string 1 (plist-get info :ref)))
|
||||||
|
:link (plist-get info :ref)
|
||||||
|
:annotation (org-link-make-string (plist-get info :ref)
|
||||||
|
(or (plist-get info :title)
|
||||||
|
(plist-get info :ref)))
|
||||||
|
:initial (or (plist-get info :body) ""))
|
||||||
(raise-frame)
|
(raise-frame)
|
||||||
(org-roam--capture nil template)
|
(org-roam-capture-
|
||||||
(message "Item captured.")))
|
:keys (plist-get info :template)
|
||||||
|
:node (org-roam-node-create :title (plist-get info :title))
|
||||||
|
:info (list :ref (plist-get info :ref)
|
||||||
|
:body (plist-get info :body))
|
||||||
|
:templates org-roam-capture-ref-templates)
|
||||||
nil)
|
nil)
|
||||||
|
|
||||||
(defun org-roam-protocol-open-file (info)
|
(defun org-roam-protocol-open-file (info)
|
||||||
|
77
org-roam-refile.el
Normal file
77
org-roam-refile.el
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
;;; org-roam-refile.el --- Refile Org-roam Notes -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
|
;; Copyright © 2020 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.0.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 "2.90.1"))
|
||||||
|
|
||||||
|
;; 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:
|
||||||
|
;;
|
||||||
|
;; Org-roam refile allows you to refile notes to your nodes.
|
||||||
|
;;
|
||||||
|
;;; Code:
|
||||||
|
(defvar org-auto-align-tags)
|
||||||
|
(defvar org-loop-over-headlines-in-active-region)
|
||||||
|
|
||||||
|
(defun org-roam-refile ()
|
||||||
|
"Refile to node."
|
||||||
|
(interactive)
|
||||||
|
(let* ((regionp (org-region-active-p))
|
||||||
|
(region-start (and regionp (region-beginning)))
|
||||||
|
(region-end (and regionp (region-end)))
|
||||||
|
(node (org-roam-node-read nil nil 'require-match))
|
||||||
|
(file (org-roam-node-file node))
|
||||||
|
(nbuf (or (find-buffer-visiting file)
|
||||||
|
(find-file-noselect file)))
|
||||||
|
level reversed)
|
||||||
|
(if regionp
|
||||||
|
(progn
|
||||||
|
(org-kill-new (buffer-substring region-start region-end))
|
||||||
|
(org-save-markers-in-region region-start region-end))
|
||||||
|
(org-copy-subtree 1 nil t))
|
||||||
|
(with-current-buffer nbuf
|
||||||
|
(org-with-wide-buffer
|
||||||
|
(goto-char (org-roam-node-point node))
|
||||||
|
(setq level (org-get-valid-level (funcall outline-level) 1)
|
||||||
|
reversed (org-notes-order-reversed-p))
|
||||||
|
(goto-char
|
||||||
|
(if reversed
|
||||||
|
(or (outline-next-heading) (point-max))
|
||||||
|
(or (save-excursion (org-get-next-sibling))
|
||||||
|
(org-end-of-subtree t t)
|
||||||
|
(point-max))))
|
||||||
|
(unless (bolp) (newline))
|
||||||
|
(org-paste-subtree level nil nil t)
|
||||||
|
(and org-auto-align-tags
|
||||||
|
(let ((org-loop-over-headlines-in-active-region nil))
|
||||||
|
(org-align-tags)))
|
||||||
|
(when (fboundp 'deactivate-mark) (deactivate-mark))))
|
||||||
|
(if regionp
|
||||||
|
(delete-region (point) (+ (point) (- region-end region-start)))
|
||||||
|
(org-preserve-local-variables
|
||||||
|
(delete-region
|
||||||
|
(and (org-back-to-heading t) (point))
|
||||||
|
(min (1+ (buffer-size)) (org-end-of-subtree t t) (point)))))))
|
||||||
|
|
||||||
|
(provide 'org-roam-refile)
|
||||||
|
;;; org-roam-refile.el ends here
|
213
org-roam-utils.el
Normal file
213
org-roam-utils.el
Normal file
@ -0,0 +1,213 @@
|
|||||||
|
;;; org-roam-utils.el --- Utilities for Org-roam -*- coding: utf-8; lexical-binding: t; -*-
|
||||||
|
|
||||||
|
;; Copyright © 2020 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.0.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 "2.90.1"))
|
||||||
|
|
||||||
|
;; 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 library implements utility functions used throughout
|
||||||
|
;; Org-roam.
|
||||||
|
;;
|
||||||
|
;;
|
||||||
|
;;; Code:
|
||||||
|
;;;; Library Requires
|
||||||
|
(require 'dash)
|
||||||
|
(require 's)
|
||||||
|
|
||||||
|
(defvar org-roam-verbose)
|
||||||
|
|
||||||
|
;; This is necessary to ensure all dependents on this module see
|
||||||
|
;; `org-mode-hook' and `org-inhibit-startup' as dynamic variables,
|
||||||
|
;; regardless of whether Org is loaded before their compilation.
|
||||||
|
(require 'org)
|
||||||
|
|
||||||
|
;;;; Utility Functions
|
||||||
|
(defun org-roam--list-interleave (lst separator)
|
||||||
|
"Interleaves elements in LST with SEPARATOR."
|
||||||
|
(when lst
|
||||||
|
(let ((new-lst (list (pop lst))))
|
||||||
|
(dolist (it lst)
|
||||||
|
(nconc new-lst (list separator it)))
|
||||||
|
new-lst)))
|
||||||
|
|
||||||
|
(defun org-roam-up-heading-or-point-min ()
|
||||||
|
"Fixed version of Org's `org-up-heading-or-point-min'."
|
||||||
|
(ignore-errors (org-back-to-heading t))
|
||||||
|
(let ((p (point)))
|
||||||
|
(if (< 1 (funcall outline-level))
|
||||||
|
(progn
|
||||||
|
(org-up-heading-safe)
|
||||||
|
(when (= (point) p)
|
||||||
|
(goto-char (point-min))))
|
||||||
|
(unless (bobp) (goto-char (point-min))))))
|
||||||
|
|
||||||
|
(defun org-roam-message (format-string &rest args)
|
||||||
|
"Pass FORMAT-STRING and ARGS to `message' when `org-roam-verbose' is t."
|
||||||
|
(when org-roam-verbose
|
||||||
|
(apply #'message `(,(concat "(org-roam) " format-string) ,@args))))
|
||||||
|
|
||||||
|
(defvar org-ref-buffer-hacked)
|
||||||
|
|
||||||
|
(defun org-roam-fontify-like-in-org-mode (s)
|
||||||
|
"Fontify string S like in Org mode.
|
||||||
|
Like `org-fontify-like-in-org-mode', but supports `org-ref'."
|
||||||
|
;; NOTE: pretend that the temporary buffer created by `org-fontify-like-in-org-mode' to
|
||||||
|
;; fontify a `cite:' reference has been hacked by org-ref, whatever that means;
|
||||||
|
;;
|
||||||
|
;; `org-ref-cite-link-face-fn', which is used to supply a face for `cite:' links, calls
|
||||||
|
;; `hack-dir-local-variables' rationalizing that `bibtex-completion' would throw some warnings
|
||||||
|
;; otherwise. This doesn't seem to be the case and calling this function just before
|
||||||
|
;; `org-font-lock-ensure' (alias of `font-lock-ensure') actually instead of fixing the alleged
|
||||||
|
;; warnings messes the things so badly that `font-lock-ensure' crashes with error and doesn't let
|
||||||
|
;; org-roam to proceed further. I don't know what's happening there exactly but disabling this hackery
|
||||||
|
;; fixes the crashing. Fortunately, org-ref provides the `org-ref-buffer-hacked' switch, which we use
|
||||||
|
;; here to make it believe that the buffer was hacked.
|
||||||
|
;;
|
||||||
|
;; This is a workaround for `cite:' links and does not have any effect on other ref types.
|
||||||
|
;;
|
||||||
|
;; `org-ref-buffer-hacked' is a buffer-local variable, therefore we inline
|
||||||
|
;; `org-fontify-like-in-org-mode' here
|
||||||
|
(with-temp-buffer
|
||||||
|
(insert s)
|
||||||
|
(let ((org-ref-buffer-hacked t))
|
||||||
|
(org-mode)
|
||||||
|
(org-font-lock-ensure)
|
||||||
|
(buffer-string))))
|
||||||
|
|
||||||
|
(defun org-roam-set-header-line-format (string)
|
||||||
|
"Set the header-line using STRING.
|
||||||
|
If the `face' property of any part of STRING is already set, then
|
||||||
|
that takes precedence. Also pad the left side of STRING so that
|
||||||
|
it aligns with the text area."
|
||||||
|
(setq-local header-line-format
|
||||||
|
(concat (propertize " " 'display '(space :align-to 0))
|
||||||
|
string)))
|
||||||
|
|
||||||
|
;;; Shielding regions
|
||||||
|
(defface org-roam-shielded
|
||||||
|
'((t :inherit (warning)))
|
||||||
|
"Face for regions that are shielded (marked as read-only).
|
||||||
|
This face is used on the region target by org-roam-insertion
|
||||||
|
during an `org-roam-capture'."
|
||||||
|
:group 'org-roam-faces)
|
||||||
|
|
||||||
|
(defun org-roam-shield-region (beg end)
|
||||||
|
"Shield region against modifications.
|
||||||
|
BEG and END are markers for the beginning and end regions.
|
||||||
|
REGION must be a cons-cell containing the marker to the region
|
||||||
|
beginning and maximum values."
|
||||||
|
(add-text-properties beg end
|
||||||
|
'(font-lock-face org-roam-shielded
|
||||||
|
read-only t)
|
||||||
|
(marker-buffer beg)))
|
||||||
|
|
||||||
|
(defun org-roam-unshield-region (beg end)
|
||||||
|
"Unshield the shielded REGION.
|
||||||
|
BEG and END are markers for the beginning and end regions."
|
||||||
|
(let ((inhibit-read-only t))
|
||||||
|
(remove-text-properties beg end
|
||||||
|
'(font-lock-face org-roam-shielded
|
||||||
|
read-only t)
|
||||||
|
(marker-buffer beg))))
|
||||||
|
|
||||||
|
;;; Formatting
|
||||||
|
(defun org-roam-format (template replacer)
|
||||||
|
"Format TEMPLATE with the function REPLACER.
|
||||||
|
REPLACER takes an argument of the format variable and optionally
|
||||||
|
an extra argument which is the EXTRA value from the call to
|
||||||
|
`org-roam-format'.
|
||||||
|
Adapted from `s-format'."
|
||||||
|
(let ((saved-match-data (match-data)))
|
||||||
|
(unwind-protect
|
||||||
|
(replace-regexp-in-string
|
||||||
|
"\\${\\([^}]+\\)}"
|
||||||
|
(lambda (md)
|
||||||
|
(let ((var (match-string 1 md))
|
||||||
|
(replacer-match-data (match-data)))
|
||||||
|
(unwind-protect
|
||||||
|
(let ((v (progn
|
||||||
|
(set-match-data saved-match-data)
|
||||||
|
(funcall replacer var))))
|
||||||
|
(if v (format "%s" v) (signal 'org-roam-format-resolve md)))
|
||||||
|
(set-match-data replacer-match-data)))) template
|
||||||
|
;; Need literal to make sure it works
|
||||||
|
t t)
|
||||||
|
(set-match-data saved-match-data))))
|
||||||
|
|
||||||
|
(defvar org-roam--cached-display-format nil)
|
||||||
|
|
||||||
|
(defun org-roam--process-display-format (format)
|
||||||
|
"Pre-calculate minimal widths needed by the FORMAT string."
|
||||||
|
(or org-roam--cached-display-format
|
||||||
|
(setq org-roam--cached-display-format
|
||||||
|
(let* ((fields-width 0)
|
||||||
|
(string-width
|
||||||
|
(string-width
|
||||||
|
(org-roam-format
|
||||||
|
format
|
||||||
|
(lambda (field)
|
||||||
|
(setq fields-width
|
||||||
|
(+ fields-width
|
||||||
|
(string-to-number
|
||||||
|
(or (cadr (split-string field ":"))
|
||||||
|
"")))))))))
|
||||||
|
(cons format (+ fields-width string-width))))))
|
||||||
|
|
||||||
|
;;; Diagnostics
|
||||||
|
;;;###autoload
|
||||||
|
(defun org-roam-version (&optional message)
|
||||||
|
"Return `org-roam' version.
|
||||||
|
Interactively, or when MESSAGE is non-nil, show in the echo area."
|
||||||
|
(interactive)
|
||||||
|
(let* ((version
|
||||||
|
(with-temp-buffer
|
||||||
|
(insert-file-contents-literally (locate-library "org-roam.el"))
|
||||||
|
(goto-char (point-min))
|
||||||
|
(save-match-data
|
||||||
|
(if (re-search-forward "\\(?:;; Version: \\([^z-a]*?$\\)\\)" nil nil)
|
||||||
|
(substring-no-properties (match-string 1))
|
||||||
|
"N/A")))))
|
||||||
|
(if (or message (called-interactively-p 'interactive))
|
||||||
|
(message "%s" version)
|
||||||
|
version)))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun org-roam-diagnostics ()
|
||||||
|
"Collect and print info for `org-roam' issues."
|
||||||
|
(interactive)
|
||||||
|
(with-current-buffer (switch-to-buffer-other-window (get-buffer-create "*org-roam diagnostics*"))
|
||||||
|
(erase-buffer)
|
||||||
|
(insert (propertize "Copy info below this line into issue:\n" 'face '(:weight bold)))
|
||||||
|
(insert (format "- Emacs: %s\n" (emacs-version)))
|
||||||
|
(insert (format "- Framework: %s\n"
|
||||||
|
(condition-case _
|
||||||
|
(completing-read "I'm using the following Emacs framework:"
|
||||||
|
'("Doom" "Spacemacs" "N/A" "I don't know"))
|
||||||
|
(quit "N/A"))))
|
||||||
|
(insert (format "- Org: %s\n" (org-version nil 'full)))
|
||||||
|
(insert (format "- Org-roam: %s" (org-roam-version)))))
|
||||||
|
|
||||||
|
(provide 'org-roam-utils)
|
||||||
|
;;; org-roam-utils.el ends here
|
1433
org-roam.el
1433
org-roam.el
File diff suppressed because it is too large
Load Diff
@ -1,2 +0,0 @@
|
|||||||
#+ROAM_ALIAS: "a1" "a 2"
|
|
||||||
#+TITLE: t1
|
|
@ -1,3 +1,6 @@
|
|||||||
#+TITLE: Bar
|
:PROPERTIES:
|
||||||
|
:ID: 440795d0-70c1-4165-993d-aebd5eef7a24
|
||||||
|
:END:
|
||||||
|
#+title: Bar
|
||||||
|
|
||||||
This is file bar. Bar links to [[file:nested/bar.org][Nested Bar]].
|
[[id:884b2341-b7fe-434d-848c-5282c0727861][Foo]]
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
#+TITLE: Foo
|
:PROPERTIES:
|
||||||
|
:ID: 884b2341-b7fe-434d-848c-5282c0727861
|
||||||
This is the foo file. It contains a link to [[file:bar.org][Bar]].
|
:END:
|
||||||
|
#+title: Foo
|
||||||
To make the tests more robust, here are some arbitrary links:
|
|
||||||
|
|
||||||
- [[https:google.com][Google]]
|
|
||||||
- [[mailto:foo@john.com][mail to foo]]
|
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
#+TITLE: Nested Bar
|
|
||||||
|
|
||||||
This file is nested, 1 level deeper. It links to both [[file:../foo.org][Foo]] and [[file:foo.org][Nested Foo]].
|
|
@ -1,3 +0,0 @@
|
|||||||
#+TITLE: Nested Foo
|
|
||||||
|
|
||||||
This file has no links.
|
|
@ -1,3 +0,0 @@
|
|||||||
no title in this file :O
|
|
||||||
|
|
||||||
links to itself, with no title: [[file:no-title.org][no-title]]
|
|
@ -1,3 +0,0 @@
|
|||||||
#+TITLE: Unlinked
|
|
||||||
|
|
||||||
Nothing links here :(
|
|
@ -1 +0,0 @@
|
|||||||
#+ROAM_KEY: https://google.com/
|
|
@ -1,9 +1,9 @@
|
|||||||
;;; test-org-roam.el --- Tests for org-roam -*- lexical-binding: t; -*-
|
;;; test-org-roam.el --- Tests for Org-roam -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
;; Copyright (C) 2020 Jethro Kuan
|
;; Copyright (C) 2020 Jethro Kuan
|
||||||
|
|
||||||
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
||||||
;; Package-Requires: ((buttercup) (with-simulated-input))
|
;; Package-Requires: ((buttercup))
|
||||||
|
|
||||||
;; This program is free software; you can redistribute it and/or modify
|
;; 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
|
;; it under the terms of the GNU General Public License as published by
|
||||||
@ -19,291 +19,35 @@
|
|||||||
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
;;; Commentary:
|
;;; Commentary:
|
||||||
|
|
||||||
;;
|
|
||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
;;;; Requirements
|
|
||||||
|
|
||||||
(require 'buttercup)
|
(require 'buttercup)
|
||||||
(require 'with-simulated-input)
|
|
||||||
(require 'org-roam)
|
(require 'org-roam)
|
||||||
(require 'dash)
|
|
||||||
|
|
||||||
(defun org-roam-test-abs-path (file-path)
|
(describe "org-roam-db-sync"
|
||||||
"Get absolute FILE-PATH from `org-roam-directory'."
|
(before-all
|
||||||
(file-truename (expand-file-name file-path org-roam-directory)))
|
(setq org-roam-directory (expand-file-name "tests/roam-files")
|
||||||
|
org-roam-db-location (expand-file-name "org-roam.db" temporary-file-directory))
|
||||||
|
(org-roam-setup))
|
||||||
|
|
||||||
(defun org-roam-test-find-new-file (path)
|
(after-all
|
||||||
"PATH."
|
(org-roam-teardown)
|
||||||
(let ((path (org-roam-test-abs-path path)))
|
(delete-file org-roam-db-location))
|
||||||
(make-directory (file-name-directory path) t)
|
|
||||||
(find-file path)))
|
|
||||||
|
|
||||||
(defvar org-roam-test-directory (file-truename (concat default-directory "tests/roam-files"))
|
(it "has the correct number of files"
|
||||||
"Directory containing org-roam test org files.")
|
(expect (caar (org-roam-db-query [:select (funcall count) :from files]))
|
||||||
|
|
||||||
(defun org-roam-test-init ()
|
|
||||||
"."
|
|
||||||
(org-roam-db--close)
|
|
||||||
(let ((original-dir org-roam-test-directory)
|
|
||||||
(new-dir (expand-file-name (make-temp-name "org-roam") temporary-file-directory)))
|
|
||||||
(copy-directory original-dir new-dir)
|
|
||||||
(setq org-roam-directory new-dir)
|
|
||||||
(org-roam-mode +1)))
|
|
||||||
|
|
||||||
;;; Tests
|
|
||||||
(describe "org-roam-db-build-cache"
|
|
||||||
(it "initializes correctly"
|
|
||||||
(org-roam-test-init)
|
|
||||||
(org-roam-db-build-cache)
|
|
||||||
|
|
||||||
;; Cache
|
|
||||||
(expect (caar (org-roam-db-query [:select (funcall count) :from files])) :to-be 8)
|
|
||||||
(expect (caar (org-roam-db-query [:select (funcall count) :from links])) :to-be 5)
|
|
||||||
(expect (caar (org-roam-db-query [:select (funcall count) :from titles])) :to-be 8)
|
|
||||||
(expect (caar (org-roam-db-query [:select (funcall count) :from titles
|
|
||||||
:where titles :is-null])) :to-be 2)
|
|
||||||
(expect (caar (org-roam-db-query [:select (funcall count) :from refs])) :to-be 1)
|
|
||||||
|
|
||||||
;; TODO Test files
|
|
||||||
|
|
||||||
;; Links
|
|
||||||
(expect (caar (org-roam-db-query [:select (funcall count) :from links
|
|
||||||
:where (= from $s1)]
|
|
||||||
(org-roam-test-abs-path "foo.org"))) :to-be 1)
|
|
||||||
(expect (caar (org-roam-db-query [:select (funcall count) :from links
|
|
||||||
:where (= from $s1)]
|
|
||||||
(org-roam-test-abs-path "nested/bar.org"))) :to-be 2)
|
|
||||||
|
|
||||||
;; Links -- File-to
|
|
||||||
(expect (caar (org-roam-db-query [:select (funcall count) :from links
|
|
||||||
:where (= to $s1)]
|
|
||||||
(org-roam-test-abs-path "nested/foo.org"))) :to-be 1)
|
|
||||||
(expect (caar (org-roam-db-query [:select (funcall count) :from links
|
|
||||||
:where (= to $s1)]
|
|
||||||
(org-roam-test-abs-path "nested/bar.org"))) :to-be 1)
|
|
||||||
(expect (caar (org-roam-db-query [:select (funcall count) :from links
|
|
||||||
:where (= to $s1)]
|
|
||||||
(org-roam-test-abs-path "unlinked.org"))) :to-be 0)
|
|
||||||
;; TODO Test titles
|
|
||||||
(expect (org-roam-db-query [:select * :from titles])
|
|
||||||
:to-have-same-items-as
|
|
||||||
(list (list (org-roam-test-abs-path "alias.org")
|
|
||||||
(list "t1" "a1" "a 2"))
|
|
||||||
(list (org-roam-test-abs-path "bar.org")
|
|
||||||
(list "Bar"))
|
|
||||||
(list (org-roam-test-abs-path "foo.org")
|
|
||||||
(list "Foo"))
|
|
||||||
(list (org-roam-test-abs-path "nested/bar.org")
|
|
||||||
(list "Nested Bar"))
|
|
||||||
(list (org-roam-test-abs-path "nested/foo.org")
|
|
||||||
(list "Nested Foo"))
|
|
||||||
(list (org-roam-test-abs-path "no-title.org") nil)
|
|
||||||
(list (org-roam-test-abs-path "web_ref.org") nil)
|
|
||||||
(list (org-roam-test-abs-path "unlinked.org")
|
|
||||||
(list "Unlinked"))))
|
|
||||||
|
|
||||||
(expect (org-roam-db-query [:select * :from refs])
|
|
||||||
:to-have-same-items-as
|
|
||||||
(list (list "https://google.com/" (org-roam-test-abs-path "web_ref.org"))))
|
|
||||||
|
|
||||||
;; Expect rebuilds to be really quick (nothing changed)
|
|
||||||
(expect (org-roam-db-build-cache)
|
|
||||||
:to-equal
|
:to-equal
|
||||||
(list :files 0 :links 0 :titles 0 :refs 0 :deleted 0))))
|
2))
|
||||||
|
|
||||||
(describe "org-roam-insert"
|
(it "has the correct number of nodes"
|
||||||
(before-each
|
(expect (caar (org-roam-db-query [:select (funcall count) :from nodes]))
|
||||||
(org-roam-test-init)
|
|
||||||
(org-roam-db--clear)
|
|
||||||
(org-roam-db-build-cache))
|
|
||||||
|
|
||||||
(it "temp1 -> foo"
|
|
||||||
(let ((buf (org-roam-test-find-new-file "temp1.org")))
|
|
||||||
(with-current-buffer buf
|
|
||||||
(with-simulated-input
|
|
||||||
"Foo RET"
|
|
||||||
(org-roam-insert nil))))
|
|
||||||
(expect (buffer-string) :to-match (regexp-quote "file:foo.org")))
|
|
||||||
|
|
||||||
(it "temp2 -> nested/foo"
|
|
||||||
(let ((buf (org-roam-test-find-new-file "temp2.org")))
|
|
||||||
(with-current-buffer buf
|
|
||||||
(with-simulated-input
|
|
||||||
"Nested SPC Foo RET"
|
|
||||||
(org-roam-insert nil))))
|
|
||||||
(expect (buffer-string) :to-match (regexp-quote "file:nested/foo.org")))
|
|
||||||
|
|
||||||
(it "nested/temp3 -> foo"
|
|
||||||
(let ((buf (org-roam-test-find-new-file "nested/temp3.org")))
|
|
||||||
(with-current-buffer buf
|
|
||||||
(with-simulated-input
|
|
||||||
"Foo RET"
|
|
||||||
(org-roam-insert nil))))
|
|
||||||
(expect (buffer-string) :to-match (regexp-quote "file:../foo.org")))
|
|
||||||
|
|
||||||
(it "a/b/temp4 -> nested/foo"
|
|
||||||
(let ((buf (org-roam-test-find-new-file "a/b/temp4.org")))
|
|
||||||
(with-current-buffer buf
|
|
||||||
(with-simulated-input
|
|
||||||
"Nested SPC Foo RET"
|
|
||||||
(org-roam-insert nil))))
|
|
||||||
(expect (buffer-string) :to-match (regexp-quote "file:../../nested/foo.org"))))
|
|
||||||
|
|
||||||
(describe "rename file updates cache"
|
|
||||||
(before-each
|
|
||||||
(org-roam-test-init)
|
|
||||||
(org-roam-db--clear)
|
|
||||||
(org-roam-db-build-cache))
|
|
||||||
|
|
||||||
(it "foo -> new_foo"
|
|
||||||
(rename-file (org-roam-test-abs-path "foo.org")
|
|
||||||
(org-roam-test-abs-path "new_foo.org"))
|
|
||||||
;; Cache should be cleared of old file
|
|
||||||
(expect (caar (org-roam-db-query [:select (funcall count)
|
|
||||||
:from titles
|
|
||||||
:where (= file $s1)]
|
|
||||||
(org-roam-test-abs-path "foo.org"))) :to-be 0)
|
|
||||||
(expect (caar (org-roam-db-query [:select (funcall count)
|
|
||||||
:from refs
|
|
||||||
:where (= file $s1)]
|
|
||||||
(org-roam-test-abs-path "foo.org"))) :to-be 0)
|
|
||||||
(expect (caar (org-roam-db-query [:select (funcall count)
|
|
||||||
:from links
|
|
||||||
:where (= from $s1)]
|
|
||||||
(org-roam-test-abs-path "foo.org"))) :to-be 0)
|
|
||||||
|
|
||||||
;; Cache should be updated
|
|
||||||
(expect (org-roam-db-query [:select [to]
|
|
||||||
:from links
|
|
||||||
:where (= from $s1)]
|
|
||||||
(org-roam-test-abs-path "new_foo.org"))
|
|
||||||
:to-have-same-items-as
|
|
||||||
(list (list (org-roam-test-abs-path "bar.org"))))
|
|
||||||
(expect (org-roam-db-query [:select [from]
|
|
||||||
:from links
|
|
||||||
:where (= to $s1)]
|
|
||||||
(org-roam-test-abs-path "new_foo.org"))
|
|
||||||
:to-have-same-items-as
|
|
||||||
(list (list (org-roam-test-abs-path "nested/bar.org"))))
|
|
||||||
|
|
||||||
;; Links are updated
|
|
||||||
(expect (with-temp-buffer
|
|
||||||
(insert-file-contents (org-roam-test-abs-path "nested/bar.org"))
|
|
||||||
(buffer-string))
|
|
||||||
:to-match
|
|
||||||
(regexp-quote "[[file:../new_foo.org][Foo]]")))
|
|
||||||
|
|
||||||
(it "foo -> foo with spaces"
|
|
||||||
(rename-file (org-roam-test-abs-path "foo.org")
|
|
||||||
(org-roam-test-abs-path "foo with spaces.org"))
|
|
||||||
;; Cache should be cleared of old file
|
|
||||||
(expect (caar (org-roam-db-query [:select (funcall count)
|
|
||||||
:from titles
|
|
||||||
:where (= file $s1)]
|
|
||||||
(org-roam-test-abs-path "foo.org"))) :to-be 0)
|
|
||||||
(expect (caar (org-roam-db-query [:select (funcall count)
|
|
||||||
:from refs
|
|
||||||
:where (= file $s1)]
|
|
||||||
(org-roam-test-abs-path "foo.org"))) :to-be 0)
|
|
||||||
(expect (caar (org-roam-db-query [:select (funcall count)
|
|
||||||
:from links
|
|
||||||
:where (= from $s1)]
|
|
||||||
(org-roam-test-abs-path "foo.org"))) :to-be 0)
|
|
||||||
|
|
||||||
;; Cache should be updated
|
|
||||||
(expect (org-roam-db-query [:select [to]
|
|
||||||
:from links
|
|
||||||
:where (= from $s1)]
|
|
||||||
(org-roam-test-abs-path "foo with spaces.org"))
|
|
||||||
:to-have-same-items-as
|
|
||||||
(list (list (org-roam-test-abs-path "bar.org"))))
|
|
||||||
(expect (org-roam-db-query [:select [from]
|
|
||||||
:from links
|
|
||||||
:where (= to $s1)]
|
|
||||||
(org-roam-test-abs-path "foo with spaces.org"))
|
|
||||||
:to-have-same-items-as
|
|
||||||
(list (list (org-roam-test-abs-path "nested/bar.org"))))
|
|
||||||
|
|
||||||
;; Links are updated
|
|
||||||
(expect (with-temp-buffer
|
|
||||||
(insert-file-contents (org-roam-test-abs-path "nested/bar.org"))
|
|
||||||
(buffer-string))
|
|
||||||
:to-match
|
|
||||||
(regexp-quote "[[file:../foo with spaces.org][Foo]]")))
|
|
||||||
|
|
||||||
(it "no-title -> meaningful-title"
|
|
||||||
(rename-file (org-roam-test-abs-path "no-title.org")
|
|
||||||
(org-roam-test-abs-path "meaningful-title.org"))
|
|
||||||
;; File has no forward links
|
|
||||||
(expect (caar (org-roam-db-query [:select (funcall count)
|
|
||||||
:from links
|
|
||||||
:where (= from $s1)]
|
|
||||||
(org-roam-test-abs-path "no-title.org"))) :to-be 0)
|
|
||||||
(expect (caar (org-roam-db-query [:select (funcall count)
|
|
||||||
:from links
|
|
||||||
:where (= from $s1)]
|
|
||||||
(org-roam-test-abs-path "meaningful-title.org"))) :to-be 1)
|
|
||||||
|
|
||||||
;; Links are updated with the appropriate name
|
|
||||||
(expect (with-temp-buffer
|
|
||||||
(insert-file-contents (org-roam-test-abs-path "meaningful-title.org"))
|
|
||||||
(buffer-string))
|
|
||||||
:to-match
|
|
||||||
(regexp-quote "[[file:meaningful-title.org][meaningful-title]]")))
|
|
||||||
|
|
||||||
(it "web_ref -> hello"
|
|
||||||
(expect (org-roam-db-query
|
|
||||||
[:select [file] :from refs
|
|
||||||
:where (= ref $s1)]
|
|
||||||
"https://google.com/")
|
|
||||||
:to-equal
|
:to-equal
|
||||||
(list (list (org-roam-test-abs-path "web_ref.org"))))
|
2))
|
||||||
(rename-file (org-roam-test-abs-path "web_ref.org")
|
|
||||||
(org-roam-test-abs-path "hello.org"))
|
|
||||||
(expect (org-roam-db-query
|
|
||||||
[:select [file] :from refs
|
|
||||||
:where (= ref $s1)]
|
|
||||||
"https://google.com/")
|
|
||||||
:to-equal (list (list (org-roam-test-abs-path "hello.org"))))
|
|
||||||
(expect (caar (org-roam-db-query
|
|
||||||
[:select [ref] :from refs
|
|
||||||
:where (= file $s1)]
|
|
||||||
(org-roam-test-abs-path "web_ref.org")))
|
|
||||||
:to-equal nil)))
|
|
||||||
|
|
||||||
(describe "delete file updates cache"
|
(it "has the correct number of links"
|
||||||
(before-each
|
(expect (caar (org-roam-db-query [:select (funcall count) :from links]))
|
||||||
(org-roam-test-init)
|
:to-equal
|
||||||
(org-roam-db--clear)
|
1)))
|
||||||
(org-roam-db-build-cache)
|
|
||||||
(sleep-for 1))
|
|
||||||
|
|
||||||
(it "delete foo"
|
|
||||||
(delete-file (org-roam-test-abs-path "foo.org"))
|
|
||||||
(expect (caar (org-roam-db-query [:select (funcall count)
|
|
||||||
:from titles
|
|
||||||
:where (= file $s1)]
|
|
||||||
(org-roam-test-abs-path "foo.org"))) :to-be 0)
|
|
||||||
(expect (caar (org-roam-db-query [:select (funcall count)
|
|
||||||
:from refs
|
|
||||||
:where (= file $s1)]
|
|
||||||
(org-roam-test-abs-path "foo.org"))) :to-be 0)
|
|
||||||
(expect (caar (org-roam-db-query [:select (funcall count)
|
|
||||||
:from links
|
|
||||||
:where (= from $s1)]
|
|
||||||
(org-roam-test-abs-path "foo.org"))) :to-be 0))
|
|
||||||
|
|
||||||
(it "delete web_ref"
|
|
||||||
(expect (org-roam-db-query [:select * :from refs])
|
|
||||||
:to-have-same-items-as
|
|
||||||
(list (list "https://google.com/" (org-roam-test-abs-path "web_ref.org"))))
|
|
||||||
(delete-file (org-roam-test-abs-path "web_ref.org"))
|
|
||||||
(expect (org-roam-db-query [:select * :from refs])
|
|
||||||
:to-have-same-items-as
|
|
||||||
(list))))
|
|
||||||
|
|
||||||
(provide 'test-org-roam)
|
(provide 'test-org-roam)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user