emacs lisp call function with prefix argument programmatically

If I’m understanding you right, you’re trying to make a keybinding that will act like you typed C-u M-x grep <ENTER>. Try this:

(global-set-key (kbd "C-c m g")
                (lambda () (interactive)
                  (setq current-prefix-arg '(4)) ; C-u
                  (call-interactively 'grep)))

Although I would probably make a named function for this:

(defun grep-with-prefix-arg ()
  (interactive)
  (setq current-prefix-arg '(4)) ; C-u
  (call-interactively 'grep))

(global-set-key (kbd "C-c m g") 'grep-with-prefix-arg)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)