Update Emacs config again

This commit is contained in:
Gabriel Arazas 2021-05-07 08:43:56 +08:00
parent de6b66c657
commit 932a81aa81
2 changed files with 70 additions and 73 deletions

View File

@ -2,10 +2,6 @@
;; Place your private configuration here! Remember, you do not need to run 'doom
;; sync' after modifying this file!
;; Some functionality uses this to identify you, e.g. GPG configuration, email
;; clients, file templates and snippets.
(setq user-full-name "Gabriel Arazas"
user-mail-address "foo.dogsquared@gmail.com")
@ -18,32 +14,40 @@
org-roam-directory "~/writings/wiki"
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'.
(setq global-display-line-numbers-mode t)
(setq display-line-numbers-type 'relative)
;; Here are some additional functions/macros that could help you configure Doom:
;;
;; - `load!' for loading external *.el files relative to this one
;; - `use-package' for configuring packages
;; - `after!' for running code after a package has loaded
;; - `add-load-path!' for adding directories to the `load-path', relative to
;; this file. Emacs searches the `load-path' when you load packages with
;; `require' or `use-package'.
;; - `map!' for binding new keys
;;
;; To get information about any of these functions/macros, move the cursor over
;; the highlighted symbol at press 'K' (non-evil users must press 'C-c g k').
;; This will open documentation for it, including demos of how they are used.
;;
;; You can also try 'gd' (or 'C-c g d') to jump to their definition and see how
;; they are implemented.
;; Search the project path with Projectile.
(setq projectile-project-search-path '("~/projects/software/" "~/writings/"))
; Set the TeX engine to LuaTeX.
(setq
time-stamp-format "%Y-%02m-%02d %02H:%02M:%02S %:z"
org-id-link-to-org-use-id t
+file-templates-dir (expand-file-name "templates" doom-private-dir)
+wiki-directory "~/writings/wiki"
org-journal-dir "~/writings/journal"
org-journal-file-format "%F"
enable-local-variables "query")
(defvar my/wiki-asset-directory-name "assets")
(defun align-non-space (BEG END)
"Align non-space columns in region BEG END."
(interactive "r")
(align-regexp BEG END "\\(\\s-*\\)\\S-+" 1 1 t))
(defun my/create-assets-folder ()
"A quick convenient function to create an assets folder in the wiki folder."
(interactive)
(if (and (not (string= (f-base (buffer-file-name))
my/wiki-asset-directory-name))
(f-descendant-of-p (buffer-file-name)
(expand-file-name +wiki-directory)))
(f-mkdir my/wiki-asset-directory-name
(f-join my/wiki-asset-directory-name (file-name-sans-extension (buffer-file-name))))
(message "Not in the wiki directory.")))
(after! tex
(TeX-engine-set "luatex")
(add-to-list 'safe-local-variable-values
@ -107,34 +111,13 @@
;; Custom keybindings
(map!
(:when (featurep! :tools wiki)
:leader
:prefix "nr"
:desc "Create the asset folder" "m" #'my/create-assets-folder)
(:when (featurep! :editor format)
:n "g=" #'+format/buffer)
(:when (featurep! :lang org +roam)
(:map org-roam-mode-map
:leader
:prefix "nr"
:desc "Find a random Org-roam note" "R" #'org-roam-random-note)))
(setq
;; Modify the time-stamp with each save.
time-stamp-format "%Y-%02m-%02d %02H:%02M:%02S %:z"
org-id-link-to-org-use-id t
;; Set file templates folder at $DOOMDIR/templates.
+file-templates-dir (expand-file-name "templates/" doom-private-dir)
;; Set the journal.
org-journal-dir "~/writings/journal"
org-journal-file-format "%F"
enable-local-variables "query"
)
(defun align-non-space (BEG END)
"Align non-space columns in region BEG END."
(interactive "r")
(align-regexp BEG END "\\(\\s-*\\)\\S-+" 1 1 t))
:n "g=" #'+format/buffer))
;; A workaround for electric-indent plugin.
;; See https://github.com/hlissner/doom-emacs/issues/3172 for more details.

View File

@ -1,20 +1,25 @@
;;; tools/wiki/config.el -*- lexical-binding: t; -*-
;;; tools/wiki/config.el --- The configuration for foo-dogsquared's wiki as a module.
;;; -*- lexical-binding: t; -*-
;;; Commentary:
;; 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")
;;; Code:
(defvar +wiki-directory "~/wiki")
(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.")
(defvar +anki-cards-directory-name "cards")
(defvar +structured-notes-directory-name "structured")
(defun +anki-editor-reset-note ()
"Reset the Anki note in point by deleting the note ID and the deck."
(defvar +anki-cards-directory (f-join +wiki-directory +anki-cards-directory-name))
(defvar +structured-notes-directory (f-join +wiki-directory +structured-notes-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)))
(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))
@ -31,7 +36,9 @@ the structured notes needed to create atmoic notes.")
org-roam-setup
org-roam-capture
org-roam-node-find)
:preface (defvar org-roam-directory nil)
:preface
(defvar org-roam-directory nil)
(defvar +wiki-directory nil)
:init
(map! :leader
:after org
@ -53,29 +60,36 @@ the structured notes needed to create atmoic notes.")
: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"))
(file-truename
(expand-file-name +wiki-directory
org-directory)))
org-roam-dailies-directory (f-join +wiki-directory "daily"))
(org-roam-setup))
(use-package! anki-editor
:hook (org-mode . anki-editor-mode)
:config
(setq anki-editor-create-decks 't
+anki-cards-directory (f-join org-roam-directory "cards"))
:preface
(defvar +wiki-directory nil)
:init
(map! :localleader
:map org-mode-map
(:prefix ("C" . "Anki cards")
"p" #'anki-editor-push-notes
"P" #'+anki-editor-push-all-notes-to-anki
"r" #'anki-editor-retry-failure-notes
"i" #'anki-editor-insert-note
"I" #'anki-editor-cloze-region
"e" #'anki-editor-export-subtree-to-html
"d" #'+anki-editor-reset-note
"D" #'+anki-editor-reset-all-notes)))
"D" #'+anki-editor-reset-all-notes))
:config
(setq anki-editor-create-decks 't
+anki-cards-directory (f-join +wiki-directory +anki-cards-directory-name)))
(use-package! dendroam
:after org-roam
:preface (defvar +wiki-directory nil)
:config
(setq +structured-notes-directory (f-join org-roam-directory "structured")))
(setq +structured-notes-directory (f-join +wiki-directory +structured-notes-directory-name)))
;;; config.el ends here