From 70d5507ed130f7b657da61b9e8df9dbe5f599394 Mon Sep 17 00:00:00 2001 From: James Cherti <60946298+jamescherti@users.noreply.github.com> Date: Tue, 11 Mar 2025 14:49:50 -0400 Subject: [PATCH] Update comments --- early-init.el | 99 +++++++++++++++++++++++++++------------------------ init.el | 38 +++++++------------- 2 files changed, 65 insertions(+), 72 deletions(-) diff --git a/early-init.el b/early-init.el index f1ab1cb..7675277 100644 --- a/early-init.el +++ b/early-init.el @@ -19,11 +19,11 @@ (defvar minimal-emacs-ui-features '() "List of user interface features to disable in minimal Emacs setup. This variable holds a list Emacs UI features that can be enabled: -- `context-menu`: Enables the context menu in graphical environments. -- `tool-bar`: Enables the tool bar in graphical environments. -- `menu-bar`: Enables the menu bar in graphical environments. -- `dialogs`: Enables both file dialogs and dialog boxes. -- `tooltips`: Enables tooltips.") +- context-menu (Enables the context menu in graphical environments.) +- tool-bar (Enables the tool bar in graphical environments.) +- menu-bar (Enables the menu bar in graphical environments.) +- dialogs (Enables both file dialogs and dialog boxes.) +- tooltips (Enables tooltips.)") (defvar minimal-emacs-frame-title-format "%b – Emacs" "Template for displaying the title bar of visible and iconified frame.") @@ -31,39 +31,40 @@ This variable holds a list Emacs UI features that can be enabled: (defvar minimal-emacs-debug (bound-and-true-p init-file-debug) "Non-nil to enable debug.") -(defvar minimal-emacs-gc-cons-threshold (* 16 1024 1024) - "The value of `gc-cons-threshold' after Emacs startup.") +(defvar minimal-emacs-gc-cons-threshold (* 32 1024 1024) + "Value to set `gc-cons-threshold' to after Emacs startup. +Ignored if `minimal-emacs-optimize-startup-gc' is nil.") (defvar minimal-emacs-optimize-startup-gc t "If non-nil, increase `gc-cons-threshold' during startup to reduce pauses. After Emacs finishes loading, `gc-cons-threshold' is restored to the value stored in `minimal-emacs--restore-gc-cons-threshold'.") +(defvar minimal-emacs-inhibit-redisplay-during-startup nil + "Suppress redisplay during startup to improve performance. +This prevents visual updates while Emacs initializes. The tradeoff is that you +won't see the progress or activities during the startup process.") + +(defvar minimal-emacs-inhibit-message-during-startup nil + "Suppress startup messages for a cleaner experience. +This slightly enhances performance. The tradeoff is that you won't be informed +of the progress or any relevant activities during startup.") + +(defvar minimal-emacs-optimize-file-name-handler-alist t + "Enable optimization of `file-name-handler-alist'. +When non-nil, this variable activates optimizations to reduce file name handler +lookups during Emacs startup.") + +(defvar minimal-emacs-disable-mode-line-during-startup t + "Disable the mode line during startup. +This reduces visual clutter and slightly enhances startup performance. The +tradeoff is that the mode line is hidden during the startup phase.") + (defvar minimal-emacs-package-initialize-and-refresh t "Whether to automatically initialize and refresh packages. When set to non-nil, Emacs will automatically call `package-initialize' and `package-refresh-contents' to set up and update the package system.") -(defvar minimal-emacs-inhibit-redisplay-during-startup nil - "Suppress redisplay during startup to improve performance. -This prevents visual updates while Emacs initializes, leading to a cleaner and -faster startup. The tradeoff is that you won't see the progress or activities -during the startup process.") - -(defvar minimal-emacs-inhibit-message-during-startup nil - "Suppress startup messages for a cleaner experience. -By disabling startup messages, this slightly enhances performance and provides a -cleaner startup. The tradeoff is that you won't be informed of the progress or -any relevant activities during startup.") - -(defvar minimal-emacs-optimize-file-name-handler-alist t) - -(defvar minimal-emacs-disable-mode-line-during-startup t - "Disable the mode line during startup to improve performance. -This reduces visual clutter and slightly enhances startup performance. The -tradeoff is that the mode line is hidden during the startup phase, giving a more -minimalistic appearance during startup.") - (defvar minimal-emacs-user-directory user-emacs-directory "The default value of the `user-emacs-directory' variable.") @@ -289,6 +290,19 @@ this stage of initialization." ;;; Performance: Disable mode-line during startup +(when (and minimal-emacs-disable-mode-line-during-startup + (not (daemonp)) + (not noninteractive) + (not minimal-emacs-debug)) + (put 'mode-line-format + 'initial-value (default-toplevel-value 'mode-line-format)) + (setq-default mode-line-format nil) + (dolist (buf (buffer-list)) + (with-current-buffer buf + (setq mode-line-format nil)))) + +;;; Restore values + (defun minimal-emacs--startup-load-user-init-file (fn &rest args) "Advice to reset `mode-line-format'. FN and ARGS are the function and args." (unwind-protect @@ -306,18 +320,8 @@ this stage of initialization." (setq-default mode-line-format (get 'mode-line-format 'initial-value)))))) -(when (and minimal-emacs-disable-mode-line-during-startup - (not (daemonp)) - (not noninteractive) - (not minimal-emacs-debug)) - (put 'mode-line-format - 'initial-value (default-toplevel-value 'mode-line-format)) - (setq-default mode-line-format nil) - (dolist (buf (buffer-list)) - (with-current-buffer buf - (setq mode-line-format nil))) - (advice-add 'startup--load-user-init-file :around - #'minimal-emacs--startup-load-user-init-file)) +(advice-add 'startup--load-user-init-file :around + #'minimal-emacs--startup-load-user-init-file) ;;; UI elements @@ -344,15 +348,16 @@ this stage of initialization." (when (bound-and-true-p tool-bar-mode) (funcall 'tool-bar-setup)))) -(unless (daemonp) - (unless noninteractive - (when (fboundp 'tool-bar-setup) - ;; Temporarily override the tool-bar-setup function to prevent it from - ;; running during the initial stages of startup - (advice-add 'tool-bar-setup :override #'ignore) +(when (and (not (daemonp)) + (not noninteractive)) + (when (fboundp 'tool-bar-setup) + ;; Temporarily override the tool-bar-setup function to prevent it from + ;; running during the initial stages of startup + (advice-add 'tool-bar-setup :override #'ignore) + + (advice-add 'startup--load-user-init-file :after + #'minimal-emacs--setup-toolbar))) - (advice-add 'startup--load-user-init-file :after - #'minimal-emacs--setup-toolbar)))) (unless (memq 'tool-bar minimal-emacs-ui-features) (push '(tool-bar-lines . 0) default-frame-alist) (setq tool-bar-mode nil)) diff --git a/init.el b/init.el index e9b03f2..dc743a1 100644 --- a/init.el +++ b/init.el @@ -178,8 +178,7 @@ (setq auto-save-no-message t) ;; Do not auto-disable auto-save after deleting large chunks of -;; text. The purpose of auto-save is to provide a failsafe, and -;; disabling it contradicts this objective. +;; text. (setq auto-save-include-big-deletions t) (setq auto-save-list-file-prefix @@ -206,8 +205,7 @@ ;;; recentf -;; `recentf' is an that maintains a list of recently accessed files, making it -;; easier to reopen files you have worked on recently. +;; `recentf' is an that maintains a list of recently accessed files. (setq recentf-max-saved-items 300) ; default is 20 (setq recentf-max-menu-items 15) (setq recentf-auto-cleanup (if (daemonp) 300 'never)) @@ -217,8 +215,7 @@ ;;; saveplace -;; `save-place-mode' enables Emacs to remember the last location within a file -;; upon reopening. +;; Enables Emacs to remember the last location within a file upon reopening. (setq save-place-file (expand-file-name "saveplace" user-emacs-directory)) (setq save-place-limit 600) @@ -254,25 +251,20 @@ ;;; Scrolling -;; Enables faster scrolling through unfontified regions. This may result in -;; brief periods of inaccurate syntax highlighting immediately after scrolling, -;; which should quickly self-correct. +;; Enables faster scrolling. This may result in brief periods of inaccurate +;; syntax highlighting, which should quickly self-correct. (setq fast-but-imprecise-scrolling t) ;; Move point to top/bottom of buffer before signaling a scrolling error. (setq scroll-error-top-bottom t) -;; Keeps screen position if the scroll command moved it vertically out of the -;; window. +;; Keep screen position if scroll command moved it vertically out of the window. (setq scroll-preserve-screen-position t) -;; Emacs spends excessive time recentering when the cursor moves more than N -;; lines past the window edges (N is the value of `scroll-conservatively'). This -;; can be slow in larger files. If `scroll-conservatively' is set above 100, the -;; window is never automatically recentered. +;; If `scroll-conservatively' is set above 100, the window is never +;; automatically recentered, which decreases the time spend recentering. (setq scroll-conservatively 101) -;; Reduce cursor lag by: ;; 1. Preventing automatic adjustments to `window-vscroll' for long lines. ;; 2. Resolving the issue of random half-screen jumps during scrolling. (setq auto-window-vscroll nil) @@ -319,9 +311,8 @@ ;; Avoid automatic frame resizing when adjusting settings. (setq global-text-scale-adjust-resizes-frames nil) -;; This controls how long Emacs will blink to show the deleted pairs with -;; `delete-pair'. A longer delay can be annoying as it causes a noticeable pause -;; after each deletion, disrupting the flow of editing. +;; A longer delay can be annoying as it causes a noticeable pause after each +;; deletion, disrupting the flow of editing. (setq delete-pair-blink-delay 0.03) (setq-default left-fringe-width 8) @@ -427,9 +418,8 @@ (setq apropos-do-all t) ;; Fixes #11: Prevents help command completion from triggering autoload. -;; (e.g., apropos-command, apropos-variable, apropos...) -;; Loading additional files for completion can slow down help commands -;; and may unintentionally execute initialization code from some libraries. +;; Loading additional files for completion can slow down help commands and may +;; unintentionally execute initialization code from some libraries. (setq help-enable-completion-autoload nil) (setq help-enable-autoload nil) (setq help-enable-symbol-autoload nil) @@ -449,9 +439,7 @@ (setq eglot-report-progress nil) ; Prevent Eglot minibuffer spam ;; Eglot optimization: Disable `eglot-events-buffer' to maintain consistent -;; performance in long-running Emacs sessions. By default, it retains 2,000,000 -;; lines, and each new event triggers pretty-printing of the entire buffer, -;; leading to a gradual performance decline. +;; performance in long-running Emacs sessions. (setq eglot-events-buffer-config '(:size 0 :format full)) ;;; Flymake