help-emacs-windows
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [h-e-w] Re: C-x C-f *.txt RET


From: Drew Adams
Subject: RE: [h-e-w] Re: C-x C-f *.txt RET
Date: Fri, 9 Jun 2006 08:43:46 -0700

    My smiley was just a reference to the Icicle solution. If all you
    wanted was a way to open all files with a certain file extension in a
    certain folder, the simple command above works well. If the directory
    (in my case c:/) does not contain any .txt files, a buffer called
    *.txt will be created.

    I know Icicles lets you do much cooler things, for example you can
    probably open all .txt files regardless of the directory they are in.

Yes, in vanilla Emacs, `C-x C-f *.txt' will open all existing files having
extension `txt' in the current directory, or it will open a new buffer
`*.txt' if no such file exists. This file-name globbing has always been
available in vanilla Emacs, AFAIK - Emacs 20, for instance.

Wrt Icicles -

In Icicles, this same, file-globbing behavior is available. What's different
in Icicles is that you can alternatively use regexp patterns to match file
names. In particular, you can match any file-name substring, not just a file
extension or a prefix (as in vanilla Emacs). For instance, you can use
`foo.*\.txt' (or `foo.*txt$') to match `foo' as a substring (anywhere) in
file names that have extension `txt' (or that simply end in `txt').

You can even use multiple regexps to match, say, multiple substrings that
appear in any order in the file name - for instance, use `foo' to match
names with substring `foo', and then use `bar' to filter and keep only those
that also have substring `bar' (whether `bar' occurs before or after `foo').
See http://www.emacswiki.org/cgi-bin/wiki/Icicles_-_Progressive_Completion
for more on this feature.

As you can guess, there is a mismatch between using `*' (as a shell
wildcard) for globbing and using `*' in a regexp - the two syntaxes are
completely different. Icicles resolves this dilemma by separating completion
(and candidate cycling) from input acceptance, and by having two kinds of
completion (and cycling): regexp and prefix (which is the vanilla Emacs
completion). `TAB' gives you the standard, prefix completion, and `S-TAB'
gives you regexp completion. In vanilla Emacs, there is also a separation of
globbing and completion, BTW: `foo*' and `foo*.el' are accepted and
correctly globbed, but they do not complete.

If you want to take advantage of file-name globbing in Icicles, then you use
prefix completion (`TAB'), foregoing regexp matching during completion.
Icicles does offer you a way to open all files whose names match a regexp,
but it does not use globbing for that. `C-!' during completion (regexp or
prefix) acts on all completion candidates, so, for `C-x C-f', `C-!' will
open all matching files (for `C-x k', `C-!' will kill all matching buffers,
and so on).

There are other characters, besides `*', that present similar syntax
dilemmas - `$' for regexps or for environment variables, `?' for regexps or
for completion help, `\' for regexps and as a directory separator (on
Windows). For more on how Icicles deals with special characters for
completion and input, see
http://www.emacswiki.org/cgi-bin/wiki/Icicles_-_Special_Characters_in_Input_
Patterns .






reply via email to

[Prev in Thread] Current Thread [Next in Thread]