xahlee / xah-fly-keys

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

Xah Fly Keys a beginner's feedback-- #67

Open DanLanglois opened 5 years ago

DanLanglois commented 5 years ago

Xah Fly Keys a beginner's feedback--

As a beginner, I focused upon learning these keys:

--I,J,K,L movement. --The command to activate command mode.

--delete word/char. Forwards, and backwards. Figure that a 'left/right' pair can be used in both cases, and maybe one for 'word' above one for 'char', and use the left hand for this. It's what I expected, is this what we find? Yes, for 'e' and 'r' as deleting a word, forwards and backwards. And then, 'd' is 'delete-char-backwords', and this makes sense.

Things get more confusing for 'delete-char-forwards'. It's the '5'. This is where I expected the 'f'. But we've already met the 'f', because it's a way to get into 'insert' mode. I guess that 'delete-char-forward' didn't merit being on the home row, of course, but also it is more confusing this way.

What about the cut, copy, paste situation. These are 'x', 'c', 'v'. Next to each other, and left hand, very logical.

What about 'undo'? And also, I'll note 'redo' though of course, vanilla Emacs undo has no associated redo. You might just prefer, as many of us do, what ordinary Emacs undo has to offer, where undoing undoing has a similar effect to redoing. However, some people have trouble with the lack of redo or a way to browse the undo tree. There is no built-in way to do these things (aside from mentally trying to keep track of a long string of changes including undos, which some people find very difficult).

Anyways, 'undo' is 'y'. I can't say I find this 'logical', it seems arbitary. In most Windows applications, the Undo command is activated by pressing the Ctrl+Z or Alt+Backspace keybindings. In all Macintosh applications, the Undo command is activated by pressing Command-Z. Furthermore, I come into this, knowing that for most applications, ctrl +Y redoes, what Ctrl +Z has undone. Z undoes, Y redoes.

I think it seems fairly perverse to have to try to wrap my head around the idea that from now in, in my emacs keybindings, 'y' is going to be 'undo'. I have in my muscle memory, 'ctrl-z' and 'ctrl-y', so that's fine I can use the key chord. While we are at it, I wonder what is next to the 'y'. With 'y' as undo, it is sitting to the right of 'mark', and to the left of 'go left one word', which we've met. So this still seems arbitary to me.

And 'mark' means the emacs set-mark-command. The text between point and the mark is called the region. And with this, we are on the way towards for one thing, making Emacs behave sanely by using visible regions like other editors. But for me it is confusing that the mark also serves as a handy beacon that you can set with C-SPC and jump to with C-u C-SPC. I am willing to believe, that mastering the mark commands will greatly speed up movement and editing. But first, one has to understand that if you want to set the mark (and nothing else) you have to follow up the preceding command with another C-SPC (or C-g) to abort the active region “selection.” So, your 'set-mark-command', this is setting the mark at point, and activating it. But it is not, so to speak, a 'push-mark-no-activate. Which might actually be more interesting to me. I didn't come up with a very good name, I might call it 'explicitly-set-the-mark. Either way, it pushes 'point' to 'mark-ring', and does not activate the region. But at this point, I realize that I am only superficially familiar with emacs. I had thought, that most people, myself included, use transient-mark-mode. In point of fact, though, this 'explicitly-set-the-mark idea that I'm talking about, is simply equivalent to [set-mark-command], when [transient-mark-mode] is disabled. This brings us back to the idea of a dedicated “jump to mark” command. Or, that is, I had been claiming that the mark also serves as a handy beacon that you can set with C-SPCand jump to withC-u C-SPC. This requires a digression..

'C-u' is bound to command 'universal-argument' (or, C-h c C-u displays "C-u runs the command universal-argument"), the universal argument command. Meanwhile, the prefix argument is a pseudo-argument that is automatically available for each Emacs command.

Note this:

http://ergoemacs.org/emacs/emacs_key_science_C-u_vs_prompt.html

'A systematic use, is that every command will have C-u variation in a consistent way. For example, 【Ctrl+u】 will always do reverse (as in {undo/redo, fill/unfill, encode/decode, …}), and 【Ctrl+u n】will do variations.'

And this:

'Prompting is usually annoying, but this can be solved by not prompting unless 【Ctrl+u】 is pressed first.'

I'm a bit lost here. But I do know that [Ctrl]U 20 [Ctrl]N will 'advance 20 lines'.

Where was I -- I had been claiming that the mark also serves as a handy beacon that you can set with C-SPC and jump to with C-u C-SPC. [Ctrl] SPC is how you set mark at cursor, but C-<SPC> C-<SPC> is how you set the mark, pushing it onto the mark ring, without activating it. And that's sort of how we got to the idea that C-u C-<SPC> is how you move point to where the mark was, and restore the mark from the ring of former marks. The logic here, is that the command C-<SPC> C-<SPC> is actually two consecutive invocations of C-<SPC> (set-mark-command); the first C-<SPC> sets the mark, and the second C-<SPC> deactivates it.

Note: The exchange-point-and-mark command (bound to C-x C-x) jumps to the mark, and puts the current position (i.e. just before the jump) on top of the mark ring. And, a side effect is that the region is activated. You can pass a prefix argument (i.e. press C-u C-x C-x) to avoid this. While, another way to navigate in the mark ring consists in using C-u C-SPC, which jumps to the mark and removes it from the mark ring.

I think I will stop there. For me the point is that I am looking at emacs as a toy, and from that perspective, it's worth some sleepless nights of playing around. I feel virtuous, everybody should know some emacs and lisp. But I think the impression that I am giving, is that there is lots to learn, and I'm juggling archaic jargon and so forth, learning emacs, on top of it learning unorthodox keybindings. I have no real respect for the value of my own time, and am probably diagnosably schizoid. I am actually having some fun here, but is that a good sign?

Note my title -- Xah Fly Keys a beginner's feedback -- and please don't blame the messenger.

P.S. As soberly as I can manage this, I beg indulgence for using 'qwerty' configuration keybindings. I don't think you're likely to be happy about that. I do think the point seems oddly quite relevant, though, for a few reasons. Do we need standards? But the familiarity of those standards becomes a circular argument for them. What if they were boneheaded standards in the first place? Such as, qwerty keyboard standards but also, such as emacs keybinding standards and if you don't like them, then also, vi keybinding standards and you don't like them either. So I come along and complain about your new keybinding standards, that they are not standard.

Well, we might have started by properly evaluating the Fact of the day: the QWERTY keyboard is bad. It does not provide the best way to type.

The first question is whether we all agree that we've known this for a while. Or do some people just love to reinvent the wheel? Is one standard as good as another? Drive on the right side of the road, or on the left side of the road? Speak English, or Speak Korean? Or Arabic? If you can convince yourself that objectively, scientifically, the QWERTY Keyboard is the slow, inefficient sibling to dvorak, then you can proceed to asking the next question: Why Are We Still Using It? Let's slow down, though, and consider that Dvorak's keyboard is used by some, and has been reported to increase typing speed and accuracy as well as decrease long-term typing related strain. Fine. I don't think you're so dogmatic about that issue. We can agree that its adoption rate has been stunted, and most people are entirely unaware of its existence. But on the other hand, stenographers type at 200 wpm, so they are doing way better, rendering this debate about QWERTY keyboard irrelevant. It's hard to learn to type steno, thus the idea is absurd, ridiculous. But compared to what? Things that make me go 'hmmmm....'

DanLanglois commented 5 years ago

What I might do, myself, for devising a 'command' set of keybindings, is organize things at a very high level.

There are three rows of keys. There is left, and right. That makes six areas. There are around 4+ keys in each area. Maybe the top row could be including the higher 'number' keys, thus, a couple of our areas have around 4+ keys.

Can each area have a focus?

There is 'cursor positioning'. left right up down, also left word and right word. That's six. Maybe also >beginning of line, and >end of line. And > start of document and >end of document. And >page up and >page down.

That's twelve items in cursor positioning. But I like the idea of totally nailing the basic movement idea, if nothing else. Really getting it handled. I think that's not even enough cursor positioning commands. There is 'cursor in middle of screen', and 'display the line number where the cursor is located', and 'go to line number x', and 'advance x lines' and such.

It may seem that I have to prioritize, because there are other things besides cursor positioning, and I'm already getting bogged down. What else?

I mentioned about 'regions'.

There is search and replace.

I think I have to give up, on inventing a brilliant new set of keybindings, the panacea for all our problems. I have actually, a real doubt as to why we can't just use the mouse scroll wheel. I'm one of those savages, who has a mouse, and uses it, fumbling with a squirrelly scroll wheel.

I wonder if you are aware of mice that have like 8 programmable buttons. Is this blasphemy. I recall seeing an assertion that the most commonly used mouse actions are clicking a window’s “Close” button (the X in the top-right corner), and clicking the “Back” button (in a browser and various other programs). How much time do you spend every day locating the Close button or the Back button with your mouse so that you can click on them? And what about that mouse you’re using – how many buttons does it have, besides the two main ones? What if it had twelve extra buttons that you could map to anything.

Mouse buttons are a revelation: I feel this needs its own bullet point. I ponder having another twelve buttons I could press without moving taking my hands off the mouse.

You can set custom shortcuts, record macros, launch applications, or paste entire blocks of common text with a simple interface.

I think in particular, of how to paste text blocks. Maybe the objectiojn is that this method does involve taking your hands off their position while typing.

The default way to cut and paste text in Emacs is to use keyboard commands, of course. But say that I want to quickly select a large block of text. Who are we kidding, here? I imply that using the mouse is an option, but let's sit with this and consider an objection -- I need to select a large chunk of text that doesn't all appear on the screen, clicking and dragging with the mouse doesn't work very well. Now what?

Too bad I can't left-click at the beginning of the desired block of text to move the insertion point to that spot. Now, use the scroll bar to scroll down in the text until you reach the end of the desired selection. Hold down the Shift key and click to select it all.

I mean, just for the record, we all do know this works, I take it? I'm thinking of Windows I suppose.. and I don't mean to be unreasonable, but my standard of reasonability here includes contemplating the idea of just always living within emacs..

DanLanglois commented 5 years ago

I present myself as being willing to put some time into emacs and lisp, because everybody should know something about them. And by 'everybody' I mean everybody in graduate school in computer science. So okay, if we like emacs, we probably are big into org mode. I'm no expert, but it's an example of what I'm willing to look into. I think org mode presents a dilemma, for Xah Fly Keys. My impression is that you can't really begin to offer support for Org Mode, besides returning to emacs keybinding defaults.

We have an interesting question here, for spacemacs, which offers some Org Mode support. I mean, Vim inspired key bindings.

I wish them all the best, but I incline to wonder, myself, about following links with the left mouse button, in Org Mode. Or again, what about subtree expansion/collapse (org-cycle) with the left mouse button. I know, there is a TAB button for that. Which is convenient, if you don't have a mouse, I can imagine. No need to explain. But I do have a mouse. Not to be sarcastic, but just, how much patience does it require, to even scroll down to the bottom of the list of Vim inspired key bindings that are provided by evil-org-mode? I mean, for dealing with tables, and with trees, and with element insertion, and links, and don't forget Emphasis, where you 'make region bold', or 'code', etc. And tagging. There is navigating in the calendar -- one day forward, and such. There is Org agenda. Seriously, I'm glancing at the evilified org agenda -- at what keybindings it supports. A few dozen. Such as 'previous item' and 'next item', for example. For the record, it's the same for 'previous item' and 'next item' in Org agenda, as it is in the Org calendar, for 'one week forward' and 'one week backward'. I guess there is something else for 'one day forward' and 'one day backward', and for month, and year. And I'm not actually guessing, either. The one day forward/backward, in Org calendar, is the same keybindings as the 'earlier view'/'later view' in Org Agenda. I don't say this isn't viable, I don't even insist that you'd have to be particularly smart to learn it. But who came up with this, a smart person? I could start by learning how to open org agenda. You type org-agenda. I'm kidding, but that would work. Also, org-capture works, and org-sort works, if that's what you want. If I'm not mistaken, there are functions that are actually called as in this list, though I guess that doesn't prevent us from remapping them, like evil-org-mode has done:

org-shiftright org-shiftleft org-shiftup org-shiftdown org-shiftcontrolright org-shiftcontrolleft org-shiftcontroldown org-shiftcontrolup

And my point, is that what I want is clear: I want several context menus on the right mouse button. Such as:

What about promoting/demoting/moving subtrees with mouse-3?

I am willing to consider that mouse-3 isn't the only way to do it, but I feel like I'm the one being indulgent, here.

DanLanglois commented 5 years ago

I run Xah-fly-keys.

Then, if I hit SPC, the leader key, I see this emacs-which-key popup:

DEL -- xah-fly-insert-mode-activat.. RET -- execute-extended-command SPC -- xah-fly-insert-mode-active.. TAB -- +xah-fly--tab-key-map ' -- xah-show-formfeed-as-line , -- +xa-fly-w-keymap 3 -- delete-window 4 -- split-window-right 5 -- balance-windows 6 -- xah-upcase-sentence 9 -- ispell-word ; -- save-buffer \ -- toggle-input-method a -- mark-whole-buffer b -- xah-toggle-previous-letter-.. c -- xah-copy-all-or-region d -- +xah-fly-e-keymap e -- +xah-fly-dot-keymap

I think in terms, here, of providing great discoverability by popping up a buffer with options when you start typing a command. The “stock” Emacs experience is hidden, most of the time.

For me I haven't gotten past learning the basics: navigation, editing, customisation.

So I stare at this, and I'm thinking about the merits of using a mnemonic key mapping, e.g. keeping VC commands under leader-v and shell commands under leader-s. Having seen spacemacs, I pass along their notion of how to do these layers:

SPC f File SPC p Project SPC t Toggle SPC b Buffer SPC m Major mode SPC g Git SPC l Layout SPC a Apps SPC h Help

Also, SPC p Project SPC f File SPC w Window SPC h Help

Now, I actually put these out of alphabetical order, just to make it more confusing. I did this to emphasize that some kinds of confusion seem just pointless. For example, what if I want to split the window, into two windows, one above the other? Well, there is this idea:

SPC w -

And then, there is this:

SPC w /

Which, will split the window into two windows, side by side.

But then also:

SPC w d

With this, You can kill a window.

But then also:

SPC w m to maximize.

What if I want to see all buffers and switch them?

SPC b b

Perhaps we all use Projectile, an Emacs library for handling projects. Well, how do you add your project for the first time?

SPC a d

How do you switch between projects?

SPC p p

Do a fuzzy file search?

SPC p f

Search for Classes and methods using Tags?

SPC p G

This will generate a TAGS file for 'project'. But also,

SPC p t

This will open a tree explorer.

Another idea that I see in spacemacs, is that each window receives a number in its modeline, so that you can hit SPC and then hit one of those numbers to switch to that window.

But my point here is not to advocate spacemacs as being great, I have looked at spacemacs for all of 45 minutes. I may never look at it again. My point is that I'm a bigger expert on spacemacs than I am on Xah-Fly-Keys, and how much time have I spent on Xah-Fly-Keys? I will never be an expert on either one. The idea that I am touting, discoverability. More specifically, I think maybe we don't want to underestimate the power of mnemonics in this context? I mean, by 'context', when you are literally popping up a context menu..

Not to belabor the point:

SPC t 8 | highlight any character past the 80th column SPC t f | display the fill column (by default the fill column is set to 80) SPC t h h | toggle highlight of the current line SPC t h i | toggle highlight indentation levels SPC t h c | toggle highlight indentation current column SPC t i | toggle indentation guide at point SPC t l | toggle truncate lines SPC t L | toggle visual lines SPC t n | toggle line numbers SPC t v | toggle smooth scrolling SPC t m b | toggle the battery status SPC t m c | toggle the org task clock (available in org layer) SPC t m m | toggle the minor mode lighters SPC t m M | toggle the major mode SPC t m p | toggle the point character position SPC t m t | toggle the mode line itself SPC t m v | toggle the version control info SPC t m V | toggle the new version lighter

Also: SPC T F | toggle frame fullscreen SPC T f | toggle display of the fringe SPC T m | toggle menu bar SPC T M | toggle frame maximize SPC T t | toggle tool bar SPC T T | toggle frame transparency SPC T ~ | display ~ in the fringe on empty lines

So I infer that the capitalized 'T' is for bigger GUI frame-oriented toggles. This brings up another issue: local and global. And actually, the global version of the toggle can be reached using the control key.

Also, I guess that if you can toggle this stuff in the modeline, then it is heavily customized -- toggle flycheck info, toggle battery info, toggle minor mode lighters.

But looking back at my list, I wonder about how to toggle auto-completion. I mean, I'm looking at spacemacs docs for all of this. And yes, there is a way.

SPC t a

Which I might have guessed. What about auto-fill mode?

SPC t F

Of course I already said that, but what if I don't remember? And what about golden-ratio mode?

SPC t g

Guide-key mode?

SPC t k

Indentation guide?

SPC t i

Of course there is also global-indentation guide:

SPC t C-i

Aggressive indent mode?

SPC t I

Smartparens mode?

SPC t p

And guess what is global smartparens:

SPC t C-p

Whitespace mode?

SPC t w

What if I want to describe current character under point?

SPC h d c (help -- describe -- character)

Describe a function, is SPC h d f

Describe a key = SPC h d k

Describe a package = SPC h d p

DanLanglois commented 5 years ago

I notice that your 'isearch' is, under qwerty, the 'n' key. I offer for whatever it is worth, that in vim one uses '/'. I might not bother to mention it, except the keys are kind of close together, right hand, bottom row. Does it have to be different? Plenty of people have some vim muscle memory. That is, perhaps, their problem.

spiderbit commented 5 years ago

For org-mode maybe that helps somebody:

(:map xah-fly-e-keymap
      ("e" . (lambda () (interactive)
           (pcase mode-name
         ("Message" (message-send-and-exit))
         (t (if org-src-mode (org-edit-src-exit)
              (org-edit-special)))))))

That's inside of a use-package function call so you have to slightly edit it for use without use-package. Leader-key + e + e becomes basically my replacement to what is bound in modes to C-c C-c.

yusi1 commented 1 year ago

I think I will stop there. For me the point is that I am looking at emacs as a toy, and from that perspective, it's worth some sleepless nights of playing around. I feel virtuous, everybody should know some emacs and lisp. But I think the impression that I am giving, is that there is lots to learn, and I'm juggling archaic jargon and so forth, learning emacs, on top of it learning unorthodox keybindings. I have no real respect for the value of my own time, and am probably diagnosably schizoid. I am actually having some fun here, but is that a good sign?

lol relatable