Open hmelman opened 3 years ago
calc-grab-region
should automatically detect whether the region is a rectangle and if so act as calc-grab-rectangle
. 😠
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:
Should I then also move embark-save
to w
for consistency? I think probably the answer is no: I think embark-save
is probably much more common an action than embark-insert
so it's OK if it gets a prized lowercase binding while embark-insert
needs a modifier.
In the file map there are actions to insert or save a relative path bound to W
and I
. If embark-insert
moved to I
, would I bind embark-insert-relative-path
to i
? That would leave it flipped with respect to w/W
, which sounds like a bad idea.
Any thoughts?
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.
FWIW I submitted emacs bug #50311 to have calc-grab-sum-down
and calc-grab-sum-across
autoload by emacs.
That went well, they'll be autoloaded in emacs 28.
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.
Mmh, Should Embark have a separate embark-rectangular-region-map? A few extra actions only make sense for rectangles, right?
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.
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.
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
.
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!).
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)
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!).
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.
So instead of
C-x r t
you useC-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.
But
C-x SPC
also sets the mark. So it's reallyC-x SPC (move around) C-t
vsC-SPC (move around) C-x r t
Ahh, yeah that is kinda nice. We'll see if I can remember that.
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.
Yes, that's what I had in mind.
It's now Emacs Bug #50403
Fixed, will be in Emacs 28 :)
Good! Thanks for doing that @hmelman.
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.
delete-file
should stay on "d" as other delete commands are on "d" and it's natural.embark-insert
to "I" so maybe it should just be that in the general map. Then the three other maps that bind commands to "I" can bind them to the more natural "i" and "I" can be more consistent.fill-region
to "f". That's fine, but the other obvious choice is "q" since M-q isfill-paragraph
and I think q is less likely to have a future conflict than f.calc-grab-region
. I'd love it ifcalc-grab-sum-down
andcalc-grab-sum-across
were bound to ":" and "_" but they're not autoloaded and little known. They would be more convenient from embark than their existing bindings on C-x :. But they're probably better in personal configs, maybe it's with a comment in a readme or wiki.embark-browse-package-url
is on "u" but FWIW paradox puts the equivalent on "v" for visit homepage