![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Only 37% of key strokes involve data entry (text), while the rest 63% are commands.
Emacs's Command Frequency
An Ergonomic Keyboard Shortcut Layout For Emacs
Emacs's Keybinding Layout
Emacs Lisp Function Frequency
An Ergonomic Keybinding Design For Emacs
Xah Lee, 2007-07 Emacs's default keybindings are very ergonomically painful, for several reasons. (For detail, see: Why Emacs's Keyboard Shortcuts Are Painful.) For a visual layout of emacs's default keybindings, see: Emacs's (default) Keybinding Layout. This page shows a redesign of emacs's shortcut set, based on ergonomic principles. Here's the outline of how this design is arrived: All the commands that has a default shortcut of M- and C- are listed. This command set is then ordered by their frequency of use. Then, commands with higher frequency of use are mapped to the most easy-to- press keys. Specifically: Meta combinations is easier than Control, home keys are easier than non-home keys, and keys pressed by the index and middle fingers are better than keys pressed by the ring finger and little finger. (this design principle is similar to the design priciple of Dvorak keyboard layout↗. Secondarily, similar commands are placed together. For example, forward-char, backward-char, previous-line, next-line (these are the arrow key commands) are all mapped to the right hand's home position in a inverted T layout. Copy/cut/paste are all ajacent to each other. By placing similar commands together, the keyboard shortcuts are made easier to remember. If we strictly go by command frequency with ease- of-key-press, then similar commands will be scattered all over. By placing similar commands together, the logical positioning makes it more coherent and easier to use, with no decrease in speed of execution. (because keyboard shortcuts are not like typing. Each shortcut is called only every few minutes) Of Emacs's shortcut set, the most frequently used commands can be grouped into 3 categories: (1) Those move the cursor. (2) those manipulate text. (3) Other. Cursor moving commands include moving the cursor to beginning/ending of char/word/line/sentence/paragraph/ screenful/file. Text editing commands includes copy/cut/paste, paste previous (yank-pop), kill-line, and some others such as fill- paragraph, just-one-space, comment-dwim. Also, commands such as mark- paragraph, are considered in this group. The third group, are commands such as execute-extended-command (M-x), keyboard-quit (C-g), and few others. (For a statistics of command frequency, see Emacs Commands Frequency.) In the Dvorak layout design, all vows are placed on the left hand's home row, and the most frequently used consonants are placed on the right hand's home row. The idea is that hands will alternate. We borrow this idea, by placing all cursor movement commands under the right hand, and all text editing commands (such as copy/cut/paste/kill- line) under the left hand. Ergonomic Emacs Keybinding Layout The following shows a layout of the redesign. In this design, only the M-«key» shortcuts are redefined. (and with some Meta-shift definition as well). Shortcuts involving Control key, or any other key sequence, are untouched. This is so to avoid radical change that will require a lot coding efforts on every major/minor mode's keymaps. Emacs's default shortcut does not put much weight on commands using the Meta-«key» space. By using the single-key shortcut space of M-«key», the operation and consistency of emacs's shortcuts are practically uneffected, while 95% of command calls now have home- row keystrokes with the thumb down. This design, since it is based on finger positions and not on command name's first letters, it is the same on QWERTY and Dvorak keyboard layout. This colored commands means holding down the Meta/Alt key. This colored commands means holding down both Meta and Shift. A blank key means it is unaltered from emacs's default command keybinding for that key. For clarity, some command names are replaced with glyphs. Here's what they mean: LEGENDS ← ackward-char → orward-char ↑ previous-line ↓ next-line ←w backward-word →w forward-word ←s backward-sentence →s forward-sentence ↑¶ backward-paragraph ↓¶ forward-paragraph |← move-beginning-of-line →| move-end-of-line ▲ scroll-down (page up) ▼ scroll-up (page down) ◀ beginning-of-buffer ▶ end-of-buffer ⌦ delete-char ⌫ delete-backward-char ⌦w kill-word ⌫w backward-kill-word ⌦l kill-line ⌦s kill-sentence copy kill-ring-save ✂ kill-region (cut) paste yank paste yank-pop previous M-x execute-extended-command Shown with QWERTY [QWERTY keyboard layout in HTML table] [Dvorak keyboard layout in HTML table] Emacs Lisp Code for Rebinding Here's the emacs lisp file for the above ergonomic keybinding design. ergonomic_keybinding_dvorak.el and ergonomic_keybinding_qwerty.el. Please send your comments or suggestions. Displaced Commands The following table shows commands that are displaced by this rebinding. Those with a asterisk * means they no longer have a shortcut. You will need to bind them if you need them: Displaced Commands QWERTY Dvorak [HTML table] Un-remapped Frequently Used Commands One of the top most used command is isearch-forward and isearch-repeat- forward. Together, they are called 1.14% with respect to all commands calls. “isearch-forward” should have a keyboard shortcut probably as M- s in this design. However, to redefine keymaps for isearch-forward involves non-trivial elisp coding by redefining its keymap. This is currently not done. There are several other commands that are frequently used and could be incorporated into this shortcut design. To be conservative, they are currently left out from this keybinding remap. These are listed below, with parenthesis showing their default shortcuts: Common commands in modern applications that emacs do not have equivalent or have difficult to press shortcuts: save-buffer (C-x C- s), write-file (save as; C-x C-w), «kill-buffer-quitely» (close tab/ window; C-x k), «next-user-buffer» (next tab/window), «previous-user- buffer», mark-whole-buffer (select all; C-x h). Frequently used emacs commands that could use easier M- shortcuts: keyboard-quit (cancel; C-g), dired (C-x d), list-buffers (C-x C-b; or ibuffer), quoted-insert (C-q). Frequently used emacs commands that does text transformations. Some of these's default shortcut keybindings are taken by ergonomic redesign (on Dvorak or QWERTY): mark-paragraph (M-h), downcase-word (M-l), upcase-word (M-u), abbrev-prefix-mark (M-'), dabbrev-expand (M-/), fill-paragraph (M-q), «remove-hard-wrap-paragraph», just-one-space (M- SPC), delete-blank-lines (C-x C-o), comment-dwim (M-;). Those in «angle brackets» indicate custom functions common to most modern text editors but does not exist in emacs. Here are some explanation of them: • kill-buffer-quitely should be like kill-buffer. It will kill the current buffer without prompting if the buffer is not unsaved. This is similar to close window (Alt+F4, Cmd-w) or close current tab in modern applications. • next-user-buffer (and previous-user-buffer) switchs to the next buffer among user's files. (i.e. skipping emacs internal buffers or those not having to do with normal files. e.g. *scratch*, *Messages*, *shell*.) This is similar to next tab or next window in modern applications. • remove-hard-wrap-paragraph does the reverse of fill-paragraph. Namely, remove the line endings of the paragraph the current cursor is on. For lisp code that does the above 3 functions, see modern_operations.el. ---- Xah xah@xahlee.org ∑ http://xahlee.org/
A surprise finding: Better Shortcut Layout vs Better Key Layout
On the subject of keyboarding ergonomics, a user may wonder whether switching from QWERTY to Dvorak provides a better improvement than switching from a lousy to better keyboard shortcut layout. (Assuming that he does only one of the above.) Of my Emacs Commands Frequency study, 37% of key strokes involves data entry (that is, calling the commands “self-insert-command” and “newline” (pressing return), while the rest 63% are calling all other commands. This seems counter-intuitive, because one might think typing should probably be the bulk of activity and moving cursor and deleting text or other commands are only done few times per minute. If we include commands invoked by the Backspace key as data entry, then 40% are data entry, while 60% are editing commands. Still surprising. Going one step further, if we consider the next group of most used commands of moving the cursors by the smallest unit (i.e. previous-line (C-p), next-line (C-n), backward-char (C-b), forward- char (C-f) (also invoked by the physical arrow keys)) as part of data entry, then, 64% are data entry and 36% are other command calls. This data seems to indicate, that a better shortcut layout is as important as a better key layout, at least for computer programing related editing tasks done in emacs. In anycase, if you are not using a Dvorak layout already, you probably should consider switching to it. Better Shortcut Layout vs Better Key Layout On the subject of keyboarding ergonomics, a user may wonder whether switching from QWERTY to Dvorak provides a better improvement than switching from a better keyboard shortcut layout. (Assuming that he does only one of the above.) Of my Emacs Commands Frequency study, 37% of key strokes involves data entry (that is, calling the commands “self-insert-command” and “newline” (pressing return), while the rest 63% are calling all other commands. This seems counter-intuitive, because one might think typing should probably be the bulk of activity and moving cursor and deleting text or other commands are only done few times per minute. If we include commands invoked by the Backspace key as data entry, then 40% are data entry, while 60% are editing commands. Still surprising. Going one step further, if we consider the next group of most used commands of moving the cursors by the smallest unit (i.e. previous-line (C-p), next-line (C-n), backward-char (C-b), forward- char (C-f) (also invoked by the physical arrow keys)) as part of data entry, then, 64% are data entry and 36% are other command calls. This data seems to indicate, that a better shortcut layout is as important as a better key layout, at least for computer programing related editing tasks done in emacs. In anycase, if you are not using a Dvorak layout already, you probably should consider switching to it. http://xahlee.org/emacs/ergonomic_emacs_keybinding.html Xah xah@xahlee.org ∑ http://xahlee.org/
news:comp.emacs, Xah Lee, Jul..Sep 2007
Очень удивлюсь, если кому-то ещё это интересно.