From: Jim Porter <jporterbugs@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org
Subject: Re: [WIP PATCH] Adding more keybindings to rectangle-mark-mode-map
Date: Sun, 2 May 2021 21:06:18 -0700 [thread overview]
Message-ID: <CANh=_JGCq=_N2YymHQvT8Jo4J=2ay2SZh-Qjh337-EpgGiTt4g@mail.gmail.com> (raw)
In-Reply-To: <jwv35v5ypqu.fsf-monnier+emacs@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 1158 bytes --]
On Sun, May 2, 2021 at 11:07 AM Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>
> Jim Porter [2021-05-02 09:36:14] wrote:
> > On Sun, May 2, 2021 at 9:09 AM Eli Zaretskii <eliz@gnu.org> wrote:
> >> > From: Jim Porter <jporterbugs@gmail.com>
> >> > I interpreted that to mean that, if Edit -> Clear is only enabled
> >> > when there's an active region/rect, `backward-delete-char-untabify'
> >> > is equivalent to a hypothetical `delete-rect-or-region'.
> >>
> >> But Edit->Clear is enabled even when the region is not active, like if
> >> you turn off transient-mark-mode.
> >
> > Ah. In that case, a new function might be safer.
>
> Indeed, we need a new function here.
> It should be a small matter of moving the code from
> `backward-delete-char-untabify' into a separate function.
For what it's worth, I think the attached patch fixes this by changing
the binding for Edit -> Clear to `delete-active-region'. I've tested
it out with and without `transient-mark-mode' using regular and
rectangular regions and it seems to work correctly. I never turn off
`transient-mark-mode' in my normal usage though, so I may have missed
some corner cases.
- Jim
[-- Attachment #2: 0001-Ensure-menu-bar-edit-clear-handles-rectangular-regio.patch --]
[-- Type: application/octet-stream, Size: 1550 bytes --]
From e0d59c2b210fceb03b5fc8df8403179fba9be845 Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Sun, 2 May 2021 20:58:00 -0700
Subject: [PATCH] Ensure `<menu-bar> <edit> <clear>' handles rectangular
regions
* lisp/delsel.el (delete-active-region): Autoload it and make it interactive.
* lisp/menu-bar.el (menu-bar-edit-menu): Bind "Clear" to
`delete-active-region'.
---
lisp/delsel.el | 2 ++
| 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/lisp/delsel.el b/lisp/delsel.el
index 982320340d..27224b1308 100644
--- a/lisp/delsel.el
+++ b/lisp/delsel.el
@@ -84,9 +84,11 @@ delete-selection-mode
(defvar delsel--replace-text-or-position nil)
+;;;###autoload
(defun delete-active-region (&optional killp)
"Delete the active region.
If KILLP in not-nil, the active region is killed instead of deleted."
+ (interactive "p")
(cond
(killp
;; Don't allow `kill-region' to change the value of `this-command'.
--git a/lisp/menu-bar.el b/lisp/menu-bar.el
index e6cce59343..b75dbf226c 100644
--- a/lisp/menu-bar.el
+++ b/lisp/menu-bar.el
@@ -495,7 +495,7 @@ menu-bar-edit-menu
'(menu-item "Select All" mark-whole-buffer
:help "Mark the whole buffer for a subsequent cut/copy"))
(bindings--define-key menu [clear]
- '(menu-item "Clear" delete-region
+ '(menu-item "Clear" delete-active-region
:enable (and mark-active
(not buffer-read-only))
:help
--
2.25.1
next prev parent reply other threads:[~2021-05-03 4:06 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-01 5:23 [WIP PATCH] Adding more keybindings to rectangle-mark-mode-map Jim Porter
2021-05-01 13:29 ` Stefan Monnier
2021-05-01 16:02 ` Jim Porter
2021-05-01 17:20 ` Stefan Monnier
2021-05-01 22:31 ` Jim Porter
2021-05-02 6:57 ` Eli Zaretskii
2021-05-02 15:48 ` Jim Porter
2021-05-02 16:09 ` Eli Zaretskii
2021-05-02 16:36 ` Jim Porter
2021-05-02 18:07 ` Stefan Monnier
2021-05-03 4:06 ` Jim Porter [this message]
2021-05-03 7:55 ` Andreas Schwab
2021-05-03 15:26 ` Jim Porter
2021-05-08 1:52 ` Stefan Monnier
2021-05-08 7:15 ` Eli Zaretskii
2021-05-08 6:55 ` Andreas Schwab
2021-05-08 18:57 ` [PATCH] Improve docstring for delete-active-region (was Re: [WIP PATCH] Adding more keybindings to rectangle-mark-mode-map) Jim Porter
2021-06-18 3:09 ` Jim Porter
2021-06-19 12:27 ` Lars Ingebrigtsen
2021-06-19 16:28 ` Jim Porter
2021-05-01 17:26 ` [WIP PATCH] Adding more keybindings to rectangle-mark-mode-map Ergus
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='CANh=_JGCq=_N2YymHQvT8Jo4J=2ay2SZh-Qjh337-EpgGiTt4g@mail.gmail.com' \
--to=jporterbugs@gmail.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/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.