[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [h-e-w] emacs grep on Windows

From: Drew Adams
Subject: RE: [h-e-w] emacs grep on Windows
Date: Tue, 5 Oct 2010 15:20:52 -0700

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

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 ()
  (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 ()
  (let ((current-prefix-arg  t))
    (call-interactively #'grep)))


You might also be interested in the version of Emacs `grep'     provided by
library `grep+.el'.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]