all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* customize grep-find-command for each invocation
@ 2006-08-29 20:02 weiqingh
  2006-08-30  2:00 ` wenbinye
  0 siblings, 1 reply; 3+ messages in thread
From: weiqingh @ 2006-08-29 20:02 UTC (permalink / raw)


hi there,

i want to set the grep-find-command differently based on each file.
(basically i need to search from a certain directory based on where the
file is). what's the best way to do it? i tried to write a new function
like this:

(defun rails-search()
  (interactive)
  ;; set grep-find-command based on value of root
  (rails-core:with-root (root)
  (setq grep-find-command (cons (concat "find " root " -name \"*.rb\" |
xargs -exec grep -i -n -s ") (+ 34 (length root))))

  (grep-find)
 )
)

when trying to run the new function, it gave me "wrong number of
arguments". i guess i need to pass arguments to grep-find. but how? i
wanted to grep-find to take the input for search string... 

thanks.

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

* Re: customize grep-find-command for each invocation
  2006-08-29 20:02 customize grep-find-command for each invocation weiqingh
@ 2006-08-30  2:00 ` wenbinye
  2006-08-30 20:55   ` weiqingh
  0 siblings, 1 reply; 3+ messages in thread
From: wenbinye @ 2006-08-30  2:00 UTC (permalink / raw)


When you write elisp code, you should always check you call the
function with right
arguments. You can use C-h f to see the arguments needed, or turn on
eldoc-mode,
the arguments will echo automatically.

What is your root value? The local variable should use 'let' bind.
grep-find-command is a string, not a cons cell.

after set grep-find-command, you can use (call-interactively
'grep-find)
or (grep-find grep-find-command) to call grep-find

weiqingh@yahoo.com wrote:
> hi there,
>
> i want to set the grep-find-command differently based on each file.
> (basically i need to search from a certain directory based on where the
> file is). what's the best way to do it? i tried to write a new function
> like this:
>
> (defun rails-search()
>   (interactive)
>   ;; set grep-find-command based on value of root
>   (rails-core:with-root (root)
>   (setq grep-find-command (cons (concat "find " root " -name \"*.rb\" |
> xargs -exec grep -i -n -s ") (+ 34 (length root))))
>
>   (grep-find)
>  )
> )
>
> when trying to run the new function, it gave me "wrong number of
> arguments". i guess i need to pass arguments to grep-find. but how? i
> wanted to grep-find to take the input for search string...
> 
> thanks.

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

* Re: customize grep-find-command for each invocation
  2006-08-30  2:00 ` wenbinye
@ 2006-08-30 20:55   ` weiqingh
  0 siblings, 0 replies; 3+ messages in thread
From: weiqingh @ 2006-08-30 20:55 UTC (permalink / raw)


thanks for your reply. the root value is defined in the
rails-core:with-root  macro.

call-interactively is what i was looking for. thanks a lot!

wenbinye@gmail.com wrote:
> When you write elisp code, you should always check you call the
> function with right
> arguments. You can use C-h f to see the arguments needed, or turn on
> eldoc-mode,
> the arguments will echo automatically.
>
> What is your root value? The local variable should use 'let' bind.
> grep-find-command is a string, not a cons cell.
>
> after set grep-find-command, you can use (call-interactively
> 'grep-find)
> or (grep-find grep-find-command) to call grep-find
>
> weiqingh@yahoo.com wrote:
> > hi there,
> >
> > i want to set the grep-find-command differently based on each file.
> > (basically i need to search from a certain directory based on where the
> > file is). what's the best way to do it? i tried to write a new function
> > like this:
> >
> > (defun rails-search()
> >   (interactive)
> >   ;; set grep-find-command based on value of root
> >   (rails-core:with-root (root)
> >   (setq grep-find-command (cons (concat "find " root " -name \"*.rb\" |
> > xargs -exec grep -i -n -s ") (+ 34 (length root))))
> >
> >   (grep-find)
> >  )
> > )
> >
> > when trying to run the new function, it gave me "wrong number of
> > arguments". i guess i need to pass arguments to grep-find. but how? i
> > wanted to grep-find to take the input for search string...
> > 
> > thanks.

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

end of thread, other threads:[~2006-08-30 20:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-29 20:02 customize grep-find-command for each invocation weiqingh
2006-08-30  2:00 ` wenbinye
2006-08-30 20:55   ` weiqingh

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.