I have problems when using the suggestion from here Code faster by extending Emacs EVIL text object
(require 'dash)
(defun jds~evil-paren-range (count beg end type inclusive)
(->> '((?\( . ?\))
(?\[ . ?\])
(?{ . ?})
(?< . ?>))
(--keep (save-excursion
(ignore-errors
(evil-select-paren (car it) (cdr it)
beg end type
count inclusive)) ))
(-min-by (-on #'> (lambda (x)
(abs (- (car x) (point) )))))
(-take 2)))
(evil-define-text-object jds~evil-a-paren (count &optional beg end type)
"Select a paren."
:extend-selection nil
(jds~evil-paren-range count beg end type t))
(evil-define-text-object jds~evil-inner-paren (count &optional beg end type)
"Select inner paren."
:extend-selection nil
(jds~evil-paren-range count beg end type nil))
(define-key evil-inner-text-objects-map "d" #'jds~evil-inner-paren)
(define-key evil-outer-text-objects-map "d" #'jds~evil-a-paren)
This works great for visually selecting various delimiters in a dwim fasion but for some reason it doesnt work well for deleting, yanking or changing. Here is an example:
Say the point (indicated by |
) is on a line as follows
|{asdf}(bar)
vad
works exactly as expected and visually selects {asdf}
.
Yet with the point at same place, dad
deletes (bar)
leaving
{asdf}|
What is going on? How do I fix this text object?