summary refs log tree commit diff
path: root/emacs
diff options
context:
space:
mode:
authornoa2025-01-10 16:59:36 +0800
committernoa2025-01-10 16:59:36 +0800
commite7696ca3e0a0d6cd79041c093ec673a31d711dae (patch)
tree38628622885c808cdfac5aa0e6fa22778be5f080 /emacs
parentf83e9e1146c5a73d24e917ebad62b0f25a7b9d57 (diff)
Add some org note configuration
Support for inline-anki and org-node
Diffstat (limited to 'emacs')
-rw-r--r--emacs/init.el60
1 files changed, 60 insertions, 0 deletions
diff --git a/emacs/init.el b/emacs/init.el
index aea61c3..1023b5b 100644
--- a/emacs/init.el
+++ b/emacs/init.el
@@ -814,6 +814,66 @@ The misspelled word is taken from OVERLAY.  WORD is the corrected word."
   (when (buffer-file-name)
     (kill-new (file-name-nondirectory (buffer-file-name)))))
 
+(use-package org
+  :init
+  ;; Repurpose underline syntax for cloze deletion face
+  (defface my-cloze '((t . (:box t))) "Cloze face for Inline-Anki")
+  (setq org-emphasis-alist '(("*" bold)
+                           ("/" italic)
+                           ("_" my-cloze) ;; new
+                           ("=" org-verbatim verbatim)
+                           ("~" org-code verbatim)
+                           ("+" (:strike-through t))))
+
+  :custom
+  (org-agenda-files '("~/Documents/Notes.org"))
+  (org-log-done 'time)
+  (org-pretty-entities t)
+  (org-hide-emphasis-markers t))
+
+(use-package org-node
+  :ensure t
+  :after org
+
+  :custom
+  (org-node-prefer-with-heading t)
+  (org-node-creation-fn #'noa/org-node-new-node)
+
+  :config
+  (org-node-cache-mode)
+  (org-node-backlink-mode)
+  (defvar noa/org-notes-file "~/Documents/Notes.org")
+  (defun noa/org-node-new-node ()
+    "Create a node in my notes file.
+Meant to be called indirectly as `org-node-creation-fn', so that some
+necessary variables are set."
+    (if (or (null org-node-proposed-title)
+            (null org-node-proposed-id))
+        (message "noa/org-node-new-node is meant to be called indirectly")
+      (when (not (file-exists-p noa/org-notes-file))
+        (user-error "Node file not found: %s" noa/org-notes-file))
+      (find-file noa/org-notes-file)
+      (goto-char (point-max))
+      (insert "* " org-node-proposed-title
+              "\n:PROPERTIES:"
+              "\n:ID:       " org-node-proposed-id
+              "\n:END:"
+              "\n")
+      (goto-char (point-max))
+      (push (current-buffer) org-node--not-yet-saved)
+      (run-hooks 'org-node-creation-hook)))
+
+  :bind (("M-s M-f" . org-node-find)
+         ("M-s M-i" . org-node-insert-link)
+         ("M-s M-g" . org-node-grep))
+  )
+
+(use-package inline-anki
+  :after org
+  :load-path "~/.config/emacs/site-lisp/inline-anki"
+  :config
+  (add-to-list 'org-structure-template-alist '("f" . "flashcard")))
+
 (use-package ctrlj
   :load-path "~/Documents/Projects/2024-10-08 Ctrlj"
   :init (global-unset-key (kbd "C-j"))