diff --git a/emacs/config.el b/emacs/config.el index 5dc59cb..7b6c8c2 100755 --- a/emacs/config.el +++ b/emacs/config.el @@ -16,7 +16,7 @@ (setq org-directory "~/writings/orgnotes" org-roam-directory "~/writings/wiki" - org-roam-dailies-directory (concat org-roam-directory "/daily")) + org-roam-dailies-directory (f-join org-roam-directory "daily")) ;; This determines the style of line numbers in effect. If set to `nil', line ;; numbers are disabled. For relative line numbers, set this to `relative'. @@ -55,54 +55,51 @@ ; Set the capture org-capture-templates `( ("i" "inbox" entry - (file ,(concat org-directory "/inbox.org")) + (file ,(f-join org-directory "inbox.org")) ,(concat "* TODO %?\n" "entered on %<%F %T %:z>")) ("p" "project" entry - (file ,(concat org-directory "/projects.org")) + (file ,(f-join org-directory "projects.org")) ,(concat "* PROJ %?\n" "- [ ] %?")) ("c" "org-protocol-capture" entry - (file ,(concat org-directory "/inbox.org")) + (file ,(f-join org-directory "inbox.org")) "* TODO [[%:link][%:description]]\n%x" :immediate-finish t)) ; Configure org-roam. - org-roam-capture-templates '( - ("p" "permanent" plain - #'org-roam-capture--get-point "%?" - :file-name "%<%Y-%m-%d-%H-%M-%S>" - :head "#+title: ${title} + org-roam-capture-templates `( + ("p" "permanent" plain "%?" + :if-new + (file+head "%<%Y-%m-%d-%H-%M-%S>.org" + "#+title: ${title} #+date: \"%<%Y-%m-%d %T %:z>\" #+date_modified: \"%<%Y-%m-%d %T %:z>\" -#+language: en" +#+language: en") :unnarrowed t) - ("c" "cards" plain - #'org-roam-capture--get-point "%?" - :head "#+title: Anki: ${title} + ("c" "cards" plain "%?" + :if-new + (file+head ,(f-join "cards" "${slug}.org") "#+title: Anki: ${title} #+date: \"%<%Y-%m-%d %T %:z>\" #+date_modified: \"%<%Y-%m-%d %T %:z>\" #+language: en -#+property: anki_deck ${title}" - :file-name "cards/${slug}" +#+property: anki_deck ${title}") :unnarrowed t) - ("l" "literature" plain - #'org-roam-capture--get-point "%?" - :head "#+title: ${title} + ("l" "literature" plain "%?" + :if-new + (file+head ,(f-join "literature" "%<%Y-%m-%d-%H-%M-%S>")"#+title: ${title} #+date: \"%<%Y-%m-%d %T %:z>\" #+date_modified: \"%<%Y-%m-%d %T %:z>\" -#+language: en" - :file-name "literature/%<%Y-%m-%d-%H-%M-%S>" - :unnarrowed t) +#+language: en") + :unnarrowed t)) - ("d" "dailies" entry - #'org-roam-capture--get-point "%?" - :file-name "daily/%<%Y-%m-%d>" - :head "#+title %<%Y-%m-%d>")) + org-roam-dailies-capture-templates `(("d" "default" entry "* %?" + :if-new + (file+head ,(expand-file-name "%<%Y-%m-%d>.org" org-roam-dailies-directory) "#+title: %<%Y-%m-%d>\n"))) ;; Get the tags from vanilla and Roam-specific properties. org-roam-tag-sources '(prop vanilla)) diff --git a/emacs/init.el b/emacs/init.el index 3e88c93..52f1d1d 100755 --- a/emacs/init.el +++ b/emacs/init.el @@ -14,12 +14,7 @@ ;; Alternatively, press 'gd' (or 'C-c g d') on a module to browse its ;; directory (for easy access to its source code). -(doom! - ;; All custom modules will be put here. - :tools - (wiki +anki) - - :input +(doom! :input ;;chinese japanese @@ -187,4 +182,8 @@ :config ;;literate - (default +bindings +smartparens)) + (default +bindings +smartparens) + + :tools + (wiki +anki + +dendron)) diff --git a/emacs/modules/tools/wiki/README.org b/emacs/modules/tools/wiki/README.org new file mode 100644 index 0000000..65e470e --- /dev/null +++ b/emacs/modules/tools/wiki/README.org @@ -0,0 +1,37 @@ +#+title: tools/wiki +#+date: "2021-05-05 00:27:26 +08:00" +#+date_modified: "2021-05-05 01:52:39 +08:00" +#+language: en + + + +* Description + +This module set up my personal wiki configuration with Emacs primarily with org-roam. +The setup uses org-roam v2. + + +** Module flags + +- ~+anki~ enables Anki cards editing with [[https://github.com/louietan/anki-editor/][anki-editor]]. +- ~+markdown~ adds Markdown support in org-roam. +- ~+dendron~ adds [[https://dendron.so/][Dendron]]-inspired features with [[https://github.com/vicrdguez/dendroam][dendroam]]. + + + +** Plugins + +- [[https://github.com/org-roam/org-roam/][org-roam]] v2 +- [[https://github.com/louietan/anki-editor/][anki-editor]] +- [[https://github.com/vicrdguez/dendroam][dendroam]] +- [[https://github.com/nobiot/md-roam][md-roam]] + + + + +* Prerequisites + +This module has a handful of requirements to work properly. + +- SQLite v3 binary is installed in order for org-roam to work. +- The ~+anki~ feature requires Anki and the setup described from the [[https://github.com/louietan/anki-editor][project README]]. diff --git a/emacs/modules/tools/wiki/config.el b/emacs/modules/tools/wiki/config.el index 9ae6cb3..48846b7 100644 --- a/emacs/modules/tools/wiki/config.el +++ b/emacs/modules/tools/wiki/config.el @@ -2,6 +2,27 @@ ;; My custom configuration for setting up my personal wiki. ;; Also a good opportunity for training my Elisp-fu. +(require 'f) + +(defvar +anki-cards-directory nil + "The location of the Anki cards") + +(defvar +structured-notes-directory nil + "The path of the structured notes used for the Dendron-like features. +The structured notes are considered separate to the org-roam notes. +Though, both notes are integrated in the mindset that org-roam is an extension of +the structured notes needed to create atmoic notes.") + +(defun +anki-editor-reset-note () + "Reset the Anki note in point by deleting the note ID and the deck." + (interactive) + (org-entry-delete (point) anki-editor-prop-note-id) + (org-entry-delete (point) anki-editor-prop-deck)) + +(defun +anki-editor-reset-all-notes () + "Reset the Anki notes in the current buffer by deleting the note ID and the deck." + (interactive) + (anki-editor-map-note-entries #'+anki-editor-reset-note)) (use-package! org-roam :hook (org-load . org-roam-mode) @@ -11,27 +32,38 @@ org-roam-capture org-roam-node-find) :preface (defvar org-roam-directory nil) - :config - (setq org-roam-completion-everywhere t) - (org-roam-setup) + :init (map! :leader + :after org + :map org-roam-dailies-map (:prefix ("n r" . "org-roam") - :desc "Go to a random node in your Roam database" "R" #'org-roam-node-random - :desc "Find node" "f" #'org-roam-node-find - :desc "Org Roam capture" "c" #'org-roam-capture - :desc "Org Roam setup" "s" #'org-roam-setup - :desc "Org Roam teardown" "S" #'org-roam-teardown - :desc "Open backlinks buffer" "b" #'org-roam-buffer-toggle + :desc "Go to a random node" "R" #'org-roam-node-random + :desc "Find node" "f" #'org-roam-node-find + :desc "Org Roam capture" "c" #'org-roam-capture + :desc "Org Roam setup" "s" #'org-roam-setup + :desc "Org Roam teardown" "S" #'org-roam-teardown + :desc "Open backlinks buffer" "b" #'org-roam-buffer-toggle - (:prefix ("d" . "dailies") - :desc "Dailies for today" "t" #'org-roam-dailies-find-today - :desc "Dailies for a specific date" "d" #'org-roam-dailies-find-date - :desc "Dailies for yesterday" "y" #'org-roam-dailies-find-yesterday)))) + (:prefix ("d" . "dailies") + :desc "Daily note for today" "t" #'org-roam-dailies-find-today + :desc "Daily note for a specific date" "d" #'org-roam-dailies-find-date + :desc "Daily note for yesterday" "y" #'org-roam-dailies-find-yesterday + :desc "Previous daily note" "Y" #'org-roam-dailies-find-previous-note))) + + :config + (setq org-roam-completion-everywhere t + org-roam-directory (file-name-as-directory + (file-truename + (expand-file-name (or org-roam-directory "roam") + org-directory))) + org-roam-dailies-directory (f-join org-roam-directory "daily")) + (org-roam-setup)) (use-package! anki-editor :hook (org-mode . anki-editor-mode) :config - (setq anki-editor-create-decks 't) + (setq anki-editor-create-decks 't + +anki-cards-directory (f-join org-roam-directory "cards")) (map! :localleader :map org-mode-map (:prefix ("C" . "Anki cards") @@ -39,4 +71,11 @@ "r" #'anki-editor-retry-failure-notes "i" #'anki-editor-insert-note "I" #'anki-editor-cloze-region - "e" #'anki-editor-export-subtree-to-html))) + "e" #'anki-editor-export-subtree-to-html + "d" #'+anki-editor-reset-note + "D" #'+anki-editor-reset-all-notes))) + +(use-package! dendroam + :after org-roam + :config + (setq +structured-notes-directory (f-join org-roam-directory "structured"))) diff --git a/emacs/modules/tools/wiki/packages.el b/emacs/modules/tools/wiki/packages.el index 495b579..cd7bf7b 100644 --- a/emacs/modules/tools/wiki/packages.el +++ b/emacs/modules/tools/wiki/packages.el @@ -1,5 +1,5 @@ ;; -*- no-byte-compile: t; -*- -;;; tools/wiki +;;; tools/wiki/packages.el ;; The main package for creating a wiki. (package! org-roam @@ -11,10 +11,10 @@ :repo "louietan/anki-editor") :pin "546774a453ef4617b1bcb0d1626e415c67cc88df")) -;;(when (featurep! +markdown) -;; (package! md-roam -;; :recipe (:host github :repo "nobiot/md-roam" :branch "v2"))) -;; -;;(when (featurep! +dendron) -;; (package! dendroam -;; :recipe (:host github :repo "vicrdguez/dendroam"))) +(when (featurep! +markdown) + (package! md-roam + :recipe (:host github :repo "nobiot/md-roam" :branch "v2"))) + +(when (featurep! +dendron) + (package! dendroam + :recipe (:host github :repo "vicrdguez/dendroam")))