summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--user/emacs/.emacs.d/init.el20
1 files changed, 19 insertions, 1 deletions
diff --git a/user/emacs/.emacs.d/init.el b/user/emacs/.emacs.d/init.el
index c425d723..0365b710 100644
--- a/user/emacs/.emacs.d/init.el
+++ b/user/emacs/.emacs.d/init.el
@@ -323,14 +323,32 @@ _p_rev       _u_pper              _=_: upper/lower       _r_esolve
   :after evil
   :config (evil-space-mode +1))
 
+;; this macro was copied from here: https://stackoverflow.com/a/22418983/4921402
+(defmacro define-and-bind-quoted-text-object (name key start-regex end-regex)
+  (let ((inner-name (make-symbol (concat "evil-inner-" name)))
+        (outer-name (make-symbol (concat "evil-a-" name))))
+    `(progn
+       (evil-define-text-object ,inner-name (count &optional beg end type)
+         (evil-select-paren ,start-regex ,end-regex beg end type count nil))
+       (evil-define-text-object ,outer-name (count &optional beg end type)
+         (evil-select-paren ,start-regex ,end-regex beg end type count t))
+       (define-key evil-inner-text-objects-map ,key #',inner-name)
+       (define-key evil-outer-text-objects-map ,key #',outer-name))))
+
 (use-package evil-surround
   :after evil
   :defer 2
-  :config (global-evil-surround-mode +1))
+  :config (progn
+            (define-and-bind-quoted-text-object "slash" "/" "\\/" "\\/")
+            (push '(?\/ . ("/" . "/")) evil-surround-pairs-alist)
+            (global-evil-surround-mode +1)))
+
 
 (use-package evil-embrace
   :after evil-surround
   :config (progn
+            (setq evil-embrace-show-help-p nil)
+            (push ?\/ evil-embrace-evil-surround-keys)
             (evil-embrace-enable-evil-surround-integration)
             (add-hook 'LaTeX-mode-hook #'embrace-LaTeX-mode-hook)
             (add-hook 'org-mode-hook #'embrace-org-mode-hook)