Why does prefix argument translate to '(4) and '(16) reddit / emacs ---------------------------------------------------------------------- pragmat1c1 · 2022-06-14 08:24 Anyone knows why the prefix argument `C-u` translates to `'(4)` in elisp code? And the double prefix argument `C-u C-u` translates to `'(16)`? What is the background of this? Why not `1` and `2`? or `'(1)` and `'(2)`? ---------------------------------------------------------------------- 7890yuiop · 2022-06-14 09:13 > the double prefix argument C-u C-u translates to '(16)? Because the value is 4^N where N is the number of times C-u is used. Hence C-u C-u C-u => '(64), etc... > Why not 1 and 2? or '(1) and '(2)? I would think because that's not very useful. Prefix args are often used for repeating things, and hammering C-u five times instead of typing C-5 would be silly. The benefit is in easily generating both small *and* large numbers. Small numbers can be generated easily regardless. Note that numeric prefix arg values like 16 are generated from the raw value '(16) so the raw values contain a numeric match for the numeric values. > why the prefix argument C-u translates to '(4) in elisp code? Probably because it's a good value, considering that odd numbers are likely less desirable, and the even numbers either side are 2 (which is barely useful on its own, and when squared is only doubled to 4), and 6 (which is squared to 36 which is rather a large increase for only two uses of C-u). ---------------------------------------------------------------------- b3n · 2022-06-14 09:50 There's no reason it has to be 4, this just happens to be a convenient default. Consider scrolling, for example, `C-v` will scroll a little bit, `C-u C-v` will scroll more, and `C-u C-u C-v` will be a really big jump. ---------------------------------------------------------------------- Alan_Shutko · 2022-06-14 13:16 I have a tiny theory that it's so that C-u C-x C-i indents four spaces, as four spaces is a common indent. Realistically, the idea that the value would be chosen globally for that one use case seems unlikely, but it's my pet theory. ---------------------------------------------------------------------- pragmat1c1 · 2022-06-14 15:25 Excellent explanation. Thank you!