diff options
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=. |
