unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* filter from find-dired
@ 2013-01-14 16:28 r_mercado
  0 siblings, 0 replies; 4+ messages in thread
From: r_mercado @ 2013-01-14 16:28 UTC (permalink / raw)
  To: help-gnu-emacs

Hello

I created a helper interactive function for my work that searches 
files from the current
directory that match the name "*subst*".

(defun find-substitutions ()
   "find substitution files in the current directory"
   (interactive)
   (find-name-dired (get-directory-name) "*substitutions*")
   )

I would like to filter the entries that sit under a .svn directory

How would I go about it?

In "plain" find, I found this works

find . -name .svn -prune -o -name "*subst*" -print 

find-dired with the same parameters does not filter the entries under
.svn, instead it includes all .svn directories

Thanks



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

* Re: filter from find-dired
@ 2013-01-14 17:26 r_mercado
  2013-01-14 17:50 ` Drew Adams
  0 siblings, 1 reply; 4+ messages in thread
From: r_mercado @ 2013-01-14 17:26 UTC (permalink / raw)
  To: r_mercado, help-gnu-emacs

Hi again,

get-directory-name is my function too. Glad to receive suggestions on 
how to improve it.

(defun get-directory-name ()
  "return the current directory"
  (interactive)
  (let (dirname components)
    (if (null (buffer-file-name (current-buffer)))
        (setq dirname (expand-file-name default-directory))
      (setq components (butlast (split-string (get-file-name) "/")))
      (setq dirname (mapconcat 'identity components "/"))
      )
    (message dirname)
    (kill-new dirname)
    dirname)
)

----Original Message----
From: r_mercado@o2.co.uk
Date: Jan 14, 2013 16:28 
To: <help-gnu-emacs@gnu.org>
Subject: filter from find-dired

Hello

I created a helper interactive function for my work that searches 
files from the current
directory that match the name "*subst*".

(defun find-substitutions ()
  "find substitution files in the current directory"
  (interactive)
  (find-name-dired (get-directory-name) "*substitutions*")
  )

I would like to filter the entries that sit under a .svn directory

How would I go about it?

In "plain" find, I found this works

find . -name .svn -prune -o -name "*subst*" -print 

find-dired with the same parameters does not filter the entries under
.svn, instead it includes all .svn directories

Thanks



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

* RE: filter from find-dired
  2013-01-14 17:26 filter from find-dired r_mercado
@ 2013-01-14 17:50 ` Drew Adams
  0 siblings, 0 replies; 4+ messages in thread
From: Drew Adams @ 2013-01-14 17:50 UTC (permalink / raw)
  To: r_mercado, help-gnu-emacs

> get-directory-name is my function too. Glad to receive suggestions on 
> how to improve it.
> 
> (defun get-directory-name ()
>   "return the current directory"
>   (interactive)
>   (let (dirname components)
>     (if (null (buffer-file-name (current-buffer)))
>         (setq dirname (expand-file-name default-directory))
>       (setq components (butlast (split-string (get-file-name) "/")))
>       (setq dirname (mapconcat 'identity components "/")))
>     (message dirname)
>     (kill-new dirname)
>     dirname))

Not sure what you are trying to do.  You don't show `get-file-name', for one
thing, so your code cannot be evaluated by someone trying to help.

If you are trying to get the (non-)directory component of an absolute file name,
consider using `file-name-(non)directory'.

When you ask for improvement suggestions, I recommend that you start by saying
what your code is intended to do.  Sometimes a completely different
implementation might be suggested, but only if someone can tell what you are
really trying to do.

Looking at just your doc string (which might be inaccurate), it would seem that
all you need is `default-directory'.  That _is_ "the current directory".

If you need that added to the kill buffer, then (kill-new default-directory)
should be adequate.




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

* RE: filter from find-dired
@ 2013-01-14 21:41 r_mercado
  0 siblings, 0 replies; 4+ messages in thread
From: r_mercado @ 2013-01-14 21:41 UTC (permalink / raw)
  To: drew.adams, help-gnu-emacs

Great. Thanks Drew

what I needed was 'default-directory'

That simplifies my previous problem to

(defun find-substitutions ()
   "find substitution files in the current directory"
   (interactive)
   (find-name-dired (default-directory) "*substitutions*")
   )

I would like to filter the entries under ".svn" directories, so that 
they are not included.



----Original Message----
From: drew.adams@oracle.com
Date: Jan 14, 2013 17:50 
To: <r_mercado@o2.co.uk>, <help-gnu-emacs@gnu.org>
Subject: RE: filter from find-dired

> get-directory-name is my function too. Glad to receive suggestions 
on 
> how to improve it.
> 
> (defun get-directory-name ()
>  "return the current directory"
>  (interactive)
>  (let (dirname components)
>    (if (null (buffer-file-name (current-buffer)))
>        (setq dirname (expand-file-name default-directory))
>      (setq components (butlast (split-string (get-file-name) "/")))
>      (setq dirname (mapconcat 'identity components "/")))
>    (message dirname)
>    (kill-new dirname)
>    dirname))

Not sure what you are trying to do. You don't show `get-file-name', 
for one
thing, so your code cannot be evaluated by someone trying to help.

If you are trying to get the (non-)directory component of an absolute 
file name,
consider using `file-name-(non)directory'.

When you ask for improvement suggestions, I recommend that you start 
by saying
what your code is intended to do. Sometimes a completely different
implementation might be suggested, but only if someone can tell what 
you are
really trying to do.

Looking at just your doc string (which might be inaccurate), it would 
seem that
all you need is `default-directory'. That _is_ "the current 
directory".

If you need that added to the kill buffer, then (kill-new default-
directory)
should be adequate.



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

end of thread, other threads:[~2013-01-14 21:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-14 17:26 filter from find-dired r_mercado
2013-01-14 17:50 ` Drew Adams
  -- strict thread matches above, loose matches on Subject: below --
2013-01-14 21:41 r_mercado
2013-01-14 16:28 r_mercado

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).