* find certain files
@ 2007-06-12 18:19 econfreerider
2007-06-12 19:54 ` Drew Adams
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: econfreerider @ 2007-06-12 18:19 UTC (permalink / raw)
To: Help-gnu-emacs
Hi all,
I am new here. I have a question I have for a long time: I use Ctrl-f to
find files in a directory, but it displays all the files under that
directory. Now I want to limit it to certain files that have certain
extensions, for example, only sas files, *.sas. If if do Ctrl-f
/projects/a/*.sas, it will open all the sas files. I want to do Ctrl-f
/projects/a/, and only display .sas files, so I can choose one. How do I do
that?
Thank you so much!
--
View this message in context: http://www.nabble.com/find-certain-files-tf3909138.html#a11084030
Sent from the Emacs - Help mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: find certain files
2007-06-12 18:19 find certain files econfreerider
@ 2007-06-12 19:54 ` Drew Adams
2007-06-12 20:37 ` econfreerider
2007-06-12 19:57 ` Eli Zaretskii
2007-06-12 20:02 ` Dieter Wilhelm
2 siblings, 1 reply; 11+ messages in thread
From: Drew Adams @ 2007-06-12 19:54 UTC (permalink / raw)
To: Help-gnu-emacs
> I use Ctrl-f to find files in a directory, but...I want to
> limit it to certain files...for example, only sas files, *.sas.
> If if do Ctrl-f /projects/a/*.sas, it will open all the sas files.
> I want to do Ctrl-f /projects/a/, and only display .sas files,
> so I can choose one. How do I do that?
Use Icicles apropos completion:
C-x C-f \.sas$ S-TAB, if the current directory is /projects/a, or
C-x C-f /projects/a/.*\.sas$ S-TAB, otherwise.
You match the file extension using the regular expression `\.sas$'. You need
to escape the `.' preceding the `sas' file-extension with a backslash, or
else it will match any character (except a newline) - as in the `.*', which
matches any character any number of times. The `$' matches the end of the
file name.
When the list of matching file-name candidates is displayed, click `mouse-2'
on the one you want. If you want to open multiple files, click `C-mouse-2'
on each one you want.
You can also cycle through the matching candidates with the `next' key, and
use `RET' to choose the current one (or `C-RET' to choose more than one).
You can also type a more specific match pattern, to match only certain SAS
files.
For example, `C-x C-f foo.*bar\.sas$ S-TAB' matches file names that start
with `foo', contain also `bar', and end with `.sas'.
You can also save a set of completions - for example, if you often use the
same set of project files. Just use `C-M->' to save the current matches in a
variable, or `C-u C-M->' to save them persistently in a cache file. Later,
when you want to retrieve them for completion with `C-x C-f', use `C-M-<'
(retrieve from a variable) or `C-u C-M-<' (retrieve from a cache file). You
are prompted for the cache file name. You can have any number of variables
or files that hold completion sets.
http://www.emacswiki.org/cgi-bin/wiki/Icicles: doc
http://www.emacswiki.org/cgi-bin/wiki/Icicles_-_Apropos_Completions: about
apropos completion
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: find certain files
2007-06-12 18:19 find certain files econfreerider
2007-06-12 19:54 ` Drew Adams
@ 2007-06-12 19:57 ` Eli Zaretskii
2007-06-12 20:24 ` econfreerider
[not found] ` <mailman.2056.1181679859.32220.help-gnu-emacs@gnu.org>
2007-06-12 20:02 ` Dieter Wilhelm
2 siblings, 2 replies; 11+ messages in thread
From: Eli Zaretskii @ 2007-06-12 19:57 UTC (permalink / raw)
To: Help-gnu-emacs
> Date: Tue, 12 Jun 2007 11:19:04 -0700 (PDT)
> From: econfreerider <econfreerider@gmail.com>
> Cc:
>
> Now I want to limit it to certain files that have certain
> extensions, for example, only sas files, *.sas. If if do Ctrl-f
> /projects/a/*.sas, it will open all the sas files. I want to do Ctrl-f
> /projects/a/, and only display .sas files, so I can choose one. How do I do
> that?
"C-x d /projects/a/*.sas RET"
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: find certain files
2007-06-12 18:19 find certain files econfreerider
2007-06-12 19:54 ` Drew Adams
2007-06-12 19:57 ` Eli Zaretskii
@ 2007-06-12 20:02 ` Dieter Wilhelm
2 siblings, 0 replies; 11+ messages in thread
From: Dieter Wilhelm @ 2007-06-12 20:02 UTC (permalink / raw)
To: econfreerider; +Cc: Help-gnu-emacs
econfreerider <econfreerider@gmail.com> writes:
> Hi all,
>
> I am new here. I have a question I have for a long time: I use Ctrl-f to
> find files in a directory, but it displays all the files under that
> directory. Now I want to limit it to certain files that have certain
> extensions, for example, only sas files, *.sas. If if do Ctrl-f
Have you already tried ido-mode?
--
Best wishes
H. Dieter Wilhelm
Darmstadt, Germany
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: find certain files
2007-06-12 19:57 ` Eli Zaretskii
@ 2007-06-12 20:24 ` econfreerider
[not found] ` <mailman.2056.1181679859.32220.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 11+ messages in thread
From: econfreerider @ 2007-06-12 20:24 UTC (permalink / raw)
To: Help-gnu-emacs
You guys are so quick and helpful. Greatly appreciate everyone's help! I am
tired of eyeballing through hundreds of files to find what I am looking
for...
Eli Zaretskii wrote:
>
>> Date: Tue, 12 Jun 2007 11:19:04 -0700 (PDT)
>> From: econfreerider <econfreerider@gmail.com>
>> Cc:
>>
>> Now I want to limit it to certain files that have certain
>> extensions, for example, only sas files, *.sas. If if do Ctrl-f
>> /projects/a/*.sas, it will open all the sas files. I want to do Ctrl-f
>> /projects/a/, and only display .sas files, so I can choose one. How do I
>> do
>> that?
>
> "C-x d /projects/a/*.sas RET"
>
>
> _______________________________________________
> help-gnu-emacs mailing list
> help-gnu-emacs@gnu.org
> http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
>
>
--
View this message in context: http://www.nabble.com/find-certain-files-tf3909138.html#a11086259
Sent from the Emacs - Help mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: find certain files
2007-06-12 19:54 ` Drew Adams
@ 2007-06-12 20:37 ` econfreerider
2007-06-12 20:54 ` Drew Adams
0 siblings, 1 reply; 11+ messages in thread
From: econfreerider @ 2007-06-12 20:37 UTC (permalink / raw)
To: Help-gnu-emacs
Hi Drew,
Thanks a lot for the suggestions. I had a hard time using S-TAB: do I need
to install Icicles?
Thanks again.
Drew Adams wrote:
>
>> I use Ctrl-f to find files in a directory, but...I want to
>> limit it to certain files...for example, only sas files, *.sas.
>> If if do Ctrl-f /projects/a/*.sas, it will open all the sas files.
>> I want to do Ctrl-f /projects/a/, and only display .sas files,
>> so I can choose one. How do I do that?
>
> Use Icicles apropos completion:
>
> C-x C-f \.sas$ S-TAB, if the current directory is /projects/a, or
>
> C-x C-f /projects/a/.*\.sas$ S-TAB, otherwise.
>
> You match the file extension using the regular expression `\.sas$'. You
> need
> to escape the `.' preceding the `sas' file-extension with a backslash, or
> else it will match any character (except a newline) - as in the `.*',
> which
> matches any character any number of times. The `$' matches the end of the
> file name.
>
> When the list of matching file-name candidates is displayed, click
> `mouse-2'
> on the one you want. If you want to open multiple files, click `C-mouse-2'
> on each one you want.
>
> You can also cycle through the matching candidates with the `next' key,
> and
> use `RET' to choose the current one (or `C-RET' to choose more than one).
> You can also type a more specific match pattern, to match only certain SAS
> files.
>
> For example, `C-x C-f foo.*bar\.sas$ S-TAB' matches file names that start
> with `foo', contain also `bar', and end with `.sas'.
>
> You can also save a set of completions - for example, if you often use the
> same set of project files. Just use `C-M->' to save the current matches in
> a
> variable, or `C-u C-M->' to save them persistently in a cache file. Later,
> when you want to retrieve them for completion with `C-x C-f', use `C-M-<'
> (retrieve from a variable) or `C-u C-M-<' (retrieve from a cache file).
> You
> are prompted for the cache file name. You can have any number of variables
> or files that hold completion sets.
>
> http://www.emacswiki.org/cgi-bin/wiki/Icicles: doc
>
> http://www.emacswiki.org/cgi-bin/wiki/Icicles_-_Apropos_Completions: about
> apropos completion
>
>
>
>
>
> _______________________________________________
> help-gnu-emacs mailing list
> help-gnu-emacs@gnu.org
> http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
>
>
--
View this message in context: http://www.nabble.com/find-certain-files-tf3909138.html#a11086554
Sent from the Emacs - Help mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: find certain files
[not found] ` <mailman.2056.1181679859.32220.help-gnu-emacs@gnu.org>
@ 2007-06-12 20:38 ` Stefan Monnier
0 siblings, 0 replies; 11+ messages in thread
From: Stefan Monnier @ 2007-06-12 20:38 UTC (permalink / raw)
To: help-gnu-emacs
>>> Now I want to limit it to certain files that have certain
>>> extensions, for example, only sas files, *.sas. If if do Ctrl-f
>>> /projects/a/*.sas, it will open all the sas files. I want to do Ctrl-f
>>> /projects/a/, and only display .sas files, so I can choose one. How do I
>>> do that?
In my unreleased completion code (which is behaves similarly to
partial-completion-mode as a first approximation), I can do:
C-x C-f ~/toto/*.sas TAB
or even
C-x C-f ~/toto/**/*.sas TAB
so as to look in subdirectories as well. Sadly, it's not in a good shape
and will need a rewrite before it has a chance to making it into Emacs
(i.e. next century maybe).
Stefan
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: find certain files
2007-06-12 20:37 ` econfreerider
@ 2007-06-12 20:54 ` Drew Adams
0 siblings, 0 replies; 11+ messages in thread
From: Drew Adams @ 2007-06-12 20:54 UTC (permalink / raw)
To: Help-gnu-emacs
> Thanks a lot for the suggestions. I had a hard time using S-TAB:
> do I need to install Icicles?
Not sure what you mean.
No one _needs_ to install Icicles.
For your question, as Eli pointed out, you can use Dired. I thought you were
specifically looking for a solution involving `C-x C-f', but if you want to
use `RET' or `mouse-2' in Dired, it will do what you need here. You can also
use `%m' in Dired to mark files that match a regexp, in case you want to act
on a group of SAS files.
Do you mean that you have trouble typing the key sequence `S-TAB'? If you
want to use Icicles, but you don't like using `S-TAB', then you can use a
different key.
BTW, "installing" Icicles means only 1) downloading the files, 2) putting
them in your Emacs `load-path', 3) loading library `icicles', and 4) turning
on Icicle mode. You can do #2-4 in your .emacs file. You do #3-4 this way:
(require 'icicles)(icy-mode 1).
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: find certain files
[not found] <mailman.2048.1181678085.32220.help-gnu-emacs@gnu.org>
@ 2007-06-12 21:05 ` Mark Elston
2007-06-12 22:51 ` Drew Adams
0 siblings, 1 reply; 11+ messages in thread
From: Mark Elston @ 2007-06-12 21:05 UTC (permalink / raw)
To: help-gnu-emacs
* Drew Adams wrote (on 6/12/2007 12:54 PM):
>> I use Ctrl-f to find files in a directory, but...I want to
>> limit it to certain files...for example, only sas files, *.sas.
>> If if do Ctrl-f /projects/a/*.sas, it will open all the sas files.
>> I want to do Ctrl-f /projects/a/, and only display .sas files,
>> so I can choose one. How do I do that?
>
> Use Icicles apropos completion:
>
> C-x C-f \.sas$ S-TAB, if the current directory is /projects/a, or
>
> C-x C-f /projects/a/.*\.sas$ S-TAB, otherwise.
>
Drew,
I tried this (I have icicles installed) and got the following traceback:
Debugger entered--Lisp error: (error "Bad format environment-variable
substitution")
read-file-name-internal(".*\\.el$" "~/site-lisp-22/" t)
all-completions(".*\\.el$" read-file-name-internal "~/site-lisp-22/" nil)
icicle-unsorted-file-name-prefix-candidates(".*\\.el$")
icicle-file-name-prefix-candidates("~/site-lisp-22/.*\\.el$")
icicle-prefix-complete-1()
icicle-prefix-complete()
icicle-call-then-update-Completions(self-insert-command 1)
icicle-self-insert(1)
call-interactively(icicle-self-insert)
old-read-file-name(#("+ File or directory: " 0 1 nil 1 2 (face
icicle-completing-prompt-prefix) 2 3 nil 3 22 (face minibuffer-prompt))
nil "~/" nil nil nil)
byte-code(<...> [icicle-prompt dir default-filename require-match
initial-input predicate old-read-file-name] 7)] 2)
read-file-name("File or directory: " nil "~/" nil nil nil)
byte-code(<...> [emacs-major-version major-mode default-directory
icicle-find-file-w-wildcards 21 read-file-name "File or directory: " nil
dired-mode fboundp diredp-find-a-file (byte-code <...>
[abbreviate-file-name dired-get-file-for-visit] 2) ((error
default-directory))] 8)
icicle-find-file()
call-interactively(icicle-find-file)
This was while trying to open a number of files in a subdirectory.
I did
C-x C-f /site-lisp-22/.*\.el$
and, before I got the chance to try the S-tab I got the above traceback.
It seems to work OK with files in the current directory, though.
This is NT Emacs 22.0.50.1 with icicles Version 22.
Mark
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: find certain files
2007-06-12 21:05 ` Mark Elston
@ 2007-06-12 22:51 ` Drew Adams
0 siblings, 0 replies; 11+ messages in thread
From: Drew Adams @ 2007-06-12 22:51 UTC (permalink / raw)
To: Mark Elston, help-gnu-emacs
> > Use Icicles apropos completion:
> >
> > C-x C-f \.sas$ S-TAB, if the current directory is /projects/a, or
> > C-x C-f /projects/a/.*\.sas$ S-TAB, otherwise.
>
> I tried this (I have icicles installed) and got the following traceback:
>
> Debugger entered--Lisp error: (error "Bad format environment-variable
> substitution")
> read-file-name-internal(".*\\.el$" "~/site-lisp-22/" t)
> all-completions(".*\\.el$" read-file-name-internal
> "~/site-lisp-22/" nil)
> icicle-unsorted-file-name-prefix-candidates(".*\\.el$")
> icicle-file-name-prefix-candidates("~/site-lisp-22/.*\\.el$")
> icicle-prefix-complete-1()
> icicle-prefix-complete()
> icicle-call-then-update-Completions(self-insert-command 1)
> icicle-self-insert(1)
> call-interactively(icicle-self-insert)
> old-read-file-name(#("+ File or directory: " 0 1 nil 1 2 (face
> icicle-completing-prompt-prefix) 2 3 nil 3 22 (face minibuffer-prompt))
> nil "~/" nil nil nil)
> byte-code(<...> [icicle-prompt dir default-filename require-match
> initial-input predicate old-read-file-name] 7)] 2)
> read-file-name("File or directory: " nil "~/" nil nil nil)
> byte-code(<...> [emacs-major-version major-mode default-directory
> icicle-find-file-w-wildcards 21 read-file-name "File or directory: " nil
> dired-mode fboundp diredp-find-a-file (byte-code <...>
> [abbreviate-file-name dired-get-file-for-visit] 2) ((error
> default-directory))] 8)
> icicle-find-file()
> call-interactively(icicle-find-file)
>
> This was while trying to open a number of files in a subdirectory.
> I did C-x C-f /site-lisp-22/.*\.el$
> and, before I got the chance to try the S-tab I got the above traceback.
>
> It seems to work OK with files in the current directory, though.
>
> This is NT Emacs 22.0.50.1 with icicles Version 22.
Hi Mark,
The backtrace suggests that you did something like this:
C-x C-f /site-lisp-22/.*\.el$ TAB 1
Try that, and you will get exactly the same error message.
The backtrace suggests that you hit TAB, which is for prefix completion, not
apropos (aka regexp) completion, and then you hit `1' as a response to the
file-name prompt. I can tell this from the call to `icicle-prefix-complete',
not `icicle-apropos-complete', and the call to `icicle-self-insert' for the
character `1' as your response to the prompt from `read-file-name'.
It is not Icicles command `icicle-find-file' (`C-x C-f') that is complaining
here; it is vanilla Emacs `find-file' (called `old-find-file' in the trace).
It complains because it was passed the raw input pattern that you typed, and
it tries to interpret the `$' in that input as part of an environment
variable name (as in, e.g., `$HOME').
TAB in Icicles is the same as it is in vanilla Emacs: it performs only
prefix completion, not regexp completion. It simply passes your input to
vanilla Emacs `find-file'. For Icicles to interpret your input as a regular
expression to match a file name, you must use S-TAB, not TAB.
If you feel I'm wrong that you used TAB here, then let's take this off list
to discuss the problem in more detail.
You might also want to take a look at this page, which explains the
interaction between file-name globbing and Icicles regexp matching:
http://www.emacswiki.org/cgi-bin/wiki/Icicles_-_Special_Characters_in_Input_
Patterns.
The main lesson on that page is that file-name globbing (*, ?, $, ., ..) and
completion are independent. This is true in both vanilla Emacs and in
Icicles. For example, in vanilla Emacs, if you use `ici* or `ici*.el as
input to find-file and hit TAB, there is no completion available. In
Icicles you can use regexp matching for completion, and you can use
file-name globbing for the final input you choose.
Even though they are completely different syntaxes that interpret some of
the same special characters differently, you can combine the two in Icicles,
within some limits. For example, `$' is not a problem, because Icicles
figures out what you want. But if you want to use `*' for file-name
globbing, then you need to forego regexp matching, and vice versa.
So, for example, `C-x C-f *.el RET' and `C-x C-f .*\.el$ S-TAB' both work,
but they do entirely different things. The former opens all Emacs-Lisp
files; the latter proposes those files as completion candidates. And in
Icicles, as in vanilla Emacs, `C-x C-f *.el TAB' will not work - you get the
message "No prefix completion", because completion does not do file-name
globbing.
Let me know if I'm mistaken about the problem you reported. Thanks for
trying Icicles and for providing this feedback - I'm sure it will help
others too. - Drew
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: find certain files
[not found] <mailman.2060.1181681757.32220.help-gnu-emacs@gnu.org>
@ 2007-06-25 8:39 ` Mathias Dahl
0 siblings, 0 replies; 11+ messages in thread
From: Mathias Dahl @ 2007-06-25 8:39 UTC (permalink / raw)
To: help-gnu-emacs
"Drew Adams" <drew.adams@oracle.com> writes:
> You need here. You can also use `%m' in Dired to mark files that
> match a regexp, in case you want to act on a group of SAS files.
And then use the little "trick" typing t (toggle marks) and k (kill
marked lines) to see only the .sas files. I use this all the time.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2007-06-25 8:39 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-12 18:19 find certain files econfreerider
2007-06-12 19:54 ` Drew Adams
2007-06-12 20:37 ` econfreerider
2007-06-12 20:54 ` Drew Adams
2007-06-12 19:57 ` Eli Zaretskii
2007-06-12 20:24 ` econfreerider
[not found] ` <mailman.2056.1181679859.32220.help-gnu-emacs@gnu.org>
2007-06-12 20:38 ` Stefan Monnier
2007-06-12 20:02 ` Dieter Wilhelm
[not found] <mailman.2048.1181678085.32220.help-gnu-emacs@gnu.org>
2007-06-12 21:05 ` Mark Elston
2007-06-12 22:51 ` Drew Adams
[not found] <mailman.2060.1181681757.32220.help-gnu-emacs@gnu.org>
2007-06-25 8:39 ` Mathias Dahl
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.