unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [WIP PATCH] Adding more keybindings to rectangle-mark-mode-map
@ 2021-05-01  5:23 Jim Porter
  2021-05-01 13:29 ` Stefan Monnier
  0 siblings, 1 reply; 18+ messages in thread
From: Jim Porter @ 2021-05-01  5:23 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1469 bytes --]

One thing that always trips me up about the otherwise very nice
`rectangle-mark-mode-map' is that it only has a few key mappings, and
is notably missing `kill-rectangle' and `copy-rectangle-as-kill'. The
attached patch adds these (remapped from `kill-region' and
`kill-ring-save'), but there are still several other rectangle
commands in the `C-x r' prefix that might be worth adding, so I
figured I'd see what others thought:

  C-x r N         rectangle-number-lines
  C-x r c         clear-rectangle
  C-x r d         delete-rectangle
  C-x r r         copy-rectangle-to-register

As far as I'm aware, none of these have non-rect analogues that we
could remap except for `C-x r r', which is similar to `C-x r s'
(`copy-to-register'). Perhaps it makes sense to map these as well, but
I don't typically use any of them so I'm not sure what would be good
mappings. At a guess though, maybe these would work?

  M-N (M-S-n)     rectangle-number-lines
  M-SPC           clear-rectangle
  C-d             delete-rectangle
  C-x r s         copy-rectangle-to-register

Finally, there's `C-x r y' (`yank-rectangle'). As I understand it at
least, this doesn't need/want an active rect so there's no real reason
to map it in `rectangle-mark-mode-map'. However, when I was learning
about rects, I always *expected* `yank-rectangle' to require me to
have an active rect. Maybe it makes sense to do something about that,
or maybe not; that's just my anecdotal experience.

- Jim

[-- Attachment #2: 0001-lisp-rect.el-rectangle-mark-mode-map-Add-kill-rectan.patch --]
[-- Type: application/octet-stream, Size: 953 bytes --]

From d10cf1dc7f459588a905134f84b76c6948f3cace Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Fri, 30 Apr 2021 21:47:29 -0700
Subject: [PATCH] * lisp/rect.el (rectangle-mark-mode-map): Add
 `kill-rectangle' and `copy-rectangle-as-kill' to map

---
 lisp/rect.el | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lisp/rect.el b/lisp/rect.el
index 504be41b67..bae9142129 100644
--- a/lisp/rect.el
+++ b/lisp/rect.el
@@ -638,6 +638,8 @@ with a prefix argument, prompt for START-AT and FORMAT."
   (let ((map (make-sparse-keymap)))
     (define-key map [?\C-o] 'open-rectangle)
     (define-key map [?\C-t] 'string-rectangle)
+    (define-key map [remap kill-region] 'kill-rectangle)
+    (define-key map [remap kill-ring-save] 'copy-rectangle-as-kill)
     (define-key map [remap exchange-point-and-mark]
       'rectangle-exchange-point-and-mark)
     (dolist (cmd '(right-char left-char forward-char backward-char
-- 
2.25.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [WIP PATCH] Adding more keybindings to rectangle-mark-mode-map
  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
  0 siblings, 1 reply; 18+ messages in thread
From: Stefan Monnier @ 2021-05-01 13:29 UTC (permalink / raw)
  To: Jim Porter; +Cc: emacs-devel

> One thing that always trips me up about the otherwise very nice
> `rectangle-mark-mode-map' is that it only has a few key mappings, and
> is notably missing `kill-rectangle' and `copy-rectangle-as-kill'.

I don't understand: `kill-region` and `kill-ring-save` already
operate on the rectangle when in `rectangle-mark-mode`, so why would you
need keybindings for `kill-rectangle' and `copy-rectangle-as-kill'?

>   C-x r N         rectangle-number-lines
>   C-x r c         clear-rectangle
[...]
>
> As far as I'm aware, none of these have non-rect analogues that we
> could remap

How 'bout we introduce analogues that operate on the region, and we
make them work on the rectangle when in `rectangle-mark-mode`?

>   C-x r d         delete-rectangle

For `delete-rectangle` we already have `delete-region`, and it operates
on the rectangle when `rectangle-mark-mode` is active.
It is not bound by default, but DEL (aka `backspace`) does delegate to
it by default when the region is active.

>   C-x r s         copy-rectangle-to-register
> except for `C-x r r', which is similar to `C-x r s'
> (`copy-to-register').

Indeed `C-x r s` should already operate on the rectangle when in
`rectangle-mark-mode`, so AFAIK there's nothing to do here.

> Finally, there's `C-x r y' (`yank-rectangle'). As I understand it at
> least, this doesn't need/want an active rect so there's no real reason
> to map it in `rectangle-mark-mode-map'. However, when I was learning
> about rects, I always *expected* `yank-rectangle' to require me to
> have an active rect. Maybe it makes sense to do something about that,
> or maybe not; that's just my anecdotal experience.

In the current system, if you killed the rectangle with `C-w` (or
`M-w`), then `C-y` will do the equivalent of `yank-rectangle`, so indeed
you don't need `rectangle-mark-mode` to be active when yanking.

This said, I do think the way yanking rectangles works currently is not
fully satisfactory, because it's not always clear/intuitive how where
the rectangle will get inserted.  So maybe we do need a special yank
command active during `rectangle-mark-mode` which replaces the selected
rectangle with the yanked one, or something like that.


        Stefan




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [WIP PATCH] Adding more keybindings to rectangle-mark-mode-map
  2021-05-01 13:29 ` Stefan Monnier
@ 2021-05-01 16:02   ` Jim Porter
  2021-05-01 17:20     ` Stefan Monnier
  2021-05-01 17:26     ` [WIP PATCH] Adding more keybindings to rectangle-mark-mode-map Ergus
  0 siblings, 2 replies; 18+ messages in thread
From: Jim Porter @ 2021-05-01 16:02 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

On Sat, May 1, 2021 at 6:29 AM Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>
> > One thing that always trips me up about the otherwise very nice
> > `rectangle-mark-mode-map' is that it only has a few key mappings, and
> > is notably missing `kill-rectangle' and `copy-rectangle-as-kill'.
>
> I don't understand: `kill-region` and `kill-ring-save` already
> operate on the rectangle when in `rectangle-mark-mode`, so why would you
> need keybindings for `kill-rectangle' and `copy-rectangle-as-kill'?

Hmm, trying again without my patch, I see that you're right. I think I
may have tripped myself up by assuming the conversion went from `C-x r
k' to `C-k' in `rectangle-mark-mode', similarly to `C-o' and `C-t' in
`rectangle-mark-mode'. Then when I looked at the key map for
`rectangle-mark-mode', I didn't see any relevant mappings and
incorrectly assumed I'd discovered the issue.

Perhaps it makes sense to bind `C-k' in `rectangle-mark-mode'? It
seems to be similar to `C-o' and `C-t' in that there are non-rect
bindings that already do something different, but they aren't
particularly relevant in `rectangle-mark-mode'.

>
> >   C-x r N         rectangle-number-lines
> >   C-x r c         clear-rectangle
> [...]
> >
> > As far as I'm aware, none of these have non-rect analogues that we
> > could remap
>
> How 'bout we introduce analogues that operate on the region, and we
> make them work on the rectangle when in `rectangle-mark-mode`?

That would be fine with me, although I'm not sure what (if any) keys
we'd bind them to...

> >   C-x r d         delete-rectangle
>
> For `delete-rectangle` we already have `delete-region`, and it operates
> on the rectangle when `rectangle-mark-mode` is active.
> It is not bound by default, but DEL (aka `backspace`) does delegate to
> it by default when the region is active.

Interesting, I didn't know that! I'd tried `M-x delete-region' (and
Edit -> Clear from the menu bar) and it deleted the whole,
non-rectangular region. Perhaps that's just a bug, since `M-x
kill-region' operates on the rect correctly.

> This said, I do think the way yanking rectangles works currently is not
> fully satisfactory, because it's not always clear/intuitive how where
> the rectangle will get inserted.  So maybe we do need a special yank
> command active during `rectangle-mark-mode` which replaces the selected
> rectangle with the yanked one, or something like that.

I agree. Once I tinkered with yanking rectangles a bit, it (mostly)
made sense to me, but instinctively, I wanted to select the rect to
yank into first. That works as you'd expect when the point is at the
beginning of the rect but not when it's at the end. I'm not sure what
I'd want to change though, since it works the same as yanking when you
have a non-rectangular region selected too.

- Jim



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [WIP PATCH] Adding more keybindings to rectangle-mark-mode-map
  2021-05-01 16:02   ` Jim Porter
@ 2021-05-01 17:20     ` Stefan Monnier
  2021-05-01 22:31       ` Jim Porter
  2021-05-01 17:26     ` [WIP PATCH] Adding more keybindings to rectangle-mark-mode-map Ergus
  1 sibling, 1 reply; 18+ messages in thread
From: Stefan Monnier @ 2021-05-01 17:20 UTC (permalink / raw)
  To: Jim Porter; +Cc: emacs-devel

> Perhaps it makes sense to bind `C-k' in `rectangle-mark-mode'? It
> seems to be similar to `C-o' and `C-t' in that there are non-rect
> bindings that already do something different, but they aren't
> particularly relevant in `rectangle-mark-mode'.

I don't have an opinion on that.

>> >   C-x r d         delete-rectangle
>>
>> For `delete-rectangle` we already have `delete-region`, and it operates
>> on the rectangle when `rectangle-mark-mode` is active.
>> It is not bound by default, but DEL (aka `backspace`) does delegate to
>> it by default when the region is active.
>
> Interesting, I didn't know that! I'd tried `M-x delete-region' (and
> Edit -> Clear from the menu bar) and it deleted the whole,
> non-rectangular region. Perhaps that's just a bug, since `M-x
> kill-region' operates on the rect correctly.

Oh, no, you're right: it's not done in `delete-region` (which is
a fairly low-level function and hence not ideal to piggy-back such
high-level UI functionality), but in `backward-delete-char-untabify`.
Whether it kills or deletes (or just does the good old backspace)
depends on `delete-active-region`.

>> This said, I do think the way yanking rectangles works currently is not
>> fully satisfactory, because it's not always clear/intuitive how where
>> the rectangle will get inserted.  So maybe we do need a special yank
>> command active during `rectangle-mark-mode` which replaces the selected
>> rectangle with the yanked one, or something like that.
>
> I agree. Once I tinkered with yanking rectangles a bit, it (mostly)
> made sense to me, but instinctively, I wanted to select the rect to
> yank into first. That works as you'd expect when the point is at the
> beginning of the rect but not when it's at the end. I'm not sure what
> I'd want to change though, since it works the same as yanking when you
> have a non-rectangular region selected too.

There's an argument to be made for making `C-y` replace the region
when active, as well, indeed.


        Stefan




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [WIP PATCH] Adding more keybindings to rectangle-mark-mode-map
  2021-05-01 16:02   ` Jim Porter
  2021-05-01 17:20     ` Stefan Monnier
@ 2021-05-01 17:26     ` Ergus
  1 sibling, 0 replies; 18+ messages in thread
From: Ergus @ 2021-05-01 17:26 UTC (permalink / raw)
  To: Jim Porter; +Cc: Stefan Monnier, emacs-devel

On Sat, May 01, 2021 at 09:02:51AM -0700, Jim Porter wrote:
>> This said, I do think the way yanking rectangles works currently is not
>> fully satisfactory, because it's not always clear/intuitive how where
>> the rectangle will get inserted.  So maybe we do need a special yank
>> command active during `rectangle-mark-mode` which replaces the selected
>> rectangle with the yanked one, or something like that.
>
>I agree. Once I tinkered with yanking rectangles a bit, it (mostly)
>made sense to me, but instinctively, I wanted to select the rect to
>yank into first. That works as you'd expect when the point is at the
>beginning of the rect but not when it's at the end. I'm not sure what
>I'd want to change though, since it works the same as yanking when you
>have a non-rectangular region selected too.
>
Yes please. The rectangular selection copy and yanking es very confusing
now. And it forces me to use the multi-cursor package too often and
recommend it to my students. In spite of it is unstable and have breaks
with undo and is incompatible with some commands.

So a good improvement in the rectangular selection could partially
replace some of the use cases we actually have for multi-cursor.

>- Jim
>



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [WIP PATCH] Adding more keybindings to rectangle-mark-mode-map
  2021-05-01 17:20     ` Stefan Monnier
@ 2021-05-01 22:31       ` Jim Porter
  2021-05-02  6:57         ` Eli Zaretskii
  0 siblings, 1 reply; 18+ messages in thread
From: Jim Porter @ 2021-05-01 22:31 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

On Sat, May 1, 2021 at 10:20 AM Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>
> > Perhaps it makes sense to bind `C-k' in `rectangle-mark-mode'? It
> > seems to be similar to `C-o' and `C-t' in that there are non-rect
> > bindings that already do something different, but they aren't
> > particularly relevant in `rectangle-mark-mode'.
>
> I don't have an opinion on that.

I don't think I have a strong opinion either. I think my confusion
came about as someone who's migrated from using the rect commands in
`C-x r` to using `rectangle-mark-mode'. Someone who isn't already
familiar with the `C-x r' rect commands probably wouldn't expect `C-k'
to kill the current rect. I wouldn't mind writing a patch for this,
but if I'm the only one who got confused this way, a patch might not
be worthwhile.

> >> For `delete-rectangle` we already have `delete-region`
[snip]
> > Interesting, I didn't know that! I'd tried `M-x delete-region' (and
> > Edit -> Clear from the menu bar) and it deleted the whole,
> > non-rectangular region.
[snip]
> Oh, no, you're right: it's not done in `delete-region` (which is
> a fairly low-level function and hence not ideal to piggy-back such
> high-level UI functionality), but in `backward-delete-char-untabify`.
> Whether it kills or deletes (or just does the good old backspace)
> depends on `delete-active-region`.

Perhaps Edit -> Clear should be bound to `backward-delete-char-untabify'?

> There's an argument to be made for making `C-y` replace the region
> when active, as well, indeed.

That's certainly what I'd expect in general, though I hesitated to
suggest it as others may prefer the current behavior, and I'm not
totally confident I'd be able to write a patch that handles all the
corner cases correctly given how widely-used `C-y' is.

- Jim



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [WIP PATCH] Adding more keybindings to rectangle-mark-mode-map
  2021-05-01 22:31       ` Jim Porter
@ 2021-05-02  6:57         ` Eli Zaretskii
  2021-05-02 15:48           ` Jim Porter
  0 siblings, 1 reply; 18+ messages in thread
From: Eli Zaretskii @ 2021-05-02  6:57 UTC (permalink / raw)
  To: Jim Porter; +Cc: monnier, emacs-devel

> From: Jim Porter <jporterbugs@gmail.com>
> Date: Sat, 1 May 2021 15:31:08 -0700
> Cc: emacs-devel@gnu.org
> 
> Perhaps Edit -> Clear should be bound to `backward-delete-char-untabify'?

??? The latter deletes a single character, whereas delete-region
deletes many characters.  How can we replace delete-region by
backward-delete-char-untabify?



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [WIP PATCH] Adding more keybindings to rectangle-mark-mode-map
  2021-05-02  6:57         ` Eli Zaretskii
@ 2021-05-02 15:48           ` Jim Porter
  2021-05-02 16:09             ` Eli Zaretskii
  0 siblings, 1 reply; 18+ messages in thread
From: Jim Porter @ 2021-05-02 15:48 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Stefan Monnier, emacs-devel

On Sat, May 1, 2021 at 11:58 PM Eli Zaretskii <eliz@gnu.org> wrote:
> > From: Jim Porter <jporterbugs@gmail.com>
> > Perhaps Edit -> Clear should be bound to `backward-delete-char-untabify'?
>
> ??? The latter deletes a single character, whereas delete-region
> deletes many characters.  How can we replace delete-region by
> backward-delete-char-untabify?

Based on what Stefan said (see below), if the region (regular or
rectangular) is active, `backward-delete-char-untabify' deletes the
*region* instead of a single character. 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'. Maybe that's not so simple, and
there's a variable I'm not aware of that can alter its behavior to not
delete the region (or some other problem). In any case, mapping Edit
-> Clear to a command that knows how to delete a rectangular region
might be helpful.

On Sat, May 1, 2021 at 10:20 AM Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> Oh, no, you're right: it's not done in `delete-region` (which is
> a fairly low-level function and hence not ideal to piggy-back such
> high-level UI functionality), but in `backward-delete-char-untabify`.
> Whether it kills or deletes (or just does the good old backspace)
> depends on `delete-active-region`.

- Jim



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [WIP PATCH] Adding more keybindings to rectangle-mark-mode-map
  2021-05-02 15:48           ` Jim Porter
@ 2021-05-02 16:09             ` Eli Zaretskii
  2021-05-02 16:36               ` Jim Porter
  0 siblings, 1 reply; 18+ messages in thread
From: Eli Zaretskii @ 2021-05-02 16:09 UTC (permalink / raw)
  To: Jim Porter; +Cc: monnier, emacs-devel

> From: Jim Porter <jporterbugs@gmail.com>
> Date: Sun, 2 May 2021 08:48:21 -0700
> Cc: Stefan Monnier <monnier@iro.umontreal.ca>, emacs-devel@gnu.org
> 
> On Sat, May 1, 2021 at 11:58 PM Eli Zaretskii <eliz@gnu.org> wrote:
> > > From: Jim Porter <jporterbugs@gmail.com>
> > > Perhaps Edit -> Clear should be bound to `backward-delete-char-untabify'?
> >
> > ??? The latter deletes a single character, whereas delete-region
> > deletes many characters.  How can we replace delete-region by
> > backward-delete-char-untabify?
> 
> Based on what Stefan said (see below), if the region (regular or
> rectangular) is active, `backward-delete-char-untabify' deletes the
> *region* instead of a single character.

Yes.

> 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.



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [WIP PATCH] Adding more keybindings to rectangle-mark-mode-map
  2021-05-02 16:09             ` Eli Zaretskii
@ 2021-05-02 16:36               ` Jim Porter
  2021-05-02 18:07                 ` Stefan Monnier
  0 siblings, 1 reply; 18+ messages in thread
From: Jim Porter @ 2021-05-02 16:36 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Stefan Monnier, emacs-devel

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, or even just leaving
it the way it is now. I don't have a strong opinion though, since I
don't use the menu-bar. I just happened to notice it while looking
into why `delete-region' didn't do what I thought it would when a rect
is selected.

- Jim



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [WIP PATCH] Adding more keybindings to rectangle-mark-mode-map
  2021-05-02 16:36               ` Jim Porter
@ 2021-05-02 18:07                 ` Stefan Monnier
  2021-05-03  4:06                   ` Jim Porter
  0 siblings, 1 reply; 18+ messages in thread
From: Stefan Monnier @ 2021-05-02 18:07 UTC (permalink / raw)
  To: Jim Porter; +Cc: Eli Zaretskii, emacs-devel

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.


        Stefan




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [WIP PATCH] Adding more keybindings to rectangle-mark-mode-map
  2021-05-02 18:07                 ` Stefan Monnier
@ 2021-05-03  4:06                   ` Jim Porter
  2021-05-03  7:55                     ` Andreas Schwab
  0 siblings, 1 reply; 18+ messages in thread
From: Jim Porter @ 2021-05-03  4:06 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Eli Zaretskii, emacs-devel

[-- 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 ++
 lisp/menu-bar.el | 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'.
diff --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


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [WIP PATCH] Adding more keybindings to rectangle-mark-mode-map
  2021-05-03  4:06                   ` Jim Porter
@ 2021-05-03  7:55                     ` Andreas Schwab
  2021-05-03 15:26                       ` Jim Porter
  0 siblings, 1 reply; 18+ messages in thread
From: Andreas Schwab @ 2021-05-03  7:55 UTC (permalink / raw)
  To: Jim Porter; +Cc: Eli Zaretskii, Stefan Monnier, emacs-devel

On Mai 02 2021, Jim Porter wrote:

> 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")

This will make KILLP always non-nil when called interactively.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [WIP PATCH] Adding more keybindings to rectangle-mark-mode-map
  2021-05-03  7:55                     ` Andreas Schwab
@ 2021-05-03 15:26                       ` Jim Porter
  2021-05-08  1:52                         ` Stefan Monnier
  2021-05-08  6:55                         ` Andreas Schwab
  0 siblings, 2 replies; 18+ messages in thread
From: Jim Porter @ 2021-05-03 15:26 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Eli Zaretskii, Stefan Monnier, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 253 bytes --]

On Mon, May 3, 2021 at 12:55 AM Andreas Schwab <schwab@linux-m68k.org> wrote:
>
> On Mai 02 2021, Jim Porter wrote:
> > +  (interactive "p")
>
> This will make KILLP always non-nil when called interactively.

Whoops! Fixed in the attached patch.

- Jim

[-- Attachment #2: 0001-Ensure-menu-bar-edit-clear-handles-rectangular-regio.patch --]
[-- Type: application/octet-stream, Size: 1550 bytes --]

From 38d3c0000f236adc299ff8c2a0bb6be120a03ab2 Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Mon, 3 May 2021 08:24:01 -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 ++
 lisp/menu-bar.el | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/delsel.el b/lisp/delsel.el
index 982320340d..96a9dcc0c7 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'.
diff --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


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [WIP PATCH] Adding more keybindings to rectangle-mark-mode-map
  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
  1 sibling, 1 reply; 18+ messages in thread
From: Stefan Monnier @ 2021-05-08  1:52 UTC (permalink / raw)
  To: Jim Porter; +Cc: Andreas Schwab, Eli Zaretskii, emacs-devel

Jim Porter [2021-05-03 08:26:11] wrote:
> On Mon, May 3, 2021 at 12:55 AM Andreas Schwab <schwab@linux-m68k.org> wrote:
>>
>> On Mai 02 2021, Jim Porter wrote:
>> > +  (interactive "p")
>>
>> This will make KILLP always non-nil when called interactively.
>
> Whoops! Fixed in the attached patch.

Thanks, pushed.
[ Sorry for the delay.  ]

BTW, according to what I see you haven't signed any copyright paperwork
for Emacs.  This change was small enough that it was acceptable as is,
but in order not to face problems in the future it would be good for you
to get the paperwork out of the way.

If that's OK with you, then please fill the form below and email it as
instructed to the FSF so they can send you the relevant paperwork
to sign.
Thanks again for your contribution,


        Stefan


Please email the following information to assign@gnu.org, and we
will send you the assignment form for your past and future changes.

Please use your full legal name (in ASCII characters) as the subject
line of the message.
----------------------------------------------------------------------
REQUEST: SEND FORM FOR PAST AND FUTURE CHANGES

[What is the name of the program or package you're contributing to?]
Emacs

[Did you copy any files or text written by someone else in these changes?
Even if that material is free software, we need to know about it.]


[Do you have an employer who might have a basis to claim to own
your changes?  Do you attend a school which might make such a claim?]


[For the copyright registration, what country are you a citizen of?]


[What year were you born?]


[Please write your email address here.]


[Please write your postal address here.]





[Which files have you changed so far, and which new files have you written
so far?]




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [WIP PATCH] Adding more keybindings to rectangle-mark-mode-map
  2021-05-03 15:26                       ` Jim Porter
  2021-05-08  1:52                         ` Stefan Monnier
@ 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
  1 sibling, 1 reply; 18+ messages in thread
From: Andreas Schwab @ 2021-05-08  6:55 UTC (permalink / raw)
  To: Jim Porter; +Cc: Eli Zaretskii, Stefan Monnier, emacs-devel

On Mai 03 2021, Jim Porter wrote:

> diff --git a/lisp/delsel.el b/lisp/delsel.el
> index 982320340d..96a9dcc0c7 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")

Please describe the effect of the prefix in the doc string.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [WIP PATCH] Adding more keybindings to rectangle-mark-mode-map
  2021-05-08  1:52                         ` Stefan Monnier
@ 2021-05-08  7:15                           ` Eli Zaretskii
  0 siblings, 0 replies; 18+ messages in thread
From: Eli Zaretskii @ 2021-05-08  7:15 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: jporterbugs, schwab, emacs-devel

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: Andreas Schwab <schwab@linux-m68k.org>,  Eli Zaretskii <eliz@gnu.org>,
>   emacs-devel@gnu.org
> Date: Fri, 07 May 2021 21:52:06 -0400
> 
> BTW, according to what I see you haven't signed any copyright paperwork
> for Emacs.

Actually, Jim does have an assignment on file.



^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH] Improve docstring for delete-active-region (was Re: [WIP PATCH] Adding more keybindings to rectangle-mark-mode-map)
  2021-05-08  6:55                         ` Andreas Schwab
@ 2021-05-08 18:57                           ` Jim Porter
  0 siblings, 0 replies; 18+ messages in thread
From: Jim Porter @ 2021-05-08 18:57 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Eli Zaretskii, Stefan Monnier, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 395 bytes --]

On Fri, May 7, 2021 at 11:55 PM Andreas Schwab <schwab@linux-m68k.org> wrote:
> Please describe the effect of the prefix in the doc string.

Good point. How does this look?

I've also attached a tiny patch to improve the docstring for the next
function in the file, `delete-selection-repeat-replace-region'. It was
using a literal "C-u", so I modified it to use
"\\[universal-argument]".

- Jim

[-- Attachment #2: 0002-Improve-docstring-for-delete-selection-repeat-replac.patch --]
[-- Type: application/octet-stream, Size: 1153 bytes --]

From 359166d632a113145ee71c4e18f03893f181aa76 Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Sat, 8 May 2021 11:53:27 -0700
Subject: [PATCH 2/2] Improve docstring for
 delete-selection-repeat-replace-region

* lisp/delsel.el (delete-selection-repeat-replace-region):
Use "\\[universal-argument]" instead of literal "C-u" in docstring.
---
 lisp/delsel.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/delsel.el b/lisp/delsel.el
index 75cc2b1c2e..3c99dd2344 100644
--- a/lisp/delsel.el
+++ b/lisp/delsel.el
@@ -108,7 +108,7 @@ delete-selection-repeat-replace-region
   "Repeat replacing text of highlighted region with typed text.
 Search for the next stretch of text identical to the region last replaced
 by typing text over it and replaces it with the same stretch of text.
-With ARG, repeat that many times.  `C-u' means until end of buffer."
+With ARG, repeat that many times.  `\\[universal-argument]' means until end of buffer."
   (interactive "P")
   (let ((old-text (and delete-selection-save-to-register
                        (get-register delete-selection-save-to-register)))
-- 
2.25.1


[-- Attachment #3: 0001-Improve-docstring-for-delete-active-region.patch --]
[-- Type: application/octet-stream, Size: 877 bytes --]

From ab1fc7b3e45a0645b313a7ab285bb926e7279012 Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Sat, 8 May 2021 11:53:16 -0700
Subject: [PATCH 1/2] Improve docstring for delete-active-region

* lisp/delsel.el (delete-active-region): Document interactive behavior.
---
 lisp/delsel.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/delsel.el b/lisp/delsel.el
index 96a9dcc0c7..75cc2b1c2e 100644
--- a/lisp/delsel.el
+++ b/lisp/delsel.el
@@ -87,7 +87,8 @@ delsel--replace-text-or-position
 ;;;###autoload
 (defun delete-active-region (&optional killp)
   "Delete the active region.
-If KILLP in not-nil, the active region is killed instead of deleted."
+If KILLP is non-nil, or if called interactively with a prefix argument,
+the active region is killed instead of deleted."
   (interactive "P")
   (cond
    (killp
-- 
2.25.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2021-05-08 18:57 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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-05-01 17:26     ` [WIP PATCH] Adding more keybindings to rectangle-mark-mode-map Ergus

unofficial mirror of emacs-devel@gnu.org 

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/emacs-devel/0 emacs-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 emacs-devel emacs-devel/ https://yhetil.org/emacs-devel \
		emacs-devel@gnu.org
	public-inbox-index emacs-devel

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.emacs.devel
	nntp://news.gmane.io/gmane.emacs.devel


code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs.git

AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git