From: Paul Nelson Date: Sun, 15 Sep 2024 20:29:46 +0000 (+0200) Subject: Add option for delete-pair to mark end of region X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=eb9bde1359465767be230659014a28dae5da51e7;p=emacs.git Add option for delete-pair to mark end of region * lisp/emacs-lisp/lisp.el (delete-pair-push-mark): New user option. (delete-pair): Use it. (Bug#73284) * etc/NEWS: Announce the new user option. (cherry picked from commit a48672c6bbf8cf0adae33b13634f3945c24c61dd) --- diff --git a/etc/NEWS b/etc/NEWS index 0f94ab65cbc..7263987a418 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -127,6 +127,12 @@ instead of raising an error. Note that if you have disabled Transient Mark mode you might prefer to use 'unix-word-rubout', as this feature relies on there being an active region. +--- +** New user option 'delete-pair-push-mark'. +This option, if non-nil, makes 'delete-pair' push a mark at the end of +the region enclosed by the deleted delimiters. This makes it easy to +act on that region. For example, we can highlight it using 'C-x C-x'. + * Changes in Specialized Modes and Packages in Emacs 31.1 diff --git a/lisp/emacs-lisp/lisp.el b/lisp/emacs-lisp/lisp.el index e9cb526894b..7c4db3d9953 100644 --- a/lisp/emacs-lisp/lisp.el +++ b/lisp/emacs-lisp/lisp.el @@ -842,10 +842,16 @@ It's used by the command `delete-pair'. The value 0 disables blinking." :group 'lisp :version "28.1") +(defcustom delete-pair-push-mark nil + "Non-nil means `delete-pair' pushes mark at end of delimited region." + :type 'boolean) + (defun delete-pair (&optional arg) "Delete a pair of characters enclosing ARG sexps that follow point. A negative ARG deletes a pair around the preceding ARG sexps instead. -The option `delete-pair-blink-delay' can disable blinking." +The option `delete-pair-blink-delay' can disable blinking. With +`delete-pair-push-mark' enabled, pushes a mark at the end of the +enclosed region." (interactive "P") (if arg (setq arg (prefix-numeric-value arg)) @@ -879,7 +885,9 @@ The option `delete-pair-blink-delay' can disable blinking." (when (and (numberp delete-pair-blink-delay) (> delete-pair-blink-delay 0)) (sit-for delete-pair-blink-delay)) - (delete-char -1))) + (delete-char -1) + (when delete-pair-push-mark + (push-mark)))) (delete-char 1)))) (defun raise-sexp (&optional n)