From b47430d46cfed1a9e128ccc684b5a570db2bca62 Mon Sep 17 00:00:00 2001 From: David Morgan Date: Wed, 5 Oct 2022 16:38:32 +0100 Subject: Use crux advice macros --- .emacs.d/lisp/init-crux.el | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to '.emacs.d/lisp/init-crux.el') diff --git a/.emacs.d/lisp/init-crux.el b/.emacs.d/lisp/init-crux.el index f7f30a7..c819c25 100644 --- a/.emacs.d/lisp/init-crux.el +++ b/.emacs.d/lisp/init-crux.el @@ -3,7 +3,25 @@ ;;; Code: (use-package crux + :defer 5 :commands crux-start-or-switch-to + :config + (defmacro crux-with-region-or-sexp-or-line (func) + "When called with no active region, call FUNC on current sexp." + `(defadvice ,func (before with-region-or-sexp-or-line activate compile) + (interactive + (cond + (mark-active (list (region-beginning) (region-end))) + ((in-string-p) (flatten-list (bounds-of-thing-at-point 'string))) + ((thing-at-point 'list) (flatten-list (bounds-of-thing-at-point 'list))) + (t (list (line-beginning-position) (line-beginning-position 2))))))) + + (crux-with-region-or-sexp-or-line sp-kill-region) + (crux-with-region-or-sexp-or-line paredit-kill-region) + (crux-with-region-or-buffer shell-command-on-region) + (crux-with-region-or-buffer indent-region) + (crux-with-region-or-buffer untabify) + (crux-with-region-or-line comment-or-uncomment-region) :bind ("C-^" . crux-top-join-line) ("C-" . crux-kill-line-backwards) -- cgit 1.4.1-2-gfad0