chore(emacs): sync from guix config
60c3d190
14 file(s) · +287 −475
| 1 | 1 | ;;; early-init.el -*- lexical-binding: t; -*- |
|
| 2 | 2 | ||
| 3 | - | ;; Faster startup: defer GC, restore after init |
|
| 4 | - | (setq gc-cons-threshold most-positive-fixnum) |
|
| 3 | + | (setq gc-cons-threshold most-positive-fixnum |
|
| 4 | + | gc-cons-percentage 1.0) |
|
| 5 | 5 | (add-hook 'emacs-startup-hook |
|
| 6 | - | (lambda () (setq gc-cons-threshold (* 16 1024 1024)))) |
|
| 6 | + | (lambda () (setq gc-cons-threshold (* 16 1024 1024) |
|
| 7 | + | gc-cons-percentage 0.1))) |
|
| 7 | 8 | ||
| 8 | - | ;; Skip UI chrome before first frame draws |
|
| 9 | + | ;; Every `load'/`require' checks file names against these regexps; skip that |
|
| 10 | + | ;; during init and restore afterwards (adapted from minimal-emacs.d) |
|
| 11 | + | (let ((handlers file-name-handler-alist)) |
|
| 12 | + | ;; keep jka-compr so compressed .el.gz libraries still load |
|
| 13 | + | (setq file-name-handler-alist (list (rassq 'jka-compr-handler handlers))) |
|
| 14 | + | (add-hook 'emacs-startup-hook |
|
| 15 | + | (lambda () |
|
| 16 | + | (setq file-name-handler-alist |
|
| 17 | + | (delete-dups (append file-name-handler-alist handlers)))) |
|
| 18 | + | 101)) |
|
| 19 | + | ||
| 9 | 20 | (setq package-enable-at-startup t |
|
| 10 | 21 | inhibit-startup-screen t |
|
| 11 | - | frame-inhibit-implied-resize t) |
|
| 22 | + | inhibit-startup-echo-area-message user-login-name |
|
| 23 | + | frame-inhibit-implied-resize t |
|
| 24 | + | frame-resize-pixelwise t |
|
| 25 | + | auto-mode-case-fold nil) |
|
| 26 | + | ||
| 27 | + | ;; Skip UI chrome before first frame draws |
|
| 12 | 28 | (push '(menu-bar-lines . 0) default-frame-alist) |
|
| 13 | 29 | (push '(tool-bar-lines . 0) default-frame-alist) |
|
| 14 | 30 | (push '(vertical-scroll-bars) default-frame-alist) |
| 1 | 1 | ;;; init.el -*- lexical-binding: t; -*- |
|
| 2 | 2 | ||
| 3 | - | (defvar my/cache-dir (expand-file-name "emacs/" "~/.cache/") |
|
| 4 | - | "Where state, backups and custom settings live (outside the dotfiles repo).") |
|
| 3 | + | (defvar my/cache-dir (expand-file-name "emacs/" "~/.cache/")) |
|
| 5 | 4 | (make-directory my/cache-dir t) |
|
| 6 | 5 | ||
| 7 | 6 | (add-to-list 'load-path (expand-file-name "lisp" user-emacs-directory)) |
|
| 9 | 8 | (setq custom-file (expand-file-name "custom.el" my/cache-dir)) |
|
| 10 | 9 | (load custom-file 'noerror 'nomessage) |
|
| 11 | 10 | ||
| 12 | - | ;;; Packages |
|
| 13 | 11 | (require 'package) |
|
| 14 | 12 | (setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/") |
|
| 15 | 13 | ("nongnu" . "https://elpa.nongnu.org/nongnu/") |
|
| 16 | 14 | ("melpa" . "https://melpa.org/packages/"))) |
|
| 17 | - | (unless package-archive-contents (package-refresh-contents)) |
|
| 15 | + | ||
| 18 | 16 | (setq use-package-always-ensure t) |
|
| 19 | 17 | ||
| 20 | 18 | (require 'init-defaults) |
|
| 22 | 20 | (require 'init-ui) |
|
| 23 | 21 | (require 'init-erc) |
|
| 24 | 22 | (require 'init-jabber) |
|
| 25 | - | (require 'init-mail) |
|
| 26 | 23 | (require 'init-lang) |
|
| 27 | 24 | (require 'init-tools) |
|
| 28 | 25 | (require 'init-term) |
|
| 43 | 43 | tooltip-delay 0.3 |
|
| 44 | 44 | tooltip-short-delay 0.08) |
|
| 45 | 45 | ||
| 46 | - | ;; Built-in minor modes worth having |
|
| 46 | + | ;; Built-in minor modes |
|
| 47 | 47 | (delete-selection-mode 1) |
|
| 48 | 48 | (electric-pair-mode 1) |
|
| 49 | 49 | (show-paren-mode 1) |
|
| 67 | 67 | read-buffer-completion-ignore-case t) |
|
| 68 | 68 | (fido-vertical-mode 1) |
|
| 69 | 69 | ||
| 70 | - | ;; Line numbers in code/text, relative like Doom config |
|
| 70 | + | ;; Line numbers in code/text |
|
| 71 | 71 | (setq display-line-numbers-type 'relative) |
|
| 72 | 72 | (add-hook 'prog-mode-hook #'display-line-numbers-mode) |
|
| 73 | 73 | (add-hook 'text-mode-hook #'display-line-numbers-mode) |
|
| 1 | 1 | ;;; init-erc.el -*- lexical-binding: t; -*- |
|
| 2 | 2 | ||
| 3 | - | (require 'auth-source-pass) |
|
| 4 | - | ||
| 5 | 3 | ;; soju password: read from `pass' (gpg-encrypted), cached in memory per session |
|
| 6 | 4 | (defvar my/soju-pass-entry "irc/soju") |
|
| 7 | 5 | (defvar my/soju--password nil) |
|
| 36 | 34 | (erc-tls :server "138.197.115.89" |
|
| 37 | 35 | :port 6697 |
|
| 38 | 36 | :nick "stevedylandev_" |
|
| 39 | - | :user (my/soju-user "erc") |
|
| 37 | + | :user (my/soju-user "erc-benson") |
|
| 40 | 38 | :password (my/soju-password))) |
|
| 41 | 39 | ||
| 42 | 40 | (provide 'init-erc) |
|
| 65 | 65 | "oT" '(ghostel-project :wk "project terminal") |
|
| 66 | 66 | "os" '(eshell :wk "eshell") |
|
| 67 | 67 | ||
| 68 | - | "m" '(:ignore t :wk "mail") |
|
| 69 | - | "mc" '(mu4e-compose-new :wk "compose") |
|
| 70 | - | "ms" '(mml-secure-message-sign-pgpmime :wk "sign") |
|
| 71 | - | "me" '(mml-secure-message-encrypt-pgpmime :wk "sign+encrypt") |
|
| 72 | - | "mE" '((lambda () (interactive) (mml-secure-message-encrypt-pgpmime t)) |
|
| 73 | - | :wk "encrypt only") |
|
| 74 | - | "md" '(my/mail-decrypt-bridge :wk "decrypt (bridge)") |
|
| 75 | - | "mn" '(mml-unsecure-message :wk "remove sign/encrypt") |
|
| 68 | + | "ll" '(gptel :wk "gptel") |
|
| 69 | + | "la" '(gptel-add :wk "add context") |
|
| 70 | + | "lr" '(gptel-context-remove-all :wk "remove context") |
|
| 71 | + | "lm" '(gptel-menu :wk "menu") |
|
| 72 | + | "ls" '(gptel-send :wk "send") |
|
| 76 | 73 | ||
| 77 | 74 | "u" '(:ignore t :wk "upload") |
|
| 78 | 75 | "uu" '(uguu-upload-file :wk "upload file") |
| 1 | 1 | ;;; init-jabber.el -*- lexical-binding: t; -*- |
|
| 2 | 2 | ||
| 3 | - | (require 'auth-source-pass) |
|
| 4 | - | ||
| 5 | - | ;; Built from git for OMEMO. Native module needs `brew install mbedtls@3' |
|
| 6 | - | ;; (4.x dropped mbedtls/aes.h); macOS has no getrandom, so shim it. |
|
| 3 | + | ;; Built from git for OMEMO. Native module needs mbedtls 3.x headers, gcc, |
|
| 4 | + | ;; make and pkg-config on PATH (4.x dropped mbedtls/aes.h). |
|
| 7 | 5 | (use-package jabber |
|
| 8 | 6 | :vc (:url "https://git.thanosapollo.org/emacs-jabber" |
|
| 9 | - | :lisp-dir "lisp" |
|
| 10 | - | :shell-command "PKG_CONFIG_PATH=/opt/homebrew/opt/mbedtls@3/lib/pkgconfig CFLAGS=\"-I/opt/homebrew/opt/emacs/include '-Dgetrandom(b,n,f)=(arc4random_buf((b),(n)),(ssize_t)(n))'\" MBED_STATIC=1 make module") |
|
| 7 | + | :lisp-dir "lisp" |
|
| 8 | + | :shell-command "MBED_STATIC=1 make module") |
|
| 11 | 9 | :defer t |
|
| 12 | 10 | :init |
|
| 13 | - | ;; `jabber-roster' autoloads from jabber-roster-menu, which never loads |
|
| 14 | - | ;; jabber.el, so :config (account list) would never run. Pull it in. |
|
| 15 | 11 | (with-eval-after-load 'jabber-roster-menu (require 'jabber)) |
|
| 16 | 12 | :config |
|
| 17 | 13 | (setq jabber-account-list |
| 1 | 1 | ;;; init-lang.el -*- lexical-binding: t; -*- |
|
| 2 | 2 | ||
| 3 | - | ;;; Syntax highlighting: tree-sitter (built-in) |
|
| 4 | - | ;; Every built-in *-ts-mode replaces its classic mode, and the grammar is |
|
| 5 | - | ;; compiled into ~/.config/emacs/tree-sitter the first time it's needed. |
|
| 6 | - | ;; Needs a C compiler (xcode-select --install). |
|
| 3 | + | ;;; Syntax highlighting: tree-sitter |
|
| 7 | 4 | (setopt treesit-enabled-modes t |
|
| 8 | 5 | treesit-auto-install-grammar 'always |
|
| 9 | 6 | treesit-font-lock-level 4) ; 4 = everything (calls, properties, operators) |
|
| 10 | 7 | ||
| 11 | - | ;;; LSP: eglot (built-in) |
|
| 12 | - | ;; Add a language: one line here. MODES is a ts-mode (or list of them), |
|
| 13 | - | ;; SERVER is the command eglot runs. Entries whose server binary isn't on |
|
| 14 | - | ;; PATH are skipped, so it's fine to list servers you haven't installed. |
|
| 15 | - | ;; A mode not built into Emacs needs its package first, e.g. |
|
| 16 | - | ;; (use-package zig-mode) then (zig-mode "zls") |
|
| 8 | + | ;;; LSP: eglot |
|
| 17 | 9 | (defvar my/lsp-servers |
|
| 18 | 10 | '(((typescript-ts-mode tsx-ts-mode js-ts-mode) "vtsls" "--stdio") |
|
| 19 | 11 | (rust-ts-mode "rust-analyzer") |
|
| 20 | 12 | ((go-ts-mode go-mod-ts-mode) "gopls") |
|
| 21 | 13 | ((c-ts-mode c++-ts-mode) "clangd") |
|
| 22 | 14 | (lua-ts-mode "lua-language-server") |
|
| 23 | - | (css-ts-mode "vscode-css-language-server" "--stdio") |
|
| 15 | + | ;;(css-ts-mode "vscode-css-language-server" "--stdio") |
|
| 24 | 16 | ((mhtml-ts-mode html-ts-mode) "vscode-html-language-server" "--stdio") |
|
| 25 | 17 | (json-ts-mode "vscode-json-language-server" "--stdio") |
|
| 26 | - | (python-ts-mode "basedpyright-langserver" "--stdio") |
|
| 27 | - | (bash-ts-mode "bash-language-server" "start")) |
|
| 18 | + | (python-ts-mode "pylsp") |
|
| 19 | + | (python-ts-mode "basedpyright-langserver" "--stdio") ; wins if both installed |
|
| 20 | + | (bash-ts-mode "bash-language-server" "start") |
|
| 21 | + | (scheme-mode "guile-lsp-server")) |
|
| 28 | 22 | "Alist of (MODES SERVER ARGS...) used to auto-start eglot.") |
|
| 29 | 23 | ||
| 30 | 24 | (use-package eglot |
|
| 31 | 25 | :ensure nil |
|
| 26 | + | :defer t |
|
| 32 | 27 | :custom |
|
| 33 | 28 | (eglot-autoshutdown t) ; kill server when last buffer closes |
|
| 34 | 29 | (eglot-events-buffer-config '(:size 0 :format full)) ; no event logging |
|
| 35 | 30 | (eglot-extend-to-xref t) ; stay in eglot when jumping into deps |
|
| 36 | 31 | :config |
|
| 37 | 32 | (dolist (entry my/lsp-servers) |
|
| 38 | - | (let ((modes (ensure-list (car entry))) |
|
| 39 | - | (cmd (cdr entry))) |
|
| 40 | - | (when (executable-find (car cmd)) |
|
| 41 | - | (add-to-list 'eglot-server-programs (cons modes cmd)) |
|
| 42 | - | (dolist (mode modes) |
|
| 43 | - | (add-hook (intern (format "%s-hook" mode)) #'eglot-ensure)))))) |
|
| 33 | + | (when (executable-find (cadr entry)) |
|
| 34 | + | (add-to-list 'eglot-server-programs |
|
| 35 | + | (cons (ensure-list (car entry)) (cdr entry)))))) |
|
| 36 | + | ||
| 37 | + | ;; Hooks go in now so eglot itself only loads when a matching buffer opens |
|
| 38 | + | (dolist (entry my/lsp-servers) |
|
| 39 | + | (when (executable-find (cadr entry)) |
|
| 40 | + | (dolist (mode (ensure-list (car entry))) |
|
| 41 | + | (add-hook (intern (format "%s-hook" mode)) #'eglot-ensure)))) |
|
| 42 | + | ||
| 43 | + | ;;; Indentation per language |
|
| 44 | + | (defvar my/indent-settings |
|
| 45 | + | '(((typescript-ts-mode tsx-ts-mode) 2 nil typescript-ts-mode-indent-offset) |
|
| 46 | + | (js-ts-mode 2 nil js-indent-level) |
|
| 47 | + | (rust-ts-mode 4 nil rust-ts-mode-indent-offset) |
|
| 48 | + | (go-ts-mode 4 t go-ts-mode-indent-offset) |
|
| 49 | + | ((c-ts-mode c++-ts-mode) 4 nil c-ts-mode-indent-offset) |
|
| 50 | + | (lua-ts-mode 2 nil lua-ts-indent-offset) |
|
| 51 | + | (css-ts-mode 2 nil css-indent-offset) |
|
| 52 | + | ((mhtml-ts-mode html-ts-mode) 2 nil html-ts-mode-indent-offset) |
|
| 53 | + | (json-ts-mode 2 nil json-ts-mode-indent-offset) |
|
| 54 | + | (python-ts-mode 4 nil python-indent-offset) |
|
| 55 | + | (bash-ts-mode 2 nil sh-basic-offset) |
|
| 56 | + | ((emacs-lisp-mode scheme-mode) 2 nil nil)) |
|
| 57 | + | "List of (MODES WIDTH TABS OFFSET-VAR) applied in each mode's hook.") |
|
| 58 | + | ||
| 59 | + | (dolist (entry my/indent-settings) |
|
| 60 | + | (pcase-let ((`(,modes ,width ,tabs ,var) entry)) |
|
| 61 | + | (dolist (mode (ensure-list modes)) |
|
| 62 | + | (add-hook (intern (format "%s-hook" mode)) |
|
| 63 | + | (lambda () |
|
| 64 | + | (setq-local tab-width width |
|
| 65 | + | indent-tabs-mode tabs) |
|
| 66 | + | (when var (set (make-local-variable var) width))))))) |
|
| 67 | + | ||
| 68 | + | ;;; Format on save |
|
| 69 | + | ;; Uses eglot when the server can format, else re-indents lisp buffers. Off for a |
|
| 70 | + | ;; buffer with SPC c F, or per project via .dir-locals.el: |
|
| 71 | + | (defvar my/format-on-save t |
|
| 72 | + | "Non-nil formats eglot-managed buffers before saving.") |
|
| 73 | + | (put 'my/format-on-save 'safe-local-variable #'booleanp) |
|
| 74 | + | ||
| 75 | + | (defvar my/reindent-modes '(emacs-lisp-mode scheme-mode) |
|
| 76 | + | "Modes without an LSP formatter that format by re-indenting the buffer.") |
|
| 77 | + | ||
| 78 | + | (defun my/format-buffer () |
|
| 79 | + | "Format with eglot if the server can, else re-indent in `my/reindent-modes'." |
|
| 80 | + | (interactive) |
|
| 81 | + | (cond ((and (fboundp 'eglot-managed-p) (eglot-managed-p) |
|
| 82 | + | (eglot-server-capable :documentFormattingProvider)) |
|
| 83 | + | (eglot-format-buffer)) |
|
| 84 | + | ((apply #'derived-mode-p my/reindent-modes) |
|
| 85 | + | (indent-region (point-min) (point-max))) |
|
| 86 | + | ((called-interactively-p 'any) |
|
| 87 | + | (message "No formatter for %s" major-mode)))) |
|
| 88 | + | ||
| 89 | + | (defun my/format-on-save () |
|
| 90 | + | (when my/format-on-save (my/format-buffer))) |
|
| 91 | + | ||
| 92 | + | (add-hook 'before-save-hook #'my/format-on-save) |
|
| 93 | + | ||
| 94 | + | (defun my/toggle-format-on-save () |
|
| 95 | + | "Toggle format on save for the current buffer." |
|
| 96 | + | (interactive) |
|
| 97 | + | (setq-local my/format-on-save (not my/format-on-save)) |
|
| 98 | + | (message "Format on save %s" (if my/format-on-save "on" "off"))) |
|
| 44 | 99 | ||
| 45 | 100 | ;; Diagnostics |
|
| 46 | 101 | (setq flymake-show-diagnostics-at-end-of-line 'short) |
|
| 50 | 105 | "c" '(:ignore t :wk "code") |
|
| 51 | 106 | "ca" '(eglot-code-actions :wk "actions") |
|
| 52 | 107 | "cr" '(eglot-rename :wk "rename") |
|
| 53 | - | "cf" '(eglot-format-buffer :wk "format") |
|
| 108 | + | "cf" '(my/format-buffer :wk "format") |
|
| 109 | + | "cF" '(my/toggle-format-on-save :wk "toggle format on save") |
|
| 54 | 110 | "cd" '(xref-find-definitions :wk "definition") |
|
| 55 | 111 | "cR" '(xref-find-references :wk "references") |
|
| 56 | 112 | "ci" '(eglot-find-implementation :wk "implementation") |
|
| 1 | - | ;;; init-mail.el -*- lexical-binding: t; -*- |
|
| 2 | - | ||
| 3 | - | ;; mu4e ships with Homebrew's `mu', not ELPA. |
|
| 4 | - | (use-package mu4e |
|
| 5 | - | :ensure nil |
|
| 6 | - | :load-path "/opt/homebrew/share/emacs/site-lisp/mu/mu4e" |
|
| 7 | - | :commands (mu4e mu4e-compose-new) |
|
| 8 | - | :config |
|
| 9 | - | (setq user-mail-address "contact@stevedylan.dev" |
|
| 10 | - | ||
| 11 | - | ;; Fetching |
|
| 12 | - | mu4e-get-mail-command "mbsync -a" |
|
| 13 | - | mu4e-update-interval 300 |
|
| 14 | - | mu4e-change-filenames-when-moving t ; required with mbsync |
|
| 15 | - | ||
| 16 | - | ;; Folders (adjust to match `mbsync -l local`) |
|
| 17 | - | mu4e-sent-folder "/local/Sent" |
|
| 18 | - | mu4e-drafts-folder "/local/Drafts" |
|
| 19 | - | mu4e-trash-folder "/local/Trash" |
|
| 20 | - | mu4e-refile-folder "/local/Archive" |
|
| 21 | - | ||
| 22 | - | ;; Sending via msmtp |
|
| 23 | - | sendmail-program (executable-find "msmtp") |
|
| 24 | - | send-mail-function #'sendmail-send-it |
|
| 25 | - | message-send-mail-function #'message-send-mail-with-sendmail |
|
| 26 | - | message-sendmail-envelope-from 'header |
|
| 27 | - | message-kill-buffer-on-exit t |
|
| 28 | - | ||
| 29 | - | ;; GPG |
|
| 30 | - | mml-secure-openpgp-sign-with-sender t ; pick key by From address |
|
| 31 | - | mml-secure-openpgp-encrypt-to-self t ; keep Sent copies readable |
|
| 32 | - | mm-verify-option 'always ; verify signatures on view |
|
| 33 | - | mm-decrypt-option 'always ; auto-decrypt on view |
|
| 34 | - | ||
| 35 | - | mu4e-maildir-shortcuts |
|
| 36 | - | '((:maildir "/local/Inbox" :key ?i) |
|
| 37 | - | (:maildir "/local/Sent" :key ?s) |
|
| 38 | - | (:maildir "/local/Drafts" :key ?d) |
|
| 39 | - | (:maildir "/local/Archive" :key ?a) |
|
| 40 | - | (:maildir "/local/Trash" :key ?t)))) |
|
| 41 | - | ||
| 42 | - | ;; Proton Bridge rewrites PGP/MIME into multipart/mixed with the armored |
|
| 43 | - | ;; block as an attachment, so Emacs won't auto-decrypt. Pull the block out |
|
| 44 | - | ;; of the raw message and decrypt it by hand. |
|
| 45 | - | (require 'mm-decode) |
|
| 46 | - | (require 'epg) |
|
| 47 | - | (require 'cl-lib) |
|
| 48 | - | ||
| 49 | - | (defun my/mail--pgp-blocks (path) |
|
| 50 | - | "Return armored PGP message strings found in the parts of PATH." |
|
| 51 | - | (with-temp-buffer |
|
| 52 | - | (insert-file-contents-literally path) |
|
| 53 | - | (let (blocks) |
|
| 54 | - | (cl-labels ((walk (h) |
|
| 55 | - | (cond ((and (consp h) (stringp (car h))) |
|
| 56 | - | (mapc #'walk (cdr h))) |
|
| 57 | - | ((and (consp h) (bufferp (car h))) |
|
| 58 | - | (let ((s (mm-get-part h))) |
|
| 59 | - | (when (string-match "-----BEGIN PGP MESSAGE-----" s) |
|
| 60 | - | (push (substring s (match-beginning 0)) blocks))))))) |
|
| 61 | - | (walk (mm-dissect-buffer t t))) |
|
| 62 | - | (nreverse blocks)))) |
|
| 63 | - | ||
| 64 | - | (defun my/mail-decrypt-bridge () |
|
| 65 | - | "Decrypt the PGP block of the mu4e message at point into a buffer." |
|
| 66 | - | (interactive) |
|
| 67 | - | (let* ((msg (mu4e-message-at-point)) |
|
| 68 | - | (blocks (or (my/mail--pgp-blocks (mu4e-message-field msg :path)) |
|
| 69 | - | (user-error "No PGP block in message"))) |
|
| 70 | - | (ctx (epg-make-context 'OpenPGP)) |
|
| 71 | - | (buf (get-buffer-create "*mail-decrypted*"))) |
|
| 72 | - | (with-current-buffer buf |
|
| 73 | - | (let ((inhibit-read-only t)) |
|
| 74 | - | (erase-buffer) |
|
| 75 | - | (dolist (b blocks) |
|
| 76 | - | (insert (decode-coding-string |
|
| 77 | - | (epg-decrypt-string ctx b) 'utf-8) |
|
| 78 | - | "\n")) |
|
| 79 | - | (goto-char (point-min)) |
|
| 80 | - | (special-mode))) |
|
| 81 | - | (pop-to-buffer buf))) |
|
| 82 | - | ||
| 83 | - | (provide 'init-mail) |
| 12 | 12 | :hook (ghostel-mode . evil-ghostel-mode)) |
|
| 13 | 13 | ||
| 14 | 14 | ;; Terminal perf tweaks, adapted from James Cherti (MIT): |
|
| 15 | - | ;; https://www.jamescherti.com/emacs-terminal-performance-vterm-eat-ansi-term-ghostel/ |
|
| 16 | 15 | (defun my/speed-up-terminal-buffer () |
|
| 17 | 16 | "Reduce unnecessary Emacs features in terminal buffers." |
|
| 18 | 17 | (let ((ghostel-buffer (derived-mode-p 'ghostel-mode))) |
| 1 | 1 | ;;; init-tools.el -*- lexical-binding: t; -*- |
|
| 2 | 2 | ||
| 3 | - | (use-package magit) |
|
| 3 | + | (use-package magit |
|
| 4 | + | :defer t) |
|
| 4 | 5 | ||
| 5 | 6 | (use-package diff-hl |
|
| 6 | 7 | :hook ((after-init . global-diff-hl-mode) |
|
| 27 | 28 | '(diff-hl-margin-delete ((t (:foreground "#aa6c6c" :background unspecified :weight bold)))))) |
|
| 28 | 29 | ||
| 29 | 30 | (use-package elfeed |
|
| 31 | + | :defer t |
|
| 30 | 32 | :config |
|
| 31 | 33 | (setq-default elfeed-search-filter "@6-months-ago") |
|
| 32 | 34 | ||
| 52 | 54 | (error (message "elfeed: feed refresh failed (%s), keeping existing list" |
|
| 53 | 55 | (error-message-string err))))) |
|
| 54 | 56 | ||
| 55 | - | ;; Fresh list before every update (`G' / `elfeed-update') |
|
| 56 | 57 | (advice-add 'elfeed-update :before #'my/elfeed-refresh-feeds) |
|
| 57 | 58 | ||
| 58 | 59 | (defun my/elfeed-show-font () |
|
| 59 | - | (face-remap-add-relative 'variable-pitch :family "BerkeleyMono Nerd Font" :height 140) |
|
| 60 | - | (face-remap-add-relative 'default :family "BerkeleyMono Nerd Font" :height 140)) |
|
| 60 | + | (face-remap-add-relative 'variable-pitch :family "BerkeleyMono Nerd Font Mono" :height 140) |
|
| 61 | + | (face-remap-add-relative 'default :family "BerkeleyMono Nerd Font Mono" :height 140)) |
|
| 61 | 62 | (add-hook 'elfeed-show-mode-hook #'my/elfeed-show-font)) |
|
| 62 | 63 | ||
| 63 | - | ;; ob-go isn't bundled with org; must load before org-babel-do-load-languages |
|
| 64 | - | (use-package ob-go) |
|
| 64 | + | (use-package ob-go |
|
| 65 | + | :defer t) |
|
| 65 | 66 | ||
| 66 | 67 | (use-package org |
|
| 67 | 68 | :ensure nil |
|
| 69 | + | :defer t |
|
| 68 | 70 | :config |
|
| 71 | + | (require 'ob-go) |
|
| 69 | 72 | (org-babel-do-load-languages |
|
| 70 | 73 | 'org-babel-load-languages |
|
| 71 | 74 | '((js . t) |
|
| 85 | 88 | "* [[%^{URL}][%^{Title}]] %^g\n:PROPERTIES:\n:ADDED: %U\n:END:\n%?" |
|
| 86 | 89 | :empty-lines 1)))) |
|
| 87 | 90 | ||
| 88 | - | ;; HTML export: darkmatter CSS from org.css, inlined so exports are self-contained |
|
| 89 | - | (use-package ox-html |
|
| 90 | - | :ensure nil |
|
| 91 | - | :after org |
|
| 92 | - | :config |
|
| 93 | - | (defun my/org-html-head () |
|
| 94 | - | "Return `org-html-head' contents with org.css inlined." |
|
| 95 | - | (let ((css (expand-file-name "org.css" user-emacs-directory))) |
|
| 96 | - | (concat "<meta name=\"theme-color\" content=\"#121113\" />\n" |
|
| 97 | - | "<style>\n" |
|
| 98 | - | (with-temp-buffer |
|
| 99 | - | (insert-file-contents css) |
|
| 100 | - | (buffer-string)) |
|
| 101 | - | "</style>"))) |
|
| 102 | - | (setq org-html-head-include-default-style nil |
|
| 103 | - | org-html-head-include-scripts nil |
|
| 104 | - | org-html-validation-link nil |
|
| 105 | - | org-html-postamble nil |
|
| 106 | - | org-html-htmlize-output-type 'css |
|
| 107 | - | org-html-head (my/org-html-head)) |
|
| 108 | - | ;; Re-read org.css on each export so edits apply without restarting |
|
| 109 | - | (advice-add 'org-html-export-as-html :before |
|
| 110 | - | (lambda (&rest _) (setq org-html-head (my/org-html-head)))) |
|
| 111 | - | (advice-add 'org-html-export-to-html :before |
|
| 112 | - | (lambda (&rest _) (setq org-html-head (my/org-html-head))))) |
|
| 113 | - | ||
| 114 | 91 | (use-package dired |
|
| 115 | 92 | :ensure nil |
|
| 116 | 93 | :custom |
|
| 126 | 103 | "l" 'dired-find-file |
|
| 127 | 104 | "q" 'quit-window)) |
|
| 128 | 105 | ||
| 129 | - | (require 'posts) |
|
| 130 | - | (require 'uguu) |
|
| 106 | + | (autoload 'posts-compose "posts" nil t) |
|
| 107 | + | (autoload 'uguu-upload-file "uguu" nil t) |
|
| 108 | + | (autoload 'uguu-upload-clipboard "uguu" nil t) |
|
| 109 | + | ||
| 110 | + | (defgroup openrouter nil |
|
| 111 | + | "OpenRouter backend for gptel." |
|
| 112 | + | :group 'gptel) |
|
| 113 | + | ||
| 114 | + | (defcustom openrouter-pass-entry "openrouter/openrouter-api-key" |
|
| 115 | + | "Name of the `pass' entry holding the API key." |
|
| 116 | + | :type 'string |
|
| 117 | + | :group 'openrouter) |
|
| 118 | + | ||
| 119 | + | (defun openrouter--api-key () |
|
| 120 | + | "Return the OpenRouter API key from password-store." |
|
| 121 | + | (require 'auth-source-pass) ; autoloaded in Emacs 28+, but cheap to be explicit |
|
| 122 | + | (let ((key (auth-source-pass-get 'secret openrouter-pass-entry))) |
|
| 123 | + | (or (and key (string-trim key)) |
|
| 124 | + | (user-error "No pass entry `%s'" openrouter-pass-entry)))) |
|
| 125 | + | ||
| 126 | + | (use-package gptel |
|
| 127 | + | :defer t |
|
| 128 | + | :config |
|
| 129 | + | (setq gptel-backend |
|
| 130 | + | (gptel-make-openai "OpenRouter" |
|
| 131 | + | :host "openrouter.ai" |
|
| 132 | + | :endpoint "/api/v1/chat/completions" |
|
| 133 | + | :stream t |
|
| 134 | + | :key #'openrouter--api-key |
|
| 135 | + | :request-params '(:tools [(:type "openrouter:web_search")]) |
|
| 136 | + | :models '(z-ai/glm-5.3 |
|
| 137 | + | z-ai/glm-5.3-flash |
|
| 138 | + | z-ai/glm-5.3-flashx)))) |
|
| 139 | + | ||
| 140 | + | (defun gptel-model (model) |
|
| 141 | + | "Set the gptel model in the current buffer." |
|
| 142 | + | (interactive |
|
| 143 | + | (list (intern (completing-read "Model: " |
|
| 144 | + | '("z-ai/glm-5.3" |
|
| 145 | + | "z-ai/glm-5.3-flash" |
|
| 146 | + | "z-ai/glm-5.3-flashx"))))) |
|
| 147 | + | (setq-local gptel-model model)) |
|
| 148 | + | ||
| 149 | + | (use-package markdown-mode |
|
| 150 | + | :defer t) |
|
| 151 | + | ||
| 131 | 152 | ||
| 132 | 153 | (provide 'init-tools) |
|
| 1 | 1 | ;;; init-ui.el -*- lexical-binding: t; -*- |
|
| 2 | 2 | ||
| 3 | 3 | (when (display-graphic-p) |
|
| 4 | - | (set-face-attribute 'default nil :family "BerkeleyMono Nerd Font" :height 140)) |
|
| 4 | + | (set-face-attribute 'default nil :family "BerkeleyMono Nerd Font Mono" :height 130)) |
|
| 5 | 5 | ||
| 6 | 6 | (use-package base16-theme) |
|
| 7 | 7 | ||
| 31 | 31 | '("?" "#666666")))) |
|
| 32 | 32 | (propertize (format " %s " letter) |
|
| 33 | 33 | 'face `(:background ,color |
|
| 34 | - | :foreground ,(alist-get 'base00 darkmatter-palette) |
|
| 35 | - | :weight bold))))) |
|
| 34 | + | :foreground ,(alist-get 'base00 darkmatter-palette) |
|
| 35 | + | :weight bold))))) |
|
| 36 | 36 | ||
| 37 | 37 | (setq-default |
|
| 38 | 38 | mode-line-format |
|
| 19 | 19 | ||
| 20 | 20 | (require 'url) |
|
| 21 | 21 | (require 'json) |
|
| 22 | + | (require 'mailcap) |
|
| 22 | 23 | (require 'subr-x) |
|
| 23 | 24 | (require 'auth-source-pass) |
|
| 24 | 25 | ||
| 33 | 34 | ||
| 34 | 35 | (defun posts--api-key () |
|
| 35 | 36 | "Return the API key from password-store." |
|
| 36 | - | (or (auth-source-pass-get 'secret posts-pass-entry) |
|
| 37 | - | (user-error "No pass entry `%s'" posts-pass-entry))) |
|
| 37 | + | ;; Encode so the header is unibyte; otherwise url-http refuses to mix |
|
| 38 | + | ;; it with a binary request body. |
|
| 39 | + | (encode-coding-string |
|
| 40 | + | (or (auth-source-pass-get 'secret posts-pass-entry) |
|
| 41 | + | (user-error "No pass entry `%s'" posts-pass-entry)) |
|
| 42 | + | 'utf-8)) |
|
| 38 | 43 | ||
| 39 | 44 | (defcustom posts-endpoint "https://posts.stevedylan.dev/api/posts" |
|
| 40 | 45 | "URL that receives the JSON post." |
|
| 41 | 46 | :type 'string |
|
| 42 | 47 | :group 'posts) |
|
| 48 | + | ||
| 49 | + | (defcustom posts-files-endpoint "https://posts.stevedylan.dev/api/files" |
|
| 50 | + | "URL that receives multipart file uploads." |
|
| 51 | + | :type 'string |
|
| 52 | + | :group 'posts) |
|
| 53 | + | ||
| 54 | + | (defconst posts--max-file-size (* 10 1024 1024) |
|
| 55 | + | "Largest file the server accepts, in bytes.") |
|
| 43 | 56 | ||
| 44 | 57 | ;;;; Fields |
|
| 45 | 58 | ||
| 132 | 145 | (kill-buffer (current-buffer)))) |
|
| 133 | 146 | nil t))) |
|
| 134 | 147 | ||
| 148 | + | ;;;; Uploading files |
|
| 149 | + | ||
| 150 | + | (defun posts--multipart-body (boundary file name) |
|
| 151 | + | "Return a unibyte multipart/form-data body for FILE using BOUNDARY. |
|
| 152 | + | NAME, when non-nil, is sent as the `name' field." |
|
| 153 | + | (let ((type (or (mailcap-file-name-to-mime-type file) |
|
| 154 | + | "application/octet-stream")) |
|
| 155 | + | (filename (replace-regexp-in-string |
|
| 156 | + | "\"" "\\\\\"" |
|
| 157 | + | (encode-coding-string (file-name-nondirectory file) 'utf-8)))) |
|
| 158 | + | (with-temp-buffer |
|
| 159 | + | (set-buffer-multibyte nil) |
|
| 160 | + | (when name |
|
| 161 | + | (insert "--" boundary "\r\n" |
|
| 162 | + | "Content-Disposition: form-data; name=\"name\"\r\n\r\n" |
|
| 163 | + | (encode-coding-string name 'utf-8) "\r\n")) |
|
| 164 | + | (insert "--" boundary "\r\n" |
|
| 165 | + | "Content-Disposition: form-data; name=\"file\"; filename=\"" |
|
| 166 | + | filename "\"\r\n" |
|
| 167 | + | "Content-Type: " type "\r\n\r\n") |
|
| 168 | + | (insert-file-contents-literally file) |
|
| 169 | + | (goto-char (point-max)) |
|
| 170 | + | (insert "\r\n--" boundary "--\r\n") |
|
| 171 | + | (buffer-string)))) |
|
| 172 | + | ||
| 173 | + | (defun posts--response-json () |
|
| 174 | + | "Parse the JSON body of the current HTTP response buffer, or nil." |
|
| 175 | + | (goto-char (point-min)) |
|
| 176 | + | (when (re-search-forward "\r?\n\r?\n" nil t) |
|
| 177 | + | (ignore-errors (json-parse-buffer :object-type 'alist)))) |
|
| 178 | + | ||
| 179 | + | (defun posts-upload-file (file &optional name callback) |
|
| 180 | + | "Upload FILE to `posts-files-endpoint'. |
|
| 181 | + | NAME, if non-empty, sets the stored filename. On success the file's |
|
| 182 | + | URL is copied to the kill ring and CALLBACK, if non-nil, is called |
|
| 183 | + | with the parsed response alist." |
|
| 184 | + | (interactive |
|
| 185 | + | (list (read-file-name "Upload file: " nil nil t) |
|
| 186 | + | (read-string "Name (optional): "))) |
|
| 187 | + | (setq file (expand-file-name file)) |
|
| 188 | + | (unless (file-regular-p file) |
|
| 189 | + | (user-error "Not a regular file: %s" file)) |
|
| 190 | + | (when (> (file-attribute-size (file-attributes file)) posts--max-file-size) |
|
| 191 | + | (user-error "File exceeds 10 MB: %s" file)) |
|
| 192 | + | (when (and name (string-empty-p (string-trim name))) |
|
| 193 | + | (setq name nil)) |
|
| 194 | + | (let* ((boundary (format "posts-%s" (md5 (format "%s%s" (random) (float-time))))) |
|
| 195 | + | (url-request-method "POST") |
|
| 196 | + | (url-request-extra-headers |
|
| 197 | + | `(("Content-Type" . ,(encode-coding-string |
|
| 198 | + | (concat "multipart/form-data; boundary=" boundary) |
|
| 199 | + | 'utf-8)) |
|
| 200 | + | ("X-API-Key" . ,(posts--api-key)))) |
|
| 201 | + | (url-request-data (posts--multipart-body boundary file name))) |
|
| 202 | + | (message "Uploading %s..." (file-name-nondirectory file)) |
|
| 203 | + | (url-retrieve |
|
| 204 | + | posts-files-endpoint |
|
| 205 | + | (lambda (status) |
|
| 206 | + | (unwind-protect |
|
| 207 | + | (let ((err (plist-get status :error)) |
|
| 208 | + | (resp (posts--response-json))) |
|
| 209 | + | (cond |
|
| 210 | + | ((equal err '(error http 409)) |
|
| 211 | + | (message "Upload failed: name `%s' is already taken" name)) |
|
| 212 | + | (err |
|
| 213 | + | (message "Upload error: %S%s" err |
|
| 214 | + | (if resp (format " %S" resp) ""))) |
|
| 215 | + | ((null (alist-get 'url resp)) |
|
| 216 | + | (message "Uploaded (unexpected response)")) |
|
| 217 | + | (t |
|
| 218 | + | (kill-new (alist-get 'url resp)) |
|
| 219 | + | (message "Uploaded: %s (copied)" (alist-get 'url resp)) |
|
| 220 | + | (when callback (funcall callback resp))))) |
|
| 221 | + | (kill-buffer (current-buffer)))) |
|
| 222 | + | nil t))) |
|
| 223 | + | ||
| 135 | 224 | ;;;; Compose buffer |
|
| 136 | 225 | ||
| 137 | 226 | (defvar posts-compose-mode-map |
|
| 138 | 227 | (let ((m (make-sparse-keymap))) |
|
| 139 | 228 | (define-key m (kbd "C-c C-c") #'posts-compose-submit) |
|
| 140 | 229 | (define-key m (kbd "C-c C-k") #'posts-compose-cancel) |
|
| 230 | + | (define-key m (kbd "C-c C-a") #'posts-compose-attach) |
|
| 141 | 231 | m) |
|
| 142 | 232 | "Keymap for `posts-compose-mode'.") |
|
| 143 | 233 | ||
| 145 | 235 | "Compose a post. Leading `name: value' lines are fields, the rest is content. |
|
| 146 | 236 | \\{posts-compose-mode-map}" |
|
| 147 | 237 | (setq header-line-format |
|
| 148 | - | "Fields as `name: value' lines, then content. C-c C-c to send, C-c C-k to cancel")) |
|
| 238 | + | "Fields as `name: value' lines, then content. C-c C-c send, C-c C-a attach file, C-c C-k cancel")) |
|
| 149 | 239 | ||
| 150 | 240 | ;;;###autoload |
|
| 151 | 241 | (defun posts-compose () |
|
| 170 | 260 | (user-error "Content is empty")) |
|
| 171 | 261 | (posts fields content) |
|
| 172 | 262 | (quit-window t))) |
|
| 263 | + | ||
| 264 | + | (defun posts-compose-attach (file &optional name) |
|
| 265 | + | "Upload FILE (stored as NAME) and insert a Markdown link at point. |
|
| 266 | + | Images are inserted as `'." |
|
| 267 | + | (interactive |
|
| 268 | + | (list (read-file-name "Attach file: " nil nil t) |
|
| 269 | + | (read-string "Name (optional): "))) |
|
| 270 | + | (let ((marker (point-marker))) |
|
| 271 | + | (posts-upload-file |
|
| 272 | + | file name |
|
| 273 | + | (lambda (resp) |
|
| 274 | + | (when (buffer-live-p (marker-buffer marker)) |
|
| 275 | + | (with-current-buffer (marker-buffer marker) |
|
| 276 | + | (save-excursion |
|
| 277 | + | (goto-char marker) |
|
| 278 | + | (insert (format "%s[%s](%s)" |
|
| 279 | + | (if (string-prefix-p "image/" (or (alist-get 'content_type resp) "")) |
|
| 280 | + | "!" "") |
|
| 281 | + | (or (alist-get 'original_name resp) |
|
| 282 | + | (alist-get 'filename resp) "") |
|
| 283 | + | (alist-get 'url resp)))))))))) |
|
| 173 | 284 | ||
| 174 | 285 | (defun posts-compose-cancel () |
|
| 175 | 286 | "Discard the compose buffer." |
|
| 1 | - | /* Darkmatter theme for org HTML export (inlined by init-tools.el) */ |
|
| 2 | - | ||
| 3 | - | @font-face { |
|
| 4 | - | font-family: "Commit Mono"; |
|
| 5 | - | src: local("Commit Mono"), local("CommitMono-400-Regular"); |
|
| 6 | - | font-weight: 400; |
|
| 7 | - | font-style: normal; |
|
| 8 | - | } |
|
| 9 | - | ||
| 10 | - | @font-face { |
|
| 11 | - | font-family: "Commit Mono"; |
|
| 12 | - | src: local("Commit Mono Bold"), local("CommitMono-700-Regular"); |
|
| 13 | - | font-weight: 700; |
|
| 14 | - | font-style: normal; |
|
| 15 | - | } |
|
| 16 | - | ||
| 17 | - | * { |
|
| 18 | - | padding: 0; |
|
| 19 | - | margin: 0; |
|
| 20 | - | box-sizing: border-box; |
|
| 21 | - | font-family: "Commit Mono", monospace, sans-serif; |
|
| 22 | - | scrollbar-width: none; |
|
| 23 | - | -ms-overflow-style: none; |
|
| 24 | - | } |
|
| 25 | - | ||
| 26 | - | html { |
|
| 27 | - | background: #121113; |
|
| 28 | - | color: #ffffff; |
|
| 29 | - | font-size: 14px; |
|
| 30 | - | line-height: 1.6; |
|
| 31 | - | } |
|
| 32 | - | ||
| 33 | - | html::-webkit-scrollbar { |
|
| 34 | - | display: none; |
|
| 35 | - | } |
|
| 36 | - | ||
| 37 | - | body { |
|
| 38 | - | max-width: 700px; |
|
| 39 | - | margin: auto; |
|
| 40 | - | padding: 0 1rem 4rem; |
|
| 41 | - | } |
|
| 42 | - | ||
| 43 | - | @media (max-width: 480px) { |
|
| 44 | - | body { |
|
| 45 | - | padding: 1rem; |
|
| 46 | - | } |
|
| 47 | - | } |
|
| 48 | - | ||
| 49 | - | a { |
|
| 50 | - | color: #ffffff; |
|
| 51 | - | text-decoration: none; |
|
| 52 | - | } |
|
| 53 | - | ||
| 54 | - | a:hover { |
|
| 55 | - | opacity: 0.7; |
|
| 56 | - | } |
|
| 57 | - | ||
| 58 | - | #content { |
|
| 59 | - | display: flex; |
|
| 60 | - | flex-direction: column; |
|
| 61 | - | gap: 1rem; |
|
| 62 | - | } |
|
| 63 | - | ||
| 64 | - | /* Title */ |
|
| 65 | - | .title { |
|
| 66 | - | margin-top: 2rem; |
|
| 67 | - | padding-bottom: 1rem; |
|
| 68 | - | border-bottom: 1px solid #333; |
|
| 69 | - | font-size: 28px; |
|
| 70 | - | font-weight: 700; |
|
| 71 | - | text-transform: uppercase; |
|
| 72 | - | text-align: left; |
|
| 73 | - | } |
|
| 74 | - | ||
| 75 | - | .subtitle { |
|
| 76 | - | font-size: 12px; |
|
| 77 | - | opacity: 0.5; |
|
| 78 | - | } |
|
| 79 | - | ||
| 80 | - | /* Headings */ |
|
| 81 | - | h1, h2, h3, h4, h5, h6 { |
|
| 82 | - | font-weight: 700; |
|
| 83 | - | } |
|
| 84 | - | ||
| 85 | - | h1 { font-size: 18px; } |
|
| 86 | - | h2 { font-size: 16px; margin-top: 1rem; } |
|
| 87 | - | h3 { font-size: 15px; } |
|
| 88 | - | h4, h5, h6 { font-size: 14px; } |
|
| 89 | - | ||
| 90 | - | .section-number-2, |
|
| 91 | - | .section-number-3, |
|
| 92 | - | .section-number-4 { |
|
| 93 | - | opacity: 0.5; |
|
| 94 | - | } |
|
| 95 | - | ||
| 96 | - | .outline-2, .outline-3, .outline-4, .outline-text-2, .outline-text-3, .outline-text-4 { |
|
| 97 | - | display: flex; |
|
| 98 | - | flex-direction: column; |
|
| 99 | - | gap: 0.75rem; |
|
| 100 | - | } |
|
| 101 | - | ||
| 102 | - | /* Text */ |
|
| 103 | - | p, li { |
|
| 104 | - | font-size: 14px; |
|
| 105 | - | } |
|
| 106 | - | ||
| 107 | - | ul, ol { |
|
| 108 | - | padding-left: 1.5rem; |
|
| 109 | - | } |
|
| 110 | - | ||
| 111 | - | li + li { |
|
| 112 | - | margin-top: 0.25rem; |
|
| 113 | - | } |
|
| 114 | - | ||
| 115 | - | b, strong { font-weight: 700; } |
|
| 116 | - | i, em { font-style: italic; } |
|
| 117 | - | del { opacity: 0.5; } |
|
| 118 | - | ||
| 119 | - | .timestamp, .timestamp-kwd, .timestamp-wrapper { |
|
| 120 | - | font-size: 12px; |
|
| 121 | - | opacity: 0.5; |
|
| 122 | - | } |
|
| 123 | - | ||
| 124 | - | .tag { |
|
| 125 | - | font-size: 12px; |
|
| 126 | - | opacity: 0.5; |
|
| 127 | - | float: right; |
|
| 128 | - | } |
|
| 129 | - | ||
| 130 | - | .tag span { |
|
| 131 | - | background: none; |
|
| 132 | - | font-weight: 400; |
|
| 133 | - | } |
|
| 134 | - | ||
| 135 | - | /* TODO keywords: no color, weight/opacity only */ |
|
| 136 | - | .todo, .done { |
|
| 137 | - | font-size: 12px; |
|
| 138 | - | font-weight: 700; |
|
| 139 | - | text-transform: uppercase; |
|
| 140 | - | } |
|
| 141 | - | ||
| 142 | - | .done { |
|
| 143 | - | opacity: 0.5; |
|
| 144 | - | } |
|
| 145 | - | ||
| 146 | - | /* Code */ |
|
| 147 | - | code { |
|
| 148 | - | background: #1e1c1f; |
|
| 149 | - | padding: 0.1rem 0.3rem; |
|
| 150 | - | font-size: 13px; |
|
| 151 | - | } |
|
| 152 | - | ||
| 153 | - | pre { |
|
| 154 | - | background: #1e1c1f; |
|
| 155 | - | color: #ffffff; |
|
| 156 | - | border: none; |
|
| 157 | - | border-radius: 0; |
|
| 158 | - | box-shadow: none; |
|
| 159 | - | padding: 0.75rem 1rem; |
|
| 160 | - | font-size: 13px; |
|
| 161 | - | overflow-x: auto; |
|
| 162 | - | white-space: pre; |
|
| 163 | - | } |
|
| 164 | - | ||
| 165 | - | pre code { |
|
| 166 | - | background: none; |
|
| 167 | - | padding: 0; |
|
| 168 | - | } |
|
| 169 | - | ||
| 170 | - | pre.src:before { |
|
| 171 | - | display: none; |
|
| 172 | - | } |
|
| 173 | - | ||
| 174 | - | /* htmlize classes (needs org-html-htmlize-output-type 'css) */ |
|
| 175 | - | pre span[class^="org-"] { |
|
| 176 | - | color: #ffffff; |
|
| 177 | - | background: none; |
|
| 178 | - | font-weight: 400; |
|
| 179 | - | font-style: normal; |
|
| 180 | - | } |
|
| 181 | - | ||
| 182 | - | pre span.org-comment, |
|
| 183 | - | pre span.org-comment-delimiter, |
|
| 184 | - | pre span.org-doc { |
|
| 185 | - | opacity: 0.5; |
|
| 186 | - | font-style: italic; |
|
| 187 | - | } |
|
| 188 | - | ||
| 189 | - | pre span.org-keyword, |
|
| 190 | - | pre span.org-function-name, |
|
| 191 | - | pre span.org-type { |
|
| 192 | - | font-weight: 700; |
|
| 193 | - | } |
|
| 194 | - | ||
| 195 | - | pre span.org-string { |
|
| 196 | - | opacity: 0.7; |
|
| 197 | - | } |
|
| 198 | - | ||
| 199 | - | /* Blockquote */ |
|
| 200 | - | blockquote { |
|
| 201 | - | border-left: 2px solid #555; |
|
| 202 | - | padding-left: 0.75rem; |
|
| 203 | - | opacity: 0.7; |
|
| 204 | - | } |
|
| 205 | - | ||
| 206 | - | blockquote p { |
|
| 207 | - | margin: 0; |
|
| 208 | - | } |
|
| 209 | - | ||
| 210 | - | /* Tables */ |
|
| 211 | - | table { |
|
| 212 | - | border-collapse: collapse; |
|
| 213 | - | width: 100%; |
|
| 214 | - | border: none; |
|
| 215 | - | } |
|
| 216 | - | ||
| 217 | - | table caption { |
|
| 218 | - | font-size: 12px; |
|
| 219 | - | opacity: 0.5; |
|
| 220 | - | text-align: left; |
|
| 221 | - | margin-bottom: 0.25rem; |
|
| 222 | - | } |
|
| 223 | - | ||
| 224 | - | th, td { |
|
| 225 | - | padding: 0.4rem 0.75rem 0.4rem 0; |
|
| 226 | - | border: none; |
|
| 227 | - | border-bottom: 1px solid #333; |
|
| 228 | - | text-align: left; |
|
| 229 | - | } |
|
| 230 | - | ||
| 231 | - | th { |
|
| 232 | - | opacity: 0.5; |
|
| 233 | - | font-weight: 400; |
|
| 234 | - | font-size: 12px; |
|
| 235 | - | text-transform: uppercase; |
|
| 236 | - | } |
|
| 237 | - | ||
| 238 | - | /* Misc */ |
|
| 239 | - | hr { |
|
| 240 | - | border: none; |
|
| 241 | - | border-top: 1px solid #333; |
|
| 242 | - | } |
|
| 243 | - | ||
| 244 | - | img { |
|
| 245 | - | max-width: 100%; |
|
| 246 | - | border-radius: 0; |
|
| 247 | - | } |
|
| 248 | - | ||
| 249 | - | figure { |
|
| 250 | - | display: flex; |
|
| 251 | - | flex-direction: column; |
|
| 252 | - | gap: 0.25rem; |
|
| 253 | - | } |
|
| 254 | - | ||
| 255 | - | figcaption, .figure-number { |
|
| 256 | - | font-size: 12px; |
|
| 257 | - | opacity: 0.5; |
|
| 258 | - | } |
|
| 259 | - | ||
| 260 | - | .footnotes, #footnotes { |
|
| 261 | - | border-top: 1px solid #333; |
|
| 262 | - | padding-top: 0.75rem; |
|
| 263 | - | font-size: 12px; |
|
| 264 | - | } |
|
| 265 | - | ||
| 266 | - | .footdef { |
|
| 267 | - | opacity: 0.7; |
|
| 268 | - | } |
|
| 269 | - | ||
| 270 | - | sup a, .footref { |
|
| 271 | - | font-size: 12px; |
|
| 272 | - | } |
|
| 273 | - | ||
| 274 | - | /* TOC */ |
|
| 275 | - | #table-of-contents { |
|
| 276 | - | border-bottom: 1px solid #333; |
|
| 277 | - | padding-bottom: 1rem; |
|
| 278 | - | } |
|
| 279 | - | ||
| 280 | - | #table-of-contents h2 { |
|
| 281 | - | font-size: 12px; |
|
| 282 | - | text-transform: uppercase; |
|
| 283 | - | opacity: 0.5; |
|
| 284 | - | margin-top: 0; |
|
| 285 | - | } |
|
| 286 | - | ||
| 287 | - | #text-table-of-contents ul { |
|
| 288 | - | list-style: none; |
|
| 289 | - | padding-left: 1rem; |
|
| 290 | - | } |
|
| 291 | - | ||
| 292 | - | #text-table-of-contents > ul { |
|
| 293 | - | padding-left: 0; |
|
| 294 | - | } |
|
| 295 | - | ||
| 296 | - | /* Postamble */ |
|
| 297 | - | #postamble, .postamble { |
|
| 298 | - | font-size: 12px; |
|
| 299 | - | opacity: 0.5; |
|
| 300 | - | } |
| 89 | 89 | ||
| 90 | 90 | ;; Fringe/line numbers share the main background, like doom-darkmatter |
|
| 91 | 91 | (setq base16-theme-distinct-fringe-background nil) |
|
| 92 | + | ;; In a tty base16 defaults to the terminal's ANSI palette by name |
|
| 93 | + | ;; (base02 -> brightyellow, i.e. orange in ghostty), so map our hex |
|
| 94 | + | ;; colors to the nearest 256-color instead. |
|
| 95 | + | (setq base16-theme-256-color-source 'colors) |
|
| 92 | 96 | ||
| 93 | 97 | (base16-theme-define |
|
| 94 | 98 | 'darkmatter |