I use igrep, but it seems to be broken on Windows with emacs 23. I'd like to switch to grep. The manual says: If you specify a prefix argument for M-x grep, it finds the tag ... There's no sample code for how to actually set the prefix argument. I know I can type C-u every time, but how do I assign it to a key (global-set-key)?
C-u is a key. ;-) Many commands that change their behavior based on a prefix arg use the prefix arg as one of their arguments. E.g.: (defun foo (arg) (interactive "P) ;; Do something according to the value of ARG, ;; which is the same as variable `current-prefix-arg'. ) If that is the case, and you want a command that _always_ performs `foo' as if you had used `C-u' interactively, you can write a command that does that: (defun my-foo () (interactive) (foo arg)) In some cases it is a bit more involved than that. For example, `foo' might do things differently depending on whether it is called interactively or from Lisp. More germane to your question, `foo' (`grep' in this case) might not provide any argument that corresponds one-to-one with the `current-prefix-arg'. You need to look at the source code for the command to see how it works interactively. In the case of `grep', you can do this to get what you want: (defun my-grep () "..." (interactive) (let ((current-prefix-arg t)) (call-interactively #'grep))) HTH. You might also be interested in the version of Emacs `grep' provided by library `grep+.el'. http://www.emacswiki.org/emacs/GrepPlus http://www.emacswiki.org/emacs/grep%2b.el