oantolin / embark

Emacs Mini-Buffer Actions Rooted in Keymaps
GNU General Public License v3.0
938 stars 56 forks source link

Comments on Embark Key Bindings #168

Open hmelman opened 3 years ago

hmelman commented 3 years ago

From comments in Consult Issue #210 I took a look at the default embark bindings. Here are some comments, though I don't think any of these are particularly important, they're just things I thought of that might be worth considering.

oantolin commented 3 years ago

calc-grab-region should automatically detect whether the region is a rectangle and if so act as calc-grab-rectangle. 😠

oantolin commented 3 years ago

I think you are right about moving embark-insert to I, to free up i which several other commands seem to want. There are a couple of things giving me pause:

Any thoughts?

hmelman commented 3 years ago

Assuming embark-insert moves to I. embark-save could move for consistency, that could the relative problem (both on lowercase). Or leave save on w and use something else like r or C-i for file's relative version.

hmelman commented 3 years ago

FWIW I submitted emacs bug #50311 to have calc-grab-sum-down and calc-grab-sum-across autoload by emacs.

hmelman commented 3 years ago

That went well, they'll be autoloaded in emacs 28.

oantolin commented 3 years ago

Let's celebrate by binding them in embark-region-map (I guess I need to add the autoloads for now, but will be able to remove them in a few years when I drop support for 27.1.)

Hey, now that you have an in with the maintainers, maybe you could propose that calc-grab-region call calc-grab-rectangle if the region is rectangular.

oantolin commented 3 years ago

Mmh, Should Embark have a separate embark-rectangular-region-map? A few extra actions only make sense for rectangles, right?

oantolin commented 3 years ago

Well, the rectangle commands very reasonably act on the rectangle between mark and point whether or not you are using rectangle-mode. So actually, they could just be added to the region map.

hmelman commented 3 years ago

Yeah, I don't understand what you mean, aren't all regions rectangular? It's just how you interpret what mark and point delimit.

I don't seem to have a rectangle-mode so I don't know what that is.

oantolin commented 3 years ago

Sorry, I got the name of the mode wrong. It is called rectangle-mark-mode and is bound by default to C-x SPC. I'm sure you are familiar with it, it's what makes the region highlight look rectangular and adds a special yank-handler to a rectangular region so that a later C-y automatically behaves as yank-rectangle.

oantolin commented 3 years ago

So, yes all regions can be considered as rectangular, but when the user explicitly turns on rectangular-mark-mode she is signalling that she intends to use the region as a rectangle. Personally the only rectangle commands I use are string-rectangle and rectangle-number-lines, and I only ever using them after using C-x SPC to turn on rectangle-mark-mode (which is unnecessary!).

hmelman commented 3 years ago

Ah. I have heard of rectangle-mark-mode but don't use it (and never remember about it). I use string-rectangle many times a day but didn't know (or completely forgot) about rectangle-number-lines, that definitely looks useful.

FWIW, I've now bound the following which may interest you (the 2nd conflicts with a binding of undo which seems odd to me):

(define-key rectangle-mark-mode-map (kbd "C-:") 'calc-grab-sum-down)
(define-key rectangle-mark-mode-map (kbd "C-_") 'calc-grab-sum-across)
oantolin commented 3 years ago

the 2nd conflicts with a binding of undo which seems odd to me

I know that undo binding very well! I prefer C-/, but had one keyboard where C-/ was very awkward to type (can't remember what layout it had), so one that one keyboard I always used C-_ instead.

For some reason it had never occurred to me to bind things in rectangle-mark-mode-map, what a great idea, thanks! It's like a built-in version of the selected package, but only for rectangles. I think I'll add your bindings (without C-, why use modifiers when they aren't necessary) and rectangle-number-lines there.

I forgot to say earlier that for string-rectangle I never use C-x r t, only C-t in the rectangle-mark-mode-map (so I even knew about the damn keymap but it never occurred to me to bind stuff there!).

hmelman commented 3 years ago

Hmmm, I'm on a mac with apple's command key set as a super key, so I mostly use s-z for undo in emacs, sometimes falling back on C-x u. I never got into C-/ but I guess it's popular.

I thought about not using the C- modifier for the binding but then though I might want to type those characters, though that does seem unlikely.

So instead of C-x r t you use C-x SPC C-t which while a little more involved to type, gives you better highlighting of the region. Not sure it's worth it to me in the string-rectangle case but in using calc-grab-sum-down I definitely wished for the rectangular highlighting.

oantolin commented 3 years ago

So instead of C-x r t you use C-x SPC C-t which while a little more involved to type, gives you better highlighting of the region.

But C-x SPC also sets the mark. So it's really C-x SPC (move around) C-t vs C-SPC (move around) C-x r t, which I think is a close call.

hmelman commented 3 years ago

But C-x SPC also sets the mark. So it's really C-x SPC (move around) C-t vs C-SPC (move around) C-x r t

Ahh, yeah that is kinda nice. We'll see if I can remember that.

hmelman commented 3 years ago

Hey, now that you have an in with the maintainers, maybe you could propose that calc-grab-region call calc-grab-rectangle if the region is rectangular.

So would it just be this:

calc-grab-region should check if rectangle-mark-mode is non-nil and if so it should behave as calc-grab-rectangle otherwise it should work as it does.

oantolin commented 3 years ago

Yes, that's what I had in mind.

hmelman commented 3 years ago

It's now Emacs Bug #50403

hmelman commented 3 years ago

Fixed, will be in Emacs 28 :)

oantolin commented 3 years ago

Good! Thanks for doing that @hmelman.