Skip to content

Commit

Permalink
feat(notes): migrate from org-roam to denote
Browse files Browse the repository at this point in the history
  • Loading branch information
abougouffa committed Oct 10, 2023
1 parent 6a845c7 commit ef9fbb6
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 88 deletions.
7 changes: 2 additions & 5 deletions local/straight/versions/default.el
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
("cfrs" . "f3a21f237b2a54e6b9f8a420a9da42b4f0a63121")
("chezmoi.el" . "1389782f8c0780c7e66f8e77b10345ba1f4eabae")
("citar" . "2c0547db57f2fb30ff071d126b256287a4e9452c")
("citar-org-roam" . "761eed66782fdbb6d65749098caa42ba43e8441d")
("citeproc-el" . "290320fc579f886255f00d7268600df7fa5cc7e8")
("clang-format" . "bce0bb4ca17ecb6e6927074920945cef2a78f5b6")
("closql" . "909752e2aa946bd91b27a1813982e2b20ae27dde")
Expand All @@ -33,7 +32,7 @@
("consult" . "e5406f282f76076d10440037ecd3460fb280706c")
("consult-eglot" . "db9d41c9812a5a8a7b9a22fa7f3c314e37584d41")
("consult-lsp" . "f8db3252c0daa41225ba4ed1c0d178b281cd3e90")
("consult-org-roam" . "2ca42a1c1641a29f1447d35be01bd1fda368a9e2")
("consult-notes" . "006b20977cc27aec4b5aca14c13824f5df0ab8cc")
("consult-project-extra" . "9fdf45fa40471900b0b158d73c4b1521a13d47ef")
("corfu" . "130098094c446d6f3c019b5d1804f7805317b177")
("corfu-terminal" . "501548c3d51f926c687e8cd838c5865ec45d03cc")
Expand All @@ -45,6 +44,7 @@
("dap-mode" . "a31f2496605d076d50d49393116f77fbb29f2631")
("dash.el" . "6db80c711ce947f6c6fa11e5c2257fff2c79d139")
("datetime" . "dc905e671a1de19da9c601de611a8913c58d6df1")
("denote" . "82cee0ce0dea63cc479b2a0d936b741c396a0fda")
("diff-hl" . "b5651f1c57b42e0f38e01a8fc8c7df9bc76d5d38")
("dirvish" . "119f9f59a618bb7b476c93e9ab1d7542c5c1df41")
("disaster" . "16bba9afb92aacf06c088c29ba47813b65a80d87")
Expand Down Expand Up @@ -84,7 +84,6 @@
("emacs-test-simple" . "8b191842318bb05da74052025192d32ebebb033a")
("emacs-undo-fu" . "0e74116fd5c7797811a91ba4eadef50d67523eb6")
("emacs-undo-fu-session" . "a6c4f73bc22401fd36e0f2fd4fe058bb28566d84")
("emacs-web-server" . "347c30494d3bcfc79de35e54538f92f4e4a46ecd")
("emacs-websocket" . "40c208eaab99999d7c1e4bea883648da24c03be3")
("emacs-which-key" . "4d20bc852545a2e602f59084a630f888542052b1")
("emacs-xkcd" . "80011da2e7def8f65233d4e0d790ca60d287081d")
Expand Down Expand Up @@ -180,8 +179,6 @@
("org-modern" . "afa7d44282d62dbba84afec2a1a6c2a3ee41e7b9")
("org-msg" . "055de4abf611c5d5e12c770fe149c1861b402817")
("org-present" . "4ec04e1b77dea76d7c30066ccf3200d2e0b7bee9")
("org-roam" . "5c06471c3a11348342719fd9011486455adeb701")
("org-roam-ui" . "5ac74960231db0bf7783c2ba7a19a60f582e91ab")
("ox-hugo" . "cb1b6cfd7b080e889352150416c1725f11ba937a")
("ox-pandoc" . "0f758517f512e375825679541b5d905be40342eb")
("page-break-lines" . "5e9ed86bb56fd076b12ae7adaf40eeaa09aed4c5")
Expand Down
34 changes: 0 additions & 34 deletions modules/me-biblio.el
Original file line number Diff line number Diff line change
Expand Up @@ -47,40 +47,6 @@
(remove-hook 'server-after-make-frame-hook
#'+citar--set-symbols-once-h)))))))

;; If `org-roam' is not active, there is no need to install `citar-org-roam'
(unless (and (memq 'me-notes minemacs-modules)
(not (memq 'org-roam minemacs-disabled-packages)))
(push 'citar-org-roam minemacs-disabled-packages))

(use-package citar-org-roam
:straight t
:after citar org-roam
:demand t
:commands +org-roam-node-from-cite
:config
;; Modified form: jethrokuan.github.io/org-roam-guide/
(defun +org-roam-node-from-cite (entry-key)
"Create an Org-Roam node from a bibliography reference."
(interactive (list (citar-select-ref)))
(let ((title (citar-format--entry
"${author editor} (${date urldate}) :: ${title}"
(citar-get-entry entry-key))))
(org-roam-capture- :templates
`(("r" "reference" plain
"%?"
:if-new (file+head "references/${citekey}.org"
,(concat
":properties:\n"
":roam_refs: [cite:@${citekey}]\n"
":end:\n"
"#+title: ${title}\n"))
:immediate-finish t
:unnarrowed t))
:info (list :citekey entry-key)
:node (org-roam-node-create :title title)
:props '(:finalize find-file))))
(citar-org-roam-mode 1))

(use-package citar-embark
:straight t
:after citar embark
Expand Down
71 changes: 22 additions & 49 deletions modules/me-notes.el
Original file line number Diff line number Diff line change
Expand Up @@ -8,64 +8,37 @@

;;; Code:

(use-package org-roam
;; Useful resources:
;; https://takeonrules.com/2022/10/01/exploring-the-denote-emacs-package/
;; https://takeonrules.com/2022/10/02/migration-plan-for-org-roam-notes-to-denote/
;; https://github.com/bitspook/notes-migrator

(use-package denote
:straight t
:init
(+map! :infix "n"
"f" #'org-roam-node-find
"r" #'org-roam-ref-find
"i" #'org-roam-node-insert
"R" #'org-roam-node-random
"B" #'org-roam-buffer-display-dedicated)
"o" #'denote-open-or-create
"j" #'denote-journal-extras-new-or-existing-entry
"J" #'denote-journal-extras-new-entry
"l" #'denote-add-links
"L" #'denote-add-missing-links
"b" #'denote-show-backlinks-buffer)
:custom
(org-roam-node-display-template (concat "${title:*} " (propertize "${tags:20}" 'face 'org-tag)))
:config
(org-roam-db-autosync-mode 1))

(use-package org-roam-protocol
:after org-roam
:demand t
:custom
(org-roam-protocol-store-links t)
;; Add this as bookmarklet in your browser
;; javascript:location.href='org-protocol://roam-ref?template=r&ref=%27+encodeURIComponent(location.href)+%27&title=%27+encodeURIComponent(document.title)+%27&body=%27+encodeURIComponent(window.getSelection())
(org-roam-capture-ref-templates
'(("r" "ref" plain "%?"
:if-new (file+head "web/%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n#+created: %U\n\n${body}\n")
:unnarrowed t)))
:config
;; Save a local snapshot of the captured web page using "single-file-cli"
(advice-add
'org-roam-protocol-open-ref :after
(defun +org-roam-protocol--single-file-snapshot-a (info)
(+single-file
(plist-get info :ref)
(+file-name-incremental
(expand-file-name
(concat "web/snapshots/" (+clean-file-name (plist-get info :title)) ".html")
org-roam-directory))))))
(denote-prompts '(title keywords)) ; These are the minimum viable prompts for notes
(denote-file-type 'org) ; I love org-mode format; reading ahead I'm setting this
(denote-date-prompt-use-org-read-date t)) ; And `org-read-date' is an amazing bit of tech

(use-package org-roam-ui
(use-package consult-notes
:straight t
:commands consult-notes consult-notes-search-in-all-notes
:init
(+map! "nu" #'org-roam-ui-open))

(use-package consult-org-roam
:straight t
:init
(+map! :infix "n"
"s" #'consult-org-roam-search
"l" #'consult-org-roam-forward-links
"b" #'consult-org-roam-backlinks
"F" #'consult-org-roam-file-find)
(fmakunbound 'consult-notes-org-roam-mode)
:custom
(consult-org-roam-grep-func #'consult-ripgrep)
(consult-org-roam-buffer-narrow-key ?r) ; custom narrow key for `consult-buffer'
(consult-org-roam-buffer-after-buffers t)
(consult-notes-file-dir-sources `(("Notes" "n" ,denote-directory))) ; Set notes dir(s), see below
(consult-notes-denote-files-function #'denote-directory-text-only-files) ; Search only for text files in denote dir
:config
(consult-org-roam-mode 1)
;; Eventually suppress previewing for certain functions
(consult-customize consult-org-roam-forward-links :preview-key (kbd "M-.")))
(consult-notes-denote-mode 1)
(consult-notes-org-headings-mode 1))


(provide 'me-notes)
Expand Down
102 changes: 102 additions & 0 deletions modules/obsolete/me-org-roam.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
;;; me-org-roam.el --- Org roam -*- lexical-binding: t; -*-

;; Copyright (C) 2022-2023 Abdelhak Bougouffa

;; Author: Abdelhak Bougouffa (concat "abougouffa" "@" "fedora" "project" "." "org")

;;; Commentary:

;;; Code:

(use-package org-roam
:straight t
:init
(+map! :infix "n"
"f" #'org-roam-node-find
"r" #'org-roam-ref-find
"i" #'org-roam-node-insert
"R" #'org-roam-node-random
"B" #'org-roam-buffer-display-dedicated)
:custom
(org-roam-node-display-template (concat "${title:*} " (propertize "${tags:20}" 'face 'org-tag)))
:config
(org-roam-db-autosync-mode 1))

(use-package org-roam-protocol
:after org-roam
:demand t
:custom
(org-roam-protocol-store-links t)
;; Add this as bookmarklet in your browser
;; javascript:location.href='org-protocol://roam-ref?template=r&ref=%27+encodeURIComponent(location.href)+%27&title=%27+encodeURIComponent(document.title)+%27&body=%27+encodeURIComponent(window.getSelection())
(org-roam-capture-ref-templates
'(("r" "ref" plain "%?"
:if-new (file+head "web/%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n#+created: %U\n\n${body}\n")
:unnarrowed t)))
:config
;; Save a local snapshot of the captured web page using "single-file-cli"
(advice-add
'org-roam-protocol-open-ref :after
(defun +org-roam-protocol--single-file-snapshot-a (info)
(+single-file
(plist-get info :ref)
(+file-name-incremental
(expand-file-name
(concat "web/snapshots/" (+clean-file-name (plist-get info :title)) ".html")
org-roam-directory))))))

(use-package org-roam-ui
:straight t
:init
(+map! "nu" #'org-roam-ui-open))

(use-package consult-org-roam
:straight t
:init
(+map! :infix "n"
"s" #'consult-org-roam-search
"l" #'consult-org-roam-forward-links
"b" #'consult-org-roam-backlinks
"F" #'consult-org-roam-file-find)
:custom
(consult-org-roam-grep-func #'consult-ripgrep)
(consult-org-roam-buffer-narrow-key ?r) ; custom narrow key for `consult-buffer'
(consult-org-roam-buffer-after-buffers t)
:config
(consult-org-roam-mode 1)
;; Eventually suppress previewing for certain functions
(consult-customize consult-org-roam-forward-links :preview-key (kbd "M-.")))

(use-package citar-org-roam
:straight t
:after citar org-roam
:demand t
:commands +org-roam-node-from-cite
:config
;; Modified form: jethrokuan.github.io/org-roam-guide/
(defun +org-roam-node-from-cite (entry-key)
"Create an Org-Roam node from a bibliography reference."
(interactive (list (citar-select-ref)))
(let ((title (citar-format--entry
"${author editor} (${date urldate}) :: ${title}"
(citar-get-entry entry-key))))
(org-roam-capture- :templates
`(("r" "reference" plain
"%?"
:if-new (file+head "references/${citekey}.org"
,(concat
":properties:\n"
":roam_refs: [cite:@${citekey}]\n"
":end:\n"
"#+title: ${title}\n"))
:immediate-finish t
:unnarrowed t))
:info (list :citekey entry-key)
:node (org-roam-node-create :title title)
:props '(:finalize find-file))))
(citar-org-roam-mode 1))


(provide 'obsolete/me-org-roam)

;;; me-org-roam.el ends here

0 comments on commit ef9fbb6

Please sign in to comment.