xahlee / xah-fly-keys

the most efficient keybinding for emacs
http://xahlee.info/emacs/misc/xah-fly-keys.html
484 stars 83 forks source link

With ARG, repeat the specified count #68

Open DanLanglois opened 5 years ago

DanLanglois commented 5 years ago

I'm looking at what the command mode does -- at its layout. '3' is 'unsplit win', '4' is 'split --', and so forth.

This means I don't get the numbers at all, in command mode. However, I wonder about this sort of use case: Suppose you press dd to delete a line (pretend it's vim, hypothetically). Next, you might move the cursor, then press 5. (5 then dot). That will delete 5 lines. Or, it might be that you want to Move to next paragraph (or to previous paragraph), or Move to next sentence (to previous sentence), or Repeat the last find (or in the opposite direction), or it's just that you are Searching regexp from input (or else the last used regexp) in the current buffer (or backward). Just in general, are you committed to never needing the numbers, in command mode?

Now, there are going to be use cases that you don't care about supporting. Either you care or you don't, either way is fine, if you have made a decision. But I note that back when dinosaurs roamed the earth, we had the 83-key keyboard, no independent arrow, home, end, page up or page down keys. And I bring this up, because of course, those functions are shared with the numeric keypad. Some people have muscle memory for the square-layout cursor movement keypad. How can you use a numeric keypad that way? Turn NUM LOCK off.

In this modern era, you youngsters have the whizzy new 104 key keyboard. The interesting action keys from the numeric keypad are conveniently replicated directly to the left of it. So yeah, Num Lock seems pointless. All modern system BIOS will set Num Lock on by default. But I am willing to pause, and 'realize' the ability that the numerical keyboard offers (within Microsoft Word in particular, for example) to move the cursor about, select text by words or by lines/paragraphs, and return to previous locations, etc. I digress, but the standard Western keyboard format distances the right column of standard keys from the numerical keyboard by inserting a bunch of relatively useless keys. It isn't actually my point at the moment, but by the way, PgUp and PgDown. These keys are EXTREMELY useful for programming. Home and End. Just as above, these keys are VERY useful (I use a lot of my loved Home and End keys). However, why these keys are useful is one thing, and maybe I don't use the keypad, but another thing is numerical keys in the top row.

So okay, note that with Numlock off, Emacs can see the difference between the keypad keys and the other keys which do the same things. If we were contemplating being able to use the keypad keys without any modifiers to invoke some of my commands, then I get it. I still have the normal function on the other set of keys. However, I'm not sure about the case of, figuratively speaking having 'numlock off', permanently. When I need to enter digits I use .. the top row? Or what, nothing? I just have to go into insert mode? That seems a big decision to be making about your command mode. I can get by with no keypad at all, but can I get by without numbers at all? There are certainly plenty of occasions when I enter numbers.

Virtual numeric keypad for command mode, not optional. To that you may reply that you've managed to get by without it for years. And as for me, heck, I can add any key to any position and delete any key. Rest assured that the second thing I might be doing, is mapping mouse events. But first, is the point about numbers in command mode..

DanLanglois commented 5 years ago

Normally, in emacs, many simple commands, such as those invoked with a single key or with M-x command-name , can be repeated by invoking them with a numeric argument that serves as a repeat count. But I guess you don't miss that feature, see above, my query about having no actual numbers in command mode.

But also, let's slow down, I've mentioned the idea here, of 'repeat'. I had been considering it as an (&optional arg) kind of thing, but while I am pining for that, I wonder where actually is the 'repeat', in the first place? The repeat command, my useful little helper. Aka .. what?

Well, I have found SPC K K. And here, this command repeats the previous Emacs command, whatever that was. Fine, this is the same as C-x z, which still works too (although I think you can also do C-x z z to repeat twice, or C-x z z z, to repeat three times). But I still wonder how would you type the equivalent of C-u 20 C-d to delete 20 characters? I first tried C-u 20 d, and found that this inserts 20 'd''s..

.

DanLanglois commented 5 years ago

A followup:

Six days later I find that I'm still meditating about this one.
("1" . xah-extend-selection) ("2" . xah-select-line) ("3" . delete-other-windows) ("4" . split-window-below) ("5" . delete-char) ("6" . xah-select-block) ("7" . xah-select-line) ("8" . xah-extend-selection) ("9" . xah-select-text-in-quote) ("0" . xah-pop-local-mark-ring)

Command mode is shadowing all of the number keys. I hadn't much faith in this idea, thinking that number keys have their uses as number keys, even in command mode. For example:

 ("c" . previous-line)
 ("n" . forward-char)
 ("h" . backward-char)
 ("t" . next-line)

I can live with 'forward-char' and 'backward-char', but when it comes to 'previous-line' and 'next-line', I pine for a 'count' argument. What if I want to move upward, COUNT times. Perhaps to a line with the same level of indentation or less. And actually, I say that I can live with 'forward-char' and 'backward-char', but I am thinking also of:

 ("r" . forward-word)
 ("g" . backward-word)   

I pine for a 'count' argument here too.

Without cross-referencing what there is currently, I also think about select-line, or about select-word, select-paragraph, select-sentence, select-symbol, select-list, select-sexp, select-whitespace. Point here being, these are areas where I might pine for a 'count' argument. Thus there is this:

 ("7" . xah-select-line)

But what if I want to select seven lines? While we are at it, interesting question what key to use for 'select-line'. I figure that "SPC" has its charms for this. Note what is in command mode currently:

 ("SPC" . xah-fly-leader-key-map)

I would say space bar is a good leader key. spacemacs uses this kind of framework. Basically space Key is the leader key or the Key to invoke the menu. However, the question remains -- what key to use for 'select-line'? I do recall in vim, v, V, or ^V (character, line or block selection). I do wonder if I should give up so easily on having "SPC" be 'select region'. What I am driving at is not shadowing the number keys. There is also this:

 ("5" . delete-char)

I love to complain, perhaps, but let me see, what about a mnemonic solution, use 'd'. But it seems like the thing to do is to expect an argument. Default to 'delete all selected lines', but maybe do a 'd' and a backward-char, to delete the character before the cursor, etc. For this it seems useful that, as I have been reading, normally, whenever a function is executed, Emacs sets the value of 'last-command' to the previous value of 'this-command'.

I seem to have eliminated the need for this:

 ("e" . xah-delete-backward-char-or-bracket-text)

Also this:

 ("i" . xah-delete-current-text-block)

And in this frame of mind, I glance again at this:

 ("6" . xah-select-block)
 ("7" . xah-select-line)
 ("8" . xah-extend-selection)
 ("9" . xah-select-text-in-quote)

Of course I want my numbers, but also, this seems rudimentary. What about revisiting the issue of text region specifiers. Can any move also serve as a valid region selector?