From: Jakub Czajka Date: Fri, 23 Dec 2022 18:30:29 +0000 (+0100) Subject: [emacs] Configure org-mode. X-Git-Url: https://git.ekhem.eu.org/?a=commitdiff_plain;h=1ffc1eb75d3db9a6604c6cffe22a107e0eb84bd3;p=guix.git [emacs] Configure org-mode. Org-mode is a built-in advanced mode for writing documents. This commit configures org-mode. It also installs org-roam and org-agenda. --- diff --git a/conf/home/emacs.scm b/conf/home/emacs.scm index 0517e92..f857ba4 100644 --- a/conf/home/emacs.scm +++ b/conf/home/emacs.scm @@ -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) @@ -133,6 +134,15 @@ (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 @@ -179,6 +189,7 @@ 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 index 0000000..a71e57a --- /dev/null +++ b/emacs/.config/emacs/conf/conf-org.el @@ -0,0 +1,114 @@ +;; Copyright (c) 2022 Jakub Czajka +;; 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)