I have made the following function to count how many
C-u prefixes a command was given (assuming it is called interactively), but I feel this is a common-enough problem that there should be a built-in function (or a package that solves this problem more robustly). Is there a better way to do this?
(defun tmp:how-many (arg) ;; Return zero if `arg' is 1 or nil (if (or (null arg) (equal arg 1)) 0 ;; If `arg' is a list (as it is when called interactively), extract ;; the number. (when (listp arg) (setq arg (car arg))) ;; Recurse (if arg (1+ (tmp:how-many (/ arg 4))) 0))) (defun tmp:test (arg) (interactive "P") (message "%S" (tmp:how-many arg)))