From d92883bff8ff5457faa09b41a1e8e404c3693594 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 20 Sep 2025 02:43:13 -0400 Subject: [PATCH] refactor!(org): remove org-roam v1 BREAKING CHANGE: This finally removes org-roam v1, which has been deprecated for nearly 5 years (since 5ef733b). Most users should already be on it. v2 has a migration wizard for anyone still on v1, which will kick in if it detects a v1 roam db. --- modules/config/default/+emacs-bindings.el | 19 +- modules/config/default/+evil-bindings.el | 18 +- modules/lang/org/README.org | 52 +--- .../{contrib-roam2.el => contrib-roam.el} | 14 +- modules/lang/org/contrib/roam.el | 243 +++++++++++++----- modules/lang/org/contrib/roam2.el | 199 -------------- modules/lang/org/doctor.el | 7 +- modules/lang/org/packages.el | 17 +- modules/tools/biblio/README.org | 2 +- modules/tools/biblio/packages.el | 3 +- 10 files changed, 197 insertions(+), 377 deletions(-) rename modules/lang/org/autoload/{contrib-roam2.el => contrib-roam.el} (95%) delete mode 100644 modules/lang/org/contrib/roam2.el diff --git a/modules/config/default/+emacs-bindings.el b/modules/config/default/+emacs-bindings.el index 22b41506f..a37a788d8 100644 --- a/modules/config/default/+emacs-bindings.el +++ b/modules/config/default/+emacs-bindings.el @@ -193,23 +193,8 @@ :desc "New Entry" "j" #'org-journal-new-entry :desc "New Scheduled Entry" "J" #'org-journal-new-scheduled-entry :desc "Search Forever" "s" #'org-journal-search-forever)) - (:when (modulep! :lang org +roam) - (:prefix ("r" . "roam") - :desc "Switch to buffer" "b" #'org-roam-switch-to-buffer - :desc "Org Roam Capture" "c" #'org-roam-capture - :desc "Find file" "f" #'org-roam-find-file - :desc "Show graph" "g" #'org-roam-graph - :desc "Insert" "i" #'org-roam-insert - :desc "Insert (skipping org-capture)" "I" #'org-roam-insert-immediate - :desc "Org Roam" "r" #'org-roam - :desc "Tag" "t" #'org-roam-tag-add - :desc "Un-tag" "T" #'org-roam-tag-delete - (: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))) - (:when (modulep! :lang org +roam2) + (:when (or (modulep! :lang org +roam) + (modulep! :lang org +roam2)) (:prefix ("r" . "roam") :desc "Open random node" "a" #'org-roam-node-random :desc "Find node" "f" #'org-roam-node-find diff --git a/modules/config/default/+evil-bindings.el b/modules/config/default/+evil-bindings.el index b1fe4997e..1e505994c 100644 --- a/modules/config/default/+evil-bindings.el +++ b/modules/config/default/+evil-bindings.el @@ -647,22 +647,8 @@ :desc "Org export to clipboard" "y" #'+org/export-to-clipboard :desc "Org export to clipboard as RTF" "Y" #'+org/export-to-clipboard-as-rich-text - (:when (modulep! :lang org +roam) - (:prefix ("r" . "roam") - :desc "Switch to buffer" "b" #'org-roam-switch-to-buffer - :desc "Org Roam Capture" "c" #'org-roam-capture - :desc "Find file" "f" #'org-roam-find-file - :desc "Show graph" "g" #'org-roam-graph - :desc "Insert" "i" #'org-roam-insert - :desc "Insert (skipping org-capture)" "I" #'org-roam-insert-immediate - :desc "Org Roam" "r" #'org-roam - (: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))) - - (:when (modulep! :lang org +roam2) + (:when (or (modulep! :lang org +roam) + (modulep! :lang org +roam2)) (:prefix ("r" . "roam") :desc "Open random node" "a" #'org-roam-node-random :desc "Find node" "f" #'org-roam-node-find diff --git a/modules/lang/org/README.org b/modules/lang/org/README.org index 465814c0f..58bbb12cb 100644 --- a/modules/lang/org/README.org +++ b/modules/lang/org/README.org @@ -79,11 +79,7 @@ https://www.mfoot.com/blog/2015/11/22/literate-emacs-configuration-with-org-mode highlighting for latex. Keep in mind: this can be expensive. If org becomes too slow, it'd be wise to disable this flag. - +roam :: - Enable integration with [[https://github.com/org-roam/org-roam-v1][org-roam v1]]. This requires ~sqlite3~ to be installed - on your system. /Incompatible with [[doom-module:+roam2]]./ -- +roam2 :: - Enable integration with [[https://github.com/org-roam/org-roam][org-roam v2]]. This requires ~sqlite3~ to be installed - on your system. /Incompatible with [[doom-module:+roam]]./ + Enable integration with [[https://github.com/org-roam/org-roam][org-roam v2]]. ** Packages - [[doom-package:htmlize]] @@ -122,9 +118,7 @@ https://www.mfoot.com/blog/2015/11/22/literate-emacs-configuration-with-org-mode - [[doom-package:org-appear]] - [[doom-package:org-modern]] - [[doom-module:+roam]] - - [[doom-package:org-roam]] (v1) -- [[doom-module:+roam2]] - - [[doom-package:org-roam]] (v2) + - [[doom-package:org-roam]] *** From Modules - [[doom-module::editor evil]] @@ -203,7 +197,8 @@ use Org's more esoteric features: dependencies are met, e.g. install the [[doom-executable:ruby]] executable for ruby support. To use ~jupyter kernels~ you need the [[doom-module:+jupyter]] flag, the associated kernel as well as the [[doom-executable:jupyter]] program. -- [[doom-package:org-roam]] (with [[doom-module:+roam]] or [[doom-module:+roam2]] flag) requires [[doom-executable:sqlite3]] to be installed. +- [[doom-package:org-roam]] (with the [[doom-module:+roam]] flag) requires Emacs to be + built with sqlite support. ** MacOS #+begin_src sh @@ -293,44 +288,7 @@ For =evil-mode= users, an overview of org-mode keybindings is provided [[https:/ #+end_src * Troubleshooting -[[doom-report:][Report an issue?]] - -** =org-roam= -*** Should I go with =+roam= (v1) or =+roam2= (v2)? -Long story short: if you're new to [[doom-package:org-roam]] and haven't used it, then you should -go with [[doom-module:+roam2]]; if you already have an ~org-roam-directory~ with the v1 files in -it, then you can keep use [[doom-module:+roam]] for the time being, but it will eventually be -removed, so you should [[https://www.orgroam.com/manual.html#How-to-migrate-from-Org_002droam-v1_003f][migrate]] at your earliest convenience. - -V1 isn't actively maintained anymore and is now basically EOL. This means that -the feature disparity between the both will continue to grow, while its existing -bugs and problems won't be addressed, at least by the main maintainers. V2 can -be considered as a complete rewrite of the package so it comes with a lot of -breaking changes. - -To learn more about v2 you can use the next resources: -- [[https://github.com/org-roam/org-roam/blob/master/doc/org-roam.org][Org-roam v2 Official Manual]] -- [[https://github.com/org-roam/org-roam/wiki/Hitchhiker's-Rough-Guide-to-Org-roam-V2][Hitchhiker's Rough Guide to Org roam V2]] -- [[https://blog.jethro.dev/posts/org_roam_v2/][Releasing Org-roam v2 - Jethro Kuan's blog]] -- [[https://org-roam.discourse.group/t/org-roam-major-redesign/1198][Thread about the redesign from Org-Roam Discourse]] - -*** Migrating your existing files from v1 (=+roam=) to v2 (=+roam2=) -V2 comes with a migration wizard for v1 users. It's new, which means issues can -appear during the migration process. Because of that, *don't forget to backup* -your ~org-roam-directory~ before attempting to migrate. - -In order to migrate from v1 to v2 using Doom follow the next steps: -1. Enable [[doom-module:+roam2]] flag (and disable [[doom-module:+roam]] if it was previously enabled) in your - =init.el=. -2. Ensure your ~org-roam-directory~ points to a directory with your v1 files. -3. Run ~$ doom sync -u~ in your shell. -4. Restart Emacs (if it was previously opened) and run ~org-roam-migrate-wizard~ - command (~M-x org-roam-migrate-wizard RET~). The wizard will automatically - attempt to backup your previous ~org-roam-directory~ to =org-roam.bak=, but - just in case backup it yourself too. -4. After the wizard is done you should be good to go. Verify the integrity of - your data and whether it did everything as expected. In case of failure - [[https://github.com/org-roam/org-roam/issues][report]] your issue. +/There are no known problems with this module./ [[doom-report:][Report one?]] * Frequently asked questions /This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]] diff --git a/modules/lang/org/autoload/contrib-roam2.el b/modules/lang/org/autoload/contrib-roam.el similarity index 95% rename from modules/lang/org/autoload/contrib-roam2.el rename to modules/lang/org/autoload/contrib-roam.el index ca56f22df..0cf90f62e 100644 --- a/modules/lang/org/autoload/contrib-roam2.el +++ b/modules/lang/org/autoload/contrib-roam.el @@ -1,8 +1,8 @@ -;;; lang/org/autoload/contrib-roam2.el -*- lexical-binding: t; -*- -;;;###if (modulep! +roam2) +;;; lang/org/autoload/contrib-roam.el -*- lexical-binding: t; -*- +;;;###if (or (modulep! +roam) (modulep! +roam2)) ;;; Custom node accessors -;;;###autoload (autoload 'org-roam-node-doom-filetitle "lang/org/autoload/contrib-roam2" nil t) +;;;###autoload (autoload 'org-roam-node-doom-filetitle "lang/org/autoload/contrib-roam" nil t) (cl-defmethod org-roam-node-doom-filetitle ((node org-roam-node)) "Return the value of \"#+title:\" (if any) from file that NODE resides in. If there's no file-level title in the file, return empty string." @@ -11,7 +11,7 @@ If there's no file-level title in the file, return empty string." (org-roam-node-file-title node)) "")) -;;;###autoload (autoload 'org-roam-node-doom-hierarchy "lang/org/autoload/contrib-roam2" nil t) +;;;###autoload (autoload 'org-roam-node-doom-hierarchy "lang/org/autoload/contrib-roam" nil t) (cl-defmethod org-roam-node-doom-hierarchy ((node org-roam-node)) "Return hierarchy for NODE, constructed of its file title, OLP and direct title. If some elements are missing, they will be stripped out." @@ -31,7 +31,7 @@ If some elements are missing, they will be stripped out." separator (propertize (string-join olp separator) 'face '(shadow italic)) separator title))))) -;;;###autoload (autoload 'org-roam-node-doom-subdirs "lang/org/autoload/contrib-roam2" nil t) +;;;###autoload (autoload 'org-roam-node-doom-subdirs "lang/org/autoload/contrib-roam" nil t) (cl-defmethod org-roam-node-doom-subdirs ((node org-roam-node)) "Return subdirectories of `org-roam-directory' in which NODE resides in. If there's none, return an empty string." @@ -41,7 +41,7 @@ If there's none, return an empty string." (file-relative-name org-roam-directory) (file-name-directory))) -;;;###autoload (autoload 'org-roam-node-doom-tags "lang/org/autoload/contrib-roam2" nil t) +;;;###autoload (autoload 'org-roam-node-doom-tags "lang/org/autoload/contrib-roam" nil t) (cl-defmethod org-roam-node-doom-tags ((node org-roam-node)) "Return tags formatted in the same way how they appear in org files." (cl-remove-if (doom-rpartial @@ -52,7 +52,7 @@ If there's none, return an empty string." (bound-and-true-p org-num-skip-tags)))) (org-roam-node-tags node))) -;;;###autoload (autoload 'org-roam-node-doom-type "lang/org/autoload/contrib-roam2" nil t) +;;;###autoload (autoload 'org-roam-node-doom-type "lang/org/autoload/contrib-roam" nil t) (cl-defmethod org-roam-node-doom-type ((node org-roam-node)) "Return the directory relative to `org-roam-directory' as a note's \"type\"." (when-let (dir (thread-first diff --git a/modules/lang/org/contrib/roam.el b/modules/lang/org/contrib/roam.el index 5ff27b074..e5888bc3f 100644 --- a/modules/lang/org/contrib/roam.el +++ b/modules/lang/org/contrib/roam.el @@ -1,93 +1,196 @@ ;;; lang/org/contrib/roam.el -*- lexical-binding: t; -*- -;;;###if (modulep! +roam) +;;;###if (or (modulep! +roam) (modulep! +roam2)) -(defvar +org-roam-open-buffer-on-find-file t - "If non-nil, open the org-roam buffer when opening an org roam file.") +(defvar +org-roam-auto-backlinks-buffer nil + "If non-nil, open and close the org-roam backlinks buffer automatically. + +This ensures the backlinks buffer is always present so long as an org roam file +is visible. Once they are all closed or killed, the backlinks buffer will be +closed.") + +(defvar +org-roam-link-to-org-use-id 'create-if-interactive + "`org-roam-directory' local value for `org-id-link-to-org-use-id'. +It's not recommended to set this to nil in order for other parts +of org-mode to properly utilize ID links.") ;; ;;; Packages (use-package! org-roam - :hook (org-load . +org-init-roam-maybe-h) - :hook (org-roam-backlinks-mode . turn-on-visual-line-mode) - :commands (org-roam-buffer-toggle-display - org-roam-dailies-find-date - org-roam-dailies-find-today - org-roam-dailies-find-tomorrow - org-roam-dailies-find-yesterday) + :hook (org-load . +org-init-roam-h) :preface ;; Set this to nil so we can later detect if the user has set custom values ;; for these variables. If not, default values will be set in the :config ;; section. (defvar org-roam-directory nil) - (defvar org-roam-db-location nil) + :init - (map! :after org - :map org-mode-map - :localleader - :prefix ("m" . "org-roam") - "b" #'org-roam-switch-to-buffer - "f" #'org-roam-find-file - "g" #'org-roam-graph - "i" #'org-roam-insert - "I" #'org-roam-insert-immediate - "m" #'org-roam - "t" #'org-roam-tag-add - "T" #'org-roam-tag-delete - (: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)) + (doom-load-packages-incrementally + '(ansi-color dash f rx seq magit-section emacsql)) + + ;; Don't display warning message dedicated for v1 users. Need to be set early. + (setq org-roam-v2-ack t) + :config - (defun +org-init-roam-maybe-h () - "Activate `org-roam-mode'. If it fails, fail gracefully." - (unless (with-demoted-errors "ORG ROAM ERROR: %s" - (org-roam-mode +1) - t) - (message "To try reinitializing org-roam, run 'M-x org-roam-mode'") - (org-roam-mode -1))) + (defun +org-init-roam-h () + "Setup `org-roam' but don't immediately initialize its database. +Instead, initialize it when it will be actually needed." + (letf! ((#'org-roam-db-sync #'ignore)) + (org-roam-db-autosync-enable))) + + (defadvice! +org-roam-try-init-db-a (&rest _) + "Try to initialize org-roam database at the last possible safe moment. +In case of failure, fail gracefully." + :before #'org-roam-db-query + (message "Initializing org-roam database...") + (advice-remove 'org-roam-db-query #'+org-roam-try-init-db-a) + (org-roam-db-sync)) + + (defadvice! +org-roam-node-insert-after-point-a (fn &rest args) + "If in evil normal mode and cursor is on a whitespace character, insert the +link after the whitespace rather than before. If at EOL, add a space before +inserting the link." + :around #'org-roam-node-insert + (if (and (bound-and-true-p evil-local-mode) + (not (evil-insert-state-p)) + (or (looking-at-p "[[:blank:]]") + (evil-eolp))) + (evil-with-state 'insert + (unless (eolp) (forward-char)) + (if (evil-eolp) (insert " ")) + (apply fn args)) + (apply fn args))) (setq org-roam-directory - (file-name-as-directory - (file-truename - (expand-file-name (or org-roam-directory "roam") - org-directory))) - org-roam-db-location (or org-roam-db-location - (concat doom-data-dir "org-roam.db")) - ;; Make org-roam buffer sticky; i.e. don't replace it when opening a - ;; file with an *-other-window command. - org-roam-buffer-window-parameters '((no-delete-other-windows . t)) - org-roam-link-use-custom-faces 'everywhere + (thread-first (or org-roam-directory "roam") + (expand-file-name org-directory) + (file-truename) + (file-name-as-directory)) + org-roam-node-display-template + (format "${doom-hierarchy:*} %s %s" + (propertize "${doom-type:12}" 'face 'font-lock-keyword-face) + (propertize "${doom-tags:42}" 'face '(:inherit org-tag :box nil))) org-roam-completion-everywhere t - org-roam-completion-system - (cond ((modulep! :completion helm) 'helm) - ((modulep! :completion ivy) 'ivy) - ((modulep! :completion ido) 'ido) - ('default))) + org-roam-db-gc-threshold most-positive-fixnum + ;; Reverse the default to favor faster searchers over slower ones. + org-roam-list-files-commands '(fd fdfind rg find)) - ;; Normally, the org-roam buffer doesn't open until you explicitly call - ;; `org-roam'. If `+org-roam-open-buffer-on-find-file' is non-nil, the - ;; org-roam buffer will be opened for you when you use `org-roam-find-file' - ;; (but not `find-file', to limit the scope of this behavior). - (add-hook! 'find-file-hook - (defun +org-roam-open-buffer-maybe-h () - (and +org-roam-open-buffer-on-find-file - (memq 'org-roam-buffer--update-maybe post-command-hook) - (not (window-parameter nil 'window-side)) ; don't proc for popups - (not (eq 'visible (org-roam-buffer--visibility))) - (with-current-buffer (window-buffer) - (org-roam-buffer--get-create))))) + (add-to-list 'org-roam-node-template-prefixes '("doom-tags" . "#")) + (add-to-list 'org-roam-node-template-prefixes '("doom-type" . "@")) - ;; Hide the mode line in the org-roam buffer, since it serves no purpose. This - ;; makes it easier to distinguish from other org buffers. - (add-hook 'org-roam-buffer-prepare-hook #'hide-mode-line-mode)) + ;; REVIEW Remove when addressed upstream. See org-roam/org-roam#2066. + (defadvice! +org--roam-fix-completion-width-for-vertico-a (fn &rest args) + "Fixes completion candidate width for vertico users." + :around #'org-roam-node-read--to-candidate + (letf! (defun org-roam-node--format-entry (template node &optional width) + (funcall org-roam-node--format-entry template node + (if (bound-and-true-p vertico-mode) + (if (minibufferp) + (window-width) + (1- (frame-width))) + width))) + (apply fn args))) + + (setq-hook! 'org-roam-find-file-hook + org-id-link-to-org-use-id +org-roam-link-to-org-use-id) + + ;; Normally, the org-roam buffer won't open until `org-roam-buffer-toggle' is + ;; explicitly called. If `+org-roam-open-buffer-on-find-file' is non-nil, the + ;; org-roam buffer will automatically open whenever a file in + ;; `org-roam-directory' is visited and closed when no org-roam buffers remain. + (add-hook! 'org-roam-find-file-hook :append + (defun +org-roam-enable-auto-backlinks-buffer-h () + (add-hook 'doom-switch-buffer-hook #'+org-roam-manage-backlinks-buffer-h))) + + (set-popup-rules! + `((,(regexp-quote org-roam-buffer) ; persistent org-roam buffer + :side right :width 0.33 :height 0.5 :ttl nil :modeline nil :quit nil :slot 1) + ("^\\*org-roam: " ; node dedicated org-roam buffer + :side right :width 0.33 :height 0.5 :ttl nil :modeline nil :quit nil :slot 2))) + + ;; Soft-wrap lines in the backlinks buffer + (add-hook 'org-roam-mode-hook #'turn-on-visual-line-mode) + + ;; Use a 'roam:X' link's description if X is empty. + ;; TODO PR this upstream? + (advice-add #'org-roam-link-follow-link :filter-args #'org-roam-link-follow-link-with-description-a) + (advice-add #'org-roam-link-replace-at-point :override #'org-roam-link-replace-at-point-a) + + (map! :map org-mode-map + :localleader + :prefix ("m" . "org-roam") + "D" #'org-roam-demote-entire-buffer + "f" #'org-roam-node-find + "F" #'org-roam-ref-find + "g" #'org-roam-graph + "i" #'org-roam-node-insert + "I" #'org-id-get-create + "m" #'org-roam-buffer-toggle + "M" #'org-roam-buffer-display-dedicated + "n" #'org-roam-capture + "r" #'org-roam-refile + "R" #'org-roam-link-replace-all + (:prefix ("d" . "by date") + :desc "Goto previous note" "b" #'org-roam-dailies-goto-previous-note + :desc "Goto date" "d" #'org-roam-dailies-goto-date + :desc "Capture date" "D" #'org-roam-dailies-capture-date + :desc "Goto next note" "f" #'org-roam-dailies-goto-next-note + :desc "Goto tomorrow" "m" #'org-roam-dailies-goto-tomorrow + :desc "Capture tomorrow" "M" #'org-roam-dailies-capture-tomorrow + :desc "Capture today" "n" #'org-roam-dailies-capture-today + :desc "Goto today" "t" #'org-roam-dailies-goto-today + :desc "Capture today" "T" #'org-roam-dailies-capture-today + :desc "Goto yesterday" "y" #'org-roam-dailies-goto-yesterday + :desc "Capture yesterday" "Y" #'org-roam-dailies-capture-yesterday + :desc "Find directory" "-" #'org-roam-dailies-find-directory) + (:prefix ("o" . "node properties") + "a" #'org-roam-alias-add + "A" #'org-roam-alias-remove + "t" #'org-roam-tag-add + "T" #'org-roam-tag-remove + "r" #'org-roam-ref-add + "R" #'org-roam-ref-remove)) + + (when (modulep! :editor evil +everywhere) + (add-hook! 'org-roam-mode-hook + (defun +org-roam-detach-magit-section-mode-map-h () + "Detach `magit-section-mode-map' from `org-roam-mode-map'. +Inheriting its keymaps introduces a lot of conflicts in +`org-roam-mode' based buffers, where Evil and leader keybindings +will become completely overridden. This is because `magit-section' +uses 'keymap text-property to attach section-unique keymaps, which +has a higher level of precedence than `emulation-mode-map-alists'. + +Note: We do this each time through the hook, because otherwise +sections seems to ignore the detachment." + (set-keymap-parent org-roam-mode-map nil))) + + (map! :map org-roam-mode-map + :nv "]" #'magit-section-forward-sibling + :nv "[" #'magit-section-backward-sibling + :nv "gj" #'magit-section-forward-sibling + :nv "gk" #'magit-section-backward-sibling + :nv "gr" #'revert-buffer + :nv "gR" #'revert-buffer + :nv "z1" #'magit-section-show-level-1 + :nv "z2" #'magit-section-show-level-2 + :nv "z3" #'magit-section-show-level-3 + :nv "z4" #'magit-section-show-level-4 + :nv "za" #'magit-section-toggle + :nv "zc" #'magit-section-hide + :nv "zC" #'magit-section-hide-children + :nv "zo" #'magit-section-show + :nv "zO" #'magit-section-show-children + :nv "zm" #'magit-section-show-level-2-all + :nv "zr" #'magit-section-show-level-4-all + :nv "C-j" #'magit-section-forward + :nv "C-k" #'magit-section-backward + :g "M-p" #'magit-section-backward-sibling + :g "M-n" #'magit-section-forward-sibling + :g [tab] #'magit-section-toggle + :g [C-tab] #'magit-section-cycle + :g [backtab] #'magit-section-cycle-global))) ;; Since the org module lazy loads org-protocol (waits until an org URL is diff --git a/modules/lang/org/contrib/roam2.el b/modules/lang/org/contrib/roam2.el deleted file mode 100644 index 96f3220eb..000000000 --- a/modules/lang/org/contrib/roam2.el +++ /dev/null @@ -1,199 +0,0 @@ -;;; lang/org/contrib/roam2.el -*- lexical-binding: t; -*- -;;;###if (modulep! +roam2) - -(defvar +org-roam-auto-backlinks-buffer nil - "If non-nil, open and close the org-roam backlinks buffer automatically. - -This ensures the backlinks buffer is always present so long as an org roam file -is visible. Once they are all closed or killed, the backlinks buffer will be -closed.") - -(defvar +org-roam-link-to-org-use-id 'create-if-interactive - "`org-roam-directory' local value for `org-id-link-to-org-use-id'. -It's not recommended to set this to nil in order for other parts -of org-mode to properly utilize ID links.") - - -;; -;;; Packages - -(use-package! org-roam - :hook (org-load . +org-init-roam-h) - :preface - ;; Set this to nil so we can later detect if the user has set custom values - ;; for these variables. If not, default values will be set in the :config - ;; section. - (defvar org-roam-directory nil) - - :init - (doom-load-packages-incrementally - '(ansi-color dash f rx seq magit-section emacsql)) - - ;; Don't display warning message dedicated for v1 users. Need to be set early. - (setq org-roam-v2-ack t) - - :config - (defun +org-init-roam-h () - "Setup `org-roam' but don't immediately initialize its database. -Instead, initialize it when it will be actually needed." - (letf! ((#'org-roam-db-sync #'ignore)) - (org-roam-db-autosync-enable))) - - (defadvice! +org-roam-try-init-db-a (&rest _) - "Try to initialize org-roam database at the last possible safe moment. -In case of failure, fail gracefully." - :before #'org-roam-db-query - (message "Initializing org-roam database...") - (advice-remove 'org-roam-db-query #'+org-roam-try-init-db-a) - (org-roam-db-sync)) - - (defadvice! +org-roam-node-insert-after-point-a (fn &rest args) - "If in evil normal mode and cursor is on a whitespace character, insert the -link after the whitespace rather than before. If at EOL, add a space before -inserting the link." - :around #'org-roam-node-insert - (if (and (bound-and-true-p evil-local-mode) - (not (evil-insert-state-p)) - (or (looking-at-p "[[:blank:]]") - (evil-eolp))) - (evil-with-state 'insert - (unless (eolp) (forward-char)) - (if (evil-eolp) (insert " ")) - (apply fn args)) - (apply fn args))) - - (setq org-roam-directory - (thread-first (or org-roam-directory "roam") - (expand-file-name org-directory) - (file-truename) - (file-name-as-directory)) - org-roam-node-display-template - (format "${doom-hierarchy:*} %s %s" - (propertize "${doom-type:12}" 'face 'font-lock-keyword-face) - (propertize "${doom-tags:42}" 'face '(:inherit org-tag :box nil))) - org-roam-completion-everywhere t - org-roam-db-gc-threshold most-positive-fixnum - ;; Reverse the default to favor faster searchers over slower ones. - org-roam-list-files-commands '(fd fdfind rg find)) - - (add-to-list 'org-roam-node-template-prefixes '("doom-tags" . "#")) - (add-to-list 'org-roam-node-template-prefixes '("doom-type" . "@")) - - ;; REVIEW Remove when addressed upstream. See org-roam/org-roam#2066. - (defadvice! +org--roam-fix-completion-width-for-vertico-a (fn &rest args) - "Fixes completion candidate width for vertico users." - :around #'org-roam-node-read--to-candidate - (letf! (defun org-roam-node--format-entry (template node &optional width) - (funcall org-roam-node--format-entry template node - (if (bound-and-true-p vertico-mode) - (if (minibufferp) - (window-width) - (1- (frame-width))) - width))) - (apply fn args))) - - (setq-hook! 'org-roam-find-file-hook - org-id-link-to-org-use-id +org-roam-link-to-org-use-id) - - ;; Normally, the org-roam buffer won't open until `org-roam-buffer-toggle' is - ;; explicitly called. If `+org-roam-open-buffer-on-find-file' is non-nil, the - ;; org-roam buffer will automatically open whenever a file in - ;; `org-roam-directory' is visited and closed when no org-roam buffers remain. - (add-hook! 'org-roam-find-file-hook :append - (defun +org-roam-enable-auto-backlinks-buffer-h () - (add-hook 'doom-switch-buffer-hook #'+org-roam-manage-backlinks-buffer-h))) - - (set-popup-rules! - `((,(regexp-quote org-roam-buffer) ; persistent org-roam buffer - :side right :width 0.33 :height 0.5 :ttl nil :modeline nil :quit nil :slot 1) - ("^\\*org-roam: " ; node dedicated org-roam buffer - :side right :width 0.33 :height 0.5 :ttl nil :modeline nil :quit nil :slot 2))) - - ;; Soft-wrap lines in the backlinks buffer - (add-hook 'org-roam-mode-hook #'turn-on-visual-line-mode) - - ;; Use a 'roam:X' link's description if X is empty. - ;; TODO PR this upstream? - (advice-add #'org-roam-link-follow-link :filter-args #'org-roam-link-follow-link-with-description-a) - (advice-add #'org-roam-link-replace-at-point :override #'org-roam-link-replace-at-point-a) - - (map! :map org-mode-map - :localleader - :prefix ("m" . "org-roam") - "D" #'org-roam-demote-entire-buffer - "f" #'org-roam-node-find - "F" #'org-roam-ref-find - "g" #'org-roam-graph - "i" #'org-roam-node-insert - "I" #'org-id-get-create - "m" #'org-roam-buffer-toggle - "M" #'org-roam-buffer-display-dedicated - "n" #'org-roam-capture - "r" #'org-roam-refile - "R" #'org-roam-link-replace-all - (:prefix ("d" . "by date") - :desc "Goto previous note" "b" #'org-roam-dailies-goto-previous-note - :desc "Goto date" "d" #'org-roam-dailies-goto-date - :desc "Capture date" "D" #'org-roam-dailies-capture-date - :desc "Goto next note" "f" #'org-roam-dailies-goto-next-note - :desc "Goto tomorrow" "m" #'org-roam-dailies-goto-tomorrow - :desc "Capture tomorrow" "M" #'org-roam-dailies-capture-tomorrow - :desc "Capture today" "n" #'org-roam-dailies-capture-today - :desc "Goto today" "t" #'org-roam-dailies-goto-today - :desc "Capture today" "T" #'org-roam-dailies-capture-today - :desc "Goto yesterday" "y" #'org-roam-dailies-goto-yesterday - :desc "Capture yesterday" "Y" #'org-roam-dailies-capture-yesterday - :desc "Find directory" "-" #'org-roam-dailies-find-directory) - (:prefix ("o" . "node properties") - "a" #'org-roam-alias-add - "A" #'org-roam-alias-remove - "t" #'org-roam-tag-add - "T" #'org-roam-tag-remove - "r" #'org-roam-ref-add - "R" #'org-roam-ref-remove)) - - (when (modulep! :editor evil +everywhere) - (add-hook! 'org-roam-mode-hook - (defun +org-roam-detach-magit-section-mode-map-h () - "Detach `magit-section-mode-map' from `org-roam-mode-map'. -Inheriting its keymaps introduces a lot of conflicts in -`org-roam-mode' based buffers, where Evil and leader keybindings -will become completely overridden. This is because `magit-section' -uses 'keymap text-property to attach section-unique keymaps, which -has a higher level of precedence than `emulation-mode-map-alists'. - -Note: We do this each time through the hook, because otherwise -sections seems to ignore the detachment." - (set-keymap-parent org-roam-mode-map nil))) - - (map! :map org-roam-mode-map - :nv "]" #'magit-section-forward-sibling - :nv "[" #'magit-section-backward-sibling - :nv "gj" #'magit-section-forward-sibling - :nv "gk" #'magit-section-backward-sibling - :nv "gr" #'revert-buffer - :nv "gR" #'revert-buffer - :nv "z1" #'magit-section-show-level-1 - :nv "z2" #'magit-section-show-level-2 - :nv "z3" #'magit-section-show-level-3 - :nv "z4" #'magit-section-show-level-4 - :nv "za" #'magit-section-toggle - :nv "zc" #'magit-section-hide - :nv "zC" #'magit-section-hide-children - :nv "zo" #'magit-section-show - :nv "zO" #'magit-section-show-children - :nv "zm" #'magit-section-show-level-2-all - :nv "zr" #'magit-section-show-level-4-all - :nv "C-j" #'magit-section-forward - :nv "C-k" #'magit-section-backward - :g "M-p" #'magit-section-backward-sibling - :g "M-n" #'magit-section-forward-sibling - :g [tab] #'magit-section-toggle - :g [C-tab] #'magit-section-cycle - :g [backtab] #'magit-section-cycle-global))) - - -;; Since the org module lazy loads org-protocol (waits until an org URL is -;; detected), we can safely chain `org-roam-protocol' to it. -(use-package! org-roam-protocol - :after org-protocol) diff --git a/modules/lang/org/doctor.el b/modules/lang/org/doctor.el index b32bfd294..a4db71722 100644 --- a/modules/lang/org/doctor.el +++ b/modules/lang/org/doctor.el @@ -5,11 +5,8 @@ (unless (executable-find "gnuplot") (warn! "Couldn't find gnuplot. org-plot/gnuplot will not work"))) -(when (modulep! +roam) - (warn! "You are using org-roam-v1. This version is unmaintained Doom support for it will eventually be removed.\ -Migrate your notes to org-roam-v2 and switch to the +roam2 flag (see the module readme).") - (unless (executable-find "sqlite3") - (warn! "Couldn't find the sqlite3 executable. org-roam will not work."))) +(when (modulep! +roam2) + (warn! "+roam2 is deprecated; use +roam instead (they install the same version)")) (when (or (modulep! +roam) (modulep! +roam2)) (unless (executable-find "dot") diff --git a/modules/lang/org/packages.el b/modules/lang/org/packages.el index 6312470b4..ef48dc8a8 100644 --- a/modules/lang/org/packages.el +++ b/modules/lang/org/packages.el @@ -97,20 +97,9 @@ :recipe (:host github :repo "hakimel/reveal.js" :files ("css" "dist" "js" "plugin")) :pin "4cf184924d59e3d2b6552190c740ea5c7ab07981")) -(cond - ((modulep! +roam) - (package! org-roam - :recipe (:host github :repo "org-roam/org-roam-v1") - :pin "946a879a4a18756a0508afba1e0b0fe070c6a8b4")) - ((modulep! +roam2) - (package! org-roam - ;; FIXME A :recipe isn't strictly necessary, but without it, our package - ;; bumper fails to distinguish between org-roam v1 and v2. - :recipe (:host github :repo "org-roam/org-roam") - :pin "89dfaef38b6caa3027f20f96a551dc8f194ac533") - (when (< emacs-major-version 29) - ;; HACK: Needed until org-roam/org-roam#2485 is resolved. - (package! emacsql :pin "491105a01f58bf0b346cbc0254766c6800b229a2")))) +(when (or (modulep! +roam) + (modulep! +roam2)) + (package! org-roam :pin "89dfaef38b6caa3027f20f96a551dc8f194ac533")) ;;; Babel (package! ob-async :pin "9aac486073f5c356ada20e716571be33a350a982") diff --git a/modules/tools/biblio/README.org b/modules/tools/biblio/README.org index 3f70459d2..9c339db7a 100644 --- a/modules/tools/biblio/README.org +++ b/modules/tools/biblio/README.org @@ -23,7 +23,7 @@ selected so it should be possible to use without modifications. - [[doom-package:parsebib]] if [[doom-module::completion ivy]] or [[doom-module::completion helm]] or [[doom-module::completion vertico]] - [[doom-package:citar]] if [[doom-module::completion vertico]] - [[doom-package:citar-embark]] if [[doom-module::completion vertico]] -- [[doom-package:citar-org-roam]] if [[doom-module::completion vertico]] and [[doom-module::lang org +roam2]] +- [[doom-package:citar-org-roam]] if [[doom-module::completion vertico]] and [[doom-module::lang org +roam]] - [[doom-package:helm-bibtex]] if [[doom-module::completion helm]] - [[doom-package:ivy-bibtex]] if [[doom-module::completion ivy]] diff --git a/modules/tools/biblio/packages.el b/modules/tools/biblio/packages.el index 8f57a3ddb..612d20ac6 100644 --- a/modules/tools/biblio/packages.el +++ b/modules/tools/biblio/packages.el @@ -10,7 +10,8 @@ (when (modulep! :completion vertico) (package! citar :pin "75a85d8d8612ec2097248524eecff3d096fc5dd5") (package! citar-embark :pin "75a85d8d8612ec2097248524eecff3d096fc5dd5") - (when (modulep! :lang org +roam2) + (when (or (modulep! :lang org +roam) + (modulep! :lang org +roam2)) (package! citar-org-roam :pin "9750cfbbf330ab3d5b15066b65bd0a0fe7c296fb"))) (package! parsebib :pin "7bfde4e4679413424a9a9af099203d5c23e32cd2")