emacs: update wiki configuration

We made it more complete except for the capture templates.
This commit is contained in:
Gabriel Arazas 2024-08-27 18:04:19 +08:00
parent d192e39178
commit ec952a017a
3 changed files with 75 additions and 14 deletions

View File

@ -9,14 +9,8 @@
(setq doom-theme 'doom-material-dark)
(setq org-directory "~/library/writings/wiki"
org-id-link-to-org-use-id t
+file-templates-dir (expand-file-name "templates" doom-private-dir)
+wiki-directory "~/library/writings/wiki"
org-export-coding-system 'utf-8
image-use-external-converter t
org-startup-with-inline-images t
(setq +file-templates-dir (expand-file-name "templates" doom-user-dir)
+wiki-directory "~/Documents/Writings/wiki"
org-roam-node-display-template
(format "${doom-hierarchy:*} %s %s %s"
(propertize "${doom-type:12}" 'face 'font-lock-keyword-face)

View File

@ -125,7 +125,8 @@
;; My custom modules should be placed here.
:tools
(wiki +anki
(wiki +sensible-config
+anki
+biblio
+graph
+krita))

View File

@ -7,7 +7,73 @@
(require 'f)
;; Code
(defvar +wiki-directory "~/wiki")
(defvar +wiki-directory "~/Documents/Writings/wiki")
(defvar +wiki-notebook-name "notebook")
(defvar +wiki-notebook-directory (f-join +wiki-directory +wiki-notebook-name))
(defvar +wiki-assets-directory-name "assets")
(defun +wiki-is-in-wiki-directory (&optional filename)
"Return t if the file buffer is in the wiki directory."
(unless filename (setq filename (buffer-file-name)))
(if (and (not (string= (f-base filename)
+wiki-asset-directory-name))
(f-descendant-of-p filename
(expand-file-name +wiki-directory)))
t
nil))
(defun +wiki-get-assets-folder (&optional filename)
"Get the assets folder of the current Org mode document."
(unless filename (setq filename (buffer-file-name)))
(if (+wiki-is-in-wiki-directory filename)
(f-join +wiki-asset-directory-name (f-base filename))
nil))
(defun +wiki-concat-assets-folder (&rest args)
"Concatenate PATH to the assets folder."
(apply #'f-join (+wiki-get-assets-folder (buffer-file-name)) args))
(defun +wiki-create-assets-folder (&optional filename)
"A quick convenient function to create the appropriate folder in the assets
folder with its buffer filename."
(interactive)
(unless filename (setq filename (buffer-file-name)))
(if (+wiki-is-in-wiki-directory)
(let* ((target (f-base filename))
(target-dir (f-join +wiki-asset-directory-name target)))
(apply #'f-mkdir (f-split target-dir))
(message "Directory '%s' has been created." target-dir))
(message "Not in the wiki directory.")))
(when (modulep! +sensible-config)
(setq org-directory +wiki-directory
;; Setting up org-roam.
org-roam-v2-ack 't
org-roam-directory +wiki-directory
org-roam-dailies-directory (f-join org-roam-directory "daily")
org-roam-db-location (f-join org-roam-directory "org-roam.db")
org-agenda-files '(,(f-join org-roam-directory "inbox"))
;; Setting up the bibliography-related stuff for this notebook.
citar-bibliography `(,(f-join +wiki-directory "references.bib"))
citar-notes-paths `(,+wiki-directory)
citar-library-paths '("~/library/references" "~/Zotero")
citar-org-roam-capture-template-key "L"
;; Set up other org-mode settings that would be beneficial to add to our
;; personal wiki.
org-export-coding-system 'utf-8
org-id-link-to-org-use-id t
org-startup-with-inline-images t
image-use-external-converter t)
;; Add extra org-modules for our default Org-mode workflow.
(add-to-list 'org-modules 'org-habit)
(add-to-list 'org-modules 'org-checklist)
;; Automate updating timestamps on save.
(add-hook! 'before-save-hook 'time-stamp))
;; New nodes should be considered draft and has to be explicitly removed to be
;; marked as completely. I don't have a good system for revisiting nodes, only
@ -23,12 +89,12 @@
(org-roam-node-random))
(when (modulep! +anki)
(defvar +anki-cards-directory-name "cards")
(defvar +anki-cards-directory (f-join +wiki-directory +anki-cards-directory-name))
(defvar +wiki-anki-cards-directory-name "cards")
(defvar +wiki-anki-cards-directory (f-join +wiki-directory +wiki-anki-cards-directory-name))
(defun +anki-editor-push-all-notes-to-anki ()
(interactive)
(anki-editor-push-notes nil nil (directory-files-recursively +anki-cards-directory "\\.*org" nil)))
(anki-editor-push-notes nil nil (directory-files-recursively +wiki-anki-cards-directory "\\.*org" nil)))
(defun +anki-editor-reset-note ()
"Reset the Anki note in point by deleting the note ID and the deck."
@ -61,7 +127,7 @@
:config
(setq anki-editor-create-decks 't
+anki-cards-directory (f-join +wiki-directory +anki-cards-directory-name))))
+wiki-anki-cards-directory (f-join +wiki-directory +wiki-anki-cards-directory-name))))
(when (modulep! +graph)
(use-package! websocket