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 enhanced-evil-paredit:
;; `paredit-mode' is a requirement
(use-package paredit
:commands paredit-mode
:hook
(emacs-lisp-mode . paredit-mode))
(use-package enhanced-evil-paredit
:commands enhanced-evil-paredit-mode
:hook (paredit-mode . enhanced-evil-paredit-mode))
Frequently asked questions
What are the differences between enhanced-evil-paredit and evil-paredit?
The enhanced-evil-paredit package is a modernized version of evil-paredit. It has been enhanced and fully functions in recent versions of Emacs (Emacs >= 28). The author decided to develop enhanced-evil-paredit because the evil-paredit package is no longer maintained and does not function in recent versions of Emacs and Evil.
Here are the enhancements in enhanced-evil-paredit:
- Handles paste using
pandP, ensuring that the pasted text has balanced parentheses. - Fix call to a non-existent function
(evil-called-interactively-p), which has been replaced by(called-interactively-p 'any). - Add new functions:
enhanced-evil-paredit-backward-deleteandenhanced-evil-paredit-forward-delete. enhanced-evil-paredit-modeonly uses the paredit functions whenparedit-modeis enabled. It acts as a wrapper that delegates commands to Paredit when Paredit is enabled and otherwise uses standard Evil commands. (The difference in behavior is that withparedit-mode, structural editing operations preserve balanced parentheses and Lisp structure, whereas withoutparedit-mode, the same operations rely on Evil motions and can disrupt parentheses and overall code structure.)- Add lexical binding with
lexical-binding: t. - Suppress Emacs Lisp warnings and add Melpa tests.
- Refactor and improve
enhanced-evil-paredit. - Create a
enhanced-evil-pareditcustomization group for user configuration. - Remove Evil state change from
enhanced-evil-paredit-mode. - Improve error handling in
enhanced-evil-paredit-check-region. - Enhance docstrings.
- Remove keymap bindings that are reserved by Emacs.
- Add
&optionalafter theendargument to make it similar to Evil functions.
ddrestores the column when there is a parentheses mismatch.
Author and License
The enhanced-evil-paredit Emacs package has been written by Roman Gonzalez and James Cherti. It is distributed under terms of the GNU General Public License version 3, or, at your choice, any later version.
Copyright (C) 2024-2026 James Cherti
Copyright (C) 2012-2015 Roman Gonzalez
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program.
Links
Other Emacs packages by the same author:
- minimal-emacs.d: This repository hosts a minimal Emacs configuration designed to serve as a foundation for your vanilla Emacs setup and provide a solid base for an enhanced Emacs experience.
- compile-angel.el: Speed up Emacs! This package guarantees that all .el files are both byte-compiled and native-compiled, which significantly speeds up Emacs.
- easysession.el: Easysession is lightweight Emacs session manager that can persist and restore file editing buffers, indirect buffers/clones, Dired buffers, the tab-bar, and the Emacs frames (with or without the Emacs frames size, width, and height).
- vim-tab-bar.el: Make the Emacs tab-bar Look Like Vim’s Tab Bar.
- elispcomp: A command line tool that allows compiling Elisp code directly from the terminal or from a shell script. It facilitates the generation of optimized .elc (byte-compiled) and .eln (native-compiled) files.
- tomorrow-night-deepblue-theme.el: The Tomorrow Night Deepblue Emacs theme is a beautiful deep blue variant of the Tomorrow Night theme, which is renowned for its elegant color palette that is pleasing to the eyes. It features a deep blue background color that creates a calming atmosphere. The theme is also a great choice for those who miss the blue themes that were trendy a few years ago.
- Ultyas: A command-line tool designed to simplify the process of converting code snippets from UltiSnips to YASnippet format.
- dir-config.el: Automatically find and evaluate .dir-config.el Elisp files to configure directory-specific settings.
- flymake-bashate.el: A package that provides a Flymake backend for the bashate Bash script style checker.
- flymake-ansible-lint.el: An Emacs package that offers a Flymake backend for
ansible-lint. - inhibit-mouse.el: A package that disables mouse input in Emacs, offering a simpler and faster alternative to the
disable-mousepackage. - 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: 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: Ensure Emacs Automatically removes trailing whitespace before saving a buffer, with an option to preserve the cursor column.
- 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: 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.
- kirigami.el: The kirigami Emacs package offers a unified interface for opening and closing folds across a diverse set of major and minor modes in Emacs, including
outline-mode,outline-minor-mode,outline-indent-minor-mode,org-mode,markdown-mode,vdiff-mode,vdiff-3way-mode,hs-minor-mode,hide-ifdef-mode,origami-mode,yafolding-mode,folding-mode, andtreesit-fold-mode. 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 folding experience. - buffer-guardian.el: Automatically saves Emacs buffers without requiring manual intervention. By default, it triggers a save when the user switches to another buffer, switches to another window or frame, Emacs loses focus, or the minibuffer is opened. Beyond standard file buffers, buffer-guardian also manages specialized editing buffers such as org-src and edit-indirect. Additional features, disabled by default, include periodic or idle-time saving of all buffers, automatic exclusion of remote, nonexistent, or large files, and support for custom exclusion rules via regular expressions or predicate functions.
Related posts:
- Emacs: Customizing the Ellipsis “…” in outline-mode and outline-minor-mode to Use a More Visually Appealing Indicator for Folded Sections, Such as ” ▼”
- Emacs: Striking through Org Mode DONE tasks
- Emacs: YAML file code Folding and Outlining
- Emacs: persist-text-scale.el – Persist and Restore the Text Scale for All Buffers
- Elispcomp: Compiling Elisp code directly from the command line
- Must-have Emacs Packages for Efficient Software Development and Text Editing
- Emacs Evil Mode: How to restore both the line and column number of a mark, not just the line number
- The compile-angel Emacs package: Byte-compile and Native-compile Emacs Lisp libraries Automatically
- easysession.el – Easily persist and restore your Emacs editing sessions
- Emacs flymake-ansible-lint.el – A Flymake backend for ansible-lint
- Enabling Emacs Native Compilation and Dynamically Adjusting the Number of Elisp Files Compiled in Parallel
- outline-indent – Indentation based Folding and Outlining in Emacs
- Preventing Emacs from entering the debugger when a specific error occurs
- Emacs: Maintaining proper indentation in indentation-sensitive programming languages
- Configure Emacs org-mode to automatically add the TODO keyword to new Org Mode headings
- Emacs package: bufferfile – Delete or rename buffer file names with their associated buffers
- Emacs: Highlighting Codetags Like TODO, FIXME, BUG, NOTE…
- pre-commit-elisp – Pre-commit hooks for Emacs Lisp (Elisp) Git repositories
- dir-config.el – Automatically find and evaluate .dir-config.el Elisp files to configure directory-specific settings
- Making the Emacs built-in tab-bar Look Like Vim’s Tab Bar