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: Rodrigo Canellas
Subject: Re: selected word as parameter to function
Date: Mon, 03 Nov 2008 18:46:53 -0200
User-agent: Thunderbird 2.0.0.17 (X11/20080925)

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 .)
)

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)



--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.





reply via email to

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