The Definitive Guide to Code Folding in Emacs

Navigating large source files containing thousands of lines of code with Emacs makes it difficult to perceive the underlying structure. For a software engineer spending the majority of the day reading and writing code, reliable folding is a requirement for maintaining focus and managing complexity. Before we dive in, please consider sharing this article on your website/blog, Mastodon, Reddit, X, or your preferred social media platforms. Sharing it will help fellow Emacs users discover better ways to manage code folding. In this article, we explore: Why code folding? Code folding is about managing cognitive load, preserving spatial memory, and controlling … Continue reading

buffer-guardian.el - Automatically Save Emacs Buffers Without Manual Intervention (When Buffers Lose Focus, Regularly, or After Emacs is Idle)

The buffer-guardian Emacs package provides buffer-guardian-mode, a global mode that automatically saves buffers without requiring manual intervention. By default, buffer-guardian-mode saves file-visiting buffers when: - Switching to another buffer. - Switching to another window or frame. - A frame is closed. - The window configuration changes (e.g., window splits). - The minibuffer is opened. - Emacs loses focus. (Skip to: Installation) Beyond standard file-visiting buffers, buffer-guardian-mode provides built-in support for: Isolated inline code buffers: It fully supports specialized editing environments like org-src (for Org mode) and edit-indirect (commonly used for Markdown code blocks). Since these temporary buffers are dynamically linked … Continue reading

Emacs Package: pathaction.el - An Emacs plugin for executing pathaction, the universal Makefile, for any file in your filesystem

The pathaction.el Emacs package provides an interface for executing .pathaction.yaml rules directly from Emacs through the pathaction cli, a flexible tool for running commands on files and directories. Think of pathaction like a Makefile for any file or directory in the filesystem. It uses a .pathaction.yaml file to figure out which command to run, and you can even use Jinja2 templating to make those commands dynamic. You can also use tags to define multiple actions for the exact same file type, like setting up one tag to run a script, and another to debug it. This tool is for software … Continue reading

ultisnips-mode.el - An Emacs major mode for editing Ultisnips snippet files (*.snippets files)

The ultisnips-mode.el is an Emacs major mode for editing Ultisnips snippet files (*.snippets files). This mode provides syntax highlighting to facilitate editing Ultisnips snippets. (Vim's UltiSnips is a snippet solution for Vim, and its snippets can be used in Emacs by converting them to the Yasnippet format using Ultyas.) Features Syntax highlighting for UltiSnips: snippet, endsnippet, global, endglobal, priority, comments, and placeholders in the form of ${1:value} or $1... Integration with outline-minor-mode or hs-minor-mode to enable folding of snippet -> endsnippet and global -> endglobal blocks. Support for commenting and uncommenting UltiSnips snippets using standard Emacs commands, such as comment-or-uncomment-region. … Continue reading

kirigami.el - A Unified Method to Fold and Unfold Text in Emacs Across a Diverse Set of Modes

The kirigami Emacs package provides a unified method to fold and unfold text in Emacs across a diverse set of Emacs modes. Supported modes include: outline-mode, outline-minor-mode, outline-indent-minor-mode, org-mode, markdown-mode, gfm-mode, outli-mode, embark-collect-mode, vdiff-mode, vdiff-3way-mode, hide-ifdef-mode, vimish-fold-mode, TeX-fold-mode (AUCTeX), fold-this-mode, origami-mode, yafolding-mode, folding-mode, ts-fold-mode, treesit-fold-mode, hs-minor-mode (hideshow), ibuffer-mode (M-x ibuffer), and profiler-report-mode (M-x profile-report). With Kirigami, folding key bindings only need to be configured once. After that, the same keys work consistently across all supported major and minor modes, providing a unified and predictable experience for opening and closing folds. The available interactive commands include: - kirigami-open-fold: Open the fold … Continue reading

quick-sdcv.el - Emacs offline dictionary using 'sdcv'

The quick-sdcv.el package provides a lightweight interface for the sdcv command-line tool, enabling Emacs to function as an offline dictionary. This package allows for immediate word definitions and translations without requiring an internet connection. Key interactive functions include: quick-sdcv-search-at-point: Searches the word under the cursor and displays the result in a dedicated buffer. quick-sdcv-search-input: Prompts for a custom input string and presents the corresponding dictionary entry in a buffer. If this package enhances your workflow, please show your support by ⭐ starring quick-sdcv on GitHub to help more Emacs users discover its benefits. Prerequisite The sdcv command. (It can usually … Continue reading

inhibit-mouse.el - Deactivate mouse input in Emacs

The inhibit-mouse package allows the disabling of mouse input in Emacs using inhibit-mouse-mode. Instead of modifying the keymap of its own mode as the disable-mouse package does, enabling inhibit-mouse-mode only modifies input-decode-map to disable mouse events, making it more efficient and faster than disable-mouse. Additionally, the inhibit-mouse package allows for the restoration of mouse input when inhibit-mouse-mode is disabled. If this enhances your workflow, please show your support by ⭐ starring inhibit-mouse on GitHub to help more Emacs users discover its benefits. Installation To install inhibit-mouse from MELPA: If you haven't already done so, add MELPA repository to your Emacs … Continue reading

flymake-bashate.el - An Emacs Flymake backend for bashate

The flymake-bashate Emacs package provides a Flymake backend for bashate, enabling real-time style checking for Bash shell scripts within Emacs. (This package can also work with Flycheck: simply use the flymake-flycheck package, which allows any Emacs Flymake backend to function as a Flycheck checker.) If this enhances your workflow, please show your support by ⭐ starring flymake-bashate.el on GitHub to help more Emacs users discover its benefits. Installation To install flymake-bashate from MELPA: If you haven't already done so, add MELPA repository to your Emacs configuration. Add the following code to your Emacs init file to install flymake-bashate from MELPA: … Continue reading

enhanced-evil-paredit.el - Prevent Parenthesis Imbalance when Using Evil-mode with Paredit

The enhanced-evil-paredit package 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. This guarantees that your Lisp code remains syntactically correct while retaining the editing features of evil-mode. If this enhances your workflow, please show your support by ⭐ starring enhanced-evil-paredit-mode on GitHub to help more Emacs users discover its benefits. Installation To install enhanced-evil-paredit from MELPA: If you haven't already done so, add MELPA repository to your Emacs configuration. Add the following code to the Emacs init file to install … Continue reading

flymake-ansible-lint.el - An Emacs Emacs Flymake backend for ansible-lint

The flymake-ansible-lint package provides a Flymake backend for ansible-lint, enabling real-time syntax and style checking for Ansible playbooks and roles within Emacs. (This package can also work with Flycheck: simply use the flymake-flycheck package, which allows any Emacs Flymake backend to function as a Flycheck checker.) Requirements ansible-lint >= 1.0.7 Installation To install flymake-ansible-lint from MELPA: If you haven't already done so, add MELPA repository to your Emacs configuration. Add the following code to your Emacs init file to install flymake-ansible-lint from MELPA: (use-package flymake-ansible-lint :commands flymake-ansible-lint-setup :hook (((yaml-ts-mode yaml-mode) . flymake-ansible-lint-setup) ((yaml-ts-mode yaml-mode) . flymake-mode))) Customizations You can configure … Continue reading

quick-fasd.el - Integrate Fasd for fast file and directory navigation in Emacs

The quick-fasd Emacs package integrates the Fasd tool into the Emacs environment. Fasd is a command-line utility that provides fast access to frequently used files and directories. After installing quick-fasd and enabling quick-fasd-mode: All visited files and directories are automatically added to the Fasd database. The quick-fasd-find-path function prompts for input and presents candidates from the Fasd index. (For example, recently accessed files can be opened, and frequently used directories can be visited without leaving Emacs.) When invoked from the minibuffer, quick-fasd-find-path appends the selected path, simplifying completion. If this package improves the workflow, consider supporting the project by ⭐ … Continue reading

pre-commit-elisp - Emacs Lisp (Elisp) Git pre-commit hooks

The pre-commit-elisp repository offers pre-commit hooks for Emacs Lisp (Elisp) projects. These hooks enforce code quality and consistency by performing automated checks on .el files prior to committing changes: elisp-check-parens: Validates that all parentheses in .el files are correctly balanced. elisp-check-byte-compile: Byte-compile Elisp files to detect compilation errors. elisp-check-native-compile: Native-compile Elisp files to detect compilation errors. elisp-indent: Indent Elisp files according to Emacs Lisp style conventions. These pre-commit hooks enforce syntactic correctness, successful byte-compilation, and consistent code formatting, ensuring a high standard of code quality and maintainability throughout the repository. If this enhances your workflow, please show your support by … Continue reading

Using Emacs vc-diff with tools such as git-crypt or Rails credentials: Handling Binary Diff Issues

Tools like git-crypt or Rails credentials provide an encryption layer for managing sensitive files within Git repositories. However, when using Emacs vc-diff on repositories protected by these tools, the diff output is incorrect because vc-diff compares the encrypted binary files directly rather than comparing the decrypted files. This occurs even when the repository is unlocked and the decrypted content is available, resulting in a failure to display meaningful diffs. The root cause Internally, vc-diff uses Git commands to compute diffs. However, it does not invoke them with the --textconv flag by default. Without --textconv, Git does not apply content filters, … Continue reading

Enhancing Git Diff for Emacs Lisp: Better Git Diff of Elisp function or macro definitions

By default, the git diff algorithm compares changes in Elisp files line by line without understanding the structural semantics of Emacs Lisp files. This means that when modifications are made within functions, the diff output does not convey how those changes relate to higher-level code constructs such as functions or macros. As a result, reviewers are presented with fragmented and often verbose diffs where the context of a change, such as which function it belongs to, is not always readily apparent. This lack of structural awareness can make it difficult to assess the purpose and impact of changes efficiently. Git … Continue reading

stripspace.el - Ensure Emacs automatically removes trailing whitespace before saving buffers (optionally preserving the cursor column, normalizing indentation, and restricting whitespace cleanup to clean buffers)

Introduction The stripspace Emacs package provides stripspace-local-mode and stripspace-global-mode, which automatically removes trailing whitespace and blank lines at the end of the buffer when saving. (Trailing whitespace refers to any spaces or tabs that appear at the end of a line, beyond the last non-whitespace character. These characters serve no purpose in the content of the file and can cause issues with version control, formatting, or code consistency. Removing trailing whitespace helps maintain clean, readable files.) If this enhances your workflow, please show your support by ⭐ starring stripspace.el on GitHub to help more Emacs users discover its benefits. The … Continue reading