From: Andreas Politz <politza@fh-trier.de>
To: help-gnu-emacs@gnu.org
Subject: Re: selected word as parameter to function
Date: Mon, 03 Nov 2008 22:20:43 +0100 [thread overview]
Message-ID: <1225747314.321174@arno.fh-trier.de> (raw)
In-Reply-To: <mailman.2815.1225745220.25473.help-gnu-emacs@gnu.org>
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)
>>
>>
>
>
prev parent reply other threads:[~2008-11-03 21:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[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 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1225747314.321174@arno.fh-trier.de \
--to=politza@fh-trier.de \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.