emacs-evil / evil-surround

you will be surrounded (surround.vim for evil, the extensible vi layer)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Delete with left paren not working?

dieggsy opened this issue · comments

This seems similar to #204, but I'm not using evil-cleverparens.

I'm just trying to delete the surrounding pair using (, and I get:

Debugger entered--Lisp error: (error "No surrounding delimiters found")
  signal(error ("No surrounding delimiters found"))
  evil-motion-range(evil-surround-edit nil nil)
  evil-operator-range(t)
  byte-code("\306\307!\310\1\311\"\211\205\22\0\211A@\206\22\0\312\262\1\30\313\1\314\"\31\315\211\32\33\315\211\34\25\16\26\26\27i\26\30\316\317\320!\16\31\321 D..." [evil-operator-range-motion evil-operator-range-type evil-operator-range-beginning evil-operator-range-end evil-inhibit-operator evil-inhibit-operator-value evil-command-properties evil-delete plist-member :motion undefined plist-get :type nil append evil-operator-range t evil-yank-handler evil-visual-state-p evil-visual-rotate upper-left :move-point this-command evil-this-operator evil-operator-start-col evil-this-register deactivate-mark] 6)
  command-execute(evil-delete)

Using ) works. I'm not entirely sure how to debug this.

Oh I see, I called evil-surround-delete-manually to test. Do the parens have have spaces for ( to work? Has this always been the case?

After a bit more debugging, this appears to be an issue with evil-embrace. When I don't load that package this works as expected.

Turns out I'm not actually sure I need embrace at all (and therefore probably don't need evil-embrace), but for posterity or anyone searching for this issue:

I'm really not a fan of how evil-embrace is coded. It seems to copy all of the source code of evil-surround functions with minor changes and override them, as opposed to minimally advising them (which is why it got out of sync, and it appears it's happened before). I found if I wanted I could achieve most of the desired effect with just the following:

(use-package embrace
  :after evil-surround
  :config
  (define-advice evil-surround-region (:around (fn beg end type char &optional force-new-line) d/embrace)
    (if (evil-surround--get-delims char)
        (funcall fn beg end type char force-new-line)
      (embrace--add-internal beg end char)))
  (define-advice evil-surround-delete (:around (fn char &optional outer inner) d/embrace)
    (if (or (and outer inner)
            (evil-surround--get-delims char))
        (funcall fn char outer inner)
      (embrace--delete char))))