diff options
| author | Tom Dalziel <tom_dl@hotmail.com> | 2023-09-12 18:50:49 +0200 |
|---|---|---|
| committer | Tom Dalziel <tom_dl@hotmail.com> | 2023-09-12 18:52:29 +0200 |
| commit | b11048d92aa253d59097a82398e142453c809692 (patch) | |
| tree | e4bc3286afe33aa0f2f1a77bc5a7ca01e9ad4756 | |
| parent | 8fad8540c490d94a820004f227552ca08e3e3857 (diff) | |
Trim whitespace from delimeters before using for deletion/change
Fixes #204
| -rw-r--r-- | evil-surround.el | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/evil-surround.el b/evil-surround.el index c46abd5..6a47d1f 100644 --- a/evil-surround.el +++ b/evil-surround.el @@ -289,6 +289,12 @@ This overlay excludes the delimeters." (evil-expand-range range) range))) +(defun evil-surround--get-delims (char) + "Given a CHAR, return delims from the pairs alist. Trim whitespace." + (cl-destructuring-bind (&optional k . (o . c)) (assoc char evil-surround-pairs-alist) + (when k + (cons (string-trim o) (string-trim c))))) + ;;;###autoload (defun evil-surround-delete (char &optional outer inner) "Delete the surrounding delimiters represented by CHAR. @@ -306,7 +312,7 @@ between these overlays is what is deleted." (t ;; no overlays specified: create them on the basis of CHAR ;; and delete after use - (let* ((delims (cdr (assoc char evil-surround-pairs-alist))) + (let* ((delims (evil-surround--get-delims char)) (outer (evil-surround-outer-overlay delims char)) (inner (evil-surround-inner-overlay delims char))) (unwind-protect @@ -330,7 +336,7 @@ overlays OUTER and INNER, which are passed to `evil-surround-delete'." (overlay-end outer) nil (if (evil-surround-valid-char-p key) key char)))) (t - (let* ((delims (cdr (assoc char evil-surround-pairs-alist))) + (let* ((delims (evil-surround--get-delims char)) (outer (evil-surround-outer-overlay delims char)) (inner (evil-surround-inner-overlay delims char))) (unwind-protect |
