all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* RE: selected word as parameter to function
       [not found] <490F4CE0.4090508@tqtvd.com>
@ 2008-11-03 20:13 ` Drew Adams
  2008-11-03 20:46   ` Rodrigo Canellas
       [not found]   ` <mailman.2815.1225745220.25473.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 4+ messages in thread
From: Drew Adams @ 2008-11-03 20:13 UTC (permalink / raw)
  To: 'Rodrigo Canellas', help-gnu-emacs

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





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

* Re: selected word as parameter to function
  2008-11-03 20:13 ` selected word as parameter to function Drew Adams
@ 2008-11-03 20:46   ` Rodrigo Canellas
  2008-11-03 22:17     ` Drew Adams
       [not found]   ` <mailman.2815.1225745220.25473.help-gnu-emacs@gnu.org>
  1 sibling, 1 reply; 4+ messages in thread
From: Rodrigo Canellas @ 2008-11-03 20:46 UTC (permalink / raw)
  To: help-gnu-emacs

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.





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

* Re: selected word as parameter to function
       [not found]   ` <mailman.2815.1225745220.25473.help-gnu-emacs@gnu.org>
@ 2008-11-03 21:20     ` Andreas Politz
  0 siblings, 0 replies; 4+ messages in thread
From: Andreas Politz @ 2008-11-03 21:20 UTC (permalink / raw)
  To: help-gnu-emacs

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


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

* RE: selected word as parameter to function
  2008-11-03 20:46   ` Rodrigo Canellas
@ 2008-11-03 22:17     ` Drew Adams
  0 siblings, 0 replies; 4+ messages in thread
From: Drew Adams @ 2008-11-03 22:17 UTC (permalink / raw)
  To: 'Rodrigo Canellas', help-gnu-emacs

> Thanks, but I would like to write it myself...

I pointed you to code that does something similar, to help you do it yourself.






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

end of thread, other threads:[~2008-11-03 22:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <490F4CE0.4090508@tqtvd.com>
2008-11-03 20:13 ` selected word as parameter to function Drew Adams
2008-11-03 20:46   ` Rodrigo Canellas
2008-11-03 22:17     ` Drew Adams
     [not found]   ` <mailman.2815.1225745220.25473.help-gnu-emacs@gnu.org>
2008-11-03 21:20     ` Andreas Politz

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.