diff options
author | Alan Pearce | 2020-01-10 12:25:45 +0100 |
---|---|---|
committer | Alan Pearce | 2020-01-10 12:25:45 +0100 |
commit | bbac413d6d50b3190b9e522ae8754c4bf858c7d8 (patch) | |
tree | 0146499984dcfb2cb241f4c13d238026f99dcadf | |
parent | 8eaf0d14cef48c3aba20c67ad199c1b02e5dcf41 (diff) | |
download | nixfiles-bbac413d6d50b3190b9e522ae8754c4bf858c7d8.tar.lz nixfiles-bbac413d6d50b3190b9e522ae8754c4bf858c7d8.tar.zst nixfiles-bbac413d6d50b3190b9e522ae8754c4bf858c7d8.zip |
Emacs: add slash surround pair
-rw-r--r-- | user/emacs/.emacs.d/init.el | 20 |
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) |