来自:https://baty.net/2023/using-both-denote-and-org-roam/
Using both Denote and Org-roam
同时使用 Denote 和 Org-roam
Denote and Org-roam are both great Emacs packages for taking notes. I’ve used each of them extensively and have waffled between them regularly. I started wondering if it makes sense to use both. It does!. Denote 和 Org-roam 都是很棒的 Emacs 软件包,用于做笔记。我已经广泛使用了它们中的每一个,并经常在它们之间徘徊。我开始想知道同时使用两者是否有意义。确实如此!.
Denote’s claim to fame is simplicity and structured file naming. Org-roam is great for daily notes, heading-level linking, and the cool visual graph. Denote的名声是简单和结构化的文件命名。Org-roam 非常适合日常笔记、标题级链接和酷炫的可视化图表。
I’ve sometimes felt (probably irrationally) icky about using Org-roam because of its dependency on external sqlite libraries. Now, with Emacs 29+, sqlite is built in, so I feel better about it. 我有时会对使用 Org-roam 感到(可能是非理性的)不舒服,因为它依赖于外部 sqlite 库。现在,在 Emacs 29+ 中,sqlite 是内置的,所以我感觉更好。
What I wanted was Org-roam’s features with Denote’s naming conventions, so I installed both packages. The trick to making it seamless was to adjust the default Org-roam template so that it creates files with the proper names. Here’s how I’ve done that. 我想要的是 Org-roam 的功能和 Denote 的命名约定,所以我安装了这两个软件包。使其无缝的诀窍是调整默认的 Org-roam 模板,以便它创建具有正确名称的文件。以下是我的做法。
(setq org-roam-capture-templates
'(("d" "default" plain "%?"
:target
(file+head "%<%Y%m%dT%H%M%S>--${slug}.org" ":PROPERTIES:\n:ID: %<%Y%m%dT%H%M%S>\n:END:\n#+title: ${title}\n#+date: [%<%Y-%m-%d %a %H:%S>]\n#+filetags: \n#+identifier: %<%Y%m%dT%H%M%S>\n\n")
:immediate-finish t
:unnarrowed t)))
I had been using GUIDs for the ID: property but here I’ve switched to IDs based on datestamps so they match the “identifier”. I’m not sure this is a great idea. You may also notice that I’m not bothering with tagging here. I don’t always use tags, anyway, so I don’t feel the need to complicate the capture process. Besides, when I do want to add tags I can use denote-keywords-add
and Denote adds to the filetags property and updates the filename automatically. This is one of the nice things about having both packages available.
我一直在为 ID: 属性使用 GUID,但在这里我已切换到基于日期戳的 ID,以便它们与“标识符”匹配。我不确定这是一个好主意。您可能还注意到,我在这里并没有为标记而烦恼。无论如何,我并不总是使用标签,所以我觉得没有必要使捕获过程复杂化。此外,当我确实想添加标签时,我可以使用 denote-keywords-add
Denote 添加到文件标签属性并自动更新文件名。这是两个软件包都可用的好处之一。
If I want to rename/tag a bunch of files at once, I can use the denote-dired-*
commands. Any time the database gets out of whack when doing this, I just run org-roam-db-sync
and we’re back in action.
如果我想一次重命名/标记一堆文件,我可以使用命令 denote-dired-*
。每当数据库在执行此操作时失常时,我都会运行 org-roam-db-sync
,然后我们又开始行动。
One other bonus is that all of my original Denote links (e.g. denote:ABC123) still work so I haven’t bothered converting everything to use Org’s id: style links. In order to include my Denote files in Org-roam’s database, I did need to add an ID: property to the top of each of them. Fortunately, I use the ID property for org-download/org-attach so most of them already had IDs. 另一个好处是我所有原始的 Denote 链接(例如 denote:ABC123)仍然有效,所以我没有费心将所有内容转换为使用 Org 的 id: 样式链接。为了将我的 Denote 文件包含在 Org-roam 的数据库中,我确实需要在每个文件的顶部添加一个 ID: 属性。幸运的是,我将 ID 属性用于组织下载/组织附加,因此他们中的大多数已经有了 ID。
Using both Denote and Org-roam seems to be working fine. Am I missing anything that might cause issues later? 同时使用Denote和Org-roam似乎工作正常。我是否遗漏了以后可能导致问题的任何内容?