How to supply the current word as a parameter to grep?
  Home FAQ Contact Sign in
gnu.emacs.help only
 
Advanced search
POPULAR GROUPS

more...

gnu.emacs.help Profile…
 Up
How to supply the current word as a parameter to grep?         


Author: etay.meiri
Date: Sep 19, 2008 05:01

Hi,

I have the following entries in my .emacs:

(global-set-key [(control shift f)] 'grep)
(setq grep-command "cd ~/work && find -name \"*.cpp\" -or -name \"*.h
\" | xargs grep -nH -e ")

I'd like have the current word supplied as a parameter to grep
whenever I hit the above key combination.
How do I accomplish that?

Thanks,

-Etay Meiri
2 Comments
RE: How to supply the current word as a parameter to grep?         


Author: Drew Adams
Date: Sep 19, 2008 07:24

> (global-set-key [(control shift f)] 'grep)
> (setq grep-command "cd ~/work && find -name \"*.cpp\" -or -name \"*.h
> \" | xargs grep -nH -e ")
>
> I'd like have the current word supplied as a parameter to grep
> whenever I hit the above key combination.
> How do I accomplish that?
no comments
Re: How to supply the current word as a parameter to grep?         


Author: harven
Date: Sep 19, 2008 08:34

On Sep 19, 2:01 pm, etay.me...@gmail.com wrote:
> Hi,
>
> I have the following entries in my .emacs:
>
> (setq grep-command "cd ~/work && find -name \"*.cpp\" -or -name \"*.h
> \" | xargs grep -nH -e ")
>
> I'd like have the current word supplied as a parameter to grep
> whenever I hit the above key combination.
> How do I accomplish that?
>
> Thanks,
>
> -Etay Meiri

The commands lgrep and rgrep are somehow more user-friendly than the M-
x grep command. The word at point can be captured using the
command (thing-at-point 'word). So you may try:
Show full article (0.80Kb)
no comments