Some evil-cp work

This commit is contained in:
Alexander Rosenberg 2024-10-16 16:56:08 -07:00
parent f55065d312
commit 48d546c561
Signed by: Zander671
GPG Key ID: 5FD0394ADBD72730

26
init.el
View File

@ -448,7 +448,31 @@ directory. Otherwise, run `find-file' on that file."
(if (member major-mode '(lisp-mode emacs-lisp-mode (if (member major-mode '(lisp-mode emacs-lisp-mode
lisp-interaction-mode)) lisp-interaction-mode))
(evil-cleverparens-mode 1) (evil-cleverparens-mode 1)
(electric-pair-local-mode 1)))) (electric-pair-local-mode 1)))
(defun my/inside-bound-p (beg end bounds)
"Return non-nil if BEG and END are inside BOUNDS.
BOUNDS should be either nil, in which case this will return nil, or a cons cell
of the form (bound-start . bound-end)"
(when bounds
(cl-destructuring-bind (bs . be) bounds
(and (>= beg bs) (<= beg be)
(>= end bs) (<= end be)))))
(defun my/-fix-evil-cp-delete (oldfun beg end type register yank-handler)
"Make `evil-cp-delete' fall back to `evil-delete' if we are inside a
string."
(if (my/inside-bound-p beg end (bounds-of-thing-at-point 'string))
(funcall 'evil-delete beg end type register yank-handler)
(funcall oldfun beg end type register yank-handler)))
(defun my/-fix-evil-cp-delete-char-or-splice
(oldfun beg end type register yank-handler)
"Make `evil-cp-delete' fall back to `evil-delete' if we are inside a
string."
(if (my/inside-bound-p beg end (bounds-of-thing-at-point 'string))
(funcall 'evil-delete-char beg end type register)
(funcall oldfun beg end type register yank-handler)))
(advice-add 'evil-cp-delete)
(advice-add 'evil-cp-delete-char-or-splice :around
'my/-fix-evil-cp-delete-char-or-splice))
;; make lisp editing nicer ;; make lisp editing nicer
(use-package aggressive-indent (use-package aggressive-indent