all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to supply the current word as a parameter to grep?
@ 2008-09-19 12:01 etay.meiri
  2008-09-19 14:24 ` Drew Adams
  2008-09-19 15:34 ` harven
  0 siblings, 2 replies; 3+ messages in thread
From: etay.meiri @ 2008-09-19 12:01 UTC (permalink / raw)
  To: help-gnu-emacs

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: How to supply the current word as a parameter to grep?
  2008-09-19 12:01 How to supply the current word as a parameter to grep? etay.meiri
@ 2008-09-19 14:24 ` Drew Adams
  2008-09-19 15:34 ` harven
  1 sibling, 0 replies; 3+ messages in thread
From: Drew Adams @ 2008-09-19 14:24 UTC (permalink / raw)
  To: etay.meiri, help-gnu-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?

See grep+.el: http://www.emacswiki.org/cgi-bin/wiki/grep%2b.el. It does that.





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to supply the current word as a parameter to grep?
  2008-09-19 12:01 How to supply the current word as a parameter to grep? etay.meiri
  2008-09-19 14:24 ` Drew Adams
@ 2008-09-19 15:34 ` harven
  1 sibling, 0 replies; 3+ messages in thread
From: harven @ 2008-09-19 15:34 UTC (permalink / raw)
  To: help-gnu-emacs

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:

(defun my-grep ()
  "look for word at point in files ending by .cpp and .h
   recursively starting from the work directory"
  (interactive)
  (rgrep (thing-at-point 'word) "*.cpp *.h" "~/work"))

(global-set-key [(control shift f)] 'my-grep)


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-09-19 15:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-19 12:01 How to supply the current word as a parameter to grep? etay.meiri
2008-09-19 14:24 ` Drew Adams
2008-09-19 15:34 ` harven

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.