diff --git a/README.md b/README.md index 7f6bb2a..41be99b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![License](https://img.shields.io/github/license/jamescherti/be-quiet.el) ![](https://raw.githubusercontent.com/jamescherti/minimal-emacs.d/main/.images/made-for-gnu-emacs.svg) -The **minimal-emacs.d** repository offers a starter kit with improved Emacs defaults and optimized startup, designed to serve as a robust foundation for your vanilla Emacs configuration and enhance your overall Emacs experience. +The **minimal-emacs.d** starter kit provides improved Emacs defaults and optimized startup, intended to serve as a solid foundation for your vanilla Emacs configuration and enhance your overall Emacs experience. The author is using **[minimal-emacs.d](https://github.com/jamescherti/minimal-emacs.d)** as his `early-init.el` and `init.el`. He is using 146 packages and his Emacs configuration starts in 0.22 seconds: ![](https://www.jamescherti.com/wp-content/uploads/minimal-emacs-startup-time.png) @@ -145,20 +145,7 @@ To prevent Emacs from saving customization information to a custom file, set `cu To customize your Emacs setup to include various user interface elements, you can use the following settings in your ``~/.emacs.d/pre-early-init.el``: ``` emacs-lisp -;; Enable both file dialogs and dialog boxes -(setq minimal-emacs-disable-dialogs nil) - -;; Enable context menu (right-click menu) -(setq minimal-emacs-disable-context-menu nil) - -;; Enable the tool bar at the top -(setq minimal-emacs-disable-tool-bar nil) - -;; Enable the menu bar at the top -(setq minimal-emacs-disable-menu-bar nil) - -;; Enable tooltips (hover text) -(setq minimal-emacs-disable-tooltips nil) +(setq minimal-emacs-ui-features '(context-menu tool-bar menu-bar dialogs tooltips)) ``` These settings control the visibility of dialogs, context menus, toolbars, menu bars, and tooltips. diff --git a/early-init.el b/early-init.el index d6530af..71c6c68 100644 --- a/early-init.el +++ b/early-init.el @@ -8,17 +8,46 @@ ;; SPDX-License-Identifier: GPL-3.0-or-later ;;; Commentary: -;; This file contains early initialization settings for Emacs. It is designed -;; to optimize the startup process and configure essential settings before the -;; main initialization. +;; The minimal-emacs.d starter kit provides improved Emacs defaults and +;; optimized startup, intended to serve as a solid foundation for your vanilla +;; Emacs configuration and enhance your overall Emacs experience. ;;; Code: -;;; Load pre-early-init.el +;;; Variables + +(defvar minimal-emacs-ui-features '(context-menu) + "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. + +Each feature in the list corresponds to a specific UI component that can be +turned on.") + +(defvar minimal-emacs-frame-title-format "%b – Emacs" + "Template for displaying the title bar of visible and iconified frame.") + +(defvar minimal-emacs-debug nil + "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-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-user-directory user-emacs-directory "The default value of the `user-emacs-directory' variable.") +;;; Load pre-early-init.el + (defun minimal-emacs-load-user-init (filename) "Execute a file of Lisp code named FILENAME." (let ((user-init-file @@ -33,42 +62,6 @@ (expand-file-name "themes/" minimal-emacs-user-directory)) (setq custom-file (expand-file-name "custom.el" minimal-emacs-user-directory)) -;;; Variables -(defvar minimal-emacs-debug nil - "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-frame-title-format "%b – Emacs" - "Template for displaying the title bar of visible and iconified frame.") - -(defvar minimal-emacs-default-gc-cons-threshold gc-cons-threshold - "The default value of `gc-cons-threshold'.") - -(defvar minimal-emacs--default-mode-line-format mode-line-format - "Default value of `mode-line-format'.") - -(defvar minimal-emacs-disable-context-menu t - "Non-nil enables the context menu in graphical environments.") - -(defvar minimal-emacs-disable-tool-bar t - "Non-nil enables the tool bar in graphical environments.") - -(defvar minimal-emacs-disable-menu-bar t - "Non-nil enables the tool bar in graphical environments.") - -(defvar minimal-emacs-disable-dialogs t - "If non-nil, enable both file dialogs and dialog boxes.") - -(defvar minimal-emacs-disable-tooltips t - "When non-nil, tooltips are enabled. If nil, tooltips are disabled.") - -(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.") - ;;; Misc (set-language-environment "UTF-8") @@ -157,10 +150,12 @@ When set to non-nil, Emacs will automatically call `package-initialize' and inhibit-message nil) (redraw-frame)) + (defvar minimal-emacs--default-mode-line-format mode-line-format + "Default value of `mode-line-format'.") (setq-default mode-line-format nil) (defun minimal-emacs--startup-load-user-init-file (fn &rest args) - "Around advice for startup--load-user-init-file to reset mode-line-format." + "Advice for startup--load-user-init-file to reset mode-line-format." (let (init) (unwind-protect (progn @@ -255,7 +250,7 @@ When set to non-nil, Emacs will automatically call `package-initialize' and ;; a superfluous and potentially expensive frame redraw at startup, depending ;; on the window system. The variables must also be set to `nil' so users don't ;; have to call the functions twice to re-enable them. -(when minimal-emacs-disable-menu-bar +(unless (memq 'menu-bar minimal-emacs-ui-features) (push '(menu-bar-lines . 0) default-frame-alist) (unless (memq window-system '(mac ns)) (setq menu-bar-mode nil))) @@ -269,7 +264,7 @@ When set to non-nil, Emacs will automatically call `package-initialize' and (:before (&rest _) minimal-emacs-setup-toolbar) (advice-remove #'tool-bar-setup #'ignore) (tool-bar-setup)))) -(when minimal-emacs-disable-tool-bar +(unless (memq 'tool-bar minimal-emacs-ui-features) (push '(tool-bar-lines . 0) default-frame-alist) (setq tool-bar-mode nil)) @@ -279,13 +274,13 @@ When set to non-nil, Emacs will automatically call `package-initialize' and (when (fboundp 'horizontal-scroll-bar-mode) (horizontal-scroll-bar-mode -1)) -(when minimal-emacs-disable-tooltips +(unless (memq 'tooltips minimal-emacs-ui-features) (when (bound-and-true-p tooltip-mode) (tooltip-mode -1))) ;; Disable GUIs because they are inconsistent across systems, desktop ;; environments, and themes, and they don't match the look of Emacs. -(when minimal-emacs-disable-dialogs +(unless (memq 'dialogs minimal-emacs-ui-features) (setq use-file-dialog nil) (setq use-dialog-box nil)) diff --git a/init.el b/init.el index 20e0d35..7f9eaff 100644 --- a/init.el +++ b/init.el @@ -8,9 +8,9 @@ ;; SPDX-License-Identifier: GPL-3.0-or-later ;;; Commentary: -;; This is the main initialization file for Emacs. It configures package -;; archives, ensures essential packages like `use-package` are installed, and -;; sets up further package management and customization settings. +;; The minimal-emacs.d starter kit provides improved Emacs defaults and +;; optimized startup, intended to serve as a solid foundation for your vanilla +;; Emacs configuration and enhance your overall Emacs experience. ;;; Code: @@ -211,8 +211,9 @@ ;;; Mouse ;; Emacs 29 -(when (and (display-graphic-p) (fboundp 'context-menu-mode)) - (add-hook 'after-init-hook #'context-menu-mode)) +(when (memq 'context-menu minimal-emacs-ui-features) + (when (and (display-graphic-p) (fboundp 'context-menu-mode)) + (add-hook 'after-init-hook #'context-menu-mode))) (setq hscroll-margin 2 hscroll-step 1