0

Is there a way to differentiate between different numbers of raw prefix arguments (e.g. C-u vs. C-u C-u) aside from checking whether the argument is (4), (16), etc.?

This seems to be what packages like Smartparens do, albeit with thin wrapper functions.

Tianxiang Xiong
  • 3,848
  • 16
  • 27
  • How is what you're asking different from 'P' option for interactive functions? – Emacs User May 19 '16 at 02:59
  • @EmacsUser What do you mean? I *am* using the "P" interactive code. – Tianxiang Xiong May 19 '16 at 03:05
  • If you had your way, what way would you rather differentiate then? I'm trying to understand your use case. – Emacs User May 19 '16 at 03:24
  • I imagine the use case is the reasonably-common practice of making a command do different things depending on how many times the user types `C-u`, and hoping that instead of comparing against `(4)`, `(16)`, `(64)`, there was some in-built provision for instead comparing against `1`, `2`, `3` to make the code a little friendlier. – phils May 19 '16 at 06:01
  • @phils is correct. It is common for commands to do (slightly) different things based on the number of raw prefix arguments. In that case, the numerical value of the argument is irrelevant. Checking for `(4)` or `(16)` seems like the wrong level of abstraction. – Tianxiang Xiong May 19 '16 at 15:03

1 Answers1

2

No, you have to do exactly that.

See also:

  • C-hig (elisp) Prefix Command Arguments
  • M-x find-function RET universal-argument-more

edit: That said, converting 4^n to n is just maths.

phils
  • 48,657
  • 3
  • 76
  • 115