Files
sydnix/users/crumb/programs/emacs/modules/syd-ui.el
Madeleine Sydney d203a71aaa feat: Encryption
2025-02-18 15:59:17 -07:00

123 lines
4.6 KiB
EmacsLisp
Executable File

;;; syd-ui.el -*- lexical-binding: t; -*-
(require 'syd-prelude)
(defvar syd-fixed-pitch-font
(font-spec :family "VictorMono Nerd Font" :size 13)
"Default fixed-pitch (monospace) font.")
(defvar syd-variable-pitch-font
(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
(load-theme 'kanagawa-wave t))
(defun syd-init-fonts-h ()
"Loads `syd-fixed-pitch-font' and `syd-variable-pitch-font'."
(dolist (map `((default . ,syd-fixed-pitch-font)
(fixed-pitch . ,syd-fixed-pitch-font)
(variable-pitch . ,syd-variable-pitch-font)))
(pcase-let ((`(,face . ,font) map))
(set-face-attribute face nil
:width 'normal :weight 'normal
:slant 'normal :font font))))
(defun syd-configure-default-frame-h ()
"Customise the default frame, primarily by adding to `default-frame-alist'."
;; Maximise the frame.
;; (add-to-list 'default-frame-alist '(fullscreen . maximized))
;; Disable the titlebar and borders (decorations).
(add-to-list 'default-frame-alist '(undecorated . t)))
(let ((hook (if (daemonp)
'server-after-make-frame-hook
'after-init-hook)))
(add-hook hook #'syd-init-fonts-h)
(add-hook hook #'syd-configure-default-frame-h))
;; Use JuliaMono as a fallback for some glyphs that VictorMono does not cover.
(dolist (char-range '((#x0250 . #x02af) ; IPA extensions
(#x2200 . #x22FF))) ; Mathematical operators
(set-fontset-font "fontset-default" char-range "JuliaMono"))
(use-package emacs
;; Display (relative) line numbers only in prog-mode derivatives.
:hook ((prog-mode-hook . display-line-numbers-mode)
;; (on-init-ui-hook . syd-configure-default-frame-h)
;; (on-init-ui-hook . syd-init-fonts-h)
)
:custom ((display-line-numbers-type 'relative)
;; Always ask "y/n"; never "yes/no".
(use-short-answers t)
;; I don't like that `grep' asks me to save unsaved files. It makes
;; me think it's about to kill my buffers.
(grep-save-buffers nil)
;; The default value is `ask', meaning that Emacs will ask for
;; confirmation any time you follow a symlink to a file under version
;; control. The documentation claims this is "dangerous, and
;; probably not what you want;" I personally don't see it, and it's
;; usually what I want.
(vc-follow-symlinks t)
;; Log native-compiler warnings, but don't display the
;; buffer. Most of the warnings are "`X' is not known to
;; be defined" which are typically nothing worth concerning.
(native-comp-async-report-warnings-errors 'silent)
;; Don't recenter the view unless >10 lines are scrolled off-screen
;; in a single movement.
(scroll-conservatively 10)
;; In modes making use of `recenter-top-bottom' (e.g. Comint,
;; Eshell), this will make the command behave more like a plain old
;; `clear` invocation.
(recenter-positions '(top)))
:config
;; Disable the menu bar, scroll bar, and tool bar.
(menu-bar-mode -1)
(scroll-bar-mode -1)
(tool-bar-mode -1))
(use-package persp-mode
:disabled
:unless noninteractive
:commands persp-switch-to-buffer
:hook (on-init-ui-hook . persp-mode)
:config
(setq persp-autokill-buffer-on-remove 'kill-weak
persp-reset-windows-on-nil-window-conf nil
persp-nil-hidden t
persp-auto-save-fname "autosave"
persp-save-dir (concat syd-data-dir "workspaces/")
persp-set-last-persp-for-new-frames t
persp-switch-to-added-buffer nil
persp-kill-foreign-buffer-behaviour 'kill
persp-remove-buffers-from-nil-persp-behaviour nil
persp-auto-resume-time -1 ; Don't auto-load on startup
persp-auto-save-opt (if noninteractive 0 1)))
(syd-add-hook 'on-init-ui-hook
(defun syd-init-ui-hacks ()
(set-popup-rule! "*Backtrace*"
:size #'doom-popup-shrink-to-fit)
(set-popup-rule! "*Messages*"
:ttl nil
:quit t)
;; Required for :quit t to do anything.
(evil-set-initial-state 'messages-buffer-mode 'motion)
(evil-set-initial-state 'debugger-mode 'normal)))
(provide 'syd-ui)