org-roam 運行 org-roam-find-file 報錯

;;; lisp/init-org-roam.el -*- lexical-binding: t; -*-


(map! :leader
            (:prefix-map ("n" . "notes")
             (:prefix ("r" . "roam")
              :desc "Switch to buffer" "l" #'org-roam-buffer-toggle
              :desc "Find file" "f"        #'org-roam-node-find
              :desc "Show Graph" "g"       #'org-roam-graph
              :desc "Insert node" "i"      #'org-roam-node-insert
              :desc "Org Roam Capture" "c"    #'org-roam-capture
              (:prefix ("d" . "by date")
               :desc "Arbitrary date" "d" #'org-roam-dailies-find-date
               :desc "Today"          "t" #'org-roam-dailies-find-today
               :desc "Tomorrow"       "m" #'org-roam-dailies-find-tomorrow
               :desc "Yesterday"      "y" #'org-roam-dailies-find-yesterday
               ))))
(use-package org-roam
      :custom
      (org-roam-directory (file-truename "~/Notes/Captures/roam"))
      :init
      (map! :after org
            :map org-mode-map
            :localleader
            :prefix ("m" . "org-roam")
            "m" #'org-roam-node-random
            "l" #'org-roam-buffer-toggle
            "f" #'org-roam-node-find
            "g" #'org-roam-graph
            "i" #'org-roam-node-insert
            "c" #'org-roam-capture
            "t" #'org-roam-tag-add
            "T" #'org-roam-tag-remove
            "a" #'org-roam-alias-add
            "A" #'org-roam-alias-remove
            "p" #'my/org-hide-properties-display
            "P" #'my/org-show-properties-display
            (:prefix ("d" . "by date")
             :desc "Find previous note" "b" #'org-roam-dailies-find-previous-note
             :desc "Find date"          "d" #'org-roam-dailies-find-date
             :desc "Find next note"     "f" #'org-roam-dailies-find-next-note
             :desc "Find tomorrow"      "m" #'org-roam-dailies-find-tomorrow
             :desc "Capture today"      "n" #'org-roam-dailies-capture-today
             :desc "Find today"         "t" #'org-roam-dailies-find-today
             :desc "Capture Date"       "v" #'org-roam-dailies-capture-date
             :desc "Find yesterday"     "y" #'org-roam-dailies-find-yesterday
             :desc "Find directory"     "." #'org-roam-dailies-find-directory))
      (map! :after org-roam
            :map org-roam-mode-map
            :n
            "q" #'quit-window)
      :config
      (org-roam-setup)
      ;; If using org-roam-protocol
      (require 'org-roam-protocol))

(defun colawithsauce/org-roam-node--annotation (node-title)
  "Return the annotation string for a NODE-TITLE.
This custom function enhances Org-roam's function of the same
name to include number of backlinks for the node."
  (let* ((node (get-text-property 0 'node node-title))
         (tags (org-roam-node-tags node))
         (count)
         (annotation))
    (setq count (caar (org-roam-db-query

                       [:select (funcall count source)
                                :from links
                                :where (= dest $s1)
                                :and (= type "id")]
                       (org-roam-node-id node))))
    (concat annotation
            (when tags (format " (%s)" (string-join tags ", ")))
            (when count (format " [%d]" count)))))

(custom-set-variables
 '(org-roam-node-annotation-function #'colawithsauce/org-roam-node--annotation)
 '(org-roam-node-display-template "${title:30} ${tags:20} ${olp:*}"))

(defun my/org-hide-properties-display ()
  "Hide Org property drawer using text properties.
Based on the code shared at
https://org-roam.discourse.group/t/org-roam-major-redesign/1198/34."
  (interactive)
  (save-excursion
    (goto-char (point-min))
    (while (re-search-forward
            "^ *:PROPERTIES:\n\\( *:.+?:.*\n\\)+ *:END:\n" nil t)
      (add-text-properties (match-beginning 0) (match-end 0)
                           (list 'display ""
                                 'line-prefix "⋮ "))))
  (save-buffer))

(defun my/org-show-properties-display ()
  "Show Org property drawer using text properties.
Based on the code shared at
https://org-roam.discourse.group/t/org-roam-major-redesign/1198/34."
  (interactive)
  (save-excursion
    (goto-char (point-min))
    (while (re-search-forward
            "^ *:PROPERTIES:\n\\( *:.+?:.*\n\\)+ *:END:\n" nil t)
      (remove-list-of-text-properties (match-beginning 0) (match-end 0)
                           (list 'display
                                 'line-prefix)))))

(provide 'init-org-roam)

基本上抄了一个doom的配置