[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-surround a3034c284d 049/175: Fix surrounding with inv
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-surround a3034c284d 049/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 a3034c284d962c28ae5a47e94037aaa8bc3e9d03
Author: Henrik Lissner <henrik@lissner.net>
Commit: Henrik Lissner <henrik@lissner.net>
Fix surrounding with invalid chars, like ESC (Fix #51)
---
evil-surround.el | 74 ++++++++++++++++++++++++++++++--------------------------
1 file changed, 40 insertions(+), 34 deletions(-)
diff --git a/evil-surround.el b/evil-surround.el
index faa7d96f4c..169de6004b 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)))
@@ -259,37 +264,38 @@ 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 '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 '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 83c2e0f369 137/175: add a "make emacs" makefile option to fire up a clean emacs..., (continued)
- [nongnu] elpa/evil-surround 83c2e0f369 137/175: add a "make emacs" makefile option to fire up a clean emacs..., ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 440d391c89 130/175: Fix visible narrowing when surrounding within a field (#135), ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround b11048d92a 173/175: Trim whitespace from delimeters before using for deletion/change, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 4d6cc94df0 146/175: Add surround text objects from local keymap (#165), ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 282a975bda 154/175: Typo fix, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround a3803cfb51 141/175: Add a test for surrounding with a tag in a macro, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 6d37e5c910 115/175: add melpa stable badge, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround f273821f57 165/175: Merge pull request #188 from skangas/nongnu-elpa-fixes, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 2bc8aa6425 160/175: Merge pull request #186 from leungbk/prefix-calls, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 4a21d756b7 168/175: Revert "Enable lexical binding", ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround a3034c284d 049/175: Fix surrounding with invalid chars, like ESC (Fix #51),
ELPA Syncer <=
- [nongnu] elpa/evil-surround 27eb4112db 050/175: Merge pull request #53 from hlissner/block-surround, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 71f380b6b6 042/175: Merge pull request #35 from Silex/master, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround ce36c8307c 047/175: correct README.md, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 641498131a 059/175: Refactor evil-surround-block, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 0eeef7a3a9 070/175: Merge pull request #68 from hlissner/master, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 8b2ca83b7c 068/175: Fix #52, #39, and #5 (linewise surrounding), ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 78eddc8077 063/175: Merge pull request #50 from yangguang760/master, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 06071c3425 060/175: let* => let, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround a70e34164e 069/175: Don't indent first line on inline linewise surround, ELPA Syncer, 2023/10/09
- [nongnu] elpa/evil-surround 5c07befaf7 090/175: Merge pull request #89 from LemmingAvalanche/execute-permissions, ELPA Syncer, 2023/10/09