emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/evil-surround c96499e91e 030/175: Extract surround-operato


From: ELPA Syncer
Subject: [nongnu] elpa/evil-surround c96499e91e 030/175: Extract surround-operator-alist to a customizeable variable
Date: Mon, 9 Oct 2023 13:01:01 -0400 (EDT)

branch: elpa/evil-surround
commit c96499e91e46e6a950c7870524e95d10af9870c2
Author: aheaume <aheaume@gmail.com>
Commit: Tim Harper <timcharper@gmail.com>

    Extract surround-operator-alist to a customizeable variable
    
    * Documentation to show how to integrate with paredit-evil
---
 README.md   | 13 +++++++++++++
 surround.el | 12 ++++++++++--
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
old mode 100644
new mode 100755
index a01aca40cb..7a1170e359
--- a/README.md
+++ b/README.md
@@ -61,6 +61,19 @@ or to add a pair that surrounds with two ` if you enter ~:
     (setq-default surround-pairs-alist (cons '(?~ ("``" . "``"))
                                              surround-pairs-alist))
 
+## Add new supported operators ##
+You can add support for new operators by adding them to 
`surround-operator-alist`.
+For more information do: `C-h v surround-operator-alist`.
+
+By default, surround works with `evil-change` and `evil-delete`.
+To add support for the evil-paredit package, you need to add 
`evil-paredit-change`
+and `evil-paredit-delete` to `surround-operator-alist`, like so:
+
+    (add-to-list 'surround-operator-alist
+                 '(evil-paredit-change . change))
+    (add-to-list 'surround-operator-alist
+                 '(evil-paredit-delete . delete))
+
 ## Usage examples ##
 
 Here are some usage examples (taken from
diff --git a/surround.el b/surround.el
old mode 100644
new mode 100755
index 72d726df7f..6564c3dbd6
--- a/surround.el
+++ b/surround.el
@@ -65,6 +65,15 @@ This only affects inserting pairs, not deleting or changing 
them."
                        (symbol :tag "Surround pair"))))
 (make-variable-buffer-local 'surround-pairs-alist)
 
+(defcustom surround-operator-alist
+  '((evil-change . change)
+    (evil-delete . delete))
+  "Association list of operators to their fundamental operation.
+Each item is of the form (OPERATOR . OPERATION)."
+  :group 'surround
+  :type '(repeat (cons (symbol :tag "Operator")
+                       (symbol :tag "Operation"))))
+
 (defvar surround-read-tag-map
   (let ((map (copy-keymap minibuffer-local-map)))
     (define-key map ">" 'exit-minibuffer)
@@ -197,8 +206,7 @@ Otherwise call `surround-delete'."
      ;; abort the calling operator
      (setq evil-inhibit-operator t)
      (list (assoc-default evil-this-operator
-                          '((evil-change . change)
-                            (evil-delete . delete))))))
+                          surround-operator-alist))))
   (cond
    ((eq operation 'change)
     (call-interactively 'surround-change))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]