From 61e81d749f4eb8102504fd9b40696d20ac64173b Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sun, 15 Aug 2021 22:08:25 -0500 Subject: Add `acdw/set-mark-or-expand-region' function and binding A combination of `set-mark-command' and `er/expand-region' that is pretty useful IMO. I'm going to keep testing it and see if it's a-ok to keep using. --- init.el | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'init.el') diff --git a/init.el b/init.el index cbdec9a..d60915b 100644 --- a/init.el +++ b/init.el @@ -1135,7 +1135,28 @@ if ripgrep is installed, otherwise `consult-grep'." )) (setup (:straight expand-region) - (:global "C-=" er/expand-region)) + + (defun acdw/set-mark-or-expand-region (arg) + "Set mark at point and activate, jump to mark, or expand region. +See `set-mark-command' and `expand-region'. + +With no prefix argument, either run `set-mark-command' on first +invocation and `er/expand-region' on each successive invocation. + +With any prefix argument +(e.g., \\[universal-argument] \\[set-mark-command]), act as with +`set-mark-command' (i.e., pop the mark). Don't care about +successive invocations." + (interactive "P") + (cond + (arg + (setq this-command 'set-mark-command) + (set-mark-command arg)) + ((eq last-command 'acdw/set-mark-or-expand-region) + (er/expand-region 1)) + (t (set-mark-command arg)))) + + (:global "C-SPC" acdw/set-mark-or-expand-region)) (setup (:straight fennel-mode) (:needs "fennel") -- cgit 1.4.1-21-gabe81