Update custom wiki Doom module

This commit is contained in:
Gabriel Arazas 2021-05-27 19:48:08 +08:00
parent 233e6bac4e
commit 071b2f56b9
8 changed files with 80 additions and 23 deletions

View File

@ -14,9 +14,9 @@
org-roam-directory "~/writings/wiki" org-roam-directory "~/writings/wiki"
org-roam-dailies-directory (f-join org-roam-directory "daily")) org-roam-dailies-directory (f-join org-roam-directory "daily"))
(setq global-display-line-numbers-mode t) (setq global-display-line-numbers-mode t
(setq display-line-numbers-type 'relative) display-line-numbers-type 'relative
(setq projectile-project-search-path '("~/projects/software/" "~/writings/")) projectile-project-search-path '("~/projects/software/" "~/writings/"))
(setq (setq
time-stamp-format "%Y-%02m-%02d %02H:%02M:%02S %:z" time-stamp-format "%Y-%02m-%02d %02H:%02M:%02S %:z"
@ -28,9 +28,15 @@
org-journal-dir "~/writings/journal" org-journal-dir "~/writings/journal"
org-journal-file-format "%F" org-journal-file-format "%F"
enable-local-variables "query") enable-local-variables "query"
image-use-external-converter t
org-startup-with-inline-images t)
(add-to-list 'org-modules 'org-habit)
(add-to-list 'org-modules 'org-checklist)
(defvar my/wiki-asset-directory-name "assets") (defvar my/wiki-asset-directory-name "assets")
(defvar my/wiki-exercises-directory "challenges")
(defun my/create-assets-folder () (defun my/create-assets-folder ()
"A quick convenient function to create an assets folder in the wiki folder." "A quick convenient function to create an assets folder in the wiki folder."
@ -51,7 +57,6 @@
(after! org (after! org
(setq (setq
time-stamp-start "date_modified:[ ]+\\\\?[\"<]+" time-stamp-start "date_modified:[ ]+\\\\?[\"<]+"
; Set the capture
org-capture-templates `( org-capture-templates `(
("i" "inbox" entry ("i" "inbox" entry
(file ,(f-join org-directory "inbox.org")) (file ,(f-join org-directory "inbox.org"))
@ -68,7 +73,6 @@
"* TODO [[%:link][%:description]]\n%x" "* TODO [[%:link][%:description]]\n%x"
:immediate-finish t)) :immediate-finish t))
; Configure org-roam.
org-roam-capture-templates `( org-roam-capture-templates `(
("p" "permanent" plain "%?" ("p" "permanent" plain "%?"
:if-new :if-new
@ -81,13 +85,21 @@
("c" "cards" plain "%?" ("c" "cards" plain "%?"
:if-new :if-new
(file+head ,(f-join "cards" "${slug}.org") "#+title: Anki: ${title} (file+head ,(f-join +anki-cards-directory-name "%<%Y>.org") "#+title: Anki: ${title}
#+date: \"%<%Y-%m-%d %T %:z>\" #+date: \"%<%Y-%m-%d %T %:z>\"
#+date_modified: \"%<%Y-%m-%d %T %:z>\" #+date_modified: \"%<%Y-%m-%d %T %:z>\"
#+language: en #+language: en
#+property: anki_deck ${title}") #+property: anki_deck ${title}")
:unnarrowed t) :unnarrowed t)
("C" "challenges" plain "%?"
:if-new
(file+head ,(f-join +wiki-directory my/wiki-exercises-directory "${slug}.org") "#+title: ${title}
#+date: \"%<%Y-%m-%d %T %:z>\"
#+date_modified: \"%<%Y-%m-%d %T %:z>\"
#+language: en")
:unnarrowed t)
("l" "literature" plain "%?" ("l" "literature" plain "%?"
:if-new :if-new
(file+head ,(f-join "literature" "%<%Y-%m-%d-%H-%M-%S>.org") "#+title: ${title} (file+head ,(f-join "literature" "%<%Y-%m-%d-%H-%M-%S>.org") "#+title: ${title}
@ -98,22 +110,22 @@
("d" "dailies" entry "* %?" ("d" "dailies" entry "* %?"
:if-new :if-new
(file+head ,(expand-file-name "%<%Y-%m-%d>.org" org-roam-dailies-directory) "#+title: %<%Y-%m-%d>\n"))) (file+head ,(expand-file-name "%<%Y-%m-%d>.org" org-roam-dailies-directory) "#+title: %<%Y-%m-%d>\n"))
("s" "structured" plain "%?"
:if-new
(file+head ,(f-join +structured-notes-directory-name "${slug}.org") "#+title: ${title}")
:unnarrowed t))
org-roam-dailies-capture-templates `(("d" "default" entry "* %?" org-roam-dailies-capture-templates `(("d" "default" entry "* %?"
:if-new :if-new
(file+head ,(expand-file-name "%<%Y-%m-%d>.org" org-roam-dailies-directory) "#+title: %<%Y-%m-%d>\n"))) (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))
(add-to-list 'org-modules 'org-checklist))
;; Custom keybindings ;; Custom keybindings
(map! (map!
(:when (featurep! :tools wiki) (:when (featurep! :tools wiki)
:leader :leader
:prefix "nr" :prefix "nr" :desc "Create the asset folder" "m" #'my/create-assets-folder)
:desc "Create the asset folder" "m" #'my/create-assets-folder)
(:when (featurep! :editor format) (:when (featurep! :editor format)
:n "g=" #'+format/buffer)) :n "g=" #'+format/buffer))
@ -127,7 +139,9 @@
(add-hook! 'before-save-hook 'time-stamp) (add-hook! 'before-save-hook 'time-stamp)
;; Add a capture hook. ;; Add a capture hook.
(add-hook! 'org-capture-prepare-finalize-hook 'org-id-get-create)
(add-hook! 'org-roam-capture-new-node-hook 'org-id-get-create) (add-hook! 'org-roam-capture-new-node-hook 'org-id-get-create)
;; Load a custom configuration for muh wiki.
(load-file (f-join +wiki-directory "config.el"))
;;; config.el ends here ;;; config.el ends here

View File

@ -186,4 +186,5 @@
:tools :tools
(wiki +anki (wiki +anki
+dendron)) +dendron
+biblio))

3
emacs/modules/tools/wiki/README.org Normal file → Executable file
View File

@ -1,6 +1,6 @@
#+title: tools/wiki #+title: tools/wiki
#+date: "2021-05-05 00:27:26 +08:00" #+date: "2021-05-05 00:27:26 +08:00"
#+date_modified: "2021-05-08 12:28:46 +08:00" #+date_modified: "2021-05-21 11:12:10 +08:00"
#+language: en #+language: en
@ -20,7 +20,6 @@ The setup uses org-roam v2.
- ~+markdown~ adds Markdown support in org-roam. - ~+markdown~ adds Markdown support in org-roam.
** Plugins ** Plugins
- [[https://github.com/org-roam/org-roam/][org-roam]] v2 - [[https://github.com/org-roam/org-roam/][org-roam]] v2

29
emacs/modules/tools/wiki/config.el Normal file → Executable file
View File

@ -9,6 +9,14 @@
;;; Code: ;;; Code:
(defvar +wiki-directory "~/wiki") (defvar +wiki-directory "~/wiki")
(defun +org-roam-split-to-random-node ()
"Open a split window sensibly for a random note."
; TODO: Create a window, open a random note, and that's it.
(interactive)
(split-window-sensibly)
(other-window 1)
(org-roam-node-random))
(use-package! org-roam (use-package! org-roam
:hook (org-load . org-roam-mode) :hook (org-load . org-roam-mode)
:commands :commands
@ -24,7 +32,8 @@
:after org :after org
:map org-roam-dailies-map :map org-roam-dailies-map
(:prefix ("n r" . "org-roam") (:prefix ("n r" . "org-roam")
:desc "Go to a random node" "R" #'org-roam-node-random :desc "Go to a random node" "r" #'org-roam-node-random
:desc "Go to a random node and split" "R" #'+org-roam-split-to-random-node
:desc "Find node" "f" #'org-roam-node-find :desc "Find node" "f" #'org-roam-node-find
:desc "Org Roam capture" "c" #'org-roam-capture :desc "Org Roam capture" "c" #'org-roam-capture
:desc "Org Roam setup" "s" #'org-roam-setup :desc "Org Roam setup" "s" #'org-roam-setup
@ -46,6 +55,22 @@
org-roam-dailies-directory (f-join +wiki-directory "daily")) org-roam-dailies-directory (f-join +wiki-directory "daily"))
(org-roam-setup)) (org-roam-setup))
(when (featurep! +biblio)
(defvar +wiki-references-filename "references.bib")
(defvar +wiki-bibliography-note-filename "references.org")
(defvar +wiki-bibliography (f-join +wiki-directory +wiki-references-filename))
(defvar +wiki-bibliography-note (f-join +wiki-directory +wiki-bibliography-note-filename))
(use-package! org-ref
:after org-roam
:config
(setq +wiki-bibliography (f-join +wiki-directory +wiki-references-filename)
org-ref-default-bibliography +wiki-bibliography
org-ref-bibliography-notes +wiki-bibliography-note))
(use-package! org-roam-bibtex
:after org-roam))
(when (featurep! +anki) (when (featurep! +anki)
(defvar +anki-cards-directory-name "cards") (defvar +anki-cards-directory-name "cards")
(defvar +anki-cards-directory (f-join +wiki-directory +anki-cards-directory-name)) (defvar +anki-cards-directory (f-join +wiki-directory +anki-cards-directory-name))
@ -61,6 +86,7 @@
"Reset the Anki notes in the current buffer by deleting the note ID and the deck." "Reset the Anki notes in the current buffer by deleting the note ID and the deck."
(interactive) (interactive)
(anki-editor-map-note-entries #'+anki-editor-reset-note)) (anki-editor-map-note-entries #'+anki-editor-reset-note))
(use-package! anki-editor (use-package! anki-editor
:hook (org-mode . anki-editor-mode) :hook (org-mode . anki-editor-mode)
:preface :preface
@ -84,6 +110,7 @@
(when (featurep! +dendron) (when (featurep! +dendron)
(defvar +structured-notes-directory-name "structured") (defvar +structured-notes-directory-name "structured")
(defvar +structured-notes-directory (f-join +wiki-directory +structured-notes-directory-name)) (defvar +structured-notes-directory (f-join +wiki-directory +structured-notes-directory-name))
(use-package! dendroam (use-package! dendroam
:after org-roam :after org-roam
:preface (defvar +wiki-directory nil) :preface (defvar +wiki-directory nil)

7
emacs/modules/tools/wiki/doctor.el Normal file → Executable file
View File

@ -3,3 +3,10 @@
(unless (executable-find "sqlite3") (unless (executable-find "sqlite3")
warn! "Couldn't find SQLite executable. org-roam will not work.") warn! "Couldn't find SQLite executable. org-roam will not work.")
(when (featurep! +biblio)
(unless (executable-find "anystyle")
warn! "Couldn't find AnyStyle CLI. The PDF scrapper from org-roam-bibtex will not work.")
(unless (featurep! :tools biblio)
warn! "Doom module ':tools biblio' is not enabled. Completion functions will not work."))

4
emacs/modules/tools/wiki/packages.el Normal file → Executable file
View File

@ -7,7 +7,9 @@
(when (featurep! +biblio) (when (featurep! +biblio)
(package! org-ref (package! org-ref
:recipe (:host github :repo "jkitchin/org-ref"))) :recipe (:host github :repo "jkitchin/org-ref"))
(package! org-roam-bibtex
:recipe (:host github :repo "org-roam/org-roam-bibtex" :branch "org-roam-v2")))
(when (featurep! +anki) (when (featurep! +anki)
(package! anki-editor (package! anki-editor

7
emacs/snippets/org-mode/begin Executable file
View File

@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: Org mode basic block
# key: begin
# --
#+begin_$1
$0
#+end_$1

View File

@ -2,6 +2,6 @@
# name: Org-Mode dynamic blocks # name: Org-Mode dynamic blocks
# key: block # key: block
# -- # --
\#+begin: ${1:<PARAMETERS>} #+begin: ${1:<PARAMETERS>}
$2 $2
\#+end: #+end: