From: Paul Nelson <ultrono@gmail.com>
To: 73284@debbugs.gnu.org
Subject: bug#73284: [PATCH] Add option to push mark after delete-pair
Date: Sun, 15 Sep 2024 22:58:09 +0200 [thread overview]
Message-ID: <CAOA-32Pa7YEjqS+_UrkWrY+vUdZZY4jFOEEuiEu3QqGoxGaLqA@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 941 bytes --]
The delete-pair command from lisp.el deletes a matched pair of
delimiters. After using this command, I often want to operate on the
region enclosed by the deleted delimiters. As far as I know, there's
currently no quick way to access the end of that region.
This patch introduces a custom option, delete-pair-push-mark. When
enabled, it causes delete-pair to push a mark at the end of the
enclosed region.
This opens up various workflows. For instance, after deleting a pair,
we can use C-x C-x to highlight the region and act on it further.
Alternatively, we can use C-M-k to delete the first sexp inside the
delimiters, then act on the remainder.
To err on the side of caution, I hid the new behavior behind a user
option, disabled by default. I could just as well see it being turned
on by default (or getting rid of the user option, making the new
behavior "mandatory"), and am open to suggestions/feedback.
Thanks, best,
Paul
[-- Attachment #2: 0001-Add-option-for-delete-pair-to-mark-end-of-region.patch --]
[-- Type: application/octet-stream, Size: 2313 bytes --]
From 0c54eff47299e8a30ab4f5fcafc44801d8983763 Mon Sep 17 00:00:00 2001
From: Paul Nelson <ultrono@gmail.com>
Date: Sun, 15 Sep 2024 22:29:46 +0200
Subject: [PATCH] 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.
* etc/NEWS: Announce the new user option.
---
etc/NEWS | 6 ++++++
lisp/emacs-lisp/lisp.el | 12 ++++++++++--
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index 492159439fc..619e0d2eadf 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -147,6 +147,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'.
+
\f
* 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 e65eec508d9..f6eebcda35a 100644
--- a/lisp/emacs-lisp/lisp.el
+++ b/lisp/emacs-lisp/lisp.el
@@ -850,10 +850,16 @@ delete-pair-blink-delay
: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))
@@ -887,7 +893,9 @@ delete-pair
(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)
--
2.39.3 (Apple Git-145)
next reply other threads:[~2024-09-15 20:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-15 20:58 Paul Nelson [this message]
2024-09-16 11:44 ` bug#73284: [PATCH] Add option to push mark after delete-pair Eli Zaretskii
2024-09-16 14:07 ` Paul Nelson
2024-09-17 6:56 ` Juri Linkov
2024-09-17 9:20 ` Sean Whitton
2024-09-21 10:25 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAOA-32Pa7YEjqS+_UrkWrY+vUdZZY4jFOEEuiEu3QqGoxGaLqA@mail.gmail.com \
--to=ultrono@gmail.com \
--cc=73284@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.