diff options
| author | ninrod <filipe.silva@gmail.com> | 2018-10-09 22:09:12 -0300 |
|---|---|---|
| committer | ninrod <filipe.silva@gmail.com> | 2018-10-09 22:09:12 -0300 |
| commit | 31b895f1e1d15968732051fe156831530bc449ad (patch) | |
| tree | c7f60909701ce59d4c1a50d37e166632649f700d /readme.org | |
| parent | 2af81ab3ac64e4b0515a157a672d8cb89f0172b9 (diff) | |
fix #143: add readme entry on how to add new pairs through evil
Diffstat (limited to 'readme.org')
| -rw-r--r-- | readme.org | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -94,7 +94,26 @@ or to add a pair that surrounds with two ` if you enter ~: (setq-default evil-surround-pairs-alist (push '(?~ . ("``" . "``")) evil-surround-pairs-alist)) #+END_SRC - +** Add new surround pairs through creation of evil objects + - You can create new evil objects that will be respected by evil-surround. Just use the following code: +#+BEGIN_SRC emacs-lisp + ;; this macro was extracted from a stackoveflow answer. link is missing + (defmacro define-and-bind-quoted-text-object (name key start-regex end-regex) + (let ((inner-name (make-symbol (concat "evil-inner-" name))) + (outer-name (make-symbol (concat "evil-a-" name)))) + `(progn + (evil-define-text-object ,inner-name (count &optional beg end type) + (evil-select-paren ,start-regex ,end-regex beg end type count nil)) + (evil-define-text-object ,outer-name (count &optional beg end type) + (evil-select-paren ,start-regex ,end-regex beg end type count t)) + (define-key evil-inner-text-objects-map ,key #',inner-name) + (define-key evil-outer-text-objects-map ,key #',outer-name)))) + + (define-and-bind-quoted-text-object "pipe" "|" "|" "|") + (define-and-bind-quoted-text-object "slash" "/" "/" "/") + (define-and-bind-quoted-text-object "dollar" "*" "*" "*") + (define-and-bind-quoted-text-object "dollar" "$" "\\$" "\\$") ;; sometimes your have to escape the regex +#+END_SRC ** Add new supported operators You can add support for new operators by adding them to =evil-surround-operator-alist=. |
