]> git.ekhem.eu.org Git - guix.git/commitdiff
[emacs] Configure org-mode.
authorJakub Czajka <jakub@ekhem.eu.org>
Fri, 23 Dec 2022 18:30:29 +0000 (19:30 +0100)
committerJakub Czajka <jczajka@google.com>
Sun, 24 Dec 2023 18:53:07 +0000 (19:53 +0100)
Org-mode is a built-in advanced mode for writing documents. This
commit configures org-mode. It also installs org-roam and org-agenda.

conf/home/emacs.scm
emacs/.config/emacs/conf/conf-org.el [new file with mode: 0644]

index 0517e92a4e7e63109234176a2393cfa6a3764833..f857ba4eda15d7cc77d2fa77eb7f5d7e53fef5d6 100644 (file)
@@ -17,6 +17,7 @@
   #:use-module (gnu packages password-utils)
   #:use-module (gnu packages pdf)
   #:use-module (gnu packages rust-apps)
+  #:use-module (gnu packages sqlite)
   #:use-module (gnu packages video)
   #:use-module (gnu services)
   #:use-module (guix gexp)
             (list "bash/.config/profile.d/50-alsa.sh"
                   "emacs/.config/emacs/conf/conf-music.el")))))
 
+(define emacs-org-service
+  (service home-program-service-type
+          (home-program-configuration
+           (packages
+            (list emacs-org-roam
+                  sqlite))
+           (dotfiles
+            (list "emacs/.config/emacs/conf/conf-org.el")))))
+
 (define emacs-package-service
   (service home-program-service-type
           (home-program-configuration
         emacs-language-service
         emacs-minibuffer-service
         emacs-music-service
+        emacs-org-service
         emacs-package-service
         emacs-pass-service
         emacs-service))
diff --git a/emacs/.config/emacs/conf/conf-org.el b/emacs/.config/emacs/conf/conf-org.el
new file mode 100644 (file)
index 0000000..a71e57a
--- /dev/null
@@ -0,0 +1,114 @@
+;; Copyright (c) 2022 Jakub Czajka <jakub@ekhem.eu.org>
+;; License: GPL-3.0 or later.
+;;
+;; conf-org.el - configuration for org mode.
+
+(require 'conf-package)
+(require 'conf-variables)
+
+(defcustom conf:org-agenda-directory
+  (expand-file-name "~/Agenda")
+  "Directory with `org-agenda' files."
+  :type 'directory
+  :group 'conf:configuration)
+
+(use-package org
+  :bind
+  ("C-c a"     . org-agenda)
+  ("C-c l"     . org-store-link)
+  ("C-c C-x ;" . org-timer-set-timer)
+  ("C-c C-x ," . org-timer-pause-or-continue)
+  ("C-c C-x _" . org-timer-stop)
+  (:map org-mode-map
+       ("C-c x" . conf:org-babel-load-this-file))
+  :custom
+  ;; Fold all lists on start-up.
+  (org-startup-folded t)
+  ;; No additional indentation in code blocks.
+  (org-edit-src-content-indentation 0)
+  ;; TABs in code blocks behave like in the major mode of the language.
+  (org-src-tab-acts-natively t)
+  ;; Preserve leading whitespace characters when exporting and when switching
+  ;; between the org buffer and the language mode edit buffer.
+  (org-src-preserve-indentation t)
+  ;; Catch changes in invisible regions. Show the region and make the simpler
+  ;; changes only if adjacent to visible text.
+  (org-catch-invisible-edits 'smart)
+  ;; Search for agenda items in `conf:org-agenda-directory'.
+  (org-agenda-files (list conf:org-agenda-directory))
+  ;; Use '-' as the global block separator.
+  (org-agenda-block-separator (char-from-name "FIGURE DASH"))
+  ;; Custom agenda views.
+  (org-agenda-custom-commands
+   '(("w" "Weekly agenda"
+      ((agenda ""
+              ((org-agenda-overriding-header "* Agenda")
+               (org-agenda-span 'week)))
+       (todo "*"
+            ((org-agenda-overriding-header "* Important TODOs")
+             (org-agenda-skip-function
+              `(org-agenda-skip-entry-if
+                'notregexp ,(format "\\[#[A|B]\\]")))))))))
+  :custom-face
+  ;; Apply default faces to org code blocks.
+  (org-block ((t :inherit default)))
+  ;; Face for lines starting with '#+'.
+  (org-meta-line ((t :foreground "#faa275")))
+  ;; Face for top level headlines.
+  (org-level-1 ((t :inherit minibuffer-prompt)))
+  ;; Face for subheadlines.
+  (org-level-2 ((t :foreground "#98EAD0")))
+  :config
+  (defun conf:org-babel-load-this-file ()
+    "Load emacs lisp source code blocks in the current file.
+This function runs `org-babel-load-file' on the current file."
+    (interactive)
+    (org-babel-load-file (buffer-file-name))))
+
+(defcustom conf:org-roam-directory
+  (expand-file-name "~/Roam")
+  "Directory with `org-roam' files."
+  :type 'directory
+  :group 'conf:configuration)
+
+(use-package org-roam
+  :when
+  (conf:executables-p (list "sqlite3"))
+  :ensure t
+  :bind
+  ("C-c rf" . org-roam-node-find)
+  ("C-c rd" . org-id-get-create)
+  ("C-c ri" . org-roam-node-insert)
+  :custom
+  (org-roam-directory conf:org-roam-directory)
+  ;; Display backlinks uniquely.
+  (org-roam-mode-sections '((org-roam-backlinks-section :unique t)
+                           org-roam-reflinks-section))
+  ;; `org-capture' templates for creating `org-roam' entities.
+  (org-roam-capture-templates
+   '(("f" "regular file" plain
+      "%?"
+      :target
+      (file "${slug}.org")
+      :empty-lines 1
+      :unnarrowed t)
+     ("t" "todo" plain
+      "* TODO %^{Priority||[#C] |[#B] |[#A] }%^{Title}\n%?"
+      :target
+      (file+head "todos/${slug}.org"
+                "#+startup: showeverything")
+      :empty-lines 1
+      :unnarrowed t)
+     ("w" "wiki" plain
+      "%?"
+      :target
+      (file+head "wikis/${slug}.org"
+                "#+startup: showeverything")
+      :empty-lines 1
+      :unnarrowed t)))
+   :config
+   ;; Enable `org-roam-db-autosync' minor mode globally. It tracks `org-roam'
+   ;; changes and keeps the session synchronized.
+   (org-roam-db-autosync-mode))
+
+(provide 'conf-org)