emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [WIP PATCH] Adding more keybindings to rectangle-mark-mode-map


From: Stefan Monnier
Subject: Re: [WIP PATCH] Adding more keybindings to rectangle-mark-mode-map
Date: Sat, 01 May 2021 09:29:42 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]