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.

5
  • How is what you're asking different from 'P' option for interactive functions?
    – Emacs User
    May 19, 2016 at 2:59
  • @EmacsUser What do you mean? I am using the "P" interactive code. May 19, 2016 at 3: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, 2016 at 3: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, 2016 at 6: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. May 19, 2016 at 15:03

1 Answer 1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.