The Org-roam v2 Great Migration

It’s probably more useful to consider “install” separate from “load” or “require”.

Installing is just storing a file in your file system, and maybe tell Emacs where it is (e.g. with load-path). This does not tell Emacs to use it. To do so, you use require, load-file, load-library, etc.

For Doom, think of it in terms of the difference between package.el (install via straight and doom sync) and use-package! in config.el (load).

Org-protocol gets installed as part of Org but not loaded automatically. You will need to load org-protocol and org-roam-protocol (e.g. require them).

2 Likes

Thanks for your response @nobiot. Since I don’t do anything myself in Doom to load org-protocol (including anything like +protocol, I didn’t realize that it wasn’t always loaded. And now that you have me looking for it, I see the function +org-init-protocol-lazy-loader-h in Doom that loads org-protocol.

So I will try setting up org-roam-protocol to load after org-protocol is lazily loaded.

Thanks :slight_smile:

1 Like

I’m trying to migrate using the great wiki post made by @nobiot, but i hit some difficulties with doom.

Just to be sure, into init.el :

(org +roam)

Into package.el

(package! org-roam
  :recipe (:host github :repo "org-roam/org-roam" :branch "v2"))

(unpin! org-mode)
(unpin! org-roam)

Into config.el

(use-package! org-roam
  :after org
  :commands
  (org-roam-buffer
   org-roam-setup
   org-roam-capture
   org-roam-node-find)
  :config
  (setq org-roam-directory (file-truename "~/Notes/2ndBrain/")
      org-roam-db-location (file-truename "~/Notes/org-roam.db")
      org-roam-link-title-format "%sº"
      org-roam-prefer-id-links t
      org-roam-index-file "20200626221151-index_para.org")
(org-roam-setup))

After doom sync -u I have an error during emacs dooms load :

Error in private config: config.el, (wrong-number-of-arguments (0 . 0) 1)
Error (org-load-hook): Error running hook "+org-init-roam-maybe-h" because: (wrong-number-of-arguments (0 . 0) 1)

:sob: everything is broken now …

I suggest to remove +roam; it’s for v1.

Much better thanks, now i try to convert my old v1 file using one script…

I really like having interactive graphing capabilities such as org-roam-graph or the org-roam-server package. Do we know when these will be supported in org-roam v2? This is really holding me back from switching to it

Not a direct answer but you will see what’s happening: State of Org-roam v2 support · Issue #161 · org-roam/org-roam-server · GitHub and can track the status.

You could offer your help if you have skills and time to accelerate the process.

I would love to help with this project as I definitely have time, but sadly I doubt I have the skills to help. I am no programmer and the only elisp I know is what I have learned through configuring emacs (and thats probably the programming language I know the best sadly) so I would probably only detriment the process.

Thanks for the link, though. Can’t wait for this!

1 Like

By the way, the graph (not form the server) is supported now. See this screen shot in a comment in this other issue: org-roam is undergoing a major redesign, will this affect org-roam-server · Issue #135 · org-roam/org-roam-server · GitHub

2 Likes

An extra note for those interested in getting org-roam-server work with org-roam v2

State of Org-roam v2 support · Issue #161 · org-roam/org-roam-server · GitHub

3 Likes

Cool! So it’s going to be a new React app (is this an accurate way to characterise it?)?

Correct. A new React app backend by the server running inside Emacs (or at least that’s the plan).

1 Like

Thanks! Looking forward to it

Thanks again for all the work on roam.

I’ve finally gotten the migrate script to work on my 7k notes. It runs to completion.

Some questions:
1 - is there a template for a standard note + ID expectation that I can set up? (see example file, that doesn’t get picked up below)
2 - Is there a similar project to org-roam-server that might’ve taken off in the last 6 months?

#+title: qubit
#+HUGO_BASE_DIR: ../export/hugo
#+roam_alias: "qubits"
#+roam_tags: compsci

Quantum bit (short form of) - defined by [[file:20200708103309-benjamin_schumacher.org][R:Benjamin Schumacher]]. A [[file:20200708103201-qubit.org][R:qubit's]] [[file:20200708105003-qubit_state.org][R:qubit state]] is represented as a vector.

Please see: org-roam-ui

Hi everyone,

I have migrated to V2, but I have much difficulty in arranging my configuration to work properly.
I can’t manage the capture-templates, the org-roam-buffer, keybindings etc.
Does anyone point me to a standard configuration from which I can copy things for minimal use?
THANKS!

(BTW, I am using doom emacs).

+roam2 flag?

I activated the +roam2 flag.

I think that it would be great to have some standard configuration file for people using doom emacs.

My configuration at the moment is attached. I hope this might help other people migrating.

EDIT: I finally got the org-roam-buffer to be configured correctly on doom emacs. changed the config below accordingly.

(setq org-roam-v2-ack t)

(use-package! org-roam
  :init
  (setq org-roam-v2-ack t)
  (map! :leader
        (:prefix-map ("n" . "notes")
         (:prefix ("r" . "roam")
          :desc "Insert new roam node" "i" #'org-roam-node-insert
          :desc "Find roam node" "f" #'org-roam-node-find
          :desc "Roam buffer" "r" #'org-roam-buffer-toggle
          (:prefix ("d" . "dailies")
           :desc "today" "d" (lambda () (interactive) (org-roam-dailies-capture-today t))
           :desc "today" "y" (lambda () (interactive) (org-roam-dailies-capture-yesterday t))
           :desc "tomorrow" "t" (lambda () (interactive) (org-roam-dailies-capture-tomorrow t))))))

  (setq org-roam-completion-everywhere 'nil)
  (setq org-roam-directory (file-truename "~/Dropbox/org-roam"))
  (setq org-roam-db-location "~/org-roam.db")

  :config
  (org-roam-setup)

  (add-hook 'org-roam-mode-hook #'turn-on-visual-line-mode)

  (setq org-roam-mode-section-functions
        (list #'org-roam-backlinks-section
              #'org-roam-reflinks-section
              #'org-roam-unlinked-references-section
              ))


  (setq org-roam-capture-templates
        '(("d" "default" plain "%?" :target
           (file+head "%<%Y%m%d%H%M%S>-${slug}.org"
                      "#+TITLE: ${title}\n#+CREATED: %U\n#+LAST_MODIFIED: %U\n#+OPTIONS: toc:nil, ':t\n#+SETUPFILE: ~/.doom.d/templates/org_latex_header.org\n\n\n\n* References \nbibliographystyle:unsrt\nbibliography:~/references.bib\n")
           :unnarrowed t)
          ("b" "book review" plain "%?" :target
           (file+head "books/%<%Y%m%d%H%M%S>-book-${slug}"
                      "#+TITLE: ${title}\n#+CREATED: %U\n#+LAST_MODIFIED: %U\n#+OPTIONS: toc:nil, ':t\n#+SETUPFILE: ~/.doom.d/templates/org_latex_header.org\n\n* Source\n\n- Author: %^{Author}\n- Title: ${title}\n\n* What I thought\n\n%?\n\n* References \nbibliographystyle:unsrt\nbibliography:~/references.bib\n")
           :unnarrowed t)
          ("p" "personal note" plain "%?" :target
           (file+head "personal/%<%Y%m%d%H%M%S>-personal-${slug}"
                      "#+TITLE: ${title}\n#+CREATED: %U\n#+LAST_MODIFIED: %U\n#+OPTIONS: toc:nil, ':t\n#+SETUPFILE: ~/.doom.d/templates/org_latex_header.org\n#+ROAM_TAGS: personal\n\n\n\n* References \nbibliographystyle:unsrt\nbibliography:~/references.bib\n")
           :unnarrowed t)))


  (setq org-roam-dailies-capture-templates
        '(("d" "default" entry "* %?" :target
           (file+head "%<%Y-%m-%d>.org"
                      "#+title: %<%Y-%m-%d>\n#+CREATED: %U\n#+LAST_MODIFIED: %U\n#+OPTIONS: toc:nil, ':t\n#+SETUPFILE: ~/.doom.d/templates/org_latex_header.org\n\n")
           :add-created t
           :jump-to-captured t
           :unnarrowed t)))


  (setq org-roam-node-display-template
        (concat "${title:80} " (propertize "${tags:20}" 'face 'org-tag))
        org-roam-node-annotation-function
        (lambda (node) (marginalia--time (org-roam-node-file-mtime node))))


  ;; mouse use for the org-roam buffer
  ;; https://org-roam.discourse.group/t/backlinks-in-org-roam-buffer/1947/20?u=nobiot
  (define-key org-roam-node-map [mouse-1] #'org-roam-node-visit)
  (define-key org-roam-preview-map [mouse-1] #'org-roam-preview-visit)


  ;;
  ;; Showing the number of backlinks for each node in org-roam-node-find
  ;;
  (cl-defmethod org-roam-node-directories ((node org-roam-node))
    (if-let ((dirs (file-name-directory (file-relative-name (org-roam-node-file node) org-roam-directory))))
        (format "(%s)" (car (f-split dirs)))
      ""))

  (cl-defmethod org-roam-node-backlinkscount ((node org-roam-node))
    (let* ((count (caar (org-roam-db-query
                         [:select (funcall count source)
                          :from links
                          :where (= dest $s1)
                          :and (= type "id")]
                         (org-roam-node-id node)))))
      (format "[%d]" count)))

  (setq org-roam-node-display-template "${directories:10} ${tags:10} ${title:100} ${backlinkscount:6}")


  ;; mathjax
  ;;
  (setq org-html-mathjax-template
        (let ((mathjax-template (expand-file-name "templates/mathjax_org_template.html" doom-private-dir)))
          (with-temp-buffer
            (insert-file-contents mathjax-template)
            (buffer-string))))

  )

(after! popup
  (set-popup-rule! "\\*org-roam\\*"
    :side 'right
    :width 0.33
    :slot 0
    :parameters '((no-other-window . t)
                 (no-delete-other-windows . t))))



2 Likes

V1 → V2 template migration.

** Default capture template
#+BEGIN_SRC emacs-lisp
(setq org-roam-capture-templates '(("d" "default" plain (function org-roam--capture-get-point)
                                    "%?"
                                    :file-name "%<%Y%m%d%H%M%S>-${slug}"
                                    :head "#+TITLE: ${title}
,#+HUGO_SLUG: ${slug}
,#+ROAM_ALIAS:
,#+ROAM_TAGS:
,#+CREATED_ON:    %u
,#+LAST_MODIFIED: %U

${title} "
                                    :unnarrowed t)))
#+END_SRC

Gets me Template needs to specify ":target". What am I missing here?

I received this when calling org-roam-note-insert for a new file.