feat(emacs): Org theming

This commit is contained in:
Madeleine Sydney
2025-02-17 02:51:21 -07:00
parent 7ab9610b6f
commit 12caaa6097
8 changed files with 280 additions and 41 deletions

View File

@@ -1,9 +0,0 @@
;; -*- mode: emacs-lisp; coding: utf-8-unix -*-
;; Minibuffer history file, automatically generated by savehist.
(setq savehist-minibuffer-history-variables '(minibuffer-history file-name-history evil-ex-history evil-ex-search-history))
(setq minibuffer-history '("file-name-concat"))
(setq file-name-history '(#("/persist/dots/users/crumb/programs/emacs/modules/syd-autosave.el" 0 64 (project "/persist/dots/"))))
(setq evil-ex-history '("qa" "w"))
(setq evil-ex-search-history '("savehi"))
(setq evil-jumps-history '((2219 #1="/persist/dots/users/crumb/programs/emacs/modules/syd-autosave.el") (1758 #1#) (3255 #1#) (3279 #1#) (1697 #1#)))

View File

@@ -0,0 +1,134 @@
;;; syd-kanagawa.el -*- lexical-binding: t; -*-
;;; Rationale: I need direct access to the Kanagawa palette, which kanagawa.el
;;; does not provide.
(defvar syd-kanagawa-palette (make-hash-table :test 'eq
:size 130))
(defvar syd-kanagawa-palette-list
'((sumi-ink-0 "#16161D")
(sumi-ink-1 "#181820")
(sumi-ink-2 "#1a1a22")
(sumi-ink-3 "#1F1F28")
(sumi-ink-4 "#2A2A37")
(sumi-ink-5 "#363646")
(sumi-ink-6 "#54546D") ; fg
;; Popup and Floats
(wave-blue-1 "#223249")
(wave-blue-2 "#2D4F67")
;; Diff and Git
(winter-green "#2B3328")
(winter-yellow "#49443C")
(winter-red "#43242B")
(winter-blue "#252535")
(autumn-green "#76946A")
(autumn-red "#C34043")
(autumn-yellow "#DCA561")
;; Diag
(samurai-red "#E82424")
(ronin-yellow "#FF9E3B")
(wave-aqua-1 "#6A9589")
(dragon-blue "#658594")
;; Fg and Comments
(old-white "#C8C093")
(fuji-white "#DCD7BA")
(fuji-gray "#727169")
(oni-violet "#957FB8")
(oni-violet-2 "#b8b4d0")
(crystal-blue "#7E9CD8")
(spring-violet-1 "#938AA9")
(spring-violet-2 "#9CABCA")
(spring-blue "#7FB4CA")
(light-blue "#A3D4D5")
(wave-aqua-2 "#7AA89F") ;; improve lightness: desaturated greenish Aqua
(spring-green "#98BB6C")
(boat-yellow-1 "#938056")
(boat-yellow-2 "#C0A36E")
(carp-yellow "#E6C384")
(sakura-pink "#D27E99")
(wave-red "#E46876")
(peach-red "#FF5D62")
(surimi-orange "#FFA066")
(katana-gray "#717C7C")
(dragon-black-0 "#0d0c0c")
(dragon-black-1 "#12120f")
(dragon-black-2 "#1D1C19")
(dragon-black-3 "#181616")
(dragon-black-4 "#282727")
(dragon-black-5 "#393836")
(dragon-black-6 "#625e5a")
(dragon-white "#c5c9c5")
(dragon-green "#87a987")
(dragon-green-2 "#8a9a7b")
(dragon-pink "#a292a3")
(dragon-orange "#b6927b")
(dragon-orange-2 "#b98d7b")
(dragon-gray "#a6a69c")
(dragon-gray1 "#9e9b93")
(dragon-gray-3 "#7a8382")
(dragon-blue-2 "#8ba4b0")
(dragon-violet "#8992a7")
(dragon-red "#c4746e")
(dragon-aqua "#8ea4a2")
(dragon-ash "#737c73")
(dragon-teal "#949fb5")
(dragon-yellow "#c4b28a")
(lotus-ink-1 "#545464")
(lotus-ink-2 "#43436c")
(lotus-gray "#dcd7ba")
(lotus-gray-2 "#716e61")
(lotus-gray-3 "#8a8980")
(lotus-white-0 "#d5cea3")
(lotus-white-1 "#dcd5ac")
(lotus-white-2 "#e5ddb0")
(lotus-white-3 "#f2ecbc")
(lotus-white-4 "#e7dba0")
(lotus-white-5 "#e4d794")
(lotus-violet-1 "#a09cac")
(lotus-violet-2 "#766b90")
(lotus-violet-3 "#c9cbd1")
(lotus-violet-4 "#624c83")
(lotus-blue-1 "#c7d7e0")
(lotus-blue-2 "#b5cbd2")
(lotus-blue-3 "#9fb5c9")
(lotus-blue-4 "#4d699b")
(lotus-blue-5 "#5d57a3")
(lotus-green "#6f894e")
(lotus-green-2 "#6e915f")
(lotus-green-3 "#b7d0ae")
(lotus-pink "#b35b79")
(lotus-orange "#cc6d00")
(lotus-orange2 "#e98a00")
(lotus-yellow "#77713f")
(lotus-yellow-2 "#836f4a")
(lotus-yellow-3 "#de9800")
(lotus-yellow-4 "#f9d791")
(lotus-red "#c84053")
(lotus-red-2 "#d7474b")
(lotus-red-3 "#e82424")
(lotus-red-4 "#d9a594")
(lotus-aqua "#597b75")
(lotus-aqua-2 "#5e857a")
(lotus-teal-1 "#4e8ca2")
(lotus-teal-2 "#6693bf")
(lotus-teal-3 "#5a7785")
(lotus-cyan "#d7e3d8")))
(cl-loop for (k v) in syd-kanagawa-palette-list
do (puthash k v syd-kanagawa-palette))
(defun syd-kanagawa-get (k)
(gethash k syd-kanagawa-palette nil))
(provide 'syd-kanagawa)

View File

@@ -80,11 +80,18 @@
:prefix-map 'syd-leader-project-map
"C" `("Compile project" . ,#'project-compile))
(general-def
:prefix-map 'syd-leader-help-package-map
"u" `("Temporarily install package" . ,#'straight-use-package)
"v" `("Browse package repo" . ,#'straight-visit-package))
;; Help
(general-def
:prefix-map 'help-map
"F" #'describe-face
"'" #'describe-char)
"'" #'describe-char
"T" #'consult-theme
"p" `("Packages" . ,syd-leader-help-package-map))
(general-def
:prefix-map 'syd-leader-notes-map)

View File

@@ -72,17 +72,56 @@ See https://lists.gnu.org/archive/html/emacs-orgmode/2019-07/msg00081.html."
(downcase uuid)
uuid)))
(defun syd-org-init-faces ()
(let ((headline `(:weight bold)))
(defun syd-org-init-theme ()
(require 'syd-kanagawa)
(let* ((hl `(:weight bold))
(fg (lambda (c) `(:foreground ,(syd-kanagawa-get c))))
(bg (lambda (c) `(:background ,(syd-kanagawa-get c))))
(block-delim `(:foreground nil
:inherit font-lock-comment-face
:extend t
,@(funcall bg 'sumi-ink-0)
:height 0.75))
(keyword '(:background nil :foreground nil
:inherit (fixed-pitch font-lock-comment-face)
:height 0.9)))
(setq org-src-block-faces
`(("jupyter-apl" syd-apl)))
(custom-theme-set-faces
'user
`(org-document-title ((t (,@hl :height 1.60))))
`(org-document-info ((t (,@hl :height 1.0))))
`(org-document-info-keyword ((t ,keyword)))
`(org-meta-line ((t ,keyword)))
`(org-level-1 ((t (,@hl :height 1.40 ,@(funcall fg 'oni-violet)))))
`(org-level-2 ((t (,@hl :height 1.35 ,@(funcall fg 'crystal-blue)))))
`(org-level-3 ((t (,@hl :height 1.30 ,@(funcall fg 'spring-violet-2)))))
`(org-level-4 ((t (,@hl :height 1.25 ,@(funcall fg 'light-blue)))))
`(org-level-5 ((t (,@hl :height 1.20 ,@(funcall fg 'wave-aqua-2)))))
`(org-level-6 ((t (,@hl :height 1.15 ,@(funcall fg 'spring-green)))))
`(org-level-7 ((t (,@hl :height 1.10 ,@(funcall fg 'boat-yellow-1)))))
`(org-level-8 ((t (,@hl :height 1.05 ,@(funcall fg 'boat-yellow-2)))))
`(org-block-begin-line ((t ,block-delim)))
`(org-block-end-line ((t ,block-delim)))
'(org-ellipsis ((t (:height 1.0))))
;; It is important that the `org-indent' face uses a fixed-pitch font, lest
;; e.g. multi-line bullets appear misaligned.
'(org-indent ((t (:inherit (org-hide fixed-pitch)))))
'(org-indent ((t (:inherit (org-hide syd-alt-fixed-pitch)))))
;; Must be fixed-pitch; `[ ]` and `[X]' should be the same width.
'(org-checkbox ((t (:inherit fixed-pitch))))
'(org-drawer ((t (:inherit (font-lock-comment-face fixed-pitch)))))
'(org-property-value ((t (:inherit fixed-pitch)))))))
`(org-drawer ((t ,block-delim)))
'(org-property-value ((t (:inherit fixed-pitch))))
'(org-special-keyword ((t (:inherit (font-lock-comment-face fixed-pitch)))))
`(org-block ((t (:inherit fixed-pitch
,@(funcall bg 'sumi-ink-2)))))
'(org-code ((t (:inherit (shadow fixed-pitch))))))))
(evil-define-command syd-org-yank-link (register)
(interactive "<x>")
(if-let* ((url (thing-at-point 'url)))
(progn (evil-set-register (or register ?\") url)
(message "Yanked link: %s" url))
(message "No URL at point")))
(defun syd-org-init-keybinds ()
(general-def
@@ -92,7 +131,8 @@ See https://lists.gnu.org/archive/html/emacs-orgmode/2019-07/msg00081.html."
[C-M-return] #'org-insert-subheading)
(general-def
:prefix-map 'syd-org-mode-links-map
"l" #'org-insert-link)
"l" #'org-insert-link
"y" #'syd-org-yank-link)
(general-define-key
:keymaps 'org-mode-map
:states '(normal visual motion emacs insert)
@@ -108,20 +148,56 @@ See https://lists.gnu.org/archive/html/emacs-orgmode/2019-07/msg00081.html."
"i" #'org-toggle-item
"I" #'org-id-get-create
"k" #'org-babel-remove-result
"l" `("Links" . ,syd-org-mode-links-map)))
"l" `("Links" . ,syd-org-mode-links-map)
"t" #'org-todo))
(use-package org
:defer-incrementally
calendar find-func format-spec org-macs org-compat org-faces org-entities
org-list org-pcomplete org-src org-footnote org-macro ob org org-agenda
org-capture
:init
;; HACK: Face specs fed directly to `org-todo-keyword-faces' don't respect
;; underlying faces like the `org-todo' face does, so we define our own
;; intermediary faces that extend from org-todo.
(with-no-warnings
(custom-declare-face 'syd-org-todo-active
'((t (:inherit (bold font-lock-constant-face org-todo)))) "")
(custom-declare-face 'syd-org-todo-project
'((t (:inherit (bold font-lock-doc-face org-todo)))) "")
(custom-declare-face 'syd-org-todo-onhold
'((t (:inherit (bold warning org-todo)))) "")
(custom-declare-face 'syd-org-todo-cancel
'((t (:inherit (bold error org-todo)))) ""))
:custom ((org-startup-folded 'content)
(org-directory "~/org")
;; Stay out of my config dir!
(org-id-locations-file (file-name-concat syd-cache-dir
"org-id-locations"))
;; New headings should be inserted /after/ the heading's contents.
(org-insert-heading-respect-content t))
(org-insert-heading-respect-content t)
;; Hide markup syntax and leave the markup.
(org-hide-emphasis-markers t)
(org-ellipsis " […]")
(org-todo-keywords
'((sequence
"TODO(t)" ; A task that needs doing & is ready to do
"PROJ(p)" ; A project, which usually contains other tasks
"STRT(s)" ; A task that is in progress
"WAIT(w)" ; Something external is holding up this task
"HOLD(h)" ; This task is paused/on hold because of me
"IDEA(i)" ; An unconfirmed and unapproved task or notion
"|"
"DONE(d)" ; Task successfully completed
"KILL(k)"))) ; Task was cancelled, aborted, or is no longer
; applicable
(org-todo-keyword-faces
'(("[-]" . syd-org-todo-active)
("STRT" . syd-org-todo-active)
("WAIT" . syd-org-todo-onhold)
("HOLD" . syd-org-todo-onhold)
("PROJ" . syd-org-todo-project)
("KILL" . syd-org-todo-cancel))))
:preface
;; Speed up initialisation by disabling modules we don't need.
(defvar org-modules
@@ -140,9 +216,13 @@ See https://lists.gnu.org/archive/html/emacs-orgmode/2019-07/msg00081.html."
(syd-add-hook 'org-mode-hook
#'org-indent-mode
#'syd-prose-mode)
(syd-org-init-faces)
(syd-org-init-theme)
(syd-org-init-keybinds))
(use-package org-appear
:hook (org-mode . org-appear-mode)
:custom (org-appear-autoemphasis t))
;; Unlike those appearing in `syd-org--init-roam-keybinds', these should be
;; available even outside of Org-mode.
(general-def
@@ -199,8 +279,7 @@ In case of failure, fail gracefully."
(use-package evil-org
:hook ((org-mode . evil-org-mode)
(org-capture-mode . evil-insert-state)
(doom-docs-org-mode . evil-org-mode))
(org-capture-mode . evil-insert-state))
:init
(defvar evil-org-retain-visual-state-on-shift t)
(defvar evil-org-special-o/O '(table-row))
@@ -215,7 +294,18 @@ In case of failure, fail gracefully."
;; (kbd syd-leader-key) nil))
(use-package hide-mode-line
:hook (org-mode-hook . hide-mode-line-mode))
:hook (org-mode . hide-mode-line-mode))
(use-package org-superstar
:hook (org-mode . org-superstar-mode)
:custom ((org-superstar-headline-bullets-list '(9675))
(org-superstar-item-bullet-alist '((?- . ?•)
(?+ . ?➤)
(?* . ?⋆))))
:config
(custom-theme-set-faces
'user
`(org-superstar-header-bullet ((t (:font ,syd-alt-fixed-pitch-font))))))
(provide 'syd-org)
;;; syd-org.el ends here

View File

@@ -31,20 +31,22 @@
(defun syd-tab-bar--name-new-tab-h (tab)
"Hooks to `tab-bar-tab-post-open-functions' such that new tabs will be
given \"explicit names\" that are static."
(syd-tab-bar-rename-tab tab (funcall syd-tab-bar-name-function)))
(defun syd-tab-bar--show-tab-bar-h (_tab)
"Show the tab-bar if it is not already visible. See
(syd-tab-bar-rename-tab tab (funcall syd-tab-bar-name-function))))
(defun syd-tab-bar--show-tab-bar-h (_tab)
"Show the tab-bar if it is not already visible. See
`syd-tab-bar-hide-tab-bar-h'."
(unless vim-tab-bar-mode
(vim-tab-bar-mode 1))))
(unless vim-tab-bar-mode
(vim-tab-bar-mode 1)))
(defun syd-tab-bar-new-tab ()
(interactive)
(let ((tab-bar-tab-post-open-functions
(cons (lambda (_tab)
(switch-to-buffer
(funcall syd-tab-bar-default-buffer-function)))
tab-bar-tab-post-open-functions)))
(-cons* (lambda (_tab)
(switch-to-buffer
(funcall syd-tab-bar-default-buffer-function)))
#'syd-tab-bar--show-tab-bar-h
tab-bar-tab-post-open-functions)))
(tab-bar-new-tab)))
(syd-add-hook 'tab-bar-tab-pre-close-functions

View File

@@ -7,9 +7,21 @@
"Default fixed-pitch (monospace) font.")
(defvar syd-variable-pitch-font
(font-spec :family "Overpass" :size 15)
(font-spec :family "IBM Plex Serif" :size 15)
"Default variable-pitch font.")
(defvar syd-alt-fixed-pitch-font
(font-spec :family "JuliaMono" :size 16)
"A monospace font secondary to `syd-fixed-pitch-font'.")
(defface syd-alt-fixed-pitch
`((t (:inherit fixed-pitch :font ,syd-alt-fixed-pitch-font)))
"TODO")
(defface syd-apl
`((t (:inherit syd-alt-fixed-pitch)))
"Face for APL code")
;; Beautiful theme in dark and light.
(use-package kanagawa-themes
:config