help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: selected word as parameter to function


From: Andreas Politz
Subject: Re: selected word as parameter to function
Date: Mon, 03 Nov 2008 22:20:43 +0100
User-agent: Mozilla-Thunderbird 2.0.0.17 (X11/20081018)

Rodrigo Canellas wrote:
Thanks, but I would like to write it myself...

I will try to get the input from the cursor's position later. For now, I would like the user to input the text.

So, I tried this:

(defun my-grep (pattern)
 "this is my grep - still developing"
 (interactive "sEnter the text to search for: ")
(grep -nH -R --include="*.cpp" --include="*.h" --include ="*.c" -e pattern .)
)


The argument to the grep function must be a complete shell command as
a string.

(grep (concat "grep -nH -R --include=\"*.cpp\" --include=\"*.h\" --include =\"*.c\" 
-e " pattern ))


When I type 'M-x my-grep', and input "Good", 'emacs' reports:

my-grep: Symbol's value as variable is void: -nH

I tried 'C-h f grep' and I could not realize what I am doing wrong...

All the help is much appreciated...

Thanks!!

Drew Adams escreveu:
I would like to create a function that would execute:

grep -nH -R --include="*.cpp" --include="*.h" --include ="*.c" -e "'selected-word'" .

Where 'selected-word' would be the word where the cursor is at (or below?).

See the code in grep+.el, which does that. See option `grepp-default-regexp-fn'
and how it is used.
(In addition, if the region is active, `grep' (in grep+.el) puts quotes around
it and uses that as the search string instead of the cursor word.)

http://www.emacswiki.org/emacs/grep%2b.el (code)

http://www.emacswiki.org/emacs/GrepPlus (doc)





reply via email to

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