Xah Lee, 2007-08
This page lists emacs's commands in the order of their frequency of use.
In emacs, each key press actually invokes a command. (For example, typing “a” actually invokes the command “self-insert-command”. Typing Ctrl+f invokes the command forward-char. Typing Alt+x invokes execute-extended-command. Typing the right arrow key “→” invokes forward-char.)
The motive of this study, is in designing a A Ergonomic Keyboard Shortcut Layout For Emacs. I needed to know which command are actually more frequently used, in order to give it a easier-to-press keybinding.
The following frequency list is based 3 users. Xah Lee (me), Marc Shapiro, “rgb” (rbielaws_@_i1_._net). The total count of all command calls is 203118. The following is a break down of each's data contribution:
Name cmd calls Percentage ------------------------------------------- rgb 93 534 46% Xah 82 090 40% Marc 27 494 13% ------------------------------------------- total 203 118 100%
The total count of self-insert-command calls is 65 496. The following is a break down by that command.
Name number of Percentage
self-insert-
command call
-------------------------------------------
Xah 29 758 45%
Marc 20 026 31%
rgb 15 712 24%
-------------------------------------------
total 65 496 100%
Following is a table showing the proportion of each person's use of data-entry commands and non-data-entry commands. “data-entry” commands are the “self-insert-command” and “newline” commands. (The “newline” is bound to the Enter/Return key.) All other commands are considered “non-data-entry”.
Name Percentage of non-data-entry commands --------------------------- rgb 83% Xah Lee 63% Marc Shapiro 26%
A higher percentage of non-data-entry commands probably means that the person is doing a lot editing, as opposed to writing. (if a person uses emacs for email or IRC chat, she's likely to have high percentage of data-entry commands.)
Commands that are executed by the same key are grouped together. For example, the commands “delete-backward-char”, “backward-delete-char-untabify”, “python-backspace”, “cperl-electric-backspace” are all just the “Backspace” key.
The following is the complete list of commands that are merged.
command names merged into this glyph
---------------------------------------------
next-line ↓
dired-next-line ↓
next-history-element ↓
previous-line ↑
dired-previous-line ↑
previous-history-element ↑
delete-backward-char ⌫
backward-delete-char-untabify ⌫
python-backspace ⌫
cperl-electric-backspace ⌫
scroll-up ▼
cua-scroll-up ▼
scroll-down ▲
cua-scroll-down ▲
isearch-forward isearch-→
isearch-repeat-forward isearch-→
isearch-backward isearch-←
isearch-repeat-backward isearch-←
For clarity, some commands are replaced by a glyph. Here's the complete list:
backward-char ← forward-char → backward-word ←w forward-word →w backward-sentence ←s forward-sentence →s backward-paragraph ↑¶ forward-paragraph ↓¶ move-beginning-of-line |← move-end-of-line →| beginning-of-buffer |◀ end-of-buffer ▶| delete-char ⌦ kill-word ⌦w backward-kill-word ⌫w kill-line ⌦l kill-sentence ⌦s kill-ring-save copy kill-region ✂
Note: Due to a ideosyncracy of emacs lisp, the following commands: kill-word, backward-kill-word, kill-line, kill-sentence, are all counted as just kill-region. In symbols, the following “⌦w”, “⌫w”, “⌦l”, “⌦s”, all are just “✂”. See end of this report for detail.
Total number of command calls: 203118
Percent of non-data-entry command calls: 67%
| Command Name | Count | % total cmd call | % non-data-entry cmd call |
|---|---|---|---|
| self-insert-command | 65496 | 32.25 | 48.00 |
| ↓ | 23960 | 11.80 | 17.56 |
| ↑ | 18917 | 9.31 | 13.87 |
| →w | 11224 | 5.53 | 8.23 |
| ←w | 6782 | 3.34 | 4.97 |
| → | 6650 | 3.27 | 4.87 |
| ⌫ | 6558 | 3.23 | 4.81 |
| ← | 4393 | 2.16 | 3.22 |
| nonincremental-repeat-search-forward | 4141 | 2.04 | 3.04 |
| ✂ | 3839 | 1.89 | 2.81 |
| back-to-indentation-or-beginning | 3273 | 1.61 | 2.40 |
| isearch-printing-char | 2682 | 1.32 | 1.97 |
| end-of-code-or-line | 2479 | 1.22 | 1.82 |
| cua-delete-region | 2309 | 1.14 | 1.69 |
| ▼ | 1896 | 0.93 | 1.39 |
| yank | 1691 | 0.83 | 1.24 |
| ▲ | 1483 | 0.73 | 1.09 |
| indent-relative | 1333 | 0.66 | 0.98 |
| save-buffer | 1302 | 0.64 | 0.95 |
| just-one-space | 1295 | 0.64 | 0.95 |
| newline | 1185 | 0.58 | 0.87 |
| handle-switch-frame | 1117 | 0.55 | 0.82 |
| (lambda nil (interactive) (scroll-up 1)) | 1095 | 0.54 | 0.80 |
| ⌦ | 996 | 0.49 | 0.73 |
| rgb-doublespace-maybe | 972 | 0.48 | 0.71 |
| search-backward | 932 | 0.46 | 0.68 |
| execute-extended-command | 900 | 0.44 | 0.66 |
| universal-argument-other-key | 891 | 0.44 | 0.65 |
| cua-copy-region | 802 | 0.39 | 0.59 |
| mouse-drag-region | 746 | 0.37 | 0.55 |
| kill-buffer-silently | 740 | 0.36 | 0.54 |
| digit-argument | 731 | 0.36 | 0.54 |
| nonincremental-search-forward | 721 | 0.35 | 0.53 |
| isearch-→ | 694 | 0.34 | 0.51 |
| cua-resize-rectangle-right | 674 | 0.33 | 0.49 |
| other-window | 672 | 0.33 | 0.49 |
| cua-resize-rectangle-down | 636 | 0.31 | 0.47 |
| undo | 624 | 0.31 | 0.46 |
| |◀ | 546 | 0.27 | 0.40 |
| mouse-set-point | 531 | 0.26 | 0.39 |
| jump-to-register | 488 | 0.24 | 0.36 |
| point-to-register | 481 | 0.24 | 0.35 |
| (lambda nil (interactive) (scroll-down 1)) | 410 | 0.20 | 0.30 |
| facemenu-set-bold | 401 | 0.20 | 0.29 |
| nonincremental-repeat-search-backward | 397 | 0.20 | 0.29 |
| minibuffer-complete | 370 | 0.18 | 0.27 |
| |← | 359 | 0.18 | 0.26 |
| set-mark-command | 351 | 0.17 | 0.26 |
| →| | 348 | 0.17 | 0.26 |
| insert-prior-line-char | 338 | 0.17 | 0.25 |
| ▶| | 336 | 0.17 | 0.25 |
| isearch-other-control-char | 324 | 0.16 | 0.24 |
| dired | 320 | 0.16 | 0.23 |
| newline-and-indent | 316 | 0.16 | 0.23 |
| dired-advertised-find-file | 308 | 0.15 | 0.23 |
| isearch-other-meta-char | 295 | 0.15 | 0.22 |
| next-file-buffer | 287 | 0.14 | 0.21 |
| find-file | 265 | 0.13 | 0.19 |
| kill-buffer | 233 | 0.11 | 0.17 |
| cua-move-rectangle-right | 228 | 0.11 | 0.17 |
| fill-paragraph | 225 | 0.11 | 0.16 |
| isearch-← | 221 | 0.11 | 0.16 |
| (lambda nil (interactive) (mark-sexp -1 t)) | 218 | 0.11 | 0.16 |
| revert-buffer | 188 | 0.09 | 0.14 |
| universal-argument | 182 | 0.09 | 0.13 |
| exit-minibuffer | 176 | 0.09 | 0.13 |
| copy | 174 | 0.09 | 0.13 |
| cua-resize-rectangle-up | 174 | 0.09 | 0.13 |
| search-word-under-cursor | 165 | 0.08 | 0.12 |
| recenter | 164 | 0.08 | 0.12 |
| cua-insert-char-rectangle | 162 | 0.08 | 0.12 |
| ediff-next-difference | 152 | 0.07 | 0.11 |
| scroll-bar-toolkit-scroll | 148 | 0.07 | 0.11 |
| kill-this-buffer | 147 | 0.07 | 0.11 |
| delete-other-windows | 145 | 0.07 | 0.11 |
| extend-selection | 144 | 0.07 | 0.11 |
| eval-last-sexp | 141 | 0.07 | 0.10 |
Here we describe how the report is generated. Each person, uses this emacs code: command-frequency.el, which will accumulate a keyed-list of all command the user calls in emacs, with key being the command name and value being its count. After some time, the user calls command-frequency-write-file which will write the output into a file.
The raw files used in this report are here: command-frequency_xah.txt, command-frequency_marc.txt, command-frequency_marc2.txt, command-frequency_rgb.txt.
A python program command-frequency.py, is used to parse these raw command-frequency files. The program aggregate all user's raw data, then groups some commands together as described in this report, and replace some command names by a corresponding glyph, and print them in HTML table format. Commands used less than 0.1% of total non-data-entry commands are not displayed.
For technical reasons, the command-frequency.el program, lumps commands backward-kill-word, kill-word, kill-line, kill-region, all into just kill-region. It would be better to modify command-frequency.el to work around this, because these commands are all very frequently used. It is important to know their exact frequency distribution.
The gist of command-frequency.el is just this line: “(add-hook 'post-command-hook 'command-frequency-record)”. The command-frequency-record simply add the value of the buildin var “this-command” to a keyed list. The reason that it lumps commands backward-kill-word, kill-word, kill-line, kill-region, all into just kill-region, is because the “this-command” actually record kill-region instead of any of the called commands. (thanks to Katsumi Yamaoka). Quote from lisp doc:
— Variable: this-command
This variable records the name of the command now being executed
by the editor command loop.
...
Some commands set this variable during their execution, as a flag
for whatever command runs next. In particular, the functions for
killing text set this-command to kill-region so that any kill
commands immediately following will know to append the killed text
to the previous kill.
If you like to participate in this research, please download command-frequency.el and send me the output. I will incorporate your data into the report. Thank you.
A previous version of this report, based on Xah Lee only, is available at command-frequency2.html.
Thanks to Ryan Yeske for writing the elisp code to compile command stats. Thanks to Marc Shapiro and “rgb” for providing me their data.
See also:
Page created: 2007-07. © 2007 by Xah Lee.