Emacs: Universal argument (C-u) in a function
I arrived here looking for a way to detect if my function had been called with C-u. This is how you do it:
(defun my-function ()
(interactive)
(if (equal current-prefix-arg nil) ; no C-u
;; then
(message "my-function was called normally")
;; else
(message "my-function was called with C-u")))
What the original poster was asking is how to call another function with C-u, from inside his/her function. I post this as a clarification to @codyChan's comment above, in the hope that it might help others.
(defun my/test ()
(interactive)
(let ((current-prefix-arg 4)) ;; emulate C-u
(call-interactively 'align-regexp) ;; invoke align-regexp interactively
)
)
Hope that helps.