summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStrawberryTea <look@strawberrytea.xyz>2023-08-18 22:41:33 -0400
committerTom Dalziel <33435574+tomdl89@users.noreply.github.com>2023-08-19 09:36:25 +0100
commit8fad8540c490d94a820004f227552ca08e3e3857 (patch)
tree5ba7aa98f1099d675781fc9f2236ab61a6dfc141
parentea14078cb2b934961b41d5179996ebd8d283273b (diff)
Revert "Revert "Enable lexical binding""
This reverts commit 4a21d756b76a50e0c0619555836c9aa98f103d3d.
-rw-r--r--evil-surround.el23
1 files changed, 14 insertions, 9 deletions
diff --git a/evil-surround.el b/evil-surround.el
index e01e8d0..c46abd5 100644
--- a/evil-surround.el
+++ b/evil-surround.el
@@ -1,4 +1,4 @@
-;;; evil-surround.el --- emulate surround.vim from Vim
+;;; evil-surround.el --- emulate surround.vim from Vim -*- lexical-binding: t; -*-
;; Copyright (C) 2010 - 2017 Tim Harper
;; Copyright (C) 2018 - 2020 The evil-surround.el Contributors
@@ -115,6 +115,11 @@ Each item is of the form (OPERATOR . OPERATION)."
(defvar evil-surround-last-deleted-left ""
"The previously deleted LEFT region.")
+(defvar evil-surround-current-pair nil
+ "The current pair.
+
+When non-nil, it can be either a cons or a function returning a cons.")
+
(defun evil-surround-read-from-minibuffer (&rest args)
(when (or evil-surround-record-repeat
(evil-repeat-recording-p))
@@ -190,13 +195,13 @@ function call in prefixed form."
(defun evil-surround-pair (char)
"Return the evil-surround pair of char.
This is a cons cell (LEFT . RIGHT), both strings."
- (let ((pair (assoc-default char evil-surround-pairs-alist)))
+ (let ((evil-surround-current-pair (assoc-default char evil-surround-pairs-alist)))
(cond
- ((functionp pair)
- (funcall pair))
+ ((functionp evil-surround-current-pair)
+ (funcall evil-surround-current-pair))
- ((consp pair)
- pair)
+ ((consp evil-surround-current-pair)
+ evil-surround-current-pair)
(t
(cons (format "%c" char) (format "%c" char))))))
@@ -425,9 +430,9 @@ Becomes this:
(when (evil-surround-valid-char-p char)
(let* ((overlay (make-overlay beg end nil nil t))
- (pair (or (and (boundp 'pair) pair) (evil-surround-pair char)))
- (open (car pair))
- (close (cdr pair))
+ (evil-surround-current-pair (or evil-surround-current-pair (evil-surround-pair char)))
+ (open (car evil-surround-current-pair))
+ (close (cdr evil-surround-current-pair))
(beg-pos (overlay-start overlay)))
(unwind-protect
(progn