Skip to content

cute-jumper/evil-embrace.el

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 

Repository files navigation

evil-embrace

https://melpa.org/packages/evil-embrace-badge.svg

Evil integration of embrace.el.

Overview

This package provides evil integration of embrace.el. Since evil-surround provides a similar set of features as embrace.el, this package aims at adding the goodies of embrace.el to evil-surround and making evil-surround even better.

Why

evil-surround is good when there is a text object defined. But unfortunately, if you want to add custom surrouding pairs, evil-surround will not be able to delete/change the pairs if there are no evil text objects defined for these pairs. For example, if you want to make \textbf{ and } as a surround pair in LaTeX-mode, you can’t either change or delete the surround pair since there is no text object for \textbf{ and }. However, using embrace, you can define whatever surrounding pairs you like, and adding, changing, and deleting will always work.

The idea of this package is that let evil-surround handle the keys that corresponds to existing text objects (i.e., (, [, etc.), which is what evil-surround is good at, and make embrace handles all the other keys of custom surrounding pairs so that you can also benefit from the extensibility that embrace offers.

In a word, you can use the default evil-surround. But whenever you want to add a custom surrounding pair, use embrace instead. To see how to add a custom pair in embrace, look at the README of embrace.el.

Usage

To enable the evil-surround integration:

(evil-embrace-enable-evil-surround-integration)

And use evil-embrace-disable-evil-surround-integration to disable whenever you don’t like it.

The keys that are processed by evil-surround are saved in the variable evil-embrace-evil-surround-keys. The default value is:

(?\( ?\[ ?\{ ?\) ?\] ?\} ?\" ?\' ?< ?> ?b ?B ?t)

Note that this variable is buffer-local. You should change it in the hook:

(add-hook 'LaTeX-mode-hook
    (lambda ()
       (add-to-list 'evil-embrace-evil-surround-keys ?o)))

Only these keys saved in the variable are processed by evil-surround, and all the other keys will be processed by embrace.

If you find the help message popup annoying, use the following code to disable it:

(setq evil-embrace-show-help-p nil)

Screencasts

Use the following settings:

(add-hook 'org-mode-hook 'embrace-org-mode-hook)
(evil-embrace-enable-evil-surround-integration)

In an org-mode file, we can change the surrounding pair in the following way (note that this whole process can’t be achieved solely by evil-surround):

./screencasts/evil-embrace.gif

About

Evil integration of embrace.el

Resources

Stars

Watchers

Forks

Packages

No packages published