commit 01d0687853d8d8f5b6330e1f4868ab44f4949c9e from: mtmn date: Mon Jul 20 16:55:26 2026 UTC change font, install circadian commit - 9c43bba67ceb79cb34f77ed711a4669cf969e0d4 commit + 01d0687853d8d8f5b6330e1f4868ab44f4949c9e blob - 484e6fb55de85eb718970acacd03a10aee071f70 blob + eb3e791886ef36bb9c4246cf14e0633805fbb86a --- README.md +++ README.md @@ -6,7 +6,7 @@ Somewhat minimal and evilified configuration set based ```sh git clone https://git.sr.ht/~mtmn/emacs ~/.config/emacs -emacs --tty +emacs ``` Run and profit. blob - 190800e7c5adb5f2661c0794bdcb39f6d6cf1f0b blob + 64f55fd228a5a0582d8c89894c334ad7cce4f0e9 --- config.org +++ config.org @@ -11,11 +11,18 @@ #+begin_src emacs-lisp :tangle early-init.el ;;; early-init.el --- Early startup tweaks -*- lexical-binding: t; -*- + ;; Crank GC and disable the file-name handler for the duration of startup; + ;; both are restored to sane runtime values on `emacs-startup-hook' below. (setq bedrock--initial-gc-threshold gc-cons-threshold - gc-cons-threshold 10000000 + bedrock--initial-file-name-handler-alist file-name-handler-alist + gc-cons-threshold most-positive-fixnum + gc-cons-percentage 0.6 + file-name-handler-alist nil byte-compile-warnings '(not obsolete) warning-suppress-log-types '((comp) (bytecomp)) native-comp-async-report-warnings-errors 'silent + native-comp-async-jobs-number (max 1 (1- (num-processors))) + native-comp-jit-compilation t inhibit-startup-echo-area-message (user-login-name) frame-resize-pixelwise t package-enable-at-startup nil @@ -24,10 +31,18 @@ straight-use-package-by-default nil straight-vc-git-default-clone-depth 1 default-frame-alist '((fullscreen . maximized) - (font . "PragmataPro Mono-14") + (font . "Go Mono-14") (internal-border-width . 0) (undecorated . t))) + (defun bedrock--restore-startup-defaults () + "Restore GC threshold, GC percentage, and `file-name-handler-alist'." + (setq gc-cons-threshold (* 128 1024 1024) + gc-cons-percentage 0.1 + file-name-handler-alist bedrock--initial-file-name-handler-alist)) + + (add-hook 'emacs-startup-hook #'bedrock--restore-startup-defaults) + (when (featurep 'pgtk) (setq default-frame-alist (append '((inhibit-double-buffering . nil) @@ -79,22 +94,27 @@ (tool-bar-mode -1) (menu-bar-mode -1) (scroll-bar-mode -1) - (set-frame-parameter nil 'font "PragmataPro Mono-14")) + (set-frame-parameter nil 'font "Go Mono-14")) (unless (display-graphic-p) (xterm-mouse-mode 1)) (cua-mode 1) - (add-hook 'prog-mode-hook #'display-line-numbers-mode) (setopt display-line-numbers-width 3) - + (add-hook 'prog-mode-hook #'display-line-numbers-mode) (add-hook 'text-mode-hook #'visual-line-mode) - (dolist (hook '(text-mode-hook prog-mode-hook)) (add-hook hook #'hl-line-mode)) (setopt tab-bar-show 1) + + ;; Start the Emacs server if it is not already running so `emacsclient' can + ;; attach to this session. Remove the server socket when this Emacs exits. + (require 'server) + (unless (server-running-p) + (server-start)) + (add-hook 'kill-emacs-hook #'server-force-delete) #+end_src * Backup and autosave @@ -134,6 +154,7 @@ (use-package which-key :straight t + :defer 1 :config (which-key-mode)) (add-to-list 'tab-bar-format 'tab-bar-format-align-right 'append) @@ -180,6 +201,16 @@ (org-mode . diff-hl-mode)) :config (global-diff-hl-show-hunk-mouse-mode)) + + (use-package circadian + :straight (circadian :type git :host github :repo "guidoschmidt/circadian.el") + :demand t + :config + (setopt calendar-latitude 48.1386) + (setopt calendar-longitude 17.1053) + (setopt circadian-themes '((:sunrise . ef-orange) + (:sunset . modus-vivendi))) + (circadian-setup)) #+end_src * Completion @@ -223,20 +254,8 @@ (use-package embark :straight t - :demand t :after consult - :bind (("C-c a" . embark-act)) - :init - (defun bedrock-avy-action-embark (pt) - "Run `embark-act' at PT, then restore the window avy jumped from." - (unwind-protect - (save-excursion - (goto-char pt) - (embark-act)) - (select-window - (cdr (ring-ref avy-ring 0)))) - t) - (setf (alist-get ?. avy-dispatch-alist) #'bedrock-avy-action-embark)) + :bind (("C-c a" . embark-act))) (use-package embark-consult :straight t @@ -250,7 +269,9 @@ (with-eval-after-load 'corfu (setopt corfu-popupinfo-delay '(0.25 . 0.1) - corfu-popupinfo-hide nil) + corfu-popupinfo-hide nil + corfu-popupinfo-max-width 80 + corfu-popupinfo-max-height 20) (corfu-popupinfo-mode)) (use-package corfu-terminal @@ -281,9 +302,19 @@ #+begin_src emacs-lisp (use-package avy :straight t - :demand t :bind (("C-c j" . avy-goto-line) - ("s-j" . avy-goto-char-timer))) + ("s-j" . avy-goto-char-timer)) + :config + (defun bedrock-avy-action-embark (pt) + "Run `embark-act' at PT, then restore the window avy jumped from." + (unwind-protect + (save-excursion + (goto-char pt) + (embark-act)) + (select-window + (cdr (ring-ref avy-ring 0)))) + t) + (setf (alist-get ?. avy-dispatch-alist) #'bedrock-avy-action-embark)) #+end_src * Evil @@ -381,6 +412,7 @@ (use-package eat :straight t + :after eshell :custom (eat-term-name "xterm") :config @@ -391,12 +423,14 @@ * Development core #+begin_src emacs-lisp - (setq major-mode-remap-alist - '((yaml-mode . yaml-ts-mode) - (bash-mode . bash-ts-mode) - (json-mode . json-ts-mode) - (css-mode . css-ts-mode) - (python-mode . python-ts-mode))) + (use-package treesit-auto + :straight t + :demand t + :custom + (treesit-auto-install t) + :config + (treesit-auto-add-to-auto-mode-alist 'all) + (global-treesit-auto-mode)) (add-hook 'prog-mode-hook #'electric-pair-mode) @@ -413,26 +447,32 @@ #+begin_src emacs-lisp (use-package yaml-mode - :straight t) + :straight t + :mode "\\.ya?ml\\'") (use-package json-mode - :straight t) + :straight t + :mode "\\.json\\'") (use-package nix-mode :straight t :mode "\\.nix\\'") (use-package go-mode - :straight t) + :straight t + :mode "\\.go\\'") (use-package zig-mode - :straight t) + :straight t + :mode "\\.zig\\'") (use-package rust-mode - :straight t) + :straight t + :mode "\\.rs\\'") (use-package elixir-mode - :straight t) + :straight t + :mode ("\\.exs?\\'" "mix\\.lock\\'")) #+end_src * LSP @@ -596,6 +636,7 @@ (keymap-set global-map "C-c f" file-prefix-map) (keymap-set file-prefix-map "f" #'project-find-file) (keymap-set file-prefix-map "r" #'consult-recent-file) + (keymap-set file-prefix-map "h" #'consult-recent-file) (keymap-set file-prefix-map "g" #'consult-ripgrep) (defvar-keymap git-prefix-map @@ -644,6 +685,10 @@ (keymap-set corfu-map "C-SPC" #'corfu-complete) (keymap-set corfu-map "C-e" #'corfu-quit) (keymap-set corfu-map "RET" #'corfu-complete)) + + (with-eval-after-load 'evil + (evil-set-leader '(normal visual) (kbd "SPC")) + (evil-define-key '(normal visual) 'global (kbd "fh") #'consult-recent-file)) #+end_src * Personal extras @@ -683,5 +728,8 @@ * Finalize #+begin_src emacs-lisp - (setq gc-cons-threshold (or bedrock--initial-gc-threshold 800000)) + ;; GC and the file-name handler are restored on `emacs-startup-hook' + ;; (see early-init). Larger process reads make eglot/LSP feel snappier. + (setopt read-process-output-max (* 4 1024 1024) + process-adaptive-read-buffering nil) #+end_src blob - 53afeb1336026bba6cbbe77414c9460a81a9bd99 blob + 736348b6f623f178e6de6dbcd8331734e36fa044 --- early-init.el +++ early-init.el @@ -1,10 +1,17 @@ ;;; early-init.el --- Early startup tweaks -*- lexical-binding: t; -*- +;; Crank GC and disable the file-name handler for the duration of startup; +;; both are restored to sane runtime values on `emacs-startup-hook' below. (setq bedrock--initial-gc-threshold gc-cons-threshold - gc-cons-threshold 10000000 + bedrock--initial-file-name-handler-alist file-name-handler-alist + gc-cons-threshold most-positive-fixnum + gc-cons-percentage 0.6 + file-name-handler-alist nil byte-compile-warnings '(not obsolete) warning-suppress-log-types '((comp) (bytecomp)) native-comp-async-report-warnings-errors 'silent + native-comp-async-jobs-number (max 1 (1- (num-processors))) + native-comp-jit-compilation t inhibit-startup-echo-area-message (user-login-name) frame-resize-pixelwise t package-enable-at-startup nil @@ -13,10 +20,18 @@ straight-use-package-by-default nil straight-vc-git-default-clone-depth 1 default-frame-alist '((fullscreen . maximized) - (font . "PragmataPro Mono-14") + (font . "Go Mono-14") (internal-border-width . 0) (undecorated . t))) +(defun bedrock--restore-startup-defaults () + "Restore GC threshold, GC percentage, and `file-name-handler-alist'." + (setq gc-cons-threshold (* 128 1024 1024) + gc-cons-percentage 0.1 + file-name-handler-alist bedrock--initial-file-name-handler-alist)) + +(add-hook 'emacs-startup-hook #'bedrock--restore-startup-defaults) + (when (featurep 'pgtk) (setq default-frame-alist (append '((inhibit-double-buffering . nil) blob - 80468f6f97a8bd2bbbdcdb5a514367f3025b6772 blob + fc0d6353b586367a4b8757c52c851e55e6dbd7dc --- init.el +++ init.el @@ -24,23 +24,28 @@ (tool-bar-mode -1) (menu-bar-mode -1) (scroll-bar-mode -1) - (set-frame-parameter nil 'font "PragmataPro Mono-14")) + (set-frame-parameter nil 'font "Go Mono-14")) (unless (display-graphic-p) (xterm-mouse-mode 1)) (cua-mode 1) -(add-hook 'prog-mode-hook #'display-line-numbers-mode) (setopt display-line-numbers-width 3) - +(add-hook 'prog-mode-hook #'display-line-numbers-mode) (add-hook 'text-mode-hook #'visual-line-mode) - (dolist (hook '(text-mode-hook prog-mode-hook)) (add-hook hook #'hl-line-mode)) (setopt tab-bar-show 1) +;; Start the Emacs server if it is not already running so `emacsclient' can +;; attach to this session. Remove the server socket when this Emacs exits. +(require 'server) +(unless (server-running-p) + (server-start)) +(add-hook 'kill-emacs-hook #'server-force-delete) + (defun bedrock--backup-file-name (fpath) "Return a backup path for FPATH, creating parent dirs if needed." (let* ((backup-root-dir (concat user-emacs-directory "emacs-backup/")) @@ -71,6 +76,7 @@ (use-package which-key :straight t + :defer 1 :config (which-key-mode)) (add-to-list 'tab-bar-format 'tab-bar-format-align-right 'append) @@ -110,6 +116,16 @@ :config (global-diff-hl-show-hunk-mouse-mode)) +(use-package circadian + :straight (circadian :type git :host github :repo "guidoschmidt/circadian.el") + :demand t + :config + (setopt calendar-latitude 48.1386) + (setopt calendar-longitude 17.1053) + (setopt circadian-themes '((:sunrise . ef-orange) + (:sunset . modus-vivendi))) + (circadian-setup)) + (setopt completion-cycle-threshold 3) (setopt tab-always-indent 'complete) @@ -148,20 +164,8 @@ (use-package embark :straight t - :demand t :after consult - :bind (("C-c a" . embark-act)) - :init - (defun bedrock-avy-action-embark (pt) - "Run `embark-act' at PT, then restore the window avy jumped from." - (unwind-protect - (save-excursion - (goto-char pt) - (embark-act)) - (select-window - (cdr (ring-ref avy-ring 0)))) - t) - (setf (alist-get ?. avy-dispatch-alist) #'bedrock-avy-action-embark)) + :bind (("C-c a" . embark-act))) (use-package embark-consult :straight t @@ -175,7 +179,9 @@ (with-eval-after-load 'corfu (setopt corfu-popupinfo-delay '(0.25 . 0.1) - corfu-popupinfo-hide nil) + corfu-popupinfo-hide nil + corfu-popupinfo-max-width 80 + corfu-popupinfo-max-height 20) (corfu-popupinfo-mode)) (use-package corfu-terminal @@ -202,9 +208,19 @@ (use-package avy :straight t - :demand t :bind (("C-c j" . avy-goto-line) - ("s-j" . avy-goto-char-timer))) + ("s-j" . avy-goto-char-timer)) + :config + (defun bedrock-avy-action-embark (pt) + "Run `embark-act' at PT, then restore the window avy jumped from." + (unwind-protect + (save-excursion + (goto-char pt) + (embark-act)) + (select-window + (cdr (ring-ref avy-ring 0)))) + t) + (setf (alist-get ?. avy-dispatch-alist) #'bedrock-avy-action-embark)) (use-package evil :straight t @@ -286,18 +302,21 @@ (use-package eat :straight t + :after eshell :custom (eat-term-name "xterm") :config (eat-eshell-mode) (eat-eshell-visual-command-mode)) -(setq major-mode-remap-alist - '((yaml-mode . yaml-ts-mode) - (bash-mode . bash-ts-mode) - (json-mode . json-ts-mode) - (css-mode . css-ts-mode) - (python-mode . python-ts-mode))) +(use-package treesit-auto + :straight t + :demand t + :custom + (treesit-auto-install t) + :config + (treesit-auto-add-to-auto-mode-alist 'all) + (global-treesit-auto-mode)) (add-hook 'prog-mode-hook #'electric-pair-mode) @@ -310,26 +329,32 @@ :bind (("C-x g" . magit-status))) (use-package yaml-mode - :straight t) + :straight t + :mode "\\.ya?ml\\'") (use-package json-mode - :straight t) + :straight t + :mode "\\.json\\'") (use-package nix-mode :straight t :mode "\\.nix\\'") (use-package go-mode - :straight t) + :straight t + :mode "\\.go\\'") (use-package zig-mode - :straight t) + :straight t + :mode "\\.zig\\'") (use-package rust-mode - :straight t) + :straight t + :mode "\\.rs\\'") (use-package elixir-mode - :straight t) + :straight t + :mode ("\\.exs?\\'" "mix\\.lock\\'")) (use-package eglot :straight (:type built-in) @@ -437,7 +462,7 @@ ("C-c l i" . org-insert-link-global) ("C-c a" . org-agenda) ("C-c c" . org-capture) - :map org-mode-map + :map org-mode-map ("TAB" . org-cycle)) :config (require 'oc-csl) @@ -465,6 +490,7 @@ (keymap-set global-map "C-c f" file-prefix-map) (keymap-set file-prefix-map "f" #'project-find-file) (keymap-set file-prefix-map "r" #'consult-recent-file) +(keymap-set file-prefix-map "h" #'consult-recent-file) (keymap-set file-prefix-map "g" #'consult-ripgrep) (defvar-keymap git-prefix-map @@ -514,6 +540,10 @@ (keymap-set corfu-map "C-e" #'corfu-quit) (keymap-set corfu-map "RET" #'corfu-complete)) +(with-eval-after-load 'evil + (evil-set-leader '(normal visual) (kbd "SPC")) + (evil-define-key '(normal visual) 'global (kbd "fh") #'consult-recent-file)) + (setopt select-enable-clipboard t select-enable-primary t save-interprogram-text-before-kill t) @@ -540,4 +570,7 @@ ("C-c t k" . tmr-remove) ("C-c t s" . tmr-stop))) -(setq gc-cons-threshold (or bedrock--initial-gc-threshold 800000)) +;; GC and the file-name handler are restored on `emacs-startup-hook' +;; (see early-init). Larger process reads make eglot/LSP feel snappier. +(setopt read-process-output-max (* 4 1024 1024) + process-adaptive-read-buffering nil)