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: Jim Porter
Subject: Re: [WIP PATCH] Adding more keybindings to rectangle-mark-mode-map
Date: Sat, 1 May 2021 09:02:51 -0700

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



reply via email to

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