all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* find-grep-dired - default directory to start with
@ 2015-07-28 12:25 Martin Barth
  2015-07-28 12:38 ` Martin Barth
  2015-07-28 12:43 ` Dmitry Gutov
  0 siblings, 2 replies; 13+ messages in thread
From: Martin Barth @ 2015-07-28 12:25 UTC (permalink / raw)
  To: help-gnu-emacs

Hello,

i've just discovered the function find-grep-dired which turns out to be
very useful for me.
When you invoke M x find-grep-dired you get asked for the starting
directory.

I am looking for a alternatetive function where this "Start directory"
can be predefined.
basically

(setq my-default-search-dir '/home/foo/bar);

and then M-x find-grep-dired-in-my-default-search-dir

Any Ideas?

Thank You
Martin!



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

* Re: find-grep-dired - default directory to start with
  2015-07-28 12:25 find-grep-dired - default directory to start with Martin Barth
@ 2015-07-28 12:38 ` Martin Barth
  2015-07-28 12:43 ` Dmitry Gutov
  1 sibling, 0 replies; 13+ messages in thread
From: Martin Barth @ 2015-07-28 12:38 UTC (permalink / raw)
  To: help-gnu-emacs

best would be a way to apply this pattern to find-dired (and others, as
well)

Regards
Martin

Am 28.07.2015 um 14:25 schrieb Martin Barth:
> Hello,
>
> i've just discovered the function find-grep-dired which turns out to be
> very useful for me.
> When you invoke M x find-grep-dired you get asked for the starting
> directory.
>
> I am looking for a alternatetive function where this "Start directory"
> can be predefined.
> basically
>
> (setq my-default-search-dir '/home/foo/bar);
>
> and then M-x find-grep-dired-in-my-default-search-dir
>
> Any Ideas?
>
> Thank You
> Martin!
>
>




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

* Re: find-grep-dired - default directory to start with
  2015-07-28 12:25 find-grep-dired - default directory to start with Martin Barth
  2015-07-28 12:38 ` Martin Barth
@ 2015-07-28 12:43 ` Dmitry Gutov
  2015-07-28 13:05   ` Martin Barth
  2015-07-28 14:27   ` find-grep-dired - default directory to start with Bobby Casey
  1 sibling, 2 replies; 13+ messages in thread
From: Dmitry Gutov @ 2015-07-28 12:43 UTC (permalink / raw)
  To: Martin Barth, help-gnu-emacs

On 07/28/2015 03:25 PM, Martin Barth wrote:

> I am looking for a alternatetive function where this "Start directory"
> can be predefined.
> basically
>
> (setq my-default-search-dir '/home/foo/bar);
>
> and then M-x find-grep-dired-in-my-default-search-dir

Define your own my-find-grep-dired, copy the definition of 
find-grep-dired there, and change it to use my-default-search-dir.

Should be easy.



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

* Re: find-grep-dired - default directory to start with
  2015-07-28 12:43 ` Dmitry Gutov
@ 2015-07-28 13:05   ` Martin Barth
  2015-07-28 13:08     ` Dmitry Gutov
  2015-07-28 14:27   ` find-grep-dired - default directory to start with Bobby Casey
  1 sibling, 1 reply; 13+ messages in thread
From: Martin Barth @ 2015-07-28 13:05 UTC (permalink / raw)
  To: Dmitry Gutov, help-gnu-emacs

How do i find the definition of this function?

Am 28.07.2015 um 14:43 schrieb Dmitry Gutov:
> On 07/28/2015 03:25 PM, Martin Barth wrote:
>
>> I am looking for a alternatetive function where this "Start directory"
>> can be predefined.
>> basically
>>
>> (setq my-default-search-dir '/home/foo/bar);
>>
>> and then M-x find-grep-dired-in-my-default-search-dir
>
> Define your own my-find-grep-dired, copy the definition of
> find-grep-dired there, and change it to use my-default-search-dir.
>
> Should be easy.
>




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

* Re: find-grep-dired - default directory to start with
  2015-07-28 13:05   ` Martin Barth
@ 2015-07-28 13:08     ` Dmitry Gutov
  2015-07-28 13:24       ` find-grep-dired - default directory to start with (SOLVED) Martin Barth
  0 siblings, 1 reply; 13+ messages in thread
From: Dmitry Gutov @ 2015-07-28 13:08 UTC (permalink / raw)
  To: Martin Barth, help-gnu-emacs

On 07/28/2015 04:05 PM, Martin Barth wrote:
> How do i find the definition of this function?

For instance, with M-x find-function.



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

* Re: find-grep-dired - default directory to start with (SOLVED)
  2015-07-28 13:08     ` Dmitry Gutov
@ 2015-07-28 13:24       ` Martin Barth
  2015-07-28 13:34         ` Dmitry Gutov
  0 siblings, 1 reply; 13+ messages in thread
From: Martin Barth @ 2015-07-28 13:24 UTC (permalink / raw)
  To: Dmitry Gutov, help-gnu-emacs


Am 28.07.2015 um 15:08 schrieb Dmitry Gutov:
> On 07/28/2015 04:05 PM, Martin Barth wrote:
>> How do i find the definition of this function?
>
> For instance, with M-x find-function.
>

Making completion list...
`find-grep' is an alias for `grep-find'
find-library-name: Can't find library
/usr/share/emacs/24.3/lisp/progmodes/grep.el

so with googling a bit i found out that there is a grep-find-command
variable that you can modify

unfortunately

(setq grep-find-command "find.. and so on") didnt work

even what was mentioned here didnt work:
http://stackoverflow.com/questions/2148575/default-string-for-grep-find-in-emacs

|(grep-compute-defaults)
(setq grep-find-command "find.. and so on)|



But this worked:
http://stackoverflow.com/questions/28915372/change-the-default-find-grep-command-in-emacs
(grep-apply-setting 'grep-find-command "find .. and so on")

Thanks







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

* Re: find-grep-dired - default directory to start with (SOLVED)
  2015-07-28 13:24       ` find-grep-dired - default directory to start with (SOLVED) Martin Barth
@ 2015-07-28 13:34         ` Dmitry Gutov
  2015-07-28 14:18           ` Michael Heerdegen
  0 siblings, 1 reply; 13+ messages in thread
From: Dmitry Gutov @ 2015-07-28 13:34 UTC (permalink / raw)
  To: Martin Barth, help-gnu-emacs

On 07/28/2015 04:24 PM, Martin Barth wrote:

> Making completion list...
> `find-grep' is an alias for `grep-find'
> find-library-name: Can't find library
> /usr/share/emacs/24.3/lisp/progmodes/grep.el

No idea what's going on there.

> so with googling a bit i found out that there is a grep-find-command
> variable that you can modify

I wouldn't call this a good solution for your problem. Now you can grep 
in an arbitrary directory at all.

Further, you'll break other commands that use grep-find-command, now or 
in the future.



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

* Re: find-grep-dired - default directory to start with (SOLVED)
  2015-07-28 13:34         ` Dmitry Gutov
@ 2015-07-28 14:18           ` Michael Heerdegen
  2015-07-28 15:54             ` Martin Barth
  2015-07-28 16:01             ` Drew Adams
  0 siblings, 2 replies; 13+ messages in thread
From: Michael Heerdegen @ 2015-07-28 14:18 UTC (permalink / raw)
  To: help-gnu-emacs

Dmitry Gutov <dgutov@yandex.ru> writes:

> On 07/28/2015 04:24 PM, Martin Barth wrote:
>
> > Making completion list...
> > `find-grep' is an alias for `grep-find'
> > find-library-name: Can't find library
> > /usr/share/emacs/24.3/lisp/progmodes/grep.el
>
> No idea what's going on there.

Maybe he doesn't have the el sources installed at his OS?  Here is the
definition:

--8<---------------cut here---------------start------------->8---
(defun grep-find (command-args)
  "Run grep via find, with user-specified args COMMAND-ARGS.
Collect output in a buffer.
While find runs asynchronously, you can use the \\[next-error] command
to find the text that grep hits refer to.

This command uses a special history list for its arguments, so you can
easily repeat a find command."
  (interactive
   (progn
     (grep-compute-defaults)
     (if grep-find-command
	 (list (read-shell-command "Run find (like this): "
                                   grep-find-command 'grep-find-history))
       ;; No default was set
       (read-string
        "compile.el: No `grep-find-command' command available. Press RET.")
       (list nil))))
  (when command-args
    (let ((null-device nil))		; see grep
      (grep command-args))))
--8<---------------cut here---------------end--------------->8---

> > so with googling a bit i found out that there is a grep-find-command
> > variable that you can modify

This can not be set directly because it has a :set spec in the
defcustom.

> I wouldn't call this a good solution for your problem. Now you can
> grep in an arbitrary directory at all.
>
> Further, you'll break other commands that use grep-find-command, now
> or in the future.

Indeed.


Michael.




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

* Re: find-grep-dired - default directory to start with
  2015-07-28 12:43 ` Dmitry Gutov
  2015-07-28 13:05   ` Martin Barth
@ 2015-07-28 14:27   ` Bobby Casey
  2015-07-28 14:30     ` Dmitry Gutov
  1 sibling, 1 reply; 13+ messages in thread
From: Bobby Casey @ 2015-07-28 14:27 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: help-gnu-emacs

On Tue, Jul 28, 2015 at 8:43 AM, Dmitry Gutov <dgutov@yandex.ru> wrote:

> On 07/28/2015 03:25 PM, Martin Barth wrote:
>
>  I am looking for a alternatetive function where this "Start directory"
>> can be predefined.
>> basically
>>
>> (setq my-default-search-dir '/home/foo/bar);
>>
>> and then M-x find-grep-dired-in-my-default-search-dir
>>
>
> Define your own my-find-grep-dired, copy the definition of find-grep-dired
> there, and change it to use my-default-search-dir.
>
> Should be easy.
>
>
Wouldn't a wrapper be more appropriate?  Something like this:

(defvar my-find-grep-dired-default "/tmp/"
  "Specifies the default search directory for my-find-grep-dired")
(defun my-find-grep-dired (regexp)
  (find-grep-dired my-find-grep-dired-default regexp))


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

* Re: find-grep-dired - default directory to start with
  2015-07-28 14:27   ` find-grep-dired - default directory to start with Bobby Casey
@ 2015-07-28 14:30     ` Dmitry Gutov
  0 siblings, 0 replies; 13+ messages in thread
From: Dmitry Gutov @ 2015-07-28 14:30 UTC (permalink / raw)
  To: Bobby Casey; +Cc: help-gnu-emacs

On 07/28/2015 05:27 PM, Bobby Casey wrote:

> Wouldn't a wrapper be more appropriate?  Something like this:
>
> (defvar my-find-grep-dired-default "/tmp/"
>    "Specifies the default search directory for my-find-grep-dired")
> (defun my-find-grep-dired (regexp)
>    (find-grep-dired my-find-grep-dired-default regexp))

Yep, that looks fine as well.




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

* Re: find-grep-dired - default directory to start with (SOLVED)
  2015-07-28 14:18           ` Michael Heerdegen
@ 2015-07-28 15:54             ` Martin Barth
  2015-07-28 16:01             ` Drew Adams
  1 sibling, 0 replies; 13+ messages in thread
From: Martin Barth @ 2015-07-28 15:54 UTC (permalink / raw)
  To: help-gnu-emacs



Am 28.07.2015 um 16:18 schrieb Michael Heerdegen:
> Dmitry Gutov <dgutov@yandex.ru> writes:
>
>> On 07/28/2015 04:24 PM, Martin Barth wrote:
>>
>>> Making completion list...
>>> `find-grep' is an alias for `grep-find'
>>> find-library-name: Can't find library
>>> /usr/share/emacs/24.3/lisp/progmodes/grep.el
>> No idea what's going on there.
> Maybe he doesn't have the el sources installed at his OS?  Here is the
> definition:
i've got only the .elc file there.

>> I wouldn't call this a good solution for your problem. Now you can
>> grep in an arbitrary directory at all.
>>
>> Further, you'll break other commands that use grep-find-command, now
>> or in the future.
> Indeed.


according to the source, isn't this considered to be changed, in order
to apply "customization"?

(defcustom grep-find-command nil
  "The default find command for \\[grep-find].
In interactive usage, the actual value of this variable is set up
by `grep-compute-defaults'; to change the default value, use
Customize or call the function `grep-apply-setting'."
  :type '(choice string
		 (const :tag "Not Set" nil))
  :set 'grep-apply-setting
  :group 'grep)


If not, then i guess there is no easy way to apply a "wrapper" since the find statement always contains the "find ." instead of what i want to achive a "find /some/where/else". So, copy paste the grep-find function and reimplement it? i am not sure if this is good since changes to grep.el will never reflect in my change again. my lisp skills are to lousy for that anyways.





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

* RE: find-grep-dired - default directory to start with (SOLVED)
  2015-07-28 14:18           ` Michael Heerdegen
  2015-07-28 15:54             ` Martin Barth
@ 2015-07-28 16:01             ` Drew Adams
  2015-07-28 16:28               ` Michael Heerdegen
  1 sibling, 1 reply; 13+ messages in thread
From: Drew Adams @ 2015-07-28 16:01 UTC (permalink / raw)
  To: Michael Heerdegen, help-gnu-emacs

> > > so with googling a bit i found out that there is a grep-find-command
> > > variable that you can modify
> 
> This can not be set directly because it has a :set spec in the
> defcustom.

A user option with a :set spec can be set directly using either
`customize-set-variable' or `customize-set-value'.  But not using
just `setq'.



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

* Re: find-grep-dired - default directory to start with (SOLVED)
  2015-07-28 16:01             ` Drew Adams
@ 2015-07-28 16:28               ` Michael Heerdegen
  0 siblings, 0 replies; 13+ messages in thread
From: Michael Heerdegen @ 2015-07-28 16:28 UTC (permalink / raw)
  To: Drew Adams; +Cc: help-gnu-emacs

Drew Adams <drew.adams@oracle.com> writes:

> A user option with a :set spec can be set directly using either
> `customize-set-variable' or `customize-set-value'.  But not using
> just `setq'.

That's what I meant (but elided).  Of course the user can also call the
specified :set function.


Michael.



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

end of thread, other threads:[~2015-07-28 16:28 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-28 12:25 find-grep-dired - default directory to start with Martin Barth
2015-07-28 12:38 ` Martin Barth
2015-07-28 12:43 ` Dmitry Gutov
2015-07-28 13:05   ` Martin Barth
2015-07-28 13:08     ` Dmitry Gutov
2015-07-28 13:24       ` find-grep-dired - default directory to start with (SOLVED) Martin Barth
2015-07-28 13:34         ` Dmitry Gutov
2015-07-28 14:18           ` Michael Heerdegen
2015-07-28 15:54             ` Martin Barth
2015-07-28 16:01             ` Drew Adams
2015-07-28 16:28               ` Michael Heerdegen
2015-07-28 14:27   ` find-grep-dired - default directory to start with Bobby Casey
2015-07-28 14:30     ` Dmitry Gutov

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.