已解决:org-protocol 设置时 ~error: (void-variable org-protocol-protocol-alist)~

(add-to-list
 org-protocol-protocol-alist
 '("org-open-file" :protocol "open-file" :function org-protocol-open-file))

(defun org-protocol-open-file (fname)
  ...)

整段代码是为了给添加的 Anki 卡片生成可以跳转回来的链接,但现在链接能生成,但无法跳转回 org 文件。

现在跳转时,emacs 想要创建新的文件夹

Directory `~/org/org-roam/org-protocol:/' does not exist! Create it? (y or n)`

原因:因为 doom 中 org-protocol 属于懒加载,所以导致找不到 org-protocol-protocol-alist 这个变量

解决方法:

(after! org-protocol
  (add-to-list 'org-protocol-protocol-alist
               '("org-open-file"
                 :protocol "open-file"
                 :function org-protocol-open-file)))