Emacs's Command Frequency

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.

Preliminary

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.

Command Frequency Table

Total number of command calls: 203118

Percent of non-data-entry command calls: 67%

Command NameCount% total cmd call% non-data-entry cmd call
self-insert-command6549632.2548.00
2396011.8017.56
189179.3113.87
→w112245.538.23
←w 67823.344.97
66503.274.87
65583.234.81
43932.163.22
nonincremental-repeat-search-forward 41412.043.04
38391.892.81
back-to-indentation-or-beginning 32731.612.40
isearch-printing-char 26821.321.97
end-of-code-or-line 24791.221.82
cua-delete-region 23091.141.69
18960.931.39
yank 16910.831.24
14830.731.09
indent-relative 13330.660.98
save-buffer 13020.640.95
just-one-space 12950.640.95
newline 11850.580.87
handle-switch-frame 11170.550.82
(lambda nil (interactive) (scroll-up 1)) 10950.540.80
9960.490.73
rgb-doublespace-maybe 9720.480.71
search-backward 9320.460.68
execute-extended-command 9000.440.66
universal-argument-other-key 8910.440.65
cua-copy-region 8020.390.59
mouse-drag-region 7460.370.55
kill-buffer-silently 7400.360.54
digit-argument 7310.360.54
nonincremental-search-forward 7210.350.53
isearch-→ 6940.340.51
cua-resize-rectangle-right 6740.330.49
other-window 6720.330.49
cua-resize-rectangle-down 6360.310.47
undo 6240.310.46
|◀ 5460.270.40
mouse-set-point 5310.260.39
jump-to-register 4880.240.36
point-to-register 4810.240.35
(lambda nil (interactive) (scroll-down 1)) 4100.200.30
facemenu-set-bold 4010.200.29
nonincremental-repeat-search-backward 3970.200.29
minibuffer-complete 3700.180.27
|← 3590.180.26
set-mark-command 3510.170.26
→| 3480.170.26
insert-prior-line-char 3380.170.25
▶| 3360.170.25
isearch-other-control-char 3240.160.24
dired 3200.160.23
newline-and-indent 3160.160.23
dired-advertised-find-file 3080.150.23
isearch-other-meta-char 2950.150.22
next-file-buffer 2870.140.21
find-file 2650.130.19
kill-buffer 2330.110.17
cua-move-rectangle-right 2280.110.17
fill-paragraph 2250.110.16
isearch-← 2210.110.16
(lambda nil (interactive) (mark-sexp -1 t)) 2180.110.16
revert-buffer 1880.090.14
universal-argument 1820.090.13
exit-minibuffer 1760.090.13
copy 1740.090.13
cua-resize-rectangle-up 1740.090.13
search-word-under-cursor 1650.080.12
recenter 1640.080.12
cua-insert-char-rectangle 1620.080.12
ediff-next-difference 1520.070.11
scroll-bar-toolkit-scroll 1480.070.11
kill-this-buffer 1470.070.11
delete-other-windows 1450.070.11
extend-selection 1440.070.11
eval-last-sexp 1410.070.10

How The Report Is Compiled

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-display which will write the stat into a buffer, then the user save it to file.

The raw data files used in this report are here: command-frequency.tgz

A python program command-frequency.py, is used to parse these raw data 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.

Lump of Kill Commands

When this report is written, the command logging program “command-frequency.el” used “this-command” variable to record what command is being called. The “this-command” lumps together backward-kill-word, kill-word, kill-line, kill-region, all into just kill-region. Therefore, in this report, the frequency for kill-region is their combined value, while each of the individual kill command is not being recorded. This problem is fixed in the current version of the “command-frequency.el”.

Reference: Elisp Manual: Command-Loop-Info.

Subsequent stat shows that, the lumped kill commands has this frequentcy distribution:

backward-kill-word0.4
kill-word.23
kill-line.34
kill-region.04

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 Katsumi Yamaoka for pointing out the problem of “this-command”. Thanks to Stefan Guath for pointing out “real-last-command”. Thanks to Marc Shapiro and “rgb” for providing me their data.


See also:

Page created: 2007-07.
© 2007 by Xah Lee.
Xah Signet