[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-surround 72d35afc40 051/175: Fix surrounding with inv
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-surround 72d35afc40 051/175: Fix surrounding with invalid chars, like ESC (Fix #51) |
Date: |
Mon, 9 Oct 2023 13:01:02 -0400 (EDT) |
branch: elpa/evil-surround
commit 72d35afc4049e4f52d8c906a8e47da56214cef6a
Author: Henrik Lissner <henrik@lissner.net>
Commit: Henrik Lissner <henrik@lissner.net>
Fix surrounding with invalid chars, like ESC (Fix #51)
---
evil-surround.el | 80 ++++++++++++++++++++++++++++++--------------------------
1 file changed, 43 insertions(+), 37 deletions(-)
diff --git a/evil-surround.el b/evil-surround.el
index 3ded066994..4a8aaf5aa5 100755
--- a/evil-surround.el
+++ b/evil-surround.el
@@ -95,6 +95,10 @@ Each item is of the form (OPERATOR . OPERATION)."
(cons (format "<%s%s>" (or tag "") (or rest ""))
(format "</%s>" (or tag "")))))
+(defun evil-surround-valid-char-p (char)
+ "Returns whether CHAR is a valid surround char or not."
+ (not (memq char '(?\C-\[ ?\C-?))))
+
(defun evil-surround-pair (char)
"Return the evil-surround pair of char.
This is a cons cell (LEFT . RIGHT), both strings."
@@ -191,9 +195,10 @@ overlays OUTER and INNER, which are passed to
`evil-surround-delete'."
(cond
((and outer inner)
(evil-surround-delete char outer inner)
- (evil-surround-region (overlay-start outer)
- (overlay-end outer)
- nil (read-char)))
+ (let ((key (read-char)))
+ (evil-surround-region (overlay-start outer)
+ (overlay-end outer)
+ nil (if (evil-surround-valid-char-p key) key
char))))
(t
(let* ((outer (evil-surround-outer-overlay char))
(inner (evil-surround-inner-overlay char)))
@@ -275,40 +280,41 @@ Becomes this:
}"
(interactive "<R>c")
- (let* ((overlay (make-overlay beg end nil nil t))
- (pair (evil-surround-pair char))
- (open (car pair))
- (close (cdr pair)))
- (unwind-protect
- (progn
- (goto-char (overlay-start overlay))
-
- (cond ((eq type 'block)
- (evil-surround-block beg end char))
-
- ((eq type 'line)
- (insert open)
- (indent-according-to-mode)
- (newline-and-indent)
- (goto-char (overlay-end overlay))
- (insert close)
- (indent-according-to-mode)
- (newline))
-
- (force-new-line
- (insert open)
- (indent-according-to-mode)
- (newline-and-indent)
- (goto-char (overlay-end overlay))
- (newline-and-indent)
- (insert close))
-
- (t
- (insert open)
- (goto-char (overlay-end overlay))
- (insert close)))
- (goto-char (overlay-start overlay)))
- (delete-overlay overlay))))
+ (when (evil-surround-valid-char-p char)
+ (let* ((overlay (make-overlay beg end nil nil t))
+ (pair (evil-surround-pair char))
+ (open (car pair))
+ (close (cdr pair)))
+ (unwind-protect
+ (progn
+ (goto-char (overlay-start overlay))
+
+ (cond ((eq type 'block)
+ (evil-surround-block beg end char))
+
+ ((eq type 'line)
+ (insert open)
+ (indent-according-to-mode)
+ (newline-and-indent)
+ (goto-char (overlay-end overlay))
+ (insert close)
+ (indent-according-to-mode)
+ (newline))
+
+ (force-new-line
+ (insert open)
+ (indent-according-to-mode)
+ (newline-and-indent)
+ (goto-char (overlay-end overlay))
+ (newline-and-indent)
+ (insert close))
+
+ (t
+ (insert open)
+ (goto-char (overlay-end overlay))
+ (insert close)))
+ (goto-char (overlay-start overlay)))
+ (delete-overlay overlay)))))
(evil-define-operator evil-Surround-region (beg end type char)
"Call surround-region, toggling force-new-line"
- [nongnu] elpa/evil-surround ea14078cb2 171/175: Make car + cdr safe for delete overlays, (continued)
- [nongnu] elpa/evil-surround ea14078cb2 171/175: Make car + cdr safe for delete overlays, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround ee19b598ca 019/175: Merge pull request #8 from cofi/master, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 9f2917cfe2 018/175: Mention the buffer local surround pairs in the readme., ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround c42ddb5d1d 023/175: add autoloads, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 31cc1da60c 026/175: Merge pull request #14 from milkypostman/master, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 0c503fc994 033/175: Merge branch 'master' of https://github.com/lyro/evil-surround, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 8b59d17d5c 038/175: Merge pull request #32 from Silex/master, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 77e7cd8de0 045/175: bring back the evil-Surround-region; make it work with yS, also, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 6f290e0270 048/175: Implement block-wise surround, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 7a2e79d7a8 039/175: Fix forgotten leftovers when renaming, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 72d35afc40 051/175: Fix surrounding with invalid chars, like ESC (Fix #51),
ELPA Syncer <=
- [nongnu] elpa/evil-surround 7cad34b28a 005/175: 'S' causes normal region to end up on it's own line, as in surround.vim, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround c43dfec32c 011/175: Update `interactive' forms, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 2f49c479bf 016/175: Merge pull request #6 from cofi/buffer-local, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 1d6b1bac4e 027/175: Add wrap in function call, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 7f8f950985 037/175: Rename surround* to evil-surround*, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 28466957f9 044/175: Update README.md, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 9508236d8e 052/175: Merge branch 'fix-esc-surround' of github.com:hlissner/evil-surround into fix-esc-surround, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 430c81f2a1 071/175: Fix #71, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 8c03039e0e 073/175: Merge pull request #73 from hlissner/linewise-surround-fix, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 277759d894 074/175: Fix repeat action (.) for ys and yS operators., ELPA Syncer, 2023/10/09