File: org-roam.texi

package info (click to toggle)
org-roam 1.2.3-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 38,912 kB
  • sloc: lisp: 4,508; sh: 741; makefile: 130
file content (2011 lines) | stat: -rw-r--r-- 65,458 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
\input texinfo    @c -*- texinfo -*-
@c %**start of header
@setfilename org-roam.info
@settitle Org-roam User Manual
@documentencoding UTF-8
@documentlanguage en
@c %**end of header

@copying
@quotation
Copyright (C) 2020-2020 Jethro Kuan <jethrokuan95@@gmail.com>

You can redistribute this document and/or modify it under the terms
of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any
later version.

This document 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.

@end quotation
@end copying

@dircategory Emacs
@direntry
* Org-roam: (org-roam). Rudimentary Roam Replica for Emacs.
@end direntry

@finalout
@titlepage
@title Org-roam User Manual
@subtitle for version 1.2.3
@author Jethro Kuan
@page
@vskip 0pt plus 1filll
@insertcopying
@end titlepage

@ifnottex
@node Top
@top Org-roam User Manual

@noindent

This manual is for Org-roam version 1.2.3.

@quotation
Copyright (C) 2020-2020 Jethro Kuan <jethrokuan95@@gmail.com>

You can redistribute this document and/or modify it under the terms of the GNU
General Public License as published by the Free Software Foundation, either
version 3 of the License, or (at your option) any later version.

This document 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.

@end quotation
@end ifnottex

@menu
* Introduction::
* Target Audience::
* A Brief Introduction to the Zettelkasten Method::
* Installation::
* Getting Started::
* Anatomy of an Org-roam File::
* The Templating System::
* Concepts and Configuration::
* Inserting Links::
* Navigating Around::
* Encryption::
* Graphing::
* Org-roam Completion System::
* Roam Protocol::
* Daily-notes::
* Diagnosing and Repairing Files::
* Finding Unlinked References::
* Performance Optimization::
* Appendix::
* FAQ::
* Keystroke Index::
* Command Index::
* Function Index::
* Variable Index::

@detailmenu
--- The Detailed Node Listing ---

A Brief Introduction to the Zettelkasten Method

* Fleeting notes::
* Permanent notes::

Installation

* Installing from MELPA::
* Installing from Apt::
* Installing from the Git Repository::
* Post-Installation Tasks::

Anatomy of an Org-roam File

* Titles::
* Tags::
* File Refs::

The Templating System

* Template Walkthrough::
* Org-roam Template Expansion::

Concepts and Configuration

* Directories and Files::
* The Org-roam Buffer::
* Org-roam Files::
* Org-roam Faces::
* The Database::

Navigating Around

* Index File::

Graphing

* Graph Options::
* Excluding Nodes and Edges::

Roam Protocol

* Installation: Installation (1). 
* The roam-file protocol::
* The roam-ref protocol::

Daily-notes

* Configuration::
* Capturing and finding daily-notes::
* Navigation::

Performance Optimization

* Profiling Key Operations::
* Garbage Collection::

Appendix

* Note-taking Workflows::
* Ecosystem::

Ecosystem

* Browsing History with winner-mode::
* Versioning Notes::
* Full-text search interface with Deft::
* Org-journal::
* Note-taking Add-ons::

Note-taking Add-ons

* Org-download::
* mathpix.el: mathpixel. 
* Org-noter / Interleave::
* Bibliography::
* Spaced Repetition::

FAQ

* How do I have more than one Org-roam directory?::
* How do I migrate from Roam Research?::
* How do I create a note whose title already matches one of the candidates?::

@end detailmenu
@end menu

@node Introduction
@chapter Introduction

Org-roam is a tool for network thought. It reproduces some of @uref{https://roamresearch.com/, Roam
Research's} @footnote{To understand more about Roam, a collection of links are available in @ref{Note-taking Workflows}.} features within the all-powerful @uref{https://orgmode.org/, Org-mode}.

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 keeps closely to Org syntax, and will work for anyone already using
Org-mode for their personal wiki.

Org-roam gains its superpowers by leveraging the mature ecosystem around
Org-mode. For example, it has first-class support for @uref{https://github.com/jkitchin/org-ref, org-ref} for citation
management.

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.

Org-roam provides several benefits over other tooling:

@itemize
@item
@strong{Privacy and Security:} Keep your personal wiki entirely offline and in your
control. Encrypt your notes with GPG@.

@item
@strong{Longevity of Plain Text:} Unlike web solutions like Roam Research, the notes
are first and foremost plain Org-mode files -- Org-roam simply builds an
auxiliary 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. The notes are still
functional even if Org-roam ceases to exist.

@item
@strong{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 pull request.

@item
@strong{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.

@item
@strong{Built on Emacs:} 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.
@end itemize

@node Target Audience
@chapter Target Audience

Org-roam is a tool that will appear unfriendly to anyone unfamiliar with Emacs
and Org-mode, but is also extremely powerful to those willing to put effort in
mastering the intricacies of the tools. Org-roam stands on the shoulders on
giants. Emacs was first created in 1976, and remains a top tier tool for editing
text and designing textual interfaces. The malleability of Emacs allowed the
creation of Org-mode, an all-purpose plain-text system for maintaining TODO
lists, planning projects, and authoring documents. Both of these tools are
incredibly vast and require significant time investment to master.

Org-roam assumes basic familiarity with these tools. It is not difficult to get
up and running with basic text-editing functionality, but one will only fully
appreciate the power of building Roam functionality into Emacs and Org-mode when
the usage of these tools become more advanced.

One key advantage to Org-roam is that building on top of Emacs gives it
malleability. This is especially important for note-taking workflows. It is our
belief that note-taking workflows are extremely personal, and there is no one
tool that's perfect for you. Org-mode and Org-roam allows you to discover what
works for you, and build that perfect tool for yourself.

If you are new to the software, and choose to take this leap of faith, I hope
you find yourself equally entranced as Neal Stephenson was.

@quotation
Emacs outshines all other editing software in approximately the same way that
the noonday sun does the stars. It is not just bigger and brighter; it simply
makes everything else vanish. – Neal Stephenson, In the Beginning was the
Command Line (1998)

@end quotation

@node A Brief Introduction to the Zettelkasten Method
@chapter A Brief Introduction to the Zettelkasten Method

Org-roam provides utilities for maintaining a digital slip-box. This section
aims to provide a brief introduction to the ``slip-box'', or ``Zettelkasten''
method. By providing some background on the method, we hope that the design
decisions of Org-roam will become clear, and that will aid in using Org-roam
appropriately. In this section we will introduce terms commonly used within the
Zettelkasten community and the Org-roam forums.

The Zettelkasten is a personal tool for thinking and writing. It places heavy
emphasis on connecting ideas, building up a web of thought. Hence, it is well
suited for knowledge workers and intellectual tasks, such as conducting
research. The Zettelkasten can act as a research partner, where conversations
with it may produce new and surprising lines of thought.

This method is attributed to German sociologist Niklas Luhmann, who using the
method had produced volumes of written works. Luhmann's slip-box was simply a
box of cards. These cards are small -- often only large enough to fit a single
concept. The size limitation encourages ideas to be broken down into individual
concepts. These ideas are explicitly linked together. The breakdown of ideas
encourages tangential exploration of ideas, increasing the surface for thought.
Making linking explicit between notes also encourages one to think about the
connections between concepts.

At the corner of each note, Luhmann ascribed each note with an ordered ID,
allowing him to link and jump between notes. In Org-roam, we simply use
hyperlinks.

Org-roam is the slip-box, digitalized in Org-mode. Every zettel (card) is a
plain-text, Org-mode file. In the same way one would maintain a paper slip-box,
Org-roam makes it easy to create new zettels, pre-filling boilerplate content
using a powerful templating system.

@menu
* Fleeting notes::
* Permanent notes::
@end menu

@node Fleeting notes
@section Fleeting notes

A slip-box requires a method for quickly capturing ideas. These are called
@strong{fleeting notes}: they are simple reminders of information or ideas that will
need to be processed later on, or trashed. This is typically accomplished using
@code{org-capture} (see @ref{capture,,,org,}), or using Org-roam's daily notes
functionality (see @ref{Daily-notes}). This provides a central inbox for collecting
thoughts, to be processed later into permanent notes.

@node Permanent notes
@section Permanent notes

Permanent notes are further split into two categories: @strong{literature notes} and
@strong{concept notes}. Literature notes can be brief annotations on a particular
source (e.g. book, website or paper), that you'd like to access later on.
Concept notes require much more care in authoring: they need to be
self-explanatory and detailed. Org-roam's templating system supports the
addition of different templates to facilitate the creation of these notes.

@node Installation
@chapter Installation

Org-roam can be installed using Emacs' package manager or manually from its
development repository.

@menu
* Installing from MELPA::
* Installing from Apt::
* Installing from the Git Repository::
* Post-Installation Tasks::
@end menu

@node Installing from MELPA
@section Installing from MELPA

Org-roam is available from Melpa and Melpa-Stable. If you haven't used Emacs'
package manager before, you may familiarize yourself with it by reading the
documentation in the Emacs manual, see @ref{Packages,,,emacs,}. Then, add one of the
archives to @samp{package-archives}:

@itemize
@item
To use Melpa:
@end itemize

@lisp
(require 'package)
(add-to-list 'package-archives
             '("melpa" . "http://melpa.org/packages/") t)
@end lisp

@itemize
@item
To use Melpa-Stable:
@end itemize

@lisp
(require 'package)
(add-to-list 'package-archives
             '("melpa-stable" . "http://stable.melpa.org/packages/") t)
@end lisp

Org-roam also depends on a recent version of Org, which can be obtained in Org's
package repository (see @ref{Installation,,,org,}). To use Org's ELPA archive:

@lisp
(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
@end lisp

Once you have added your preferred archive, you need to update the
local package list using:

@example
M-x package-refresh-contents RET
@end example

Once you have done that, you can install Org-roam and its dependencies
using:

@example
M-x package-install RET org-roam RET
@end example

Now see @ref{Post-Installation Tasks}.

@node Installing from Apt
@section Installing from Apt

Users of Debian 11 or later or Ubuntu 20.10 or later can simply install Org-roam
using Apt:

@example
apt-get install elpa-org-roam
@end example

Org-roam will then be autoloaded into Emacs.

@node Installing from the Git Repository
@section Installing from the Git Repository

You may install Org-roam directly from the repository on @uref{https://github.com/org-roam/org-roam, GitHub} if you like.
This will give you access to the latest version hours or days before it appears
on MELPA, and months (or more) before it is added to the Debian or Ubuntu
repositories. This will also give you access to various developmental branches
that may be available.

Note, however, that development version, and especially any feature branches,
may not always be in working order. You'll need to be prepared to do some
debugging, or to manually roll-back to working versions, if you install from
GitHub.

Installing from GitHub requires that you clone the repository:

@example
git clone https://github.com/org-roam/org-roam.git /path/to/org/roam
@end example

where @code{./path/to/org/roam} is the location you will store your copy of the code.

Next, you need to add this location to your load path, and @code{require} the
Org-roam library. Add the following code to your @code{.emacs}:

@lisp
(add-to-list 'load-path "/path/to/org/roam")
(require 'org-roam)
@end lisp

You now have Org-roam installed. However, you don't necessarily have the
dependencies that it requires. These include:

@itemize
@item
dash

@item
f

@item
s

@item
org

@item
emacsql

@item
emacsql-sqlite3
@end itemize

You can install this manually as well, or get the latest version from MELPA@. You
may wish to use @uref{https://github.com/jwiegley/use-package, use-package}, @uref{https://github.com/raxod502/straight.el, straight.el} to help manage this.

If you would like to install the manual for access from Emacs' built-in Info
system, you'll need to compile the .texi source file, and install it in an
appropriate location.

To compile the .texi source file, from a terminal navigate to the @code{/doc}
subdirectory of the Org-roam repository, and run the following:

@example
make infodir=/path/to/my/info/files install-info
@end example

Where @code{/path/to/my/info/files} is the location where you keep info files. This
target directory needs to be stored in the variable
`Info-default-directory-list`. If you aren't using one of the default info
locations, you can configure this with the following in your @code{.emacs} file:

@lisp
(require 'info)
(add-to-list 'Info-default-directory-list
             "/path/to/my/info/files")
@end lisp

You can also use one of the default locations, such as:

@itemize
@item
@emph{usr/local/share/info}

@item
@emph{usr/share/info}

@item
@emph{usr/local/share/info}
@end itemize

If you do this, you'll need to make sure you have write-access to that location,
or run the above @code{make} command as root.

Now that the info file is ready, you need to add it to the corresponding @code{dir}
file:

@example
install-info /path/to/my/info/files/org-roam.info /path/to/my/info/files/dir
@end example

@node Post-Installation Tasks
@section Post-Installation Tasks

Org-roam uses @code{emacsql-sqlite3}, which requires @code{sqlite3} to be located on
@code{exec-path}. Please ensure that @code{sqlite3} is installed appropriately on your
operating system. You can verify that this is the case by executing:

@lisp
(executable-find "sqlite3")
@end lisp

If you have @code{sqlite3} installed, and @code{executable-find} still reports @code{nil}, then
it is likely that the path to the executable is not a member of the Emacs
variable @code{exec-path}. You may rectify this by manually adding the path within
your Emacs configuration:

@lisp
(add-to-list 'exec-path "path/to/sqlite3")
@end lisp

@node Getting Started
@chapter Getting Started

This short tutorial describes the essential commands used in Org-roam, to help
you get started.

First, it is important to understand how Org-roam was designed. Org-roam was
built to support a workflow that was not possible with vanilla Org-mode. This
flow is modelled after the @uref{https://zettelkasten.de/, Zettelkasten Method}, and many of @uref{https://roamresearch.com, Roam Research's}
workflows. Org-roam does not magically make note-taking better -- this often
requires a radical change in your current note-taking workflow. To understand
more about the methods and madness, see @ref{Note-taking Workflows}.

To first start using Org-roam, one needs to pick a location to store the
Org-roam files. The directory that will contain your notes is specified by the
variable @code{org-roam-directory}. This variable needs to be set before any calls to
Org-roam functions, including enabling @code{org-roam-mode}. For this tutorial,
create an empty directory, and set @code{org-roam-directory}:

@lisp
(make-directory "~/org-roam")
(setq org-roam-directory "~/org-roam")
@end lisp

We encourage using a flat hierarchy for storing notes, but some prefer using
folders for storing specific kinds of notes (e.g. websites, papers). This is
fine; Org-roam searches recursively within @code{org-roam-directory} for notes.
Instead of relying on the file hierarchy for any form of categorization, one
should use links between files to establish connections between notes.

Next, we need to enable the global minor mode @code{org-roam-mode}. This sets up
Emacs with several hooks, building a cache that is kept consistent as your
slip-box grows. We recommend starting @code{org-roam-mode} on startup:

@lisp
(add-hook 'after-init-hook 'org-roam-mode)
@end lisp

To build the cache manually, one can run @code{M-x org-roam-db-build-cache}. Cache
builds may take a while the first time, but is often instantaneous in subsequent
runs because it only reprocesses modified files.

Let us now create our first note. Call @code{M-x org-roam-find-file}. This shows a
list of titles for notes that reside in @code{org-roam-directory}. It should show
nothing right now, since there are no notes in the directory. Entering the title
of the note you wish to create, and pressing @code{RET} should begin the note
creation process. This process uses @code{org-capture}'s templating system, and can
be customized (see @ref{The Templating System}). Using the default template, pressing
@code{C-c C-c} finishes the note capture. Running @code{M-x org-roam-find-file} again
should show the note you have created, and selecting that entry will bring you
to that note.

Org-roam makes it easy to create notes, and link them together. To link notes
together, we call @code{M-x org-roam-insert}. This brings up a prompt with a list of
title for existing notes. Selecting an existing entry will create and insert a
link to the current file. Entering a non-existent title will create a new note
with that title. Good usage of Org-roam requires liberally linking files: this
facilitates building up a dense graph of inter-connected notes.

Org-roam provides an interface to view backlinks. It shows backlinks for the
currently active Org-roam note, along with some surrounding context. To toggle
the visibility of this buffer, call @code{M-x org-roam}.

For a visual representation of the notes and their connections, Org-roam also
provides graphing capabilities, using Graphviz. It generates graphs 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 (see @ref{Roam Protocol}).

@node Anatomy of an Org-roam File
@chapter Anatomy of an Org-roam File

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.

@menu
* Titles::
* Tags::
* File Refs::
@end menu

@node Titles
@section Titles

To easily find a note, a title needs to be prescribed to a note. A note can have
many titles: this allows a note to be referred to by different names, which is
especially useful for topics or concepts with acronyms. For example, for a note
like ``World War 2'', it may be desirable to also refer to it using the acronym
``WWII''.

Org-roam calls @code{org-roam--extract-titles} to extract titles. It uses the
variable @code{org-roam-title-sources}, to control how the titles are extracted. The
title extraction methods supported are:

@itemize
@item
@code{'title}: This extracts the title using the file @code{#+title} property

@item
@code{'headline}: This extracts the title from the first headline in the Org file

@item
@code{'alias}: This extracts a list of titles using the @code{#+roam_alias} property.
The aliases are space-delimited, and can be multi-worded using quotes.
@end itemize

Take for example the following org file:

@example
#+title: World War 2
#+roam_alias: "WWII" "World War II"

* Headline
@end example

@multitable {aaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaa}
@headitem Method
@tab Titles
@item @code{'title}
@tab '(``World War 2'')
@item @code{'headline}
@tab '(``Headline'')
@item @code{'alias}
@tab '(``WWII'' ``World War II'')
@end multitable

One can freely control which extraction methods to use by customizing
@code{org-roam-title-sources}: see the doc-string for the variable for more
information. If all methods of title extraction return no results, the file-name
is used in place of the titles for completions.

If you wish to add your own title extraction method, you may push a symbol
@code{'foo} into @code{org-roam-title-sources}, and define a
@code{org-roam--extract-titles-foo} which accepts no arguments. See
@code{org-roam--extract-titles-title} for an example.

@node Tags
@section Tags

Tags are used as meta-data for files: they facilitate interactions with notes
where titles are insufficient. For example, tags allow for categorization of
notes: differentiating between bibliographical and structure notes during
interactive commands.

Org-roam calls @code{org-roam--extract-tags} to extract tags from files. It uses the
variable @code{org-roam-tag-sources}, to control how tags are extracted. The tag
extraction methods supported are:

@itemize
@item
@code{'prop}: This extracts tags from the @code{#+roam_tags} property. Tags are space
delimited, and can be multi-word using double quotes.

@item
@code{'all-directories}: All sub-directories relative to @code{org-roam-directory} are
extracted as tags. That is, if a file is located at relative path
@code{foo/bar/file.org}, the file will have tags @code{foo} and @code{bar}.

@item
@code{'last-directory}: Extracts the last directory relative to
@code{org-roam-directory} as the tag. That is, if a file is located at relative
path @code{foo/bar/file.org}, the file will have tag @code{bar}.

@item
@code{'first-directory}: Extracts the first directory relative to
@code{org-roam-directory} as the tag. That is, if a file is located at relative
path @code{foo/bar/file.org}, the file will have tag @code{foo}.
@end itemize

By default, only the @code{'prop} extraction method is enabled. To enable the other
extraction methods, you may modify @code{org-roam-tag-sources}:

@lisp
(setq org-roam-tag-sources '(prop last-directory))
@end lisp

If you wish to add your own tag extraction method, you may push a symbol @code{'foo}
into @code{org-roam-tag-sources}, and define a @code{org-roam--extract-tags-foo} which
accepts the absolute file path as its argument. See
@code{org-roam--extract-tags-prop} for an example.

@node File Refs
@section File Refs

Refs are unique identifiers for files. For example, a note for a website may
contain a ref:

@example
#+title: Google
#+roam_key: https://www.google.com/
@end example

These keys allow references to the key to show up in the backlinks buffer. For
instance, with the example above, if another file then links to
@uref{https://www.google.com}, that will show up as a “Ref Backlink”.

These keys also come in useful for when taking website notes, using the
 @code{roam-ref} protocol (see @ref{Roam Protocol}).

@uref{https://github.com/jkitchin/org-ref, org-ref} citation keys can also be used as refs:

@example
#+title: Neural Ordinary Differential Equations
#+roam_key: cite:chen18_neural_ordin_differ_equat
@end example

@float Figure
@image{images/org-ref-citelink,,,,png}
@caption{org-ref-citelink}
@end float

You may assign multiple refs to a single file, for example when you want
multiple papers in a series to share the same note, or an article has a citation
key and a URL at the same time.

@node The Templating System
@chapter The Templating System

Rather than creating blank files on @code{org-roam-insert} and @code{org-roam-find-file},
it may be desirable to prefill the file with templated content. This may
include:

@itemize
@item
Time of creation

@item
File it was created from

@item
Clipboard content

@item
Any other data you may want to input manually
@end itemize

This requires a complex template insertion system. Fortunately, Org ships with a
powerful one: @code{org-capture} (see @ref{capture,,,org,}). However, org-capture was not
designed for such use. Org-roam abuses @code{org-capture}, extending its syntax and
capabilities. To first understand how org-roam's templating system works, it may
be useful to look into basic usage of @code{org-capture}.

For these reasons, Org-roam capture templates are not compatible with regular
@code{org-capture}. Hence, Org-roam's templates can be customized by instead
modifying the variable @code{org-roam-capture-templates}. Just like
@code{org-capture-templates}, @code{org-roam-capture-templates} can contain multiple
templates. If @code{org-roam-capture-templates} only contains one template, there
will be no prompt for template selection.

@menu
* Template Walkthrough::
* Org-roam Template Expansion::
@end menu

@node Template Walkthrough
@section Template Walkthrough

To demonstrate the additions made to org-capture templates. Here, we walkthrough
the default template, reproduced below.

@lisp
("d" "default" plain (function org-roam--capture-get-point)
     "%?"
     :file-name "%<%Y%m%d%H%M%S>-$@{slug@}"
     :head "#+title: $@{title@}\n"
     :unnarrowed t)
@end lisp

@itemize
@item
The template has short key @code{"d"}. If you have only one template, org-roam
automatically chooses this template for you.

@item
The template is given a description of @code{"default"}.

@item
@code{plain} text is inserted. Other options include Org headings via
@code{entry}.

@item
@code{(function org-roam--capture-get-point)} should not be changed.

@item
@code{"%?"} is the template inserted on each call to @code{org-roam-capture--capture}.
This template means don't insert any content, but place the cursor here.

@item
@code{: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
@code{/path/to/org-roam-directory/20200213032037-foo.org}. This template also
allows you to specify if you want the note to go into a subdirectory. For
example, the template @code{private/$@{slug@}} will create notes in
@code{/path/to/org-roam-directory/private}.

@item
@code{:head} contains the initial template to be inserted (once only), at
the beginning of the file. Here, the title global attribute is
inserted.

@item
@code{:unnarrowed t} tells org-capture to show the contents for the whole
file, rather than narrowing to just the entry.
@end itemize

Other options you may want to learn about include @code{:immediate-finish}.

@node Org-roam Template Expansion
@section Org-roam Template Expansion

Org-roam's template definitions also extend org-capture's template syntax, to
allow prefilling of strings. We have seen a glimpse of this in @ref{Template Walkthrough, , Template
Walkthrough}.

In org-roam templates, the @code{$@{var@}} syntax allows for the expansion of
variables, stored in @code{org-roam-capture--info}. For example, during
@code{org-roam-insert}, the user is prompted for a title. Upon entering a
non-existent title, the @code{title} key in @code{org-roam-capture--info} is set to the
provided title. @code{$@{title@}} is then expanded into the provided title during the
org-capture process. Any variables that do not contain strings, are prompted for
values using @code{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
@uref{https://orgmode.org/manual/Template-expansion.html#Template-expansion, org-capture's documentation page}.

To illustrate this dual expansion process, take for example the template string:
@code{"%<%Y%m%d%H%M%S>-$@{title@}"}, with the title @code{"Foo"}. The template is first
expanded into @code{%<%Y%m%d%H%M%S>-Foo}. Then org-capture expands @code{%<%Y%m%d%H%M%S>}
with timestamp: e.g. @code{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 @code{%(EXP)} template expansion to call @code{format-time-string}
directly to provide its third argument to specify UTC@.

@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)
@end lisp

@node Concepts and Configuration
@chapter Concepts and Configuration

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 @code{M-x customize-group
org-roam}.

@menu
* Directories and Files::
* The Org-roam Buffer::
* Org-roam Files::
* Org-roam Faces::
* The Database::
@end menu

@node Directories and Files
@section Directories and Files

This section concerns the placement and creation of files.

@defvar org-roam-directory

This is the default path to Org-roam files. All Org files, at any level of
nesting, are considered part of the Org-roam.
@end defvar

@defvar org-roam-db-location

Location of the Org-roam database. If this is non-nil, the Org-roam sqlite
database is saved here.

It is the user’s responsibility to set this correctly, especially when used
with multiple Org-roam instances.
@end defvar

@defvar org-roam-file-exclude-regexp

Files matching this regular expression are excluded from the Org-roam.
@end defvar

@node The Org-roam Buffer
@section The Org-roam Buffer

The Org-roam buffer displays backlinks for the currently active Org-roam note.

@defopt org-roam-buffer

The name of the org-roam buffer. Defaults to @code{*org-roam*}.
@end defopt

@defopt org-roam-buffer-position

The position of the Org-roam buffer side window. Valid values are @code{'left},
@code{'right}, @code{'top}, @code{'bottom}.
@end defopt

@defopt org-roam-buffer-width

Width of @code{org-roam-buffer}. Has an effect only if @code{org-roam-buffer-position} is
@code{'left} or @code{'right}.
@end defopt

@defopt org-roam-buffer-height

Height of @code{org-roam-buffer}. Has an effect only if @code{org-roam-buffer-position} is
@code{'top} or @code{'bottom}.
@end defopt

@defopt org-roam-buffer-window-parameters

Additional window parameters for the org-roam-buffer side window.

For example one can prevent the window from being deleted when calling
@code{delete-other-windows}, by setting it with the following:

@code{(setq org-roam-buffer-window-parameters '((no-delete-other-windows . t)))}
@end defopt

@node Org-roam Files
@section Org-roam Files

Org-roam files are created and prefilled using Org-roam's templating
system. The templating system is customizable (see @ref{The Templating System}).

@node Org-roam Faces
@section Org-roam Faces

Org-roam introduces several faces to distinguish links within the same buffer.
These faces are enabled by default in Org-roam notes.

@defopt org-roam-link-use-custom-faces

When @code{t}, use custom faces only inside Org-roam notes.
When @code{everywhere}, the custom face is applied additionally to non Org-roam notes.
When @code{nil}, do not use Org-roam's custom faces.
@end defopt

The @code{org-roam-link} face is the face applied to links to other Org-roam files.
This distinguishes internal links from external links (e.g. external web links).

The @code{org-roam-link-current} face corresponds to links to the same file it is in.

The @code{org-roam-link-invalid} face is applied to links that are broken. These are
links to files or IDs that cannot be found.

@node The Database
@section @strong{TODO} The Database

Org-roam is backed by a Sqlite database.

@defopt org-roam-db-update-method

Method to update the Org-roam database.

@code{'immediate}: Update the database immediately upon file changes.

@code{'idle-timer}: Updates the database if dirty, if Emacs idles for
@code{org-roam-db-update-idle-seconds}.
@end defopt

@defopt org-roam-db-update-idle-seconds

Number of idle seconds before triggering an Org-roam database update. This is
only valid if @code{org-roam-db-update-method} is @code{'idle-timer}.
@end defopt

@node Inserting Links
@chapter Inserting Links

The preferred mode of linking is via @code{file} links to files, and @code{id} links for
headlines. This maintains the strongest compatibility with Org-mode, ensuring
that the links still function without Org-roam, and work well exporting to other
backends.

@code{file} links can be inserted via @code{org-roam-insert}. Links to headlines can be
inserted by navigating to the desired headline and calling @code{org-store-link}.
This will create an ID for the headline if it does not already exist, and
populate the Org-roam database. The link can then be inserted via
@code{org-insert-link}.

An alternative mode of insertion is using Org-roam's @code{roam} links. Org-roam
registers this link type, and interprets the path as follows:

@itemize
 @item
 @code{[[roam:title]]}links to an Org-roam file with title or alias ``title''

@item
 @code{[[roam:*headline]]}links to the headline ``headline'' in the current
Org-roam file

@item
 @code{[[roam:title*headline]]}links to the headline ``headline'' in the Org-roam
file with title or alias ``title''
@end itemize

@code{roam} links support auto-completion via @code{completion-at-point}: simply call
@code{completion-at-point} within a roam link. Users of @code{company-mode} may want to
prepend @code{company-capf} to the beginning of variable @code{company-backends}.

To easily insert @code{roam} links, one may wish to use a package like @uref{https://github.com/emacsorphanage/key-chord/, key-chord}. In
the following example, typing ``[['' will insert a stub @code{roam} link:

@lisp
(key-chord-define org-mode-map "[[" #'my/insert-roam-link)

(defun my/insert-roam-link ()
    "Inserts an Org-roam link."
    (interactive)
    (insert "[[roam:]]")
    (backward-char 2))
@end lisp

@defopt org-roam-link-title-format

To distinguish between org-roam links and regular links, one may choose to use
special indicators for Org-roam links. Defaults to @code{"%s"}.

If your version of Org is at least @code{9.2}, consider styling the link differently,
by customizing the @code{org-roam-link}, and @code{org-roam-link-current} faces.
@end defopt

@defopt org-roam-completion-ignore-case

When non-nil, the @code{roam} link completions are ignore case. For example,
calling @code{completion-at-point} within @code{[[roam:fo]]} will present a completion
for a file with title ``Foo''. Defaults to @code{t}.
@end defopt

@defopt org-roam-link-auto-replace

When non-nil, @code{roam} links will be replaced with @code{file} or @code{id} links when
they are navigated to, and on file save, when a match is found. This is
desirable to maintain compatibility with vanilla Org, but resolved links are
harder to edit. Defaults to @code{t}.
@end defopt

@node Navigating Around
@chapter Navigating Around

@menu
* Index File::
@end menu

@node Index File
@section Index File

As your collection grows, you might want to create an index where you keep links
to your main files.

In Org-roam, you can define the path to your index file by setting
@code{org-roam-index-file}.

@defvar org-roam-index-file

Path to the Org-roam index file.

The path can be a string or a function. If it is a string, it should be the
path (absolute or relative to @code{org-roam-directory}) to the index file. If it
is is a function, the function should return the path to the index file.
Otherwise, the index is assumed to be a note in @code{org-roam-index} whose
title is @code{"Index"}.
@end defvar

@defun org-roam-find-index

Opens the Index file in the current @code{org-roam-directory}.
@end defun

@node Encryption
@chapter Encryption

One may wish to keep private, encrypted files. Org-roam supports encryption (via
GPG), which can be enabled for all new files by setting @code{org-roam-encrypt-files}
to @code{t}. When enabled, new files are created with the @code{.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.

@defopt org-roam-encrypt-files

Whether to encrypt new files. If true, create files with .org.gpg extension.
@end defopt

@node Graphing
@chapter Graphing

Org-roam provides graphing capabilities to explore interconnections between
notes. This is done by performing SQL queries and generating images using
@uref{https://graphviz.org/, Graphviz}. The graph can also be navigated: see @ref{Roam Protocol}.

The entry point to graph creation is @code{org-roam-graph}.

@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:

@itemize
@item
@code{nil}       show the graph.

@item
@code{C-u}       show the graph for FILE@.

@item
@code{C-u N}     show the graph for FILE limiting nodes to N steps.

@item
@code{C-u C-u}   build the graph.

@item
@code{C-u -}     build the graph for FILE@.

@item
@code{C-u -N}    build the graph for FILE limiting nodes to N steps.
@end itemize
@end defun

@defopt org-roam-graph-executable

Path to the graphing executable (in this case, Graphviz). Set this if Org-roam
is unable to find the Graphviz executable on your system.

You may also choose to use @code{neato} in place of @code{dot}, which generates a more
compact graph layout.
@end defopt

@defopt org-roam-graph-viewer

Org-roam defaults to using Firefox (located on PATH) to view the SVG, but you
may choose to set it to:

@itemize
@item
A string, which is a path to the program used

@item
a function accepting a single argument: the graph file path.
@end itemize

@code{nil} uses @code{view-file} to view the graph.

If you are using WSL2 and would like to open the graph in Windows, you can use
the second option to set the browser and network file path:

@lisp
(setq org-roam-graph-viewer
    (lambda (file)
      (let ((org-roam-graph-viewer "/mnt/c/Program Files/Mozilla Firefox/firefox.exe"))
        (org-roam-graph--open (concat "file://///wsl$/Ubuntu" file)))))
@end lisp
@end defopt

@menu
* Graph Options::
* Excluding Nodes and Edges::
@end menu

@node Graph Options
@section Graph Options

Graphviz provides many options for customizing the graph output, and Org-roam
supports some of them. See @uref{https://graphviz.gitlab.io/_pages/doc/info/attrs.html}
for customizable options.

@defopt org-roam-graph-extra-config

Extra options passed to graphviz for the digraph (The ``G'' attributes).
Example: @code{'~(("rankdir" . "LR"))}
@end defopt

@defopt org-roam-graph-node-extra-config

Extra options for nodes in the graphviz output (The ``N'' attributes).
Example: @code{'(("color" . "skyblue"))}
@end defopt

@defopt org-roam-graph-edge-extra-config

Extra options for edges in the graphviz output (The ``E'' attributes).
Example: @code{'(("dir" . "back"))}
@end defopt

@defopt org-roam-graph-edge-cites-extra-config

Extra options for citation edges in the graphviz output.
Example: @code{'(("color" . "red"))}
@end defopt

@node Excluding Nodes and Edges
@section Excluding Nodes and Edges

One may want to exclude certain files to declutter the graph.

@defopt org-roam-graph-exclude-matcher

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.
@end defopt

@example
(setq org-roam-graph-exclude-matcher '("private" "dailies"))
@end example

This setting excludes all files whose path contain ``private'' or ``dailies''.

@node Org-roam Completion System
@chapter Org-roam Completion System

Org-roam allows customization of which minibuffer completion system to use for
its interactive commands. The default setting uses Emacs' standard
@code{completing-read} mechanism.

@lisp
(setq org-roam-completion-system 'default)
@end lisp

If you have installed Helm or Ivy, and have their modes enabled, under the
@code{'default} setting they will be used.

In the rare scenario where you use Ivy globally, but prefer @uref{https://emacs-helm.github.io/helm/, Helm} for org-roam
commands, set:

@lisp
(setq org-roam-completion-system 'helm)
@end lisp

Other options include @code{'ido}, and @code{'ivy}.

@node Roam Protocol
@chapter Roam Protocol

Org-roam extends @code{org-protocol} with 2 protocols: the @code{roam-file} and @code{roam-ref}
protocols.

@menu
* Installation: Installation (1). 
* The roam-file protocol::
* The roam-ref protocol::
@end menu

@node Installation (1)
@section Installation

To enable Org-roam's protocol extensions, you have to add the following to your
init file:

@lisp
(require 'org-roam-protocol)
@end lisp

The instructions for setting up @code{org-protocol} are reproduced below.

We will also need to create a desktop application for @code{emacsclient}. The
instructions for various platforms are shown below.

For Linux users, create a desktop application in
@code{~/.local/share/applications/org-protocol.desktop}:

@example
[Desktop Entry]
Name=Org-Protocol
Exec=emacsclient %u
Icon=emacs-icon
Type=Application
Terminal=false
MimeType=x-scheme-handler/org-protocol
@end example

Associate @code{org-protocol://} links with the desktop application by
running in your shell:

@example
xdg-mime default org-protocol.desktop x-scheme-handler/org-protocol
@end example

To disable the ``confirm'' prompt in Chrome, you can also make Chrome show a
checkbox to tick, so that the @code{Org-Protocol Client} app will be used without
confirmation. To do this, run in a shell:

@example
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
@end example

and then restart Chrome (for example, by navigating to <chrome://restart>) to
make the new policy take effect.

See @uref{https://www.chromium.org/administrators/linux-quick-start, here} for more info on the @code{/etc/opt/chrome/policies/managed} directory and
@uref{https://cloud.google.com/docs/chrome-enterprise/policies/?policy=ExternalProtocolDialogShowAlwaysOpenCheckbox, here} for information on the @code{ExternalProtocolDialogShowAlwaysOpenCheckbox} policy.

For MacOS, one solution is to use @uref{https://github.com/sveinbjornt/Platypus, Platypus}. Here are the instructions for
setting up with Platypus and Chrome:

@itemize
@item
Install and launch Platypus (with @uref{https://brew.sh/, Homebrew}):
@end itemize

@example
brew cask install platypus
@end example

@itemize
@item
Create a script @code{launch_emacs.sh}:
@end itemize

@example
#!/usr/bin/env bash
/usr/local/bin/emacsclient --no-wait $1
@end example

@itemize
@item
Create a Platypus app with the following settings:
@end itemize

@multitable {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaa}
@headitem Setting
@tab Value
@item App Name
@tab ``OrgProtocol''
@item Script Type
@tab ``env'' · ``/usr/bin/env''
@item Script Path
@tab ``path/to/launch-emacs.sh''
@item Interface
@tab None
@item Accept dropped items
@tab true
@item Remain running after execution
@tab false
@end multitable


Inside @code{Settings}:

@multitable {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa} {aaaaaaaaaaaaaa}
@headitem Setting
@tab Value
@item Accept dropped files
@tab true
@item Register as URI scheme handler
@tab true
@item Protocol
@tab ``org-protocol''
@end multitable

To disable the ``confirm'' prompt in Chrome, you can also make Chrome
show a checkbox to tick, so that the @code{OrgProtocol} app will be used
without confirmation. To do this, run in a shell:

@example
defaults write com.google.Chrome ExternalProtocolDialogShowAlwaysOpenCheckbox -bool true
@end example


If you're using @uref{https://github.com/railwaycat/homebrew-emacsmacport, Emacs Mac Port}, it registered its `Emacs.app` as the default
handler for the URL scheme `org-protocol`. To make @code{OrgProtocol.app}
the default handler instead, run:

@example
defaults write com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers -array-add \
'@{"LSHandlerPreferredVersions" = @{ "LSHandlerRoleAll" = "-"; @}; LSHandlerRoleAll = "org.yourusername.OrgProtocol"; LSHandlerURLScheme = "org-protocol";@}'
@end example

Then restart your computer.

For Windows, create a temporary @code{org-protocol.reg} file:

@example
REGEDIT4

[HKEY_CLASSES_ROOT\org-protocol]
@@="URL:Org Protocol"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\org-protocol\shell]
[HKEY_CLASSES_ROOT\org-protocol\shell\open]
[HKEY_CLASSES_ROOT\org-protocol\shell\open\command]
@@="\"C:\\Windows\\System32\\wsl.exe\" emacsclient \"%1\""
@end example

The above will forward the protocol to WSL@. If you run Emacs natively on
Windows, replace the last line with:

@example
@@="\"c:\\path\\to\\emacs\\bin\\emacsclientw.exe\"  \"%1\""
@end example

After executing the .reg file, the protocol is registered and you can delete the
file.

@node The roam-file protocol
@section The roam-file protocol

This is a simple protocol that opens the path specified by the @code{file}
key (e.g. @code{org-protocol://roam-file?file=/tmp/file.org}). This is used
in the generated graph.

@node The roam-ref protocol
@section The roam-ref protocol

This protocol finds or creates a new note with a given @code{roam_key} (see @ref{Anatomy of an Org-roam File}):

@image{images/roam-ref,,,,gif}

To use this, create the following @uref{https://en.wikipedia.org/wiki/Bookmarklet, bookmarklet} in your browser:

@example
javascript:location.href =
    'org-protocol://roam-ref?template=r&ref='
    + encodeURIComponent(location.href)
    + '&title='
    + encodeURIComponent(document.title)
    + '&body='
    + encodeURIComponent(window.getSelection())
@end example

or as a keybinding in @code{qutebrowser} in , using the @code{config.py} file (see
@uref{https://github.com/qutebrowser/qutebrowser/blob/master/doc/help/configuring.asciidoc, Configuring qutebrowser}):

@example
config.bind("<Ctrl-r>", "open javascript:location.href='org-protocol://roam-ref?template=r&ref='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)")
@end example

where @code{template} is the template key for a template in
@code{org-roam-capture-ref-templates} (see @ref{The Templating System}). These templates
should contain a @code{#+roam_key: $@{ref@}} in it.

@node Daily-notes
@chapter Daily-notes

Org-roam provides journaling capabilities akin to
@ref{Org-journal} with @code{org-roam-dailies}.

@menu
* Configuration::
* Capturing and finding daily-notes::
* Navigation::
@end menu

@node Configuration
@section Configuration

For @code{org-roam-dailies} to work, you need to define two variables:

@defvar @code{org-roam-dailies-directory}

Path to daily-notes.
@end defvar

@defvar @code{org-roam-dailies-capture-templates}

Capture templates for daily-notes in Org-roam.
@end defvar

Here is a sane default configuration:

@lisp
(setq org-roam-dailies-directory "daily/")

(setq org-roam-dailies-capture-templates
      '(("d" "default" entry
         #'org-roam-capture--get-point
         "* %?"
         :file-name "daily/%<%Y-%m-%d>"
         :head "#+title: %<%Y-%m-%d>\n\n")))
@end lisp

Make sure that @code{org-roam-dailies-directory} appears in @code{:file-name} for your
notes to be recognized as daily-notes. You can have different templates placing
their notes in different directories, but the one in
@code{org-roam-dailies-directory} will be considered as the main one in commands.

See @ref{The Templating System} for creating new
templates. @code{org-roam-dailies} provides an extra @code{:olp} option which allows
specifying the outline-path to a heading:

@lisp
(setq org-roam-dailies-capture-templates
      '(("l" "lab" entry
         #'org-roam-capture--get-point
         "* %?"
         :file-name "daily/%<%Y-%m-%d>"
         :head "#+title: %<%Y-%m-%d>\n\n* Lab notes\n* Journal"
         :olp ("Journal"))

        ("j" "journal" entry
         #'org-roam-capture--get-point
         "* %?"
         :file-name "daily/%<%Y-%m-%d>"
         :head "#+title: %<%Y-%m-%d>\n\n* Lab notes\n* Journal"
         :olp ("Lab notes"))))
@end lisp

The template @code{l} will put its notes under the heading ‘Lab notes’, and the
template @code{j} will put its notes under the heading ‘Journal’. When you use
@code{:olp}, make sure that the headings are present in @code{:head}.

@node Capturing and finding daily-notes
@section Capturing and finding daily-notes

@defun @code{org-roam-dailies-capture-today} &optional goto

Create an entry in the daily note for today.

When @code{goto} is non-nil, go the note without creating an entry.
@end defun

@defun @code{org-roam-dailies-find-today}

Find the daily note for today, creating it if necessary.
@end defun

There are variants of those commands for @code{-yesterday} and @code{-tomorrow}:

@defun @code{org-roam-dailies-capture-yesterday} n &optional goto

Create an entry in the daily note for yesteday.

With numeric argument @code{n}, use the daily note @code{n} days in the past.
@end defun

@defun @code{org-roam-dailies-find-yesterday}

With numeric argument N, use the daily-note N days in the future.
@end defun

There are also commands which allow you to use Emacs’s @code{calendar} to find the date

@defun @code{org-roam-dailies-capture-date}

Create an entry in the daily note for a date using the calendar.

Prefer past dates, unless @code{prefer-future} is non-nil.

With a 'C-u' prefix or when @code{goto} is non-nil, go the note without
creating an entry.
@end defun

@defun @code{org-roam-dailies-find-date}

Find the daily note for a date using the calendar, creating it if necessary.

Prefer past dates, unless @code{prefer-future} is non-nil.
@end defun

@node Navigation
@section Navigation

You can navigate between daily-notes:

@defun @code{org-roam-dailies-find-directory}

Find and open @code{org-roam-dailies-directory}.
@end defun

@defun @code{org-roam-dailies-find-previous-note}

When in an daily-note, find the previous one.
@end defun

@defun @code{org-roam-dailies-find-next-note}

When in an daily-note, find the next one.
@end defun

@node Diagnosing and Repairing Files
@chapter Diagnosing and Repairing Files

Org-roam provides a utility for diagnosing and repairing problematic files via
@code{org-roam-doctor}. By default, @code{org-roam-doctor} runs the check on the current
Org-roam file. To run the check only for the current file, run @code{C-u M-x
org-roam-doctor}, but note that this may take some time.

@defun org-roam-doctor &optional this-buffer

Perform a check on Org-roam files to ensure cleanliness. If THIS-BUFFER, run
the check only for the current buffer.
@end defun

The checks run are defined in @code{org-roam-doctor--checkers}. By default, there are
checkers for broken links and invalid @samp{#+roam_*} properties.

Each checker is an instance of @code{org-roam-doctor-checker}. To define a checker,
use @code{make-org-roam-doctor-checker}. Here is a sample definition:

@lisp
(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))
               ("R" . ("Replace link (keep label)" . org-roam-doctor--replace-link-keep-label))))
@end lisp

The @code{:name} property is the name of the function run. The function takes in the
Org parse tree, and returns a list of @code{(point error-message)}. @code{:description} is
a short description of what the checker does. @code{:actions} is an alist containing
elements of the form @code{(char . (prompt . function))}. These actions are defined
per checker, to perform autofixes for the errors. For each error detected,
@code{org-roam-doctor} will move the point to the current error, and pop-up a help
window displaying the error message, as well as the list of actions that can be
taken provided in @code{:actions}.

@node Finding Unlinked References
@chapter Finding Unlinked References

Unlinked references are occurrences of strings of text that exactly match the
title or alias of an existing note in the Org-roam database. Org-roam provides
facilities for discovering these unlinked references, so one may decide whether
to convert them into links.

To use this feature, simply call @code{M-x org-roam-unlinked-references} from within
an Org-roam note. Internally, Org-roam uses @uref{https://github.com/BurntSushi/ripgrep, ripgrep} and a clever PCRE regex to
find occurrences of the title or aliases of the currently open note in all
Org-roam files. Hence, this requires a version of ripgrep that is compiled with
PCRE support.

@quotation
NOTE: Since ripgrep cannot read encrypted files, this function cannot find
unlinked references within encrypted files.

@end quotation

@node Performance Optimization
@chapter Performance Optimization

@menu
* Profiling Key Operations::
* Garbage Collection::
@end menu

@node Profiling Key Operations
@section @strong{TODO} Profiling Key Operations

@node Garbage Collection
@section Garbage Collection

During the cache-build process, Org-roam generates a lot of in-memory
data-structures (such as the Org file's AST), which are discarded after use.
These structures are garbage collected at regular intervals (see @ref{Garbage Collection,info:elisp#Garbage Collection,,elisp,}).

Org-roam provides the option @code{org-roam-db-gc-threshold} to temporarily change
the threshold value for GC to be triggered during these memory-intensive
operations. To reduce the number of garbage collection processes, one may set
@code{org-roam-db-gc-threshold} to a high value (such as @code{most-positive-fixnum}):

@lisp
(setq org-roam-db-gc-threshold most-positive-fixnum)
@end lisp

@node Appendix
@chapter Appendix

@menu
* Note-taking Workflows::
* Ecosystem::
@end menu

@node Note-taking Workflows
@section Note-taking Workflows

@itemize
 @item
 Books@itemize
@item
@uref{https://www.goodreads.com/book/show/34507927-how-to-take-smart-notes, How To Take Smart Notes}
@end itemize

@item
 Articles@itemize
@item
@uref{https://www.lesswrong.com/posts/NfdHG6oHBJ8Qxc26s/the-zettelkasten-method-1, The Zettelkasten Method - LessWrong 2.0}

@item
@uref{https://reddit.com/r/RoamResearch/comments/eho7de/building_a_second_brain_in_roamand_why_you_might, Building a Second Brain in Roam@dots{}And Why You Might Want To : RoamResearch}

@item
@uref{https://www.nateliason.com/blog/roam, Roam Research: Why I Love It and How I Use It - Nat Eliason}

@item
@uref{https://twitter.com/adam_keesling/status/1196864424725774336?s=20, Adam Keesling's Twitter Thread}

@item
@uref{https://blog.jethro.dev/posts/how_to_take_smart_notes_org/, How To Take Smart Notes With Org-mode · Jethro Kuan}
@end itemize

@item
 Threads@itemize
@item
@uref{https://news.ycombinator.com/item?id=22473209, Ask HN: How to Take Good Notes}
@end itemize

@item
 Videos@itemize
@item
@uref{https://www.youtube.com/watch?v=RvWic15iXjk, How to Use Roam to Outline a New Article in Under 20 Minutes}
@end itemize
@end itemize

@node Ecosystem
@section Ecosystem

@menu
* Browsing History with winner-mode::
* Versioning Notes::
* Full-text search interface with Deft::
* Org-journal::
* Note-taking Add-ons::
@end menu

@node Browsing History with winner-mode
@subsection Browsing History with winner-mode

@code{winner-mode} is a global minor mode that allows one to undo and redo changes in
the window configuration. It is included with GNU Emacs since version 20.

@code{winner-mode} can be used as a simple version of browser history for Org-roam.
Each click through org-roam links (from both Org files and the backlinks buffer)
causes changes in window configuration, which can be undone and redone using
@code{winner-mode}. To use @code{winner-mode}, simply enable it, and bind the appropriate
interactive functions:

@lisp
(winner-mode +1)
(define-key winner-mode-map (kbd "<M-left>") #'winner-undo)
(define-key winner-mode-map (kbd "<M-right>") #'winner-redo)

@end lisp

@node Versioning Notes
@subsection Versioning Notes

Since Org-roam notes are just plain text, it is trivial to track changes in your
notes database using version control systems such as @uref{https://git-scm.com/, Git}. Simply initialize
@code{org-roam-directory} as a Git repository, and commit your files at regular or
appropriate intervals. @uref{https://magit.vc/, Magit} is a great interface to Git within Emacs.

In addition, it may be useful to observe how a particular note has evolved, by
looking at the file history. @uref{https://gitlab.com/pidu/git-timemachine, Git-timemachine} allows you to visit historic
versions of a tracked Org-roam note.

@node Full-text search interface with Deft
@subsection Full-text search interface with Deft

@uref{https://jblevins.org/projects/deft/, Deft} provides a nice interface for browsing and filtering org-roam notes.

@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/"))
@end lisp

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 @code{org-roam}'s functionality. Here I'm
using @uref{https://github.com/raxod502/el-patch, el-patch}:

@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))))
@end lisp

The Deft interface can slow down quickly when the number of files get huge.
@uref{https://github.com/hasu/notdeft, Notdeft} is a fork of Deft that uses an external search engine and indexer.

@node Org-journal
@subsection Org-journal

@uref{https://github.com/bastibe/org-journal, Org-journal} provides journaling capabilities to Org-mode. A lot of its
functionalities have been incorporated into Org-roam under the name
@ref{Daily-notes, , @code{org-roam-dailies}}. It remains a good tool if you want to isolate your verbose
journal entries from the ideas you would write on a scratchpad.

@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/journal/files/")
  (org-journal-date-format "%A, %d %B %Y"))
@end lisp

@node Note-taking Add-ons
@subsection Note-taking Add-ons

These are some plugins that make note-taking in Org-mode more enjoyable.

@menu
* Org-download::
* mathpix.el: mathpixel. 
* Org-noter / Interleave::
* Bibliography::
* Spaced Repetition::
@end menu

@node Org-download
@unnumberedsubsubsec Org-download

@uref{https://github.com/abo-abo/org-download, Org-download} lets you screenshot and yank images from the web into your notes:

@float Figure
@image{images/org-download,,,,gif}
@caption{org-download}
@end float

@lisp
(use-package org-download
  :after org
  :bind
  (:map org-mode-map
        (("s-Y" . org-download-screenshot)
         ("s-y" . org-download-yank))))
@end lisp

@node mathpixel
@unnumberedsubsubsec mathpix.el

@uref{https://github.com/jethrokuan/mathpix.el, mathpix.el} uses @uref{https://mathpix.com/, Mathpix's} API to convert clips into latex equations:

@float Figure
@image{images/mathpix,,,,gif}
@caption{mathpix}
@end float

@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))
@end lisp

@node Org-noter / Interleave
@unnumberedsubsubsec Org-noter / Interleave

@uref{https://github.com/weirdNox/org-noter, Org-noter} and
@uref{https://github.com/rudolfochrist/interleave, Interleave} are both
projects that allow synchronised annotation of documents (PDF, EPUB
etc.) within Org-mode.

@node Bibliography
@unnumberedsubsubsec Bibliography

@uref{https://github.com/org-roam/org-roam-bibtex, org-roam-bibtex} offers
tight integration between
@uref{https://github.com/jkitchin/org-ref, org-ref},
@uref{https://github.com/tmalsburg/helm-bibtex, helm-bibtex} and
@code{org-roam}. This helps you manage your bibliographic notes under
@code{org-roam}.

For example, though helm-bibtex provides the ability to visit notes for
bibliographic entries, org-roam-bibtex extends it with the ability to visit the
file with the right @samp{#+roam_key}.

@node Spaced Repetition
@unnumberedsubsubsec Spaced Repetition

@uref{https://www.leonrische.me/fc/index.html, Org-fc} is a spaced repetition system that scales well with a large number of
files. Other alternatives include @uref{https://orgmode.org/worg/org-contrib/org-drill.html, org-drill}, and @uref{https://github.com/abo-abo/pamparam, pamparam}.

@node FAQ
@chapter FAQ

@menu
* How do I have more than one Org-roam directory?::
* How do I migrate from Roam Research?::
* How do I create a note whose title already matches one of the candidates?::
@end menu

@node How do I have more than one Org-roam directory?
@section How do I have more than one Org-roam directory?

Emacs supports directory-local variables, allowing the value of
@code{org-roam-directory} to be different in different directories. It does this by
checking for a file named @code{.dir-locals.el}.

To add support for multiple directories, override the @code{org-roam-directory}
variable using directory-local variables. This is what @code{.dir-locals.el} may
contain:

@lisp
((nil . ((org-roam-directory . ".")
         (org-roam-db-location . "./org-roam.db"))))
@end lisp

All files within that directory will be treated as their own separate set of
Org-roam files. Remember to run @code{org-roam-db-build-cache} from a file within
that directory, at least once.

@node How do I migrate from Roam Research?
@section How do I migrate from Roam Research?

Fabio has produced a command-line tool that converts markdown files exported
from Roam Research into Org-roam compatible markdown. More instructions are
provided @uref{https://github.com/fabioberger/roam-migration, in the repository}.

@node How do I create a note whose title already matches one of the candidates?
@section How do I create a note whose title already matches one of the candidates?

This situation arises when, for example, one would like to create a note titled
``bar'' when ``barricade'' already exists.

The solution is dependent on the mini-buffer completion framework in use. Here
are the solutions:

@itemize
 @item
 Ivycall @code{ivy-immediate-done}, typically bound to @code{C-M-j}. Alternatively,
set @code{ivy-use-selectable-prompt} to @code{t}, so that ``bar'' is now selectable.

@item
 HelmOrg-roam should provide a selectable ``[?] bar'' candidate at the top of
the candidate list.
@end itemize

@node Keystroke Index
@appendix Keystroke Index

@printindex ky

@node Command Index
@appendix Command Index

@printindex cp

@node Function Index
@appendix Function Index

@printindex fn

@node Variable Index
@appendix Variable Index

@printindex vr

Emacs 28.0.50 (Org mode 9.4)
@bye