diff --git a/.LICENSE b/.github/LICENSE similarity index 100% rename from .LICENSE rename to .github/LICENSE diff --git a/.gitignore b/.gitignore index 793116d..e28235b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ !README.md !early-init.el !init.el -!.images/ !.github/ !.LICENSE diff --git a/.images/made-for-gnu-emacs.svg b/.images/made-for-gnu-emacs.svg deleted file mode 100644 index 5f9df38..0000000 --- a/.images/made-for-gnu-emacs.svg +++ /dev/null @@ -1 +0,0 @@ -Made for: GNU EmacsMade forGNU Emacs \ No newline at end of file diff --git a/README.md b/README.md index 5d6d983..53611a3 100644 --- a/README.md +++ b/README.md @@ -8,13 +8,51 @@ My dotfiles are based on the [minimal-emacs.d](https://github.com/jamescherti/mi The original repository contains a lot of useful info, so do check it out. + ## Dotfiles setup +

+ +

+ +**Here are the instructions for installing minimal-emacs.d:** [Install minimal-emacs.d](#install-minimal-emacsd). + +## Looking for the ideal starter kit to customize Emacs? You have found it. + +The *minimal-emacs.d* project is: +- **Minimal yet effective:** A solid starting point. +- **Better defaults:** Improved settings for usability, UI, garbage collection, and built-in packages. +- **0 packages loaded / No forced modes:** Unlike other frameworks or starter kits, *minimal-emacs.d* does not impose modes or require packages. **You have full control** over which global or minor modes to enable and which packages to load with `require`. +- **Customizable foundation:** Designed to be extended, not replaced. This README.md offers extensive recommendations for customizing your *minimal-emacs.d* configuration. (Reminder: [Never modify init.el and early-init.el. Modify these instead...](#customizations-never-modify-initel-and-early-initel-modify-these-instead)) + +The *minimal-emacs.d* project includes two initialization files: +- `early-init.el`: Loaded early in the Emacs startup process, before the graphical interface is initialized. Introduced in Emacs 27, this file configures settings that influence startup performance and GUI behavior prior to package loading. +- `init.el`: Loaded after the graphical interface is initialized. This file contains user customizations, including variable settings, package loading, mode configurations, and keybindings. + +![](https://www.jamescherti.com/misc/screenshot-minimal-emacs-2.png) +*(The theme shown in the screenshot above is ef-melissa-light, which is part of the ef-themes collection available on MELPA.)* +![](https://www.jamescherti.com/misc/screenshot-minimal-emacs-1.png) +*(The theme shown in the screenshot above is doom-one, which is part of the doom-themes collection available on MELPA.)* +![](https://www.jamescherti.com/misc/screenshot-minimal-emacs-3.png) +*(The theme shown in the screenshot above is the *[tomorrow-night-deepblue-theme.el](https://github.com/jamescherti/tomorrow-night-deepblue-theme.el)*, available on MELPA.)* + +### Startup + +The author uses *minimal-emacs.d* as his `early-init.el` and `init.el`, alongside **146 packages** ([See the packages that the author is using here](https://www.jamescherti.com/essential-emacs-packages/)). Yet, thanks to its efficient design, Emacs still **starts in just 0.22 seconds**: Author of [minimal-emacs.d](https://github.com/jamescherti/minimal-emacs.d) suggests putting (almost) everything into the post-init.el file, which I simply do not agree with. I am used to using plug-in files, with the main one only having the bare minimum of content. As such, post-init.el file only contains the minimal setup code, and at the end loads the files in the `.config.d` folder, in alphanumeric order. In those plug-in files the real magic happens. All the files are heavily documented, with mostly self-explanatory names, so I think it will be redundant to list them here. See the files in `config.d` directory for more. + +In addition to *minimal-emacs.d*, startup speed is influenced by your computer's processing power and disk speed. To establish a baseline, start Emacs with only *minimal-emacs.d* and no additional configurations, then run `M-x emacs-init-time`. Incrementally modify your init files and observe the impact on startup time. For consistent comparisons, always test on the same computer and Emacs version. It's also important to ensure that all packages are deferred using `:defer t` and `:commands`, which makes Emacs load them only when needed (see additional examples in this README.md). While startup time is important, other factors, like native compilation, are even more important. Although native compilation may introduce some brief initial and negligible initial delay, it is beneficial in the long run as it significantly speeds up Emacs. + + +## Table of Contents + - [*minimal-emacs.d* - A Customizable Emacs `init.el` and `early-init.el` that Provides Better Defaults and Faster Startup](#minimal-emacsd---a-customizable-emacs-initel-and-early-initel-that-provides-better-defaults-and-faster-startup) + - [Introduction](#introduction) + - [Looking for the ideal starter kit to customize Emacs? You have found it.](#looking-for-the-ideal-starter-kit-to-customize-emacs-you-have-found-it) + - [Startup](#startup) - [Install minimal-emacs.d](#install-minimal-emacsd) - [Install minimal-emacs.d into `~/.emacs.d`](#install-minimal-emacsd-into-emacsd) - [Alternative: Install minimal-emacs.d into `~/.minimal-emacs.d`](#alternative-install-minimal-emacsd-into-minimal-emacsd) @@ -33,11 +71,15 @@ As such, post-init.el file only contains the minimal setup code, and at the end - [Configuring Vertico, Consult, and Embark](#configuring-vertico-consult-and-embark) - [Code folding](#code-folding) - [Changing the default theme](#changing-the-default-theme) + - [Automatic removal of trailing whitespace on save](#automatic-removal-of-trailing-whitespace-on-save) - [Enhancing undo/redo](#enhancing-undoredo) - [Configuring Vim keybindings using Evil?](#configuring-vim-keybindings-using-evil) - [Configuring LSP Servers with Eglot (built-in)](#configuring-lsp-servers-with-eglot-built-in) - [Session Management](#session-management) - [Configuring org-mode](#configuring-org-mode) + - [Configuring markdown-mode (e.g., README.md syntax)](#configuring-markdown-mode-eg-readmemd-syntax) + - [Tree-sitter Integration (Better Syntax Highlighting)](#tree-sitter-integration-better-syntax-highlighting) + - [Treemacs, a tree layout file explorer (Sidebar file explorer)](#treemacs-a-tree-layout-file-explorer-sidebar-file-explorer) - [Inhibit the mouse](#inhibit-the-mouse) - [Spell checker](#spell-checker) - [Asynchronous code formatting without cursor disruption](#asynchronous-code-formatting-without-cursor-disruption) @@ -45,18 +87,19 @@ As such, post-init.el file only contains the minimal setup code, and at the end - [Enhancing the Elisp development experience](#enhancing-the-elisp-development-experience) - [Showing the tab-bar](#showing-the-tab-bar) - [Preventing Emacs from saving custom.el](#preventing-emacs-from-saving-customel) + - [Changing the Default Font](#changing-the-default-font) - [Which other customizations can be interesting to add?](#which-other-customizations-can-be-interesting-to-add) - [Customizations: pre-early-init.el](#customizations-pre-early-initel) - - [Reducing clutter in `~/.emacs.d` by redirecting files to `~/emacs.d/var/`](#reducing-clutter-in-emacsd-by-redirecting-files-to-emacsdvar) - - [Configuring straight.el?](#configuring-straightel) + - [Reducing clutter in `~/.emacs.d` by redirecting files to `~/.emacs.d/var/`](#reducing-clutter-in-emacsd-by-redirecting-files-to-emacsdvar) + - [Configuring straight.el](#configuring-straightel) - [Configuring elpaca (package manager)](#configuring-elpaca-package-manager) - [Frequently asked questions](#frequently-asked-questions) + - [Customizing Scroll Recentering](#customizing-scroll-recentering) - [How to display Emacs startup duration?](#how-to-display-emacs-startup-duration) - [How to use MELPA stable?](#how-to-use-melpa-stable) - [How to load a local lisp file for machine-specific configurations?](#how-to-load-a-local-lisp-file-for-machine-specific-configurations) - [How to load Emacs customizations?](#how-to-load-emacs-customizations) - [How to increase gc-cons-threshold?](#how-to-increase-gc-cons-threshold) - - [How to change the outline-mode or outline-minor-mode Ellipsis (...) to (▼)?](#how-to-change-the-outline-mode-or-outline-minor-mode-ellipsis--to-) - [How to prevent Emacs from loading .dir-locals.el files?](#how-to-prevent-emacs-from-loading-dir-localsel-files) - [How to make minimal-emacs.d use an environment variable to change ~/.emacs.d to another directory?](#how-to-make-minimal-emacsd-use-an-environment-variable-to-change-emacsd-to-another-directory) - [Are post-early-init.el and pre-init.el the same file in terms of the logic?](#are-post-early-initel-and-pre-initel-the-same-file-in-terms-of-the-logic) @@ -106,7 +149,6 @@ To keep your Emacs configuration up to date, you can pull the latest changes fro git -C ~/.emacs.d pull ``` - ## Customizations: Never modify init.el and early-init.el. Modify these instead... **The `init.el` and `early-init.el` files should never be modified directly** because they are intended to be managed by Git during an update. @@ -157,6 +199,8 @@ These settings control the visibility of dialogs, context menus, toolbars, menu ## Customizations: Packages (post-init.el) +This README.md offers guidance on installing optional external packages. While Emacs and minimal-emacs.d are fully functional without them, the recommended packages can enhance your experience and introduce additional features, which is why they are suggested. + ### Optimization: Native Compilation Native compilation enhances Emacs performance by converting Elisp code into native machine code, resulting in faster execution and improved responsiveness. @@ -169,6 +213,10 @@ Native compilation enhances Emacs performance by converting Elisp code into nati 2. Ensure all libraries are byte-compiled and native-compiled using [compile-angel.el](https://github.com/jamescherti/compile-angel.el). To install compile-angel, add the following code at the very beginning of your `~/.emacs.d/post-init.el` file, before all other packages: ```emacs-lisp +;; Native compilation enhances Emacs performance by converting Elisp code into +;; native machine code, resulting in faster execution and improved +;; responsiveness. +;; ;; Ensure adding the following compile-angel code at the very beginning ;; of your `~/.emacs.d/post-init.el` file, before all other packages. (use-package compile-angel @@ -186,6 +234,8 @@ Native compilation enhances Emacs performance by converting Elisp code into nati ;; implications and thoroughly test your code. For example, if you're using ;; `use-package', you'll need to explicitly add `(require 'use-package)` at ;; the top of your init file. + (push "/init.el" compile-angel-excluded-files) + (push "/early-init.el" compile-angel-excluded-files) (push "/pre-init.el" compile-angel-excluded-files) (push "/post-init.el" compile-angel-excluded-files) (push "/pre-early-init.el" compile-angel-excluded-files) @@ -213,7 +263,9 @@ The recentf, savehist, saveplace, and auto-revert built-in packages are already (add-hook 'after-init-hook #'(lambda() (let ((inhibit-message t)) (recentf-mode 1)))) -(add-hook 'kill-emacs-hook #'recentf-cleanup) + +(with-eval-after-load "recentf" + (add-hook 'kill-emacs-hook #'recentf-cleanup)) ;; savehist is an Emacs feature that preserves the minibuffer history between ;; sessions. It saves the history of inputs in the minibuffer, such as commands, @@ -251,6 +303,15 @@ When `auto-save-visited-mode` is enabled, Emacs will auto-save file-visiting buf This is different from `auto-save-mode`: `auto-save-mode` periodically saves all modified buffers, creating backup files, including those not associated with a file, while `auto-save-visited-mode` only saves file-visiting buffers after a period of idle time, directly saving to the file itself without creating backup files. ``` emacs-lisp +;; When auto-save-visited-mode is enabled, Emacs will auto-save file-visiting +;; buffers after a certain amount of idle time if the user forgets to save it +;; with save-buffer or C-x s for example. +;; +;; This is different from auto-save-mode: auto-save-mode periodically saves +;; all modified buffers, creating backup files, including those not associated +;; with a file, while auto-save-visited-mode only saves file-visiting buffers +;; after a period of idle time, directly saving to the file itself without +;; creating backup files. (setq auto-save-visited-interval 5) ; Save after 5 seconds if inactivity (auto-save-visited-mode 1) ``` @@ -265,9 +326,11 @@ Cape, or Completion At Point Extensions, extends the capabilities of in-buffer c To configure `corfu` and `cape`, add the following to `~/.emacs.d/post-init.el`: ``` emacs-lisp +;; Corfu enhances in-buffer completion by displaying a compact popup with +;; current candidates, positioned either below or above the point. Candidates +;; can be selected by navigating up or down. (use-package corfu :ensure t - :defer t :commands (corfu-mode global-corfu-mode) :hook ((prog-mode . corfu-mode) @@ -285,9 +348,11 @@ To configure `corfu` and `cape`, add the following to `~/.emacs.d/post-init.el`: :config (global-corfu-mode)) +;; Cape, or Completion At Point Extensions, extends the capabilities of +;; in-buffer completion. It integrates with Corfu or the default completion UI, +;; by providing additional backends through completion-at-point-functions. (use-package cape :ensure t - :defer t :commands (cape-dabbrev cape-file cape-elisp-block) :bind ("C-c p" . cape-prefix-map) :init @@ -312,38 +377,41 @@ Embark integrates with these tools to provide context-sensitive actions and quic Add the following to `~/.emacs.d/post-init.el` to set up Vertico, Consult, and Embark: ``` emacs-lisp +;; Vertico provides a vertical completion interface, making it easier to +;; navigate and select from completion candidates (e.g., when `M-x` is pressed). (use-package vertico ;; (Note: It is recommended to also enable the savehist package.) :ensure t - :defer t - :commands vertico-mode - :hook (after-init . vertico-mode)) + :config + (vertico-mode)) +;; Vertico leverages Orderless' flexible matching capabilities, allowing users +;; to input multiple patterns separated by spaces, which Orderless then +;; matches in any order against the candidates. (use-package orderless - ;; Vertico leverages Orderless' flexible matching capabilities, allowing users - ;; to input multiple patterns separated by spaces, which Orderless then - ;; matches in any order against the candidates. :ensure t :custom (completion-styles '(orderless basic)) (completion-category-defaults nil) (completion-category-overrides '((file (styles partial-completion))))) +;; Marginalia allows Embark to offer you preconfigured actions in more contexts. +;; In addition to that, Marginalia also enhances Vertico by adding rich +;; annotations to the completion candidates displayed in Vertico's interface. (use-package marginalia - ;; Marginalia allows Embark to offer you preconfigured actions in more contexts. - ;; In addition to that, Marginalia also enhances Vertico by adding rich - ;; annotations to the completion candidates displayed in Vertico's interface. :ensure t - :defer t :commands (marginalia-mode marginalia-cycle) :hook (after-init . marginalia-mode)) +;; Embark integrates with Consult and Vertico to provide context-sensitive +;; actions and quick access to commands based on the current selection, further +;; improving user efficiency and workflow within Emacs. Together, they create a +;; cohesive and powerful environment for managing completions and interactions. (use-package embark ;; Embark is an Emacs package that acts like a context menu, allowing ;; users to perform context-sensitive actions on selected items ;; directly from the completion interface. :ensure t - :defer t :commands (embark-act embark-dwim embark-export @@ -370,6 +438,8 @@ Add the following to `~/.emacs.d/post-init.el` to set up Vertico, Consult, and E :hook (embark-collect-mode . consult-preview-at-point-mode)) +;; Consult offers a suite of commands for efficient searching, previewing, and +;; interacting with buffers, file contents, and more, improving various tasks. (use-package consult :ensure t :bind (;; C-c bindings in `mode-specific-map' @@ -440,6 +510,17 @@ Add the following to `~/.emacs.d/post-init.el` to set up Vertico, Consult, and E (setq xref-show-xrefs-function #'consult-xref xref-show-definitions-function #'consult-xref) + ;; Aggressive asynchronous that yield instantaneous results. (suitable for + ;; high-performance systems.) Note: Minad, the author of Consult, does not + ;; recommend aggressive values. + ;; Read: https://github.com/minad/consult/discussions/951 + ;; + ;; However, the author of minimal-emacs.d uses these parameters to achieve + ;; immediate feedback from Consult. + ;; (setq consult-async-input-debounce 0.02 + ;; consult-async-input-throttle 0.05 + ;; consult-async-refresh-delay 0.02) + :config (consult-customize consult-theme :preview-key '(:debounce 0.2 any) @@ -461,18 +542,44 @@ Alternatively, `hs-minor-mode` offers basic code folding for blocks defined by c For example, to enable `outline-minor-mode` in Emacs Lisp: ``` emacs-lisp -(add-hook 'emacs-lisp-mode-hook #'outline-minor-mode) +;; The built-in outline-minor-mode provides structured code folding in modes +;; such as Emacs Lisp and Python, allowing users to collapse and expand sections +;; based on headings or indentation levels. This feature enhances navigation and +;; improves the management of large files with hierarchical structures. +(use-package outline + :ensure nil + :commands outline-minor-mode + :hook + ((emacs-lisp-mode . outline-minor-mode) + ;; Use " ▼" instead of the default ellipsis "..." for folded text to make + ;; folds more visually distinctive and readable. + (outline-minor-mode + . + (lambda() + (let* ((display-table (or buffer-display-table (make-display-table))) + (face-offset (* (face-id 'shadow) (ash 1 22))) + (value (vconcat (mapcar (lambda (c) (+ face-offset c)) " ▼")))) + (set-display-table-slot display-table 'selective-display value) + (setq buffer-display-table display-table)))))) ``` For folding based on indentation levels, the **[outline-indent](https://github.com/jamescherti/outline-indent.el)** Emacs package provides a minor mode that enables folding according to the indentation structure: ```elisp +;; The outline-indent Emacs package provides a minor mode that enables code +;; folding based on indentation levels. +;; +;; In addition to code folding, *outline-indent* allows: +;; - Moving indented blocks up and down +;; - Indenting/unindenting to adjust indentation levels +;; - Inserting a new line with the same indentation level as the current line +;; - Move backward/forward to the indentation level of the current line +;; - and other features. (use-package outline-indent :ensure t - :defer t :commands outline-indent-minor-mode :custom - (outline-indent-ellipsis " ▼ ") + (outline-indent-ellipsis " ▼") :init ;; The minor mode can also be automatically activated for a certain modes. @@ -483,9 +590,7 @@ For folding based on indentation levels, the **[outline-indent](https://github.c (add-hook 'yaml-ts-mode-hook #'outline-indent-minor-mode)) ``` -In addition to code folding, *outline-indent* also allows: moving indented blocks up and down, indenting/unindenting to adjust indentation levels, inserting a new line with the same indentation level as the current line, Move backward/forward to the indentation level of the current line, and more. - -![](https://raw.githubusercontent.com/jamescherti/outline-indent.el/main/.screenshot2.png) +![](https://raw.githubusercontent.com/jamescherti/outline-indent.el/main/.images/screenshot2.png) ### Changing the default theme @@ -531,6 +636,42 @@ If you're interested in exploring third-party Emacs themes, consider the followi - `doom-themes` (available on MELPA): An extensive collection of high-quality, visually appealing themes for Emacs, designed to offer a sleek and modern aesthetic, while drawing inspiration from popular community themes. - `tomorrow-night-deepblue-theme` (available on MELPA): A beautiful deep blue variant of the Tomorrow Night theme, which is renowned for its elegant color palette. It features a deep blue background color that creates a calming atmosphere. This theme is a great choice for those who miss the blue themes that were trendy a few years ago. (The theme was inspired by classic text editors such as QuickBASIC, RHIDE, and Turbo Pascal, as well as tools such as Midnight Commander.) +### Automatic removal of trailing whitespace on save + +**Trailing whitespace** refers to any spaces or tabs that appear after the last non-whitespace character on a line. These characters have no semantic value and can lead to unnecessary diffs in version control, inconsistent formatting, or visual clutter. Removing them improves code clarity and consistency. + +The [stripspace](https://github.com/jamescherti/stripspace.el) Emacs package provides `stripspace-local-mode`, a minor mode that automatically removes trailing whitespace and blank lines at the end of the buffer when saving. + +To enable **stripspace** and automatically delete trailing whitespace, add the following configuration to `~/.emacs.d/post-init.el`: +```elisp +;; The stripspace Emacs package provides stripspace-local-mode, a minor mode +;; that automatically removes trailing whitespace and blank lines at the end of +;; the buffer when saving. +(use-package stripspace + :ensure t + :commands stripspace-local-mode + + ;; Enable for prog-mode-hook, text-mode-hook, conf-mode-hook + :hook ((prog-mode . stripspace-local-mode) + (text-mode . stripspace-local-mode) + (conf-mode . stripspace-local-mode)) + + :custom + ;; The `stripspace-only-if-initially-clean' option: + ;; - nil to always delete trailing whitespace. + ;; - Non-nil to only delete whitespace when the buffer is clean initially. + ;; (The initial cleanliness check is performed when `stripspace-local-mode' + ;; is enabled.) + (stripspace-only-if-initially-clean nil) + + ;; Enabling `stripspace-restore-column' preserves the cursor's column position + ;; even after stripping spaces. This is useful in scenarios where you add + ;; extra spaces and then save the file. Although the spaces are removed in the + ;; saved file, the cursor remains in the same position, ensuring a consistent + ;; editing experience without affecting cursor placement. + (stripspace-restore-column t)) +``` + ### Enhancing undo/redo The undo-fu package is a lightweight wrapper around Emacs' built-in undo system, providing more convenient undo/redo functionality while preserving access to the full undo history. The undo-fu-session package complements undo-fu by enabling the saving and restoration of undo history across Emacs sessions, even after restarting. @@ -545,7 +686,7 @@ To install and configure these packages, add the following to `~/.emacs.d/post-i ;; The undo-fu package is a lightweight wrapper around Emacs' built-in undo ;; system, providing more convenient undo/redo functionality. (use-package undo-fu - :defer t + :ensure t :commands (undo-fu-only-undo undo-fu-only-redo undo-fu-only-redo-all @@ -558,7 +699,7 @@ To install and configure these packages, add the following to `~/.emacs.d/post-i ;; The undo-fu-session package complements undo-fu by enabling the saving ;; and restoration of undo history across Emacs sessions, even after restarting. (use-package undo-fu-session - :defer t + :ensure t :commands undo-fu-session-global-mode :hook (after-init . undo-fu-session-global-mode)) ``` @@ -568,34 +709,61 @@ To install and configure these packages, add the following to `~/.emacs.d/post-i Configuring Vim keybindings in Emacs can greatly enhance your editing efficiency if you are accustomed to Vim's modal editing style. Add the following to `~/.emacs.d/post-init.el` to set up [Evil mode](https://github.com/emacs-evil/evil): ``` emacs-lisp -;; Required by evil-collection -(eval-when-compile - ;; It has to be defined before evil - (setq evil-want-integration t) - (setq evil-want-keybinding nil)) - ;; Uncomment the following if you are using undo-fu ;; (setq evil-undo-system 'undo-fu) ;; Vim emulation (use-package evil :ensure t - :defer t :commands (evil-mode evil-define-key) - :hook (after-init . evil-mode)) + :hook (after-init . evil-mode) -(eval-when-compile - ;; It has to be defined before evil-colllection - (setq evil-collection-setup-minibuffer t)) + :init + ;; It has to be defined before evil + (setq evil-want-integration t) + (setq evil-want-keybinding nil) + + :custom + ;; Make :s in visual mode operate only on the actual visual selection + ;; (character or block), instead of the full lines covered by the selection + (evil-ex-visual-char-range t) + ;; Use Vim-style regular expressions in search and substitute commands, + ;; allowing features like \v (very magic), \zs, and \ze for precise matches + (evil-ex-search-vim-style-regexp t) + ;; Enable automatic horizontal split below + (evil-split-window-below t) + ;; Enable automatic vertical split to the right + (evil-vsplit-window-right t) + ;; Disable echoing Evil state to avoid replacing eldoc + (evil-echo-state nil) + ;; Do not move cursor back when exiting insert state + (evil-move-cursor-back nil) + ;; Make `v$` exclude the final newline + (evil-v$-excludes-newline t) + ;; Allow C-h to delete in insert state + (evil-want-C-h-delete t) + ;; Enable C-u to delete back to indentation in insert state + (evil-want-C-u-delete t) + ;; Enable fine-grained undo behavior + (evil-want-fine-undo t) + ;; Allow moving cursor beyond end-of-line in visual block mode + (evil-move-beyond-eol t) + ;; Disable wrapping of search around buffer + (evil-search-wrap nil) + ;; Whether Y yanks to the end of the line + (evil-want-Y-yank-to-eol t)) (use-package evil-collection :after evil :ensure t + :init + ;; It has to be defined before evil-colllection + (setq evil-collection-setup-minibuffer t) :config (evil-collection-init)) ``` -You can also use the [vim-tab-bar](https://github.com/jamescherti/vim-tab-bar.el) Emacs package to `~/.emacs.d/post-init.el` to give the built-in Emacs tab-bar a style similar to Vim's tabbed browsing interface: +You can also install the [vim-tab-bar](https://github.com/jamescherti/vim-tab-bar.el) package to enhance the built-in Emacs tab-bar with a minimalist, Vim-inspired design that automatically adapts to the active Emacs theme. Beyond its Vim-inspired design, the *vim-tab-bar* package is valued by users who prioritize theme consistency, as it integrates the Emacs tab-bar with any Emacs theme, producing a visually coherent and polished interface: ``` emacs-lisp ;; Give Emacs tab-bar a style similar to Vim's (use-package vim-tab-bar @@ -604,12 +772,20 @@ You can also use the [vim-tab-bar](https://github.com/jamescherti/vim-tab-bar.el :hook (after-init . vim-tab-bar-mode)) ``` +![](https://raw.githubusercontent.com/jamescherti/vim-tab-bar.el/main/.screenshots/emacs-tab-like-vim.png) + +*(The screenshot above showcases how vim-tab-bar modifies the built-in Emacs tab-bar.)* + The `evil-surround` package simplifies handling surrounding characters, such as parentheses, brackets, quotes, etc. It provides key bindings to easily add, change, or delete these surrounding characters in pairs. For instance, you can surround the currently selected text with double quotes in visual state using `S"` or `gS"`: ``` emacs-lisp +;; The evil-surround package simplifies handling surrounding characters, such as +;; parentheses, brackets, quotes, etc. It provides key bindings to easily add, +;; change, or delete these surrounding characters in pairs. For instance, you +;; can surround the currently selected text with double quotes in visual state +;; using S" or gS". (use-package evil-surround :after evil :ensure t - :defer t :commands global-evil-surround-mode :custom (evil-surround-pairs-alist @@ -628,6 +804,8 @@ The `evil-surround` package simplifies handling surrounding characters, such as You can also add the following code to enable commenting and uncommenting by pressing `gcc` in normal mode and `gc` in visual mode (thanks you to the Reddit user u/mistakenuser for this contribution, which replaces the evil-commentary package): ``` emacs-lisp +;; The following code enables commenting and uncommenting by pressing gcc in +;; normal mode and gc in visual mode. (with-eval-after-load "evil" (evil-define-operator my-evil-comment-or-uncomment (beg end) "Toggle comment for the region between BEG and END." @@ -638,15 +816,12 @@ You can also add the following code to enable commenting and uncommenting by pre ### Configuring LSP Servers with Eglot (built-in) -To set up Language Server Protocol (LSP) servers using Eglot, you can configure it in your Emacs setup as follows. This configuration ensures minimal disruption from Eglot's progress reporting and optimizes performance by disabling unnecessary logging. - -To configure `eglot`, add the following to `~/.emacs.d/post-init.el`: +To set up Language Server Protocol (LSP) servers using Eglot, you can configure it, add the following to `~/.emacs.d/post-init.el`: ``` emacs-lisp +;; Set up the Language Server Protocol (LSP) servers using Eglot. (use-package eglot :ensure nil - :defer t - :commands (eglot - eglot-ensure + :commands (eglot-ensure eglot-rename eglot-format-buffer)) ``` @@ -654,6 +829,11 @@ To configure `eglot`, add the following to `~/.emacs.d/post-init.el`: Here is an example of how to configure Eglot to enable or disable certain options for the `pylsp` server in Python development. (Note that a third-party tool, [python-lsp-server](https://github.com/python-lsp/python-lsp-server), must be installed): ``` emacs-lisp +;; Configure Eglot to enable or disable certain options for the pylsp server +;; in Python development. (Note that a third-party tool, +;; https://github.com/python-lsp/python-lsp-server, must be installed), +(add-hook 'python-mode-hook #'eglot-ensure) +(add-hook 'python-ts-mode-hook #'eglot-ensure) (setq-default eglot-workspace-configuration `(:pylsp (:plugins (;; Fix imports and syntax using `eglot-format-buffer` @@ -670,9 +850,6 @@ Here is an example of how to configure Eglot to enable or disable certain option :yapf (:enabled :json-false) :rope_autoimport (:enabled :json-false))))) - -(add-hook 'python-mode-hook #'eglot) -(add-hook 'python-ts-mode-hook #'eglot) ``` ### Session Management @@ -681,9 +858,14 @@ The [easysession](https://github.com/jamescherti/easysession.el) Emacs package i To configure **easysession**, add the following to `~/.emacs.d/post-init.el`: ``` emacs-lisp +;; The easysession Emacs package is a session manager for Emacs that can persist +;; and restore file editing buffers, indirect buffers/clones, Dired buffers, +;; windows/splits, the built-in tab-bar (including tabs, their buffers, and +;; windows), and Emacs frames. It offers a convenient and effortless way to +;; manage Emacs editing sessions and utilizes built-in Emacs functions to +;; persist and restore frames. (use-package easysession :ensure t - :defer t :commands (easysession-switch-to easysession-save-as easysession-save-mode @@ -710,11 +892,17 @@ To configure **easysession**, add the following to `~/.emacs.d/post-init.el`: ### Configuring org-mode +Org mode is a major mode designed for organizing notes, planning, task management, and authoring documents using plain text with a simple and expressive markup syntax. It supports hierarchical outlines, TODO lists, scheduling, deadlines, time tracking, and exporting to multiple formats including HTML, LaTeX, PDF, and Markdown. + To configure **org-mode**, add the following to `~/.emacs.d/post-init.el`: ```elisp +;; Org mode is a major mode designed for organizing notes, planning, task +;; management, and authoring documents using plain text with a simple and +;; expressive markup syntax. It supports hierarchical outlines, TODO lists, +;; scheduling, deadlines, time tracking, and exporting to multiple formats +;; including HTML, LaTeX, PDF, and Markdown. (use-package org :ensure t - :defer t :commands (org-mode org-version) :mode ("\\.org\\'" . org-mode) @@ -723,11 +911,189 @@ To configure **org-mode**, add the following to `~/.emacs.d/post-init.el`: (org-startup-indented t) (org-adapt-indentation nil) (org-edit-src-content-indentation 0) - (org-startup-truncated t) - (org-fontify-done-headline t) - (org-fontify-todo-headline t) - (org-fontify-whole-heading-line t) - (org-fontify-quote-and-verse-blocks t)) + ;; (org-fontify-done-headline t) + ;; (org-fontify-todo-headline t) + ;; (org-fontify-whole-heading-line t) + ;; (org-fontify-quote-and-verse-blocks t) + (org-startup-truncated t)) +``` + +### Configuring markdown-mode (e.g., README.md syntax) + +The [markdown-mode](https://github.com/jrblevin/markdown-mode) package provides a major mode for Emacs for syntax highlighting, editing commands, and preview support for Markdown documents. It supports core Markdown syntax as well as extensions like GitHub Flavored Markdown (GFM). + +To configure **markdown-mode**, add the following to `~/.emacs.d/post-init.el`: +```elisp +;; The markdown-mode package provides a major mode for Emacs for syntax +;; highlighting, editing commands, and preview support for Markdown documents. +;; It supports core Markdown syntax as well as extensions like GitHub Flavored +;; Markdown (GFM). +(use-package markdown-mode + :commands (gfm-mode + gfm-view-mode + markdown-mode + markdown-view-mode) + :mode (("\\.markdown\\'" . markdown-mode) + ("\\.md\\'" . markdown-mode) + ("README\\.md\\'" . gfm-mode)) + :init + (setq markdown-command "multimarkdown") + + :bind + (:map markdown-mode-map + ("C-c C-e" . markdown-do))) +``` + +This configuration sets up `markdown-mode` with deferred loading to improve startup performance. The `:commands` and `:mode` keywords ensure that the mode is loaded only when needed—for example, when opening `.md`, `.markdown`, or `README.md` files. Files named `README.md` are specifically associated with `gfm-mode`, which is for GitHub Flavored Markdown syntax. The `markdown-command` variable is set to `"multimarkdown"` to specify the Markdown processor used for previews and exports. Additionally, a keybinding (`C-c C-e`) is defined in `markdown-mode-map` to invoke `markdown-do`, which can be customized to perform common Markdown-related actions. + +### Tree-sitter Integration (Better Syntax Highlighting) + +Tree-sitter is an incremental parsing system introduced in Emacs 29 that provides precise, high-performance syntax analysis and highlighting by constructing concrete syntax trees from source code. It supports a broad set of programming languages, including Bash, C, C++, C#, CMake, CSS, Dockerfile, Go, Java, JavaScript, JSON, Python, Rust, TOML, TypeScript, YAML, Elisp, Lua, Markdown, and many others. Unlike traditional font-lock, which relies on regular expressions, Tree-sitter uses formal grammar definitions to build real-time parse trees, enabling accurate syntax highlighting, structural navigation, code folding, and foundational support for advanced editing features like refactoring. + +The configuration below enables Tree-sitter support using the [treesit-auto](https://github.com/renzmann/treesit-auto) package. Setting `treesit-auto-add-to-auto-mode-alist` to `'all` ensures that all available Tree-sitter modes are automatically activated for their corresponding file types. Enabling `global-treesit-auto-mode` applies this behavior globally, improving syntax accuracy and consistency across supported languages. + +To enable Tree-sitter, add the following to your `~/.emacs.d/post-init.el`: + +```elisp +;; Tree-sitter in Emacs is an incremental parsing system introduced in Emacs 29 +;; that provides precise, high-performance syntax highlighting. It supports a +;; broad set of programming languages, including Bash, C, C++, C#, CMake, CSS, +;; Dockerfile, Go, Java, JavaScript, JSON, Python, Rust, TOML, TypeScript, YAML, +;; Elisp, Lua, Markdown, and many others. +(use-package treesit-auto + :ensure t + :custom + (treesit-auto-install 'prompt) + :config + (treesit-auto-add-to-auto-mode-alist 'all) + (global-treesit-auto-mode)) +``` + +### Treemacs, a tree layout file explorer (Sidebar file explorer) + +The [treemacs](https://github.com/Alexander-Miller/treemacs) package is a file and project explorer for Emacs that provides a visually structured tree layout similar to file browsers in modern IDEs. It integrates well with various Emacs packages such as `projectile`, `lsp-mode`, and `magit`, allowing users to navigate their project structure efficiently. + +![](https://raw.githubusercontent.com/Alexander-Miller/treemacs/refs/heads/master/screenshots/screenshot.png) + +To configure **treemacs**, add the following to `~/.emacs.d/post-init.el`: +```elisp +;; A file and project explorer for Emacs that displays a structured tree +;; layout, similar to file browsers in modern IDEs. It functions as a sidebar +;; in the left window, providing a persistent view of files, projects, and +;; other elements. +(use-package treemacs + :ensure t + :commands (treemacs + treemacs-select-window + treemacs-delete-other-windows + treemacs-select-directory + treemacs-bookmark + treemacs-find-file + treemacs-find-tag) + + :bind + (:map global-map + ("M-0" . treemacs-select-window) + ("C-x t 1" . treemacs-delete-other-windows) + ("C-x t t" . treemacs) + ("C-x t d" . treemacs-select-directory) + ("C-x t B" . treemacs-bookmark) + ("C-x t C-t" . treemacs-find-file) + ("C-x t M-t" . treemacs-find-tag)) + + :init + (with-eval-after-load 'winum + (define-key winum-keymap (kbd "M-0") #'treemacs-select-window)) + + :config + (setq treemacs-collapse-dirs (if treemacs-python-executable 3 0) + treemacs-deferred-git-apply-delay 0.5 + treemacs-directory-name-transformer #'identity + treemacs-display-in-side-window t + treemacs-eldoc-display 'simple + treemacs-file-event-delay 2000 + treemacs-file-extension-regex treemacs-last-period-regex-value + treemacs-file-follow-delay 0.2 + treemacs-file-name-transformer #'identity + treemacs-follow-after-init t + treemacs-expand-after-init t + treemacs-find-workspace-method 'find-for-file-or-pick-first + treemacs-git-command-pipe "" + treemacs-goto-tag-strategy 'refetch-index + treemacs-header-scroll-indicators '(nil . "^^^^^^") + treemacs-hide-dot-git-directory t + treemacs-indentation 2 + treemacs-indentation-string " " + treemacs-is-never-other-window nil + treemacs-max-git-entries 5000 + treemacs-missing-project-action 'ask + treemacs-move-files-by-mouse-dragging t + treemacs-move-forward-on-expand nil + treemacs-no-png-images nil + treemacs-no-delete-other-windows t + treemacs-project-follow-cleanup nil + treemacs-persist-file (expand-file-name ".cache/treemacs-persist" user-emacs-directory) + treemacs-position 'left + treemacs-read-string-input 'from-child-frame + treemacs-recenter-distance 0.1 + treemacs-recenter-after-file-follow nil + treemacs-recenter-after-tag-follow nil + treemacs-recenter-after-project-jump 'always + treemacs-recenter-after-project-expand 'on-distance + treemacs-litter-directories '("/node_modules" "/.venv" "/.cask") + treemacs-project-follow-into-home nil + treemacs-show-cursor nil + treemacs-show-hidden-files t + treemacs-silent-filewatch nil + treemacs-silent-refresh nil + treemacs-sorting 'alphabetic-asc + treemacs-select-when-already-in-treemacs 'move-back + treemacs-space-between-root-nodes t + treemacs-tag-follow-cleanup t + treemacs-tag-follow-delay 1.5 + treemacs-text-scale nil + treemacs-user-mode-line-format nil + treemacs-user-header-line-format nil + treemacs-wide-toggle-width 70 + treemacs-width 35 + treemacs-width-increment 1 + treemacs-width-is-initially-locked t + treemacs-workspace-switch-cleanup nil) + + ;; The default width and height of the icons is 22 pixels. If you are + ;; using a Hi-DPI display, uncomment this to double the icon size. + ;; (treemacs-resize-icons 44) + + (treemacs-follow-mode t) + (treemacs-filewatch-mode t) + (treemacs-fringe-indicator-mode 'always) + + ;;(when treemacs-python-executable + ;; (treemacs-git-commit-diff-mode t)) + + (pcase (cons (not (null (executable-find "git"))) + (not (null treemacs-python-executable))) + (`(t . t) + (treemacs-git-mode 'deferred)) + (`(t . _) + (treemacs-git-mode 'simple))) + + (treemacs-hide-gitignored-files-mode nil)) + +;; (use-package treemacs-evil +;; :after (treemacs evil) +;; :ensure t) +;; +;; (use-package treemacs-icons-dired +;; :hook (dired-mode . treemacs-icons-dired-enable-once) +;; :ensure t) +;; +;; (use-package treemacs-tab-bar ; treemacs-tab-bar if you use tab-bar-mode +;; :after (treemacs) +;; :ensure t +;; :config (treemacs-set-scope-type 'Tabs)) +;; +;; (treemacs-start-on-boot) ``` ### Inhibit the mouse @@ -740,6 +1106,11 @@ This package is useful for users who want to disable the mouse to: To configure **inhibit-mouse**, add the following to `~/.emacs.d/post-init.el`: ```emacs-lisp +;; This package is useful for users who want to disable the mouse to: +;; - Prevent accidental clicks or cursor movements that may unexpectedly change +;; the cursor position. +;; - Reinforce a keyboard-centric workflow by discouraging reliance on the mouse +;; for navigation. (use-package inhibit-mouse :ensure t :config @@ -758,7 +1129,6 @@ To configure **flyspell**, add the following to `~/.emacs.d/post-init.el`: ``` emacs-lisp (use-package ispell :ensure nil - :defer t :commands (ispell ispell-minor-mode) :custom ;; Set the ispell program name to aspell @@ -770,9 +1140,11 @@ To configure **flyspell**, add the following to `~/.emacs.d/post-init.el`: ;; language code (e.g., "en_GB" for British English, "de_DE" for German). (ispell-extra-args '("--sug-mode=ultra" "--lang=en_US"))) +;; The flyspell package is a built-in Emacs minor mode that provides +;; on-the-fly spell checking. It highlights misspelled words as you type, +;; offering interactive corrections. (use-package flyspell :ensure nil - :defer t :commands flyspell-mode :hook ((prog-mode . flyspell-prog-mode) @@ -802,9 +1174,10 @@ To maintain cursor stability, Apheleia generates an RCS patch, applies it select To configure **apheleia**, add the following to `~/.emacs.d/post-init.el`: ```elisp +;; Apheleia is an Emacs package designed to run code formatters (e.g., Shfmt, +;; Black and Prettier) asynchronously without disrupting the cursor position. (use-package apheleia :ensure t - :defer t :commands (apheleia-mode apheleia-global-mode) :hook ((prog-mode . apheleia-mode))) @@ -816,8 +1189,10 @@ Helpful is an alternative to the built-in Emacs help that provides much more con To configure **helpful**, add the following to `~/.emacs.d/post-init.el`: ```emacs-lisp +;; Helpful is an alternative to the built-in Emacs help that provides much more +;; contextual information. (use-package helpful - :defer t + :ensure t :commands (helpful-callable helpful-variable helpful-key @@ -841,7 +1216,6 @@ To enhance the Elisp development experience, add the following to `~/.emacs.d/po ;; Enables automatic indentation of code while typing (use-package aggressive-indent :ensure t - :defer t :commands aggressive-indent-mode :hook (emacs-lisp-mode . aggressive-indent-mode)) @@ -849,7 +1223,6 @@ To enhance the Elisp development experience, add the following to `~/.emacs.d/po ;; Highlights function and variable definitions in Emacs Lisp mode (use-package highlight-defined :ensure t - :defer t :commands highlight-defined-mode :hook (emacs-lisp-mode . highlight-defined-mode)) @@ -860,7 +1233,6 @@ Other optional packages that may be useful include: ;; Prevent parenthesis imbalance (use-package paredit :ensure t - :defer t :commands paredit-mode :hook (emacs-lisp-mode . paredit-mode) @@ -871,7 +1243,6 @@ Other optional packages that may be useful include: ;; -------------------------------------------------------------------------- ;; (use-package enhanced-evil-paredit ;; :ensure t -;; :defer t ;; :commands enhanced-evil-paredit-mode ;; :hook ;; (paredit-mode . enhanced-evil-paredit-mode)) @@ -879,7 +1250,6 @@ Other optional packages that may be useful include: ;; Displays visible indicators for page breaks (use-package page-break-lines :ensure t - :defer t :commands (page-break-lines-mode global-page-break-lines-mode) :hook @@ -889,7 +1259,6 @@ Other optional packages that may be useful include: ;; special forms, and symbols in Emacs Lisp (use-package elisp-refs :ensure t - :defer t :commands (elisp-refs-function elisp-refs-macro elisp-refs-variable @@ -901,6 +1270,8 @@ Other optional packages that may be useful include: Configure the `tab-bar-show` variable to 1 to display the tab bar exclusively when multiple tabs are open: ```elisp +;; Configure the `tab-bar-show` variable to 1 to display the tab bar exclusively +;; when multiple tabs are open: (setopt tab-bar-show 1) ``` @@ -908,9 +1279,29 @@ Configure the `tab-bar-show` variable to 1 to display the tab bar exclusively wh To prevent Emacs from saving customization information to a custom file, set `custom-file` to `null-device` by adding to the following to `~/.emacs.d/post-init.el`: ``` emacs-lisp +;; Prevent Emacs from saving customization information to a custom file (setq custom-file null-device) ``` +### Changing the Default Font + +To customize the default font, add the following expression to your `~/.emacs.d/post-init.el`: + +```elisp +;; Set the default font to DejaVu Sans Mono with specific size and weight +(set-face-attribute 'default nil + :height 130 :weight 'normal :family "DejaVu Sans Mono") +``` + +- Modify the `':weight`' value to control the font thickness/boldness. It must be one of the following symbols: `'ultra-heavy`, `'heavy` (a.k.a. `'black`), `'ultra-bold` (a.k.a. `'extra-bold`), `'bold`, `'semi-bold` (a.k.a. `'demi-bold`), `'medium`, `'normal` (a.k.a. `'regular`, a.k.a. `'book`), `'semi-light` (a.k.a. `'demi-light`), `'light`, `'extra-light` (a.k.a. `'ultra-light`), or `'thin`. +- Modify the :height value to set the font size, where 100 corresponds to 10 pt, 130 to 13 pt, and so on. +- Modify the `:family` value to specify a different font, according to your preference. You can replace it with, for example, "Iosevka Term", "Inconsolata", "JetBrains Mono", "Source Code Pro", or "Hack". (The authors preferred font family is "Iosevka Term", medium weight.) + +On Linux, you can display a comprehensive list of all installed font families by executing the following command: +``` +fc-list : family | sed 's/,/\n/g' | sort -u +``` + ### Which other customizations can be interesting to add? 1. Read the following article from the same author: [Essential Emacs Packages for Efficient Software Development and Text Editing](https://www.jamescherti.com/essential-emacs-packages/) @@ -920,17 +1311,25 @@ To prevent Emacs from saving customization information to a custom file, set `cu ;; Allow Emacs to upgrade built-in packages, such as Org mode (setq package-install-upgrade-built-in t) +;; When Delete Selection mode is enabled, typed text replaces the selection +;; if the selection is active. +(delete-selection-mode 1) + ;; Display the current line and column numbers in the mode line (setq line-number-mode t) (setq column-number-mode t) (setq mode-line-position-column-line-format '("%l:%C")) ;; Display of line numbers in the buffer: -;; (display-line-numbers-mode 1) +(setq-default display-line-numbers-type 'relative) +(dolist (hook '(prog-mode-hook text-mode-hook conf-mode-hook)) + (add-hook hook #'display-line-numbers-mode)) + +;; Set the maximum level of syntax highlighting for Tree-sitter modes +(setq treesit-font-lock-level 4) (use-package which-key :ensure nil ; builtin - :defer t :commands which-key-mode :hook (after-init . which-key-mode) :custom @@ -968,8 +1367,7 @@ To prevent Emacs from saving customization information to a custom file, set `cu :custom (uniquify-buffer-name-style 'reverse) (uniquify-separator "•") - (uniquify-after-kill-buffer-p t) - (uniquify-ignore-buffers-re "^\\*")) + (uniquify-after-kill-buffer-p t)) ;; Window dividers separate windows visually. Window dividers are bars that can ;; be dragged with the mouse, thus allowing you to easily resize adjacent @@ -995,6 +1393,9 @@ To prevent Emacs from saving customization information to a custom file, set `cu "\\|^flymake_.*")) (add-hook 'dired-mode-hook #'dired-omit-mode) +;; Enables visual indication of minibuffer recursion depth after initialization. +(add-hook 'after-init-hook #'minibuffer-depth-indicate-mode) + ;; Configure Emacs to ask for confirmation before exiting (setq confirm-kill-emacs 'y-or-n-p) @@ -1012,7 +1413,7 @@ It is also recommended to read the following articles: ## Customizations: pre-early-init.el -### Reducing clutter in `~/.emacs.d` by redirecting files to `~/emacs.d/var/` +### Reducing clutter in `~/.emacs.d` by redirecting files to `~/.emacs.d/var/` Emacs, by default, stores various configuration files, caches, backups, and other data in the `~/.emacs.d` directory. Over time, this directory can become cluttered with numerous files, making it difficult to manage and maintain. @@ -1020,7 +1421,7 @@ A common solution to this issue is installing the no-littering package; however, An alternative lightweight approach is to simply change the default `~/.emacs.d` directory to `~/.emacs.d/var/`, which will contain all the files that Emacs typically stores in the base directory. This can be accomplished by adding the following code to `~/.emacs.d/pre-early-init.el`: ``` emacs-lisp -;; Reducing clutter in ~/.emacs.d by redirecting files to ~/emacs.d/var/ +;; Reducing clutter in ~/.emacs.d by redirecting files to ~/.emacs.d/var/ ;; IMPORTANT: This part should be in the pre-early-init.el file (setq minimal-emacs-var-dir (expand-file-name "var/" minimal-emacs-user-directory)) (setq package-user-dir (expand-file-name "elpa" minimal-emacs-var-dir)) @@ -1029,7 +1430,9 @@ An alternative lightweight approach is to simply change the default `~/.emacs.d` **IMPORTANT:** The code above should be added to `~/.emacs.d/pre-early-init.el`, not the other files, as it modifies the behavior of all subsequent init files. -### Configuring straight.el? +### Configuring straight.el + +The `straight.el` package is a declarative package manager for Emacs that aims to replace traditional systems like `package.el` by providing more precise control over package installation and management. Unlike `package.el`, which relies on downloading pre-built packages from ELPA archives, `straight.el` clones packages directly from their source repositories (typically Git), enabling reproducible and fully source-controlled package configurations. [Add the straight.el bootstrap code](https://github.com/radian-software/straight.el?tab=readme-ov-file#getting-started) to `~/.emacs.d/pre-init.el`: ``` emacs-lisp @@ -1053,6 +1456,8 @@ An alternative lightweight approach is to simply change the default `~/.emacs.d` ### Configuring elpaca (package manager) +Elpaca is a modern, asynchronous package manager for Emacs designed to be a drop-in replacement for `package.el` and `straight.el`, with enhanced performance and flexibility. Unlike traditional Emacs package managers, Elpaca installs packages asynchronously, allowing Emacs to remain responsive during installation and updates. + Add to `~/.emacs.d/pre-early-init.el`: ```elisp ;; By default, minimal-emacs-package-initialize-and-refresh is set to t, which @@ -1063,7 +1468,8 @@ Add to `~/.emacs.d/pre-early-init.el`: And [add the elpaca bootstrap code](https://github.com/progfolio/elpaca?tab=readme-ov-file#installer) to `~/.emacs.d/pre-init.el`: ```elisp -(defvar elpaca-installer-version 0.10) +;; Elpaca bootstrap +(defvar elpaca-installer-version 0.11) (defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory)) (defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory)) (defvar elpaca-repos-directory (expand-file-name "repos/" elpaca-directory)) @@ -1098,7 +1504,7 @@ And [add the elpaca bootstrap code](https://github.com/progfolio/elpaca?tab=read (unless (require 'elpaca-autoloads nil t) (require 'elpaca) (elpaca-generate-autoloads "elpaca" repo) - (load "./elpaca-autoloads"))) + (let ((load-source-file-function nil)) (load "./elpaca-autoloads")))) (add-hook 'after-init-hook #'elpaca-process-queues) (elpaca `(,@elpaca-order)) @@ -1113,6 +1519,32 @@ And [add the elpaca bootstrap code](https://github.com/progfolio/elpaca?tab=read ## Frequently asked questions +### Customizing Scroll Recentering + +By default, minimal-emacs.d sets `scroll-conservatively` to `101`: + +```emacs-lisp +(setq scroll-conservatively 101) ; Default minimal-emacs.d value +``` + +A value of `101` minimizes screen movement and maintains point visibility with minimal adjustment, which many users find optimal for rapid navigation. + +You can override this in your `post-init.el` file. Setting it to `0` forces Emacs to recenter the point aggressively, typically positioning it in the middle of the window: + +```emacs-lisp +(setq scroll-conservatively 0) ; NOT RECOMMENDED. SET IT TO 101 INSTEAD. +``` + +Although this offers more surrounding context, it results in frequent and pronounced screen movement, which can disrupt navigation. A value of `0` is generally discouraged unless this behavior is explicitly desired. + +Most users prefer `101`. Some select `10` as a compromise: + +```emacs-lisp +(setq scroll-conservatively 10) ; Note: You might prefer 101 over 10. +``` + +A value of `10` permits occasional recentering for additional context but introduces more movement than `101`. + ### How to display Emacs startup duration? To measure and display the time taken for Emacs to start, you can use the following Emacs Lisp function. This function will report both the startup duration and the number of garbage collections that occurred during initialization. @@ -1150,10 +1582,10 @@ If you prefer MELPA Stable over MELPA, you can add MELPA Stable and prioritize i ;; This change increases MELPA Stable priority to 70, above MELPA, ;; ensuring that MELPA is preferred for package installations ;; over MELPA Stable. -(customize-set-variable 'package-archive-priorities '(("gnu" . 99) - ("nongnu" . 80) - ("melpa-stable" . 70) - ("melpa" . 0))) +(setq package-archive-priorities '(("gnu" . 99) + ("nongnu" . 80) + ("melpa-stable" . 70) + ("melpa" . 0))) ``` ### How to load a local lisp file for machine-specific configurations? @@ -1184,10 +1616,6 @@ Add the following to `~/.emacs.d/pre-early-init.el` to ensure that *minimal-emac (setq minimal-emacs-gc-cons-threshold (* 64 1024 1024)) ``` -### How to change the outline-mode or outline-minor-mode Ellipsis (...) to (▼)? - -If you want to to change the outline-mode or outline-minor-mode Ellipsis (...) to (▼), use the code snippet in this article: [Changing the Ellipsis (“…”) in outline-mode and outline-minor-mode](https://www.jamescherti.com/emacs-customize-ellipsis-outline-minor-mode/). - ### How to prevent Emacs from loading .dir-locals.el files? By default, Emacs loads `.dir-locals.el` from the current directory or its parents and applies project-specific settings such as indentation, compilation commands, or custom minor modes. While useful in many cases, this behavior can introduce unintended overrides, inconsistencies, or even security risks when working with untrusted projects. @@ -1286,6 +1714,7 @@ A drawback of using the early-init phase instead of init is that if a package fa - [rrajath](https://www.reddit.com/r/emacs/comments/1ihn2tv/comment/mb0ja8k/) has been using the minimal-emacs.d config for the past several months and loves it. His previous setup used to take around 4 seconds to load, but with minimal-emacs.d, it now loads in just 1 second. - [LionyxML](https://www.reddit.com/r/emacs/comments/1ihn2tv/comment/mb35t9y/) considers that *minimal-emacs.d* contains one of the best README files he has ever read. The author of *minimal-emacs.d* found his comment encouraging. Reading this README.md is highly recommended for anyone looking to start customizing their *minimal-emacs.d* configuration. - [cyneox](https://www.reddit.com/r/emacs/comments/1ihn2tv/comment/mdnzgqx/): "Still using it and loving it! Thanks for the regular updates." +- [panchoh](https://github.com/jamescherti/minimal-emacs.d/pull/62#issuecomment-2869865979): "...thank you, @jamescherti! Keep up the fantastic work you are doing!" ### Minimal-emacs.d configurations from users @@ -1297,6 +1726,8 @@ A drawback of using the early-init phase instead of init is that if a package fa - [Mark Norton's minimal-emacs.d configuration](https://github.com/Remillard/minimal-emacs.d/tree/develop) +- [smahm006 minimal-emacs.d configuration](https://github.com/smahm006/minimal-emacs.d) + Please share your configuration. It could serve as inspiration for other users. ## Features @@ -1375,3 +1806,6 @@ Other Emacs packages by the same author: - [inhibit-mouse.el](https://github.com/jamescherti/inhibit-mouse.el): A package that disables mouse input in Emacs, offering a simpler and faster alternative to the disable-mouse package. - [quick-sdcv.el](https://github.com/jamescherti/quick-sdcv.el): This package enables Emacs to function as an offline dictionary by using the sdcv command-line tool directly within Emacs. - [enhanced-evil-paredit.el](https://github.com/jamescherti/enhanced-evil-paredit.el): An Emacs package that prevents parenthesis imbalance when using *evil-mode* with *paredit*. It intercepts *evil-mode* commands such as delete, change, and paste, blocking their execution if they would break the parenthetical structure. +- [stripspace.el](https://github.com/jamescherti/stripspace.el): Ensure Emacs Automatically removes trailing whitespace before saving a buffer, with an option to preserve the cursor column. +- [persist-text-scale.el](https://github.com/jamescherti/persist-text-scale.el): Ensure that all adjustments made with text-scale-increase and text-scale-decrease are persisted and restored across sessions. +- [pathaction.el](https://github.com/jamescherti/pathaction.el): Execute the pathaction command-line tool from Emacs. The pathaction command-line tool enables the execution of specific commands on targeted files or directories. Its key advantage lies in its flexibility, allowing users to handle various types of files simply by passing the file or directory as an argument to the pathaction tool. The tool uses a .pathaction.yaml rule-set file to determine which command to execute. Additionally, Jinja2 templating can be employed in the rule-set file to further customize the commands. diff --git a/early-init.el b/early-init.el index fd949cc..867bf29 100644 --- a/early-init.el +++ b/early-init.el @@ -4,21 +4,36 @@ ;; URL: https://github.com/jamescherti/minimal-emacs.d ;; Package-Requires: ((emacs "29.1")) ;; Keywords: maint -;; Version: 1.2.0 +;; Version: 1.2.1 ;; SPDX-License-Identifier: GPL-3.0-or-later ;;; Commentary: -;; The minimal-emacs.d project is a customizable base that provides better Emacs -;; defaults and optimized startup, intended to serve as a solid foundation for -;; your vanilla Emacs configuration. +;; The minimal-emacs.d project is a lightweight and optimized Emacs base +;; (init.el and early-init.el) that gives you full control over your +;; configuration. It provides better defaults, an optimized startup, and a clean +;; foundation for building your own vanilla Emacs setup. +;; +;; Building the minimal-emacs.d init.el and early-init.el was the result of +;; extensive research and testing to fine-tune the best parameters and +;; optimizations for an Emacs configuration. +;; +;; Do not modify this file; instead, modify pre-early-init.el or +;; post-early-init.el. ;;; Code: +;;; Internal variables + +(defvar minimal-emacs--backup-gc-cons-threshold gc-cons-threshold + "Backup of the original value of `gc-cons-threshold' before startup.") + +(setq gc-cons-threshold most-positive-fixnum) + ;;; Variables (defvar minimal-emacs-ui-features '() "List of user interface features to enable in minimal Emacs setup. -This variable holds a list Emacs UI features that can be enabled: +This variable holds a list of 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.) @@ -31,14 +46,17 @@ 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 (* 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'.") +stored in `minimal-emacs-gc-cons-threshold'.") + +(defvar minimal-emacs-gc-cons-threshold (* 32 1024 1024) + "Value to which `gc-cons-threshold' is set after Emacs startup. +Ignored if `minimal-emacs-optimize-startup-gc' is nil.") + +(defvar minimal-emacs-gc-cons-threshold-restore-delay nil + "Number of seconds to wait before restoring `gc-cons-threshold'.") (defvar minimal-emacs-inhibit-redisplay-during-startup nil "Suppress redisplay during startup to improve performance. @@ -66,15 +84,21 @@ 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-setup-native-compilation t - "If non-nil, enable and configure native compilation. -When enabled, this variable sets the following: + "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'") +- `package-native-compile' +If nil, these variables are left at their default values and are not +modified during setup.") (defvar minimal-emacs-user-directory user-emacs-directory "The default value of the `user-emacs-directory' variable.") +(defvar minimal-emacs-dired-group-directories-first nil + "If non-nil, group directories first in Dired listings.") + ;;; Load pre-early-init.el ;; Prefer loading newer compiled files @@ -135,22 +159,33 @@ pre-early-init.el, and post-early-init.el.") (setq garbage-collection-messages minimal-emacs-debug) (defun minimal-emacs--restore-gc-cons-threshold () - "Restore `minimal-emacs-gc-cons-threshold'." - (setq gc-cons-threshold minimal-emacs-gc-cons-threshold)) + "Restore `gc-cons-threshold' to `minimal-emacs-gc-cons-threshold'." + (if (bound-and-true-p minimal-emacs-gc-cons-threshold-restore-delay) + ;; Defer garbage collection during initialization to avoid 2 collections. + (run-at-time + minimal-emacs-gc-cons-threshold-restore-delay nil + (lambda () (setq gc-cons-threshold minimal-emacs-gc-cons-threshold))) + (setq gc-cons-threshold minimal-emacs-gc-cons-threshold))) -(when minimal-emacs-optimize-startup-gc - (setq gc-cons-threshold most-positive-fixnum) - (add-hook 'emacs-startup-hook #'minimal-emacs--restore-gc-cons-threshold 105)) +(if minimal-emacs-optimize-startup-gc + ;; `gc-cons-threshold' is managed by minimal-emacs.d + (add-hook 'emacs-startup-hook #'minimal-emacs--restore-gc-cons-threshold 105) + ;; gc-cons-threshold is not managed by minimal-emacs.d. + ;; If it is equal to `most-positive-fixnum', this indicates that the user has + ;; not overridden the value in their `pre-early-init.el' configuration. + (when (= gc-cons-threshold most-positive-fixnum) + (setq gc-cons-threshold minimal-emacs--backup-gc-cons-threshold))) ;;; Native compilation and Byte compilation (if (and (featurep 'native-compile) (fboundp 'native-comp-available-p) (native-comp-available-p)) - ;; Activate `native-compile' - (setq native-comp-deferred-compilation minimal-emacs-setup-native-compilation - native-comp-jit-compilation minimal-emacs-setup-native-compilation - package-native-compile minimal-emacs-setup-native-compilation) + (when minimal-emacs-setup-native-compilation + ;; Activate `native-compile' + (setq native-comp-deferred-compilation t + native-comp-jit-compilation t + package-native-compile t)) ;; Deactivate the `native-compile' feature if it is not available (setq features (delq 'native-compile features))) @@ -180,6 +215,9 @@ pre-early-init.el, and post-early-init.el.") (setq warning-minimum-level (if minimal-emacs-debug :warning :error)) (setq warning-suppress-types '((lexical-binding))) +(when minimal-emacs-debug + (setq message-log-max 16384)) + ;;; Performance: Miscellaneous options ;; Font compacting can be very resource-intensive, especially when rendering @@ -187,6 +225,10 @@ pre-early-init.el, and post-early-init.el.") (setq inhibit-compacting-font-caches t) (when (and (not (daemonp)) (not noninteractive)) + ;; Resizing the Emacs frame can be costly when changing the font. Disable this + ;; to improve startup times with fonts larger than the system default. + (setq frame-resize-pixelwise t) + ;; Without this, Emacs will try to resize itself to a specific column size (setq frame-inhibit-implied-resize t) @@ -216,8 +258,13 @@ pre-early-init.el, and post-early-init.el.") ;; `inhibit-startup-screen', but it would still initialize anyway. (advice-add 'display-startup-screen :override #'ignore) - ;; Shave seconds off startup time by starting the scratch buffer in - ;; `fundamental-mode' + ;; 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) @@ -416,9 +463,9 @@ this stage of initialization." (setq package-archives '(("melpa" . "https://melpa.org/packages/") ("gnu" . "https://elpa.gnu.org/packages/") ("nongnu" . "https://elpa.nongnu.org/nongnu/"))) -(customize-set-variable 'package-archive-priorities '(("gnu" . 99) - ("nongnu" . 80) - ("melpa" . 70))) +(setq package-archive-priorities '(("gnu" . 99) + ("nongnu" . 80) + ("melpa" . 70))) ;;; Load post-early-init.el (minimal-emacs-load-user-init "post-early-init.el") diff --git a/init.el b/init.el index 38fd499..6cf44ee 100644 --- a/init.el +++ b/init.el @@ -4,13 +4,20 @@ ;; URL: https://github.com/jamescherti/minimal-emacs.d ;; Package-Requires: ((emacs "29.1")) ;; Keywords: maint -;; Version: 1.2.0 +;; Version: 1.2.1 ;; SPDX-License-Identifier: GPL-3.0-or-later ;;; Commentary: -;; The minimal-emacs.d project is a customizable base that provides better Emacs -;; defaults and optimized startup, intended to serve as a solid foundation for -;; your vanilla Emacs configuration. +;; The minimal-emacs.d project is a lightweight and optimized Emacs base +;; (init.el and early-init.el) that gives you full control over your +;; configuration. It provides better defaults, an optimized startup, and a clean +;; foundation for building your own vanilla Emacs setup. +;; +;; Building the minimal-emacs.d init.el and early-init.el was the result of +;; extensive research and testing to fine-tune the best parameters and +;; optimizations for an Emacs configuration. +;; +;; Do not modify this file; instead, modify pre-init.el or post-init.el. ;;; Code: @@ -31,6 +38,11 @@ (setq use-short-answers t) (advice-add 'yes-or-no-p :override #'y-or-n-p)) +;;; Features, warnings, and errors + +;; Disable warnings from the legacy advice API. They aren't useful. +(setq ad-redefinition-action 'accept) + ;;; Undo/redo (setq undo-limit (* 13 160000) @@ -51,11 +63,6 @@ ;; Ensure use-package is available (require 'use-package)) -;;; Features, warnings, and errors - -;; Disable warnings from the legacy advice API. They aren't useful. -(setq ad-redefinition-action 'accept) - ;;; Minibuffer ;; Allow nested minibuffers @@ -69,7 +76,8 @@ ;;; User interface ;; By default, Emacs "updates" its ui more often than it needs to -(setq idle-update-delay 1.0) +(setq which-func-update-delay 1.0) +(setq idle-update-delay which-func-update-delay) ;; Obsolete in >= 30.1 (defalias #'view-hello-file #'ignore) ; Never show the hello file @@ -77,6 +85,11 @@ (setq visible-bell nil) (setq ring-bell-function #'ignore) +;; In PGTK, this timeout introduces latency. Reducing it from the default 0.1 +;; improves responsiveness of childframes and related packages. +(when (boundp 'pgtk-wait-for-event-timeout) + (setq pgtk-wait-for-event-timeout 0.001)) + ;;; Show-paren (setq show-paren-delay 0.1 @@ -90,13 +103,11 @@ compilation-ask-about-save nil compilation-scroll-output 'first-error) -;; Recenter to the middle of the window for `compile-goto-error', which is also -;; used by `wgrep' and `embark-export'. -(setq next-error-recenter '(4)) - ;;; Misc -(setq whitespace-line-column nil) ; whitespace-mode +(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) @@ -104,9 +115,6 @@ (setq truncate-string-ellipsis "…") -;; Improve Emacs' responsiveness by delaying syntax highlighting during input -(setq redisplay-skip-fontification-on-input t) - ;; Disable truncation of printed s-expressions in the message buffer (setq eval-expression-print-length nil eval-expression-print-level nil) @@ -114,6 +122,20 @@ ;; Position underlines at the descent line instead of the baseline. (setq x-underline-at-descent-line t) +(setq tramp-verbose 1) +(setq tramp-completion-reread-directory-timeout 50) +(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. +(setq next-line-add-newlines nil) + ;;; Files ;; Delete by moving to trash in interactive mode @@ -161,6 +183,7 @@ (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. ;;; Auto save @@ -226,10 +249,6 @@ ;;; Frames and windows -;; Resizing the Emacs frame can be costly when changing the font. Disable this -;; to improve startup times with fonts larger than the system default. -(setq frame-resize-pixelwise t) - ;; 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) @@ -242,6 +261,12 @@ window-divider-default-places t 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 ;; Enables faster scrolling. This may result in brief periods of inaccurate @@ -290,8 +315,7 @@ ;; Don't blink the paren matching the one at point, it's too distracting. (setq blink-matching-paren nil) -;; Don't stretch the cursor to fit wide characters, it is disorienting, -;; especially for tabs. +;; 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 @@ -326,13 +350,18 @@ ;; when the window is narrower than `truncate-partial-width-windows' characters. (setq truncate-partial-width-windows nil) +;; Configure automatic indentation to be triggered exclusively by newline and +;; DEL (backspace) characters. +(setq-default electric-indent-chars '(?\n ?\^?)) + ;; Prefer spaces over tabs. Spaces offer a more consistent default compared to ;; 8-space tabs. This setting can be adjusted on a per-mode basis as needed. (setq-default indent-tabs-mode nil tab-width 4) ;; Enable indentation and completion using the TAB key -(setq-default tab-always-indent nil) +(setq tab-always-indent 'complete) +(setq tab-first-completion 'word-or-paren-or-punct) ;; Perf: Reduce command completion overhead. (setq read-extended-command-predicate #'command-completion-default-include-p) @@ -371,16 +400,22 @@ (setq sh-indent-after-continuation 'always) -;;; Dired +;;; Dired and ls-lisp (setq dired-free-space nil - dired-dwim-target t ; Propose a target for intelligent moving or copying. + dired-dwim-target t ; Propose a target for intelligent moving/copying dired-deletion-confirmer 'y-or-n-p dired-filter-verbose nil dired-recursive-deletes 'top dired-recursive-copies 'always - dired-create-destination-dirs 'ask - image-dired-thumb-size 150) + dired-create-destination-dirs 'ask) + +;; This is a higher-level predicate that wraps `dired-directory-changed-p' +;; with additional logic. This `dired-buffer-stale-p' predicate handles remote +;; files, wdired, unreadable dirs, and delegates to dired-directory-changed-p +;; for modification checks. +(setq auto-revert-remote-files nil) +(setq dired-auto-revert-buffer 'dired-buffer-stale-p) (setq dired-vc-rename-file t) @@ -391,7 +426,18 @@ (setq dired-omit-verbose nil) (setq dired-omit-files (concat "\\`[.]\\'")) -;; ls-lisp +;; Group directories first +(when minimal-emacs-dired-group-directories-first + (with-eval-after-load 'dired + (let ((args "--group-directories-first -ahlv")) + (when (or (eq system-type 'darwin) + (eq system-type 'berkeley-unix)) + (if-let* ((gls (executable-find "gls"))) + (setq insert-directory-program gls) + (setq args nil))) + (when args + (setq dired-listing-switches args))))) + (setq ls-lisp-verbosity nil) (setq ls-lisp-dirs-first t) @@ -416,29 +462,31 @@ ;;; Eglot -(setq eglot-sync-connect 1 - eglot-autoshutdown t) +;; 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 +;; available once the connection is established in the background. +(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 (setq eglot-extend-to-xref t) ;; Eglot optimization -(setq jsonrpc-event-hook nil) -(setq eglot-events-buffer-size 0) -(setq eglot-report-progress nil) ; Prevent Eglot minibuffer spam +(if minimal-emacs-debug + (setq eglot-events-buffer-config '(:size 2000000 :format full)) + ;; This reduces log clutter to improves performance. + (setq jsonrpc-event-hook nil) + ;; Reduce memory usage and avoid cluttering *EGLOT events* buffer + (setq eglot-events-buffer-size 0) ; Deprecated + (setq eglot-events-buffer-config '(:size 0 :format short))) -;; Eglot optimization: Disable `eglot-events-buffer' to maintain consistent -;; performance in long-running Emacs sessions. -(setq eglot-events-buffer-config '(:size 0 :format full)) +(setq eglot-report-progress minimal-emacs-debug) ; Prevent minibuffer spam ;;; Flymake -(setq flymake-fringe-indicator-position 'left-fringe) (setq flymake-show-diagnostics-at-end-of-line nil) -;; Suppress the display of Flymake error counters when there are no errors. -(setq flymake-suppress-zero-counters t) - ;; Disable wrapping around when navigating Flymake errors. (setq flymake-wrap-around nil) @@ -459,8 +507,8 @@ (setq flyspell-issue-welcome-flag nil) -;; Greatly improves flyspell performance by preventing messages from being -;; displayed for each word when checking the entire buffer. +;; Improves flyspell performance by preventing messages from being displayed for +;; each word when checking the entire buffer. (setq flyspell-issue-message-flag nil) ;;; ispell @@ -475,10 +523,10 @@ (setq ibuffer-formats '((mark modified read-only locked - " " (name 40 40 :left :elide) - " " (size 8 -1 :right) - " " (mode 18 18 :left :elide) " " filename-and-process) - (mark " " (name 16 -1) " " filename))) + " " (name 55 55 :left :elide) + " " (size 8 -1 :right) + " " (mode 18 18 :left :elide) " " filename-and-process) + (mark " " (name 16 -1) " " filename))) ;;; xref @@ -498,13 +546,22 @@ ;;; dabbrev (setq dabbrev-upcase-means-case-search t) + (setq dabbrev-ignored-buffer-modes '(archive-mode image-mode docview-mode tags-table-mode pdf-view-mode)) +(setq dabbrev-ignored-buffer-regexps + '(;; - Buffers starting with a space (internal or temporary buffers) + "\\` " + ;; Tags files such as ETAGS, GTAGS, RTAGS, TAGS, e?tags, and GPATH, + ;; including versions with numeric extensions like <123> + "\\(?:\\(?:[EG]?\\|GR\\)TAGS\\|e?tags\\|GPATH\\)\\(<[0-9]+>\\)?")) + ;;; Remove warnings from narrow-to-region, upcase-region... (dolist (cmd '(list-timers narrow-to-region upcase-region downcase-region - erase-buffer scroll-left dired-find-alternate-file)) + list-threads erase-buffer scroll-left + dired-find-alternate-file)) (put cmd 'disabled nil)) ;;; Load post init