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

command-execute: Autoloading file /home/k/.emacs.d/elpa/org-roam-20210717.1454/org-roam.elc failed to define function org-roam-find-file

剛剛升級了V2

我的配置如下,就是把官方的扒過來了

(use-package org-roam
  :ensure t
  :hook
  (after-init . org-roam-mode)
  :custom
  (org-roam-directory (file-truename "~/write/org-roam/"))
  :bind (:map org-roam-mode-map
          (("C-c n l" . org-roam)
           ("C-c n f" . org-roam-find-file)
           ("C-c n g" . org-roam-graph))
          :map org-mode-map
          (("C-c n i" . org-roam-insert))
          (("C-c n I" . org-roam-insert-immediate))))

(setq org-roam-v2-ack t)

https://github.com/org-roam/org-roam#installation

https://github.com/org-roam/org-roam/wiki/Hitchhiker’s-Rough-Guide-to-Org-roam-V2

V1和V2的配置是不兼容的,许多命令都修改了

1赞

原來在v2裏都改了 find-file改成了 node-find

謝謝,請問你能分享一下你的配置嗎? 比如如何方便的打開backlink的buffer?

還有v2是如何看link圖的?

看图用org-roam-graph 打开buffer有个命令是org-roam-buffer-toggle,给它绑个快捷键。

配置可以参考这个 https://github.com/seagle0128/.emacs.d/blob/master/lisp/init-org.el ,或者官网就有配置推荐

v2 没有 org-roam-insert-immediate 命令了?

v2里改成 org-roam-node-insert了。

;;; 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的配置