This commit is contained in:
2026-03-20 11:21:11 +09:00
3 changed files with 1356 additions and 805 deletions

1726
README.md

File diff suppressed because it is too large Load Diff

View File

@@ -1,10 +1,10 @@
;;; early-init.el --- Early Init -*- lexical-binding: t; -*- ;;; early-init.el --- Early Init -*- lexical-binding: t; -*-
;; Author: James Cherti ;; Author: James Cherti <https://www.jamescherti.com/contact/>
;; URL: https://github.com/jamescherti/minimal-emacs.d ;; URL: https://github.com/jamescherti/minimal-emacs.d
;; Package-Requires: ((emacs "29.1")) ;; Package-Requires: ((emacs "29.1"))
;; Keywords: maint ;; Keywords: maint
;; Version: 1.3.1 ;; Version: 1.4.1
;; SPDX-License-Identifier: GPL-3.0-or-later ;; SPDX-License-Identifier: GPL-3.0-or-later
;;; Commentary: ;;; Commentary:
@@ -81,16 +81,6 @@ tradeoff is that the mode line is hidden during the startup phase.")
When set to non-nil, Emacs will automatically call `package-initialize' and When set to non-nil, Emacs will automatically call `package-initialize' and
`package-refresh-contents' to set up and update the package system.") `package-refresh-contents' to set up and update the package system.")
(defvar minimal-emacs-setup-native-compilation t
"Controls whether native compilation settings are enabled during setup.
When non-nil, the following variables are set to non-nil to enable
native compilation features:
- `native-comp-deferred-compilation'
- `native-comp-jit-compilation'
- `package-native-compile'
If nil, these variables are left at their default values and are not
modified during setup.")
(defvar minimal-emacs-inhibit-redisplay-during-startup nil (defvar minimal-emacs-inhibit-redisplay-during-startup nil
"Suppress redisplay during startup to improve performance. "Suppress redisplay during startup to improve performance.
This prevents visual updates while Emacs initializes. The tradeoff is that you This prevents visual updates while Emacs initializes. The tradeoff is that you
@@ -105,6 +95,18 @@ of the progress or any relevant activities during startup.")
"Directory beneath minimal-emacs.d files are placed. "Directory beneath minimal-emacs.d files are placed.
Note that this should end with a directory separator.") Note that this should end with a directory separator.")
(defvar minimal-emacs-load-pre-early-init t
"If non-nil, attempt to load `pre-early-init.el`.")
(defvar minimal-emacs-load-post-early-init t
"If non-nil, attempt to load `post-early-init.el`.")
(defvar minimal-emacs-load-pre-init t
"If non-nil, attempt to load `pre-init.el`.")
(defvar minimal-emacs-load-post-init t
"If non-nil, attempt to load `post-init.el`.")
;;; Load pre-early-init.el ;;; Load pre-early-init.el
;; Prefer loading newer compiled files ;; Prefer loading newer compiled files
@@ -122,8 +124,10 @@ Note that this should end with a directory separator.")
(error "Emacs ignored loading 'init.el'. Please ensure that files such as ~/.emacs or ~/.emacs.el do not exist, as they may be preventing Emacs from loading the 'init.el' file")) (error "Emacs ignored loading 'init.el'. Please ensure that files such as ~/.emacs or ~/.emacs.el do not exist, as they may be preventing Emacs from loading the 'init.el' file"))
(t (t
(error "Configuration error. Debug by starting Emacs with: emacs --debug-init"))))) (error "Configuration error. Debug by starting Emacs with: --debug-init")))))
(add-hook 'emacs-startup-hook #'minimal-emacs--check-success 102)
(unless noninteractive
(add-hook 'emacs-startup-hook #'minimal-emacs--check-success 102))
(defvar minimal-emacs-load-compiled-init-files nil (defvar minimal-emacs-load-compiled-init-files nil
"If non-nil, attempt to load byte-compiled .elc for init files. "If non-nil, attempt to load byte-compiled .elc for init files.
@@ -153,7 +157,8 @@ pre-early-init.el, and post-early-init.el.")
(setq init-file (minimal-emacs--remove-el-file-suffix init-file)) (setq init-file (minimal-emacs--remove-el-file-suffix init-file))
(load init-file :no-error (not minimal-emacs-debug))))) (load init-file :no-error (not minimal-emacs-debug)))))
(minimal-emacs-load-user-init "pre-early-init.el") (when minimal-emacs-load-pre-early-init
(minimal-emacs-load-user-init "pre-early-init.el"))
(setq custom-theme-directory (setq custom-theme-directory
(expand-file-name "themes/" minimal-emacs-user-directory)) (expand-file-name "themes/" minimal-emacs-user-directory))
@@ -171,7 +176,9 @@ pre-early-init.el, and post-early-init.el.")
(defun minimal-emacs--restore-gc () (defun minimal-emacs--restore-gc ()
"Restore garbage collection settings." "Restore garbage collection settings."
(if (bound-and-true-p minimal-emacs-gc-cons-threshold-restore-delay) (if (and (bound-and-true-p minimal-emacs-gc-cons-threshold-restore-delay)
;; In noninteractive mode, the event loop does not run
(not noninteractive))
;; Defer garbage collection during initialization to avoid 2 collections. ;; Defer garbage collection during initialization to avoid 2 collections.
(run-with-timer minimal-emacs-gc-cons-threshold-restore-delay nil (run-with-timer minimal-emacs-gc-cons-threshold-restore-delay nil
#'minimal-emacs--restore-gc-values) #'minimal-emacs--restore-gc-values)
@@ -187,12 +194,9 @@ pre-early-init.el, and post-early-init.el.")
;;; Native compilation and Byte compilation ;;; Native compilation and Byte compilation
(if (and (featurep 'native-compile) (unless (and (featurep 'native-compile)
(fboundp 'native-comp-available-p) (fboundp 'native-comp-available-p)
(native-comp-available-p)) (native-comp-available-p))
(when minimal-emacs-setup-native-compilation
;; Activate `native-compile'
(setq package-native-compile t))
;; Deactivate the `native-compile' feature if it is not available ;; Deactivate the `native-compile' feature if it is not available
(setq features (delq 'native-compile features))) (setq features (delq 'native-compile features)))
@@ -207,9 +211,6 @@ pre-early-init.el, and post-early-init.el.")
(set-language-environment "UTF-8") (set-language-environment "UTF-8")
;; Set-language-environment sets default-input-method, which is unwanted.
(setq default-input-method nil)
;; Increase how much is read from processes in a single chunk ;; Increase how much is read from processes in a single chunk
(setq read-process-output-max (* 2 1024 1024)) ; 1024kb (setq read-process-output-max (* 2 1024 1024)) ; 1024kb
@@ -238,7 +239,7 @@ pre-early-init.el, and post-early-init.el.")
;; icon fonts on Windows. This will increase memory usage. ;; icon fonts on Windows. This will increase memory usage.
(setq inhibit-compacting-font-caches t) (setq inhibit-compacting-font-caches t)
(when (and (not (daemonp)) (not noninteractive)) (when (not noninteractive)
;; Resizing the Emacs frame can be costly when changing the font. Disable this ;; Resizing the Emacs frame can be costly when changing the font. Disable this
;; to improve startup times with fonts larger than the system default. ;; to improve startup times with fonts larger than the system default.
(setq frame-resize-pixelwise t) (setq frame-resize-pixelwise t)
@@ -272,16 +273,6 @@ pre-early-init.el, and post-early-init.el.")
;; `inhibit-startup-screen', but it would still initialize anyway. ;; `inhibit-startup-screen', but it would still initialize anyway.
(advice-add 'display-startup-screen :override #'ignore) (advice-add 'display-startup-screen :override #'ignore)
;; The initial buffer is created during startup even in non-interactive
;; sessions, and its major mode is fully initialized. Modes like `text-mode',
;; `org-mode', or even the default `lisp-interaction-mode' load extra packages
;; and run hooks, which can slow down startup.
;;
;; Using `fundamental-mode' for the initial buffer to avoid unnecessary
;; startup overhead.
(setq initial-major-mode 'fundamental-mode
initial-scratch-message nil)
(unless minimal-emacs-debug (unless minimal-emacs-debug
;; Unset command line options irrelevant to the current OS. These options ;; Unset command line options irrelevant to the current OS. These options
;; are still processed by `command-line-1` but have no effect. ;; are still processed by `command-line-1` but have no effect.
@@ -315,7 +306,6 @@ this stage of initialization."
minimal-emacs--old-file-name-handler-alist)))) minimal-emacs--old-file-name-handler-alist))))
(when (and minimal-emacs-optimize-file-name-handler-alist (when (and minimal-emacs-optimize-file-name-handler-alist
(not (daemonp))
(not minimal-emacs-debug)) (not minimal-emacs-debug))
;; Determine the state of bundled libraries using calc-loaddefs.el. If ;; Determine the state of bundled libraries using calc-loaddefs.el. If
;; compressed, retain the gzip handler in `file-name-handler-alist`. If ;; compressed, retain the gzip handler in `file-name-handler-alist`. If
@@ -347,7 +337,6 @@ this stage of initialization."
(remove-hook 'post-command-hook #'minimal-emacs--reset-inhibit-redisplay)) (remove-hook 'post-command-hook #'minimal-emacs--reset-inhibit-redisplay))
(when (and minimal-emacs-inhibit-redisplay-during-startup (when (and minimal-emacs-inhibit-redisplay-during-startup
(not (daemonp))
(not noninteractive) (not noninteractive)
(not minimal-emacs-debug)) (not minimal-emacs-debug))
;; Suppress redisplay and redraw during startup to avoid delays and ;; Suppress redisplay and redraw during startup to avoid delays and
@@ -363,7 +352,6 @@ this stage of initialization."
(remove-hook 'post-command-hook #'minimal-emacs--reset-inhibit-message)) (remove-hook 'post-command-hook #'minimal-emacs--reset-inhibit-message))
(when (and minimal-emacs-inhibit-message-during-startup (when (and minimal-emacs-inhibit-message-during-startup
(not (daemonp))
(not noninteractive) (not noninteractive)
(not minimal-emacs-debug)) (not minimal-emacs-debug))
(setq-default inhibit-message t) (setq-default inhibit-message t)
@@ -371,8 +359,10 @@ this stage of initialization."
;;; Performance: Disable mode-line during startup ;;; Performance: Disable mode-line during startup
(defvar-local minimal-emacs--hidden-mode-line nil
"Store the buffer-local value of `mode-line-format' during startup.")
(when (and minimal-emacs-disable-mode-line-during-startup (when (and minimal-emacs-disable-mode-line-during-startup
(not (daemonp))
(not noninteractive) (not noninteractive)
(not minimal-emacs-debug)) (not minimal-emacs-debug))
(put 'mode-line-format (put 'mode-line-format
@@ -380,7 +370,9 @@ this stage of initialization."
(setq-default mode-line-format nil) (setq-default mode-line-format nil)
(dolist (buf (buffer-list)) (dolist (buf (buffer-list))
(with-current-buffer buf (with-current-buffer buf
(setq mode-line-format nil)))) (when (local-variable-p 'mode-line-format)
(setq minimal-emacs--hidden-mode-line mode-line-format)
(setq mode-line-format nil)))))
;;; Restore values ;;; Restore values
@@ -399,7 +391,12 @@ this stage of initialization."
(when minimal-emacs-disable-mode-line-during-startup (when minimal-emacs-disable-mode-line-during-startup
(unless (default-toplevel-value 'mode-line-format) (unless (default-toplevel-value 'mode-line-format)
(setq-default mode-line-format (get 'mode-line-format (setq-default mode-line-format (get 'mode-line-format
'initial-value)))))) 'initial-value)))
(dolist (buf (buffer-list))
(with-current-buffer buf
(when (local-variable-p 'minimal-emacs--hidden-mode-line)
(setq mode-line-format minimal-emacs--hidden-mode-line)
(kill-local-variable 'minimal-emacs--hidden-mode-line)))))))
(advice-add 'startup--load-user-init-file :around (advice-add 'startup--load-user-init-file :around
#'minimal-emacs--startup-load-user-init-file) #'minimal-emacs--startup-load-user-init-file)
@@ -429,8 +426,7 @@ this stage of initialization."
(when (bound-and-true-p tool-bar-mode) (when (bound-and-true-p tool-bar-mode)
(funcall 'tool-bar-setup)))) (funcall 'tool-bar-setup))))
(when (and (not (daemonp)) (unless noninteractive
(not noninteractive))
(when (fboundp 'tool-bar-setup) (when (fboundp 'tool-bar-setup)
;; Temporarily override the tool-bar-setup function to prevent it from ;; Temporarily override the tool-bar-setup function to prevent it from
;; running during the initial stages of startup ;; running during the initial stages of startup
@@ -463,21 +459,18 @@ this stage of initialization."
(setq tls-checktrust t) ; Ensure SSL/TLS connections undergo trust verification (setq tls-checktrust t) ; Ensure SSL/TLS connections undergo trust verification
(setq gnutls-min-prime-bits 3072) ; Stronger GnuTLS encryption (setq gnutls-min-prime-bits 3072) ; Stronger GnuTLS encryption
;;; package.el ;; This results in a more compact output that emphasizes performance
(setq package-enable-at-startup nil) (setq use-package-expand-minimally t)
(setq use-package-compute-statistics minimal-emacs-debug)
;; Setting use-package-expand-minimally to (t) results in a more compact output
;; that emphasizes performance over clarity.
(setq use-package-expand-minimally (not noninteractive))
(setq package-quickstart-file
(expand-file-name "package-quickstart.el" user-emacs-directory))
(setq use-package-minimum-reported-time (if minimal-emacs-debug 0 0.1)) (setq use-package-minimum-reported-time (if minimal-emacs-debug 0 0.1))
(setq use-package-verbose minimal-emacs-debug) (setq use-package-verbose minimal-emacs-debug)
(setq package-enable-at-startup nil) ; Let the init.el file handle this (setq use-package-always-ensure (not noninteractive))
(setq use-package-always-ensure t)
(setq use-package-enable-imenu-support t) (setq use-package-enable-imenu-support t)
;; package.el
(setq package-enable-at-startup nil) ; Let the init.el file handle this
(setq package-quickstart-file
(expand-file-name "package-quickstart.el" user-emacs-directory))
(setq package-archives '(("melpa" . "https://melpa.org/packages/") (setq package-archives '(("melpa" . "https://melpa.org/packages/")
("gnu" . "https://elpa.gnu.org/packages/") ("gnu" . "https://elpa.gnu.org/packages/")
("nongnu" . "https://elpa.nongnu.org/nongnu/") ("nongnu" . "https://elpa.nongnu.org/nongnu/")
@@ -488,7 +481,9 @@ this stage of initialization."
("melpa-stable" . 50))) ("melpa-stable" . 50)))
;;; Load post-early-init.el ;;; Load post-early-init.el
(minimal-emacs-load-user-init "post-early-init.el")
(when minimal-emacs-load-post-early-init
(minimal-emacs-load-user-init "post-early-init.el"))
;; Local variables: ;; Local variables:
;; byte-compile-warnings: (not obsolete free-vars) ;; byte-compile-warnings: (not obsolete free-vars)

222
init.el
View File

@@ -1,10 +1,10 @@
;;; init.el --- Init -*- lexical-binding: t; -*- ;;; init.el --- Init -*- lexical-binding: t; -*-
;; Author: James Cherti ;; Author: James Cherti <https://www.jamescherti.com/contact/>
;; URL: https://github.com/jamescherti/minimal-emacs.d ;; URL: https://github.com/jamescherti/minimal-emacs.d
;; Package-Requires: ((emacs "29.1")) ;; Package-Requires: ((emacs "29.1"))
;; Keywords: maint ;; Keywords: maint
;; Version: 1.3.1 ;; Version: 1.4.1
;; SPDX-License-Identifier: GPL-3.0-or-later ;; SPDX-License-Identifier: GPL-3.0-or-later
;;; Commentary: ;;; Commentary:
@@ -22,12 +22,27 @@
;;; Code: ;;; Code:
;;; Load pre-init.el ;;; Load pre-init.el
(if (fboundp 'minimal-emacs-load-user-init) (if (fboundp 'minimal-emacs-load-user-init)
(minimal-emacs-load-user-init "pre-init.el") (when minimal-emacs-load-pre-init
(error "The early-init.el file failed to loaded")) (minimal-emacs-load-user-init "pre-init.el"))
(error "The early-init.el file failed to load"))
;;; Before package ;;; Before package
;; The initial buffer is created during startup even in non-interactive
;; sessions, and its major mode is fully initialized. Modes like `text-mode',
;; `org-mode', or even the default `lisp-interaction-mode' load extra packages
;; and run hooks, which can slow down startup.
;;
;; Using `fundamental-mode' for the initial buffer to avoid unnecessary
;; startup overhead.
(setq initial-major-mode 'fundamental-mode
initial-scratch-message nil)
;; Set-language-environment sets default-input-method, which is unwanted.
(setq default-input-method nil)
;; Ask the user whether to terminate asynchronous compilations on exit. ;; Ask the user whether to terminate asynchronous compilations on exit.
;; This prevents native compilation from leaving temporary files in /tmp. ;; This prevents native compilation from leaving temporary files in /tmp.
(setq native-comp-async-query-on-exit t) (setq native-comp-async-query-on-exit t)
@@ -46,29 +61,29 @@
;;; package.el ;;; package.el
(when (bound-and-true-p minimal-emacs-package-initialize-and-refresh) (when (and (bound-and-true-p minimal-emacs-package-initialize-and-refresh)
(not (bound-and-true-p byte-compile-current-file))
(not (or (fboundp 'straight-use-package)
(fboundp 'elpaca))))
;; Initialize and refresh package contents again if needed ;; Initialize and refresh package contents again if needed
(package-initialize) (package-initialize)
;; Install use-package if necessary (unless package-archive-contents
(unless (package-installed-p 'use-package)
(unless (seq-empty-p package-archive-contents)
(package-refresh-contents)) (package-refresh-contents))
(when (and (version< emacs-version "29.1")
(not (package-installed-p 'use-package)))
(package-install 'use-package)) (package-install 'use-package))
;; Ensure use-package is available
(require 'use-package)) (require 'use-package))
;;; Minibuffer ;;; Minibuffer
;; Allow nested minibuffers (setq enable-recursive-minibuffers t) ; Allow nested minibuffers
(setq enable-recursive-minibuffers t)
;; Keep the cursor out of the read-only portions of the.minibuffer ;; Keep the cursor out of the read-only portions of the.minibuffer
(setq minibuffer-prompt-properties (setq minibuffer-prompt-properties
'(read-only t intangible t cursor-intangible t face minibuffer-prompt)) '(read-only t intangible t cursor-intangible t face minibuffer-prompt))
(add-hook 'minibuffer-setup-hook #'cursor-intangible-mode) (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)
;;; User interface ;;; Display and user interface
;; By default, Emacs "updates" its ui more often than it needs to ;; By default, Emacs "updates" its ui more often than it needs to
(setq which-func-update-delay 1.0) (setq which-func-update-delay 1.0)
@@ -80,6 +95,13 @@
(setq visible-bell nil) (setq visible-bell nil)
(setq ring-bell-function #'ignore) (setq ring-bell-function #'ignore)
;; Position underlines at the descent line instead of the baseline.
(setq x-underline-at-descent-line t)
(setq truncate-string-ellipsis "")
(setq display-time-default-load-average nil) ; Omit load average
;;; Show-paren ;;; Show-paren
(setq show-paren-delay 0.1 (setq show-paren-delay 0.1
@@ -87,34 +109,10 @@
show-paren-when-point-inside-paren t show-paren-when-point-inside-paren t
show-paren-when-point-in-periphery t) show-paren-when-point-in-periphery t)
;;; Misc ;;; Buffer management
(setq custom-buffer-done-kill t) (setq custom-buffer-done-kill t)
(setq whitespace-line-column nil) ; Use the value of `fill-column'.
;; Can be activated with `display-line-numbers-mode'
(setq-default display-line-numbers-width 3)
(setq-default display-line-numbers-widen t)
(setq truncate-string-ellipsis "")
;; Disable truncation of printed s-expressions in the message buffer
(setq eval-expression-print-length nil
eval-expression-print-level nil)
;; Position underlines at the descent line instead of the baseline.
(setq x-underline-at-descent-line t)
(setq remote-file-name-inhibit-cache 50)
;; Automatically rescan the buffer for Imenu entries when `imenu' is invoked
;; This ensures the index reflects recent edits.
(setq imenu-auto-rescan t)
;; Prevent truncation of long function names in `imenu' listings
(setq imenu-max-item-length 160)
;; Disable auto-adding a new line at the bottom when scrolling. ;; Disable auto-adding a new line at the bottom when scrolling.
(setq next-line-add-newlines nil) (setq next-line-add-newlines nil)
@@ -122,10 +120,47 @@
;; Benefit: you never lose bookmarks if Emacs crashes. ;; Benefit: you never lose bookmarks if Emacs crashes.
(setq bookmark-save-flag 1) (setq bookmark-save-flag 1)
;;; tramp (setq uniquify-buffer-name-style 'forward)
(setq remote-file-name-inhibit-cache 50)
;; Disable fontification during user input to reduce lag in large buffers.
;; Also helps marginally with scrolling performance.
(setq redisplay-skip-fontification-on-input t)
;;; Misc
(setq whitespace-line-column nil) ; Use the value of `fill-column'.
;; Disable ellipsis when printing s-expressions in the message buffer
(setq eval-expression-print-length nil
eval-expression-print-level nil)
;; This directs gpg-agent to use the minibuffer for passphrase entry
(setq epg-pinentry-mode 'loopback)
;; By default, Emacs stores sensitive authinfo credentials as unencrypted text
;; in your home directory. Use GPG to encrypt the authinfo file for enhanced
;; security.
(setq auth-sources (list "~/.authinfo.gpg"))
;;; `display-line-numbers-mode'
(setq-default display-line-numbers-width 3)
(setq-default display-line-numbers-widen t)
;;; imenu
;; Automatically rescan the buffer for Imenu entries when `imenu' is invoked
;; This ensures the index reflects recent edits.
(setq imenu-auto-rescan t)
;; Prevent truncation of long function names in `imenu' listings
(setq imenu-max-item-length 160)
;;; Tramp
(setq tramp-verbose 1) (setq tramp-verbose 1)
(setq tramp-completion-reread-directory-timeout 50)
;;; Files ;;; Files
@@ -136,18 +171,16 @@
;; Ignoring this is acceptable since it will redirect to the buffer regardless. ;; Ignoring this is acceptable since it will redirect to the buffer regardless.
(setq find-file-suppress-same-file-warnings t) (setq find-file-suppress-same-file-warnings t)
;; Resolve symlinks so that operations are conducted from the file's directory ;; Resolve symlinks to avoid duplicate buffers
(setq find-file-visit-truename t (setq find-file-visit-truename t
;; Automatically follow a symlink to its source if that source is managed
;; by a version control system, rather than asking for permission.
vc-follow-symlinks t) vc-follow-symlinks t)
;; Prefer vertical splits over horizontal ones ;; Prefer vertical splits over horizontal ones
(setq split-width-threshold 170 (setq split-width-threshold 170
split-height-threshold nil) split-height-threshold nil)
;;; Buffers
(setq uniquify-buffer-name-style 'forward)
;;; comint (general command interpreter in a window) ;;; comint (general command interpreter in a window)
(setq ansi-color-for-comint-mode t (setq ansi-color-for-comint-mode t
@@ -165,8 +198,16 @@
;;; Backup files ;;; Backup files
;; Avoid backups or lockfiles to prevent creating world-readable copies of files ;; Disable the creation of lockfiles (e.g., .#filename).
;; Modern workflows rely on `global-auto-revert-mode' to handle external file
;; changes gracefully, making the restrictive nature of lockfiles unnecessary.
(setq create-lockfiles nil) (setq create-lockfiles nil)
;; Disable backup files (e.g., filename~). Note that `auto-save-default'
;; remains enabled by default. Even with `make-backup-files' backups disabled,
;; Emacs will still generate temporary recovery files (e.g., #filename#) for
;; unsaved buffers. This protects your active work from sudden crashes while
;; ensuring the file system is cleaned up immediately upon a successful save.
(setq make-backup-files nil) (setq make-backup-files nil)
(setq backup-directory-alist (setq backup-directory-alist
@@ -182,7 +223,6 @@
;;; VC ;;; VC
(setq vc-git-print-log-follow t) (setq vc-git-print-log-follow t)
(setq vc-make-backup-files nil) ; Do not backup version controlled files
(setq vc-git-diff-switches '("--histogram")) ; Faster algorithm for diffing. (setq vc-git-diff-switches '("--histogram")) ; Faster algorithm for diffing.
;;; Auto save ;;; Auto save
@@ -190,9 +230,13 @@
;; Enable auto-save to safeguard against crashes or data loss. The ;; Enable auto-save to safeguard against crashes or data loss. The
;; `recover-file' or `recover-session' functions can be used to restore ;; `recover-file' or `recover-session' functions can be used to restore
;; auto-saved data. ;; auto-saved data.
(setq auto-save-default nil)
(setq auto-save-no-message t) (setq auto-save-no-message t)
(when noninteractive
;; The command line interface
(setq enable-dir-local-variables nil)
(setq case-fold-search nil))
;; Do not auto-disable auto-save after deleting large chunks of ;; Do not auto-disable auto-save after deleting large chunks of
;; text. ;; text.
(setq auto-save-include-big-deletions t) (setq auto-save-include-big-deletions t)
@@ -202,6 +246,20 @@
(setq tramp-auto-save-directory (setq tramp-auto-save-directory
(expand-file-name "tramp-autosave/" user-emacs-directory)) (expand-file-name "tramp-autosave/" user-emacs-directory))
(setq auto-save-file-name-transforms
`(("\\`/[^/]*:\\([^/]*/\\)*\\([^/]*\\)\\'"
,(file-name-concat auto-save-list-file-prefix "tramp-\\2-") sha1)
("\\`/\\([^/]+/\\)*\\([^/]+\\)\\'"
,(file-name-concat auto-save-list-file-prefix "\\2-") sha1)))
;; Ensure the directory for auto-save session logs exists with restricted
;; permissions.
(when auto-save-default
(let ((auto-save-dir (file-name-directory auto-save-list-file-prefix)))
(unless (file-exists-p auto-save-dir)
(with-file-modes #o700
(make-directory auto-save-dir t)))))
;; Auto save options ;; Auto save options
(setq kill-buffer-delete-auto-save-files t) (setq kill-buffer-delete-auto-save-files t)
@@ -211,9 +269,6 @@
;;; Auto revert ;;; Auto revert
;; Auto-revert in Emacs is a feature that automatically updates the contents of ;; Auto-revert in Emacs is a feature that automatically updates the contents of
;; a buffer to reflect changes made to the underlying file. ;; a buffer to reflect changes made to the underlying file.
(setq revert-without-query (list ".") ; Do not prompt
auto-revert-stop-on-user-input nil
auto-revert-verbose t)
;; Revert other buffers (e.g, Dired) ;; Revert other buffers (e.g, Dired)
(setq global-auto-revert-non-file-buffers t) (setq global-auto-revert-non-file-buffers t)
@@ -225,7 +280,6 @@
(setq recentf-max-saved-items 300) ; default is 20 (setq recentf-max-saved-items 300) ; default is 20
(setq recentf-max-menu-items 15) (setq recentf-max-menu-items 15)
(setq recentf-auto-cleanup 'mode) (setq recentf-auto-cleanup 'mode)
(setq recentf-exclude nil)
;;; saveplace ;;; saveplace
@@ -238,19 +292,13 @@
;; `savehist-mode' is an Emacs feature that preserves the minibuffer history ;; `savehist-mode' is an Emacs feature that preserves the minibuffer history
;; between sessions. ;; between sessions.
(setq history-length 300) (setq history-length 300)
(setq savehist-save-minibuffer-history t) ;; Default
(setq savehist-additional-variables (setq savehist-additional-variables
'(kill-ring ; clipboard '(register-alist ; macros
register-alist ; macros
mark-ring global-mark-ring ; marks mark-ring global-mark-ring ; marks
search-ring regexp-search-ring)) ; searches search-ring regexp-search-ring)) ; searches
;;; Frames and windows ;;; Frames and windows
;; However, do not resize windows pixelwise, as this can cause crashes in some
;; cases when resizing too many windows at once or rapidly.
(setq window-resize-pixelwise nil)
(setq resize-mini-windows 'grow-only) (setq resize-mini-windows 'grow-only)
;; The native border "uses" a pixel of the fringe on the rightmost ;; The native border "uses" a pixel of the fringe on the rightmost
@@ -259,12 +307,6 @@
window-divider-default-places t window-divider-default-places t
window-divider-default-right-width 1) window-divider-default-right-width 1)
;;; Fontification
;; Disable fontification during user input to reduce lag in large buffers.
;; Also helps marginally with scrolling performance.
(setq redisplay-skip-fontification-on-input t)
;;; Scrolling ;;; Scrolling
;; Enables faster scrolling. This may result in brief periods of inaccurate ;; Enables faster scrolling. This may result in brief periods of inaccurate
@@ -286,20 +328,10 @@
;; 2. Resolving the issue of random half-screen jumps during scrolling. ;; 2. Resolving the issue of random half-screen jumps during scrolling.
(setq auto-window-vscroll nil) (setq auto-window-vscroll nil)
;; Number of lines of margin at the top and bottom of a window.
(setq scroll-margin 0)
;; Number of lines of continuity when scrolling by screenfuls.
(setq next-screen-context-lines 0)
;; Horizontal scrolling ;; Horizontal scrolling
(setq hscroll-margin 2 (setq hscroll-margin 2
hscroll-step 1) hscroll-step 1)
;;; Mouse
(setq mouse-yank-at-point nil)
;; Emacs 29 ;; Emacs 29
(when (memq 'context-menu minimal-emacs-ui-features) (when (memq 'context-menu minimal-emacs-ui-features)
(when (and (display-graphic-p) (fboundp 'context-menu-mode)) (when (and (display-graphic-p) (fboundp 'context-menu-mode))
@@ -315,12 +347,8 @@
;; Don't blink the paren matching the one at point, it's too distracting. ;; Don't blink the paren matching the one at point, it's too distracting.
(setq blink-matching-paren nil) (setq blink-matching-paren nil)
;; Do not extend the cursor to fit wide characters
(setq x-stretch-cursor nil)
;; Reduce rendering/line scan work by not rendering cursors or regions in ;; Reduce rendering/line scan work by not rendering cursors or regions in
;; non-focused windows. ;; non-focused windows.
(setq-default cursor-in-non-selected-windows nil)
(setq highlight-nonselected-windows nil) (setq highlight-nonselected-windows nil)
;;; Text editing, indent, font, and formatting ;;; Text editing, indent, font, and formatting
@@ -332,13 +360,6 @@
;; deletion, disrupting the flow of editing. ;; deletion, disrupting the flow of editing.
(setq delete-pair-blink-delay 0.03) (setq delete-pair-blink-delay 0.03)
(setq-default left-fringe-width 8)
(setq-default right-fringe-width 8)
;; Disable visual indicators in the fringe for buffer boundaries and empty lines
(setq-default indicate-buffer-boundaries nil)
(setq-default indicate-empty-lines nil)
;; Continue wrapped lines at whitespace rather than breaking in the ;; Continue wrapped lines at whitespace rather than breaking in the
;; middle of a word. ;; middle of a word.
(setq-default word-wrap t) (setq-default word-wrap t)
@@ -388,11 +409,6 @@
;; Eliminate delay before highlighting search matches ;; Eliminate delay before highlighting search matches
(setq lazy-highlight-initial-delay 0) (setq lazy-highlight-initial-delay 0)
;;; Modeline
;; Makes Emacs omit the load average information from the mode line.
(setq display-time-default-load-average nil)
;;; Filetype ;;; Filetype
;; Do not notify the user each time Python tries to guess the indentation offset ;; Do not notify the user each time Python tries to guess the indentation offset
@@ -448,13 +464,14 @@
;;; Eglot ;;; Eglot
(setq eglot-report-progress minimal-emacs-debug) ; Prevent minibuffer spam
(setq eglot-autoshutdown t) ; Shut down after killing last managed buffer
;; A setting of nil or 0 means Eglot will not block the UI at all, allowing ;; A setting of nil or 0 means Eglot will not block the UI at all, allowing
;; Emacs to remain fully responsive, although LSP features will only become ;; Emacs to remain fully responsive, although LSP features will only become
;; available once the connection is established in the background. ;; available once the connection is established in the background.
(setq eglot-sync-connect 0) (setq eglot-sync-connect 0)
(setq eglot-autoshutdown t) ; Shut down server after killing last managed buffer
;; Activate Eglot in cross-referenced non-project files ;; Activate Eglot in cross-referenced non-project files
(setq eglot-extend-to-xref t) (setq eglot-extend-to-xref t)
@@ -467,19 +484,14 @@
(setq eglot-events-buffer-size 0) ; Deprecated (setq eglot-events-buffer-size 0) ; Deprecated
(setq eglot-events-buffer-config '(:size 0 :format short))) (setq eglot-events-buffer-config '(:size 0 :format short)))
(setq eglot-report-progress minimal-emacs-debug) ; Prevent minibuffer spam
;;; Flymake ;;; Flymake
(setq flymake-show-diagnostics-at-end-of-line nil) (setq flymake-show-diagnostics-at-end-of-line nil)
;; Disable wrapping around when navigating Flymake errors.
(setq flymake-wrap-around nil) (setq flymake-wrap-around nil)
;;; hl-line-mode ;;; hl-line-mode
;; Restrict `hl-line-mode' highlighting to the current window, reducing visual ;; Highlighting the current window, reducing clutter and improving performance
;; clutter and slightly improving `hl-line-mode' performance.
(setq hl-line-sticky-flag nil) (setq hl-line-sticky-flag nil)
(setq global-hl-line-sticky-flag nil) (setq global-hl-line-sticky-flag nil)
@@ -491,11 +503,10 @@
;;; flyspell ;;; flyspell
(setq flyspell-issue-welcome-flag nil)
;; Improves flyspell performance by preventing messages from being displayed for ;; Improves flyspell performance by preventing messages from being displayed for
;; each word when checking the entire buffer. ;; each word when checking the entire buffer.
(setq flyspell-issue-message-flag nil) (setq flyspell-issue-message-flag nil)
(setq flyspell-issue-welcome-flag nil)
;;; ispell ;;; ispell
@@ -522,8 +533,8 @@
;;; abbrev ;;; abbrev
;; Ensure `abbrev_defs` is stored in the correct location when ;; Ensure the abbrev_defs file is stored in the correct location when
;; `user-emacs-directory` is modified, as it defaults to ~/.emacs.d/abbrev_defs ;; `user-emacs-directory' is modified, as it defaults to ~/.emacs.d/abbrev_defs
;; regardless of the change. ;; regardless of the change.
(setq abbrev-file-name (expand-file-name "abbrev_defs" user-emacs-directory)) (setq abbrev-file-name (expand-file-name "abbrev_defs" user-emacs-directory))
@@ -553,8 +564,11 @@
(put cmd 'disabled nil)) (put cmd 'disabled nil))
;;; Load post init ;;; Load post init
(when (fboundp 'minimal-emacs-load-user-init)
(when (and minimal-emacs-load-post-init
(fboundp 'minimal-emacs-load-user-init))
(minimal-emacs-load-user-init "post-init.el")) (minimal-emacs-load-user-init "post-init.el"))
(setq minimal-emacs--success t) (setq minimal-emacs--success t)
;; Local variables: ;; Local variables: