customize kill behavior of elisp symbol in string/doc/comment

This commit is contained in:
zedhugh committed 2022-11-02 00:51:44 +08:00
1 parent f9283e4b35
commit 9b770e0129
1 file changed
+15 -1
+15 -1
View File
@@ -42,7 +42,16 @@
(defun creature/awesome-pair-kill-template-string-curly-content () (defun creature/awesome-pair-kill-template-string-curly-content ()
(interactive) (interactive)
(save-excursion (save-excursion
(kill-region (point) (progn (search-forward "}") (1- (point)))))) (kill-region (point) (save-excursion (search-forward "}") (1- (point))))))
(defun creature/in-elisp-string-symbol ()
(when (and (derived-mode-p 'emacs-lisp-mode))
(let ((faces (get-text-property (point) 'face)))
(and (listp faces)
(memq 'font-lock-constant-face faces)
(or (memq 'font-lock-doc-face faces)
(memq 'font-lock-string-face faces)
(memq 'font-lock-comment-face faces))))))
(defun creature/awesome-pair-kill () (defun creature/awesome-pair-kill ()
(interactive) (interactive)
@@ -50,6 +59,11 @@
(creature/awesome-pair-in-template-string-p) (creature/awesome-pair-in-template-string-p)
(awesome-pair-in-curly-p)) (awesome-pair-in-curly-p))
(creature/awesome-pair-kill-template-string-curly-content)) (creature/awesome-pair-kill-template-string-curly-content))
((creature/in-elisp-string-symbol)
(kill-region (point)
(save-excursion
(search-forward "'" (pos-eol))
(1- (point)))))
(t (t
(funcall-interactively #'awesome-pair-kill)))) (funcall-interactively #'awesome-pair-kill))))