From: "Drew Adams" <drew.adams@oracle.com>
To: "'Kenneth Goldman'" <kgoldman@us.ibm.com>,
"'Emacs mailing list'" <help-gnu-emacs@gnu.org>
Cc: help-emacs-windows@gnu.org
Subject: RE: [h-e-w] emacs grep on Windows
Date: Tue, 5 Oct 2010 15:32:03 -0700 [thread overview]
Message-ID: <B71AE435900E460AB315AA01447EED69@us.oracle.com> (raw)
In-Reply-To: <AF4AE27C841A4802B788F19EDBAB2EC3@us.oracle.com>
Sorry. Resending my reply with clearer quoting of your post, and redirecting to
help-gnu-emacs (this is not really Windows-specific).
> 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
next parent reply other threads:[~2010-10-05 22:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <OFCD5BE2EA.1E6A44BD-ON862577B3.0074243D-862577B3.0074B442@us.ibm.com>
[not found] ` <AF4AE27C841A4802B788F19EDBAB2EC3@us.oracle.com>
2010-10-05 22:32 ` Drew Adams [this message]
2010-10-05 22:37 ` [h-e-w] emacs grep on Windows Lennart Borgman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=B71AE435900E460AB315AA01447EED69@us.oracle.com \
--to=drew.adams@oracle.com \
--cc=help-emacs-windows@gnu.org \
--cc=help-gnu-emacs@gnu.org \
--cc=kgoldman@us.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.