unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Ignore patterns for find-file tab completion?
@ 2006-10-29 17:58 Andy Gimblett
  2006-10-29 18:04 ` Leo
  2006-10-29 18:38 ` Drew Adams
  0 siblings, 2 replies; 4+ messages in thread
From: Andy Gimblett @ 2006-10-29 17:58 UTC (permalink / raw)


Hi there,

I've been using emacs for about five years now; I know my way around
reasonably well, but haven't done any elisp programming other than
very simple stuff in my .emacs (a couple of lines at most).  I've just
joined this list in order to ask a question regarding tab completion
when opening a file using find-file (ie just with C-x C-f).

In short: is it possible to specify a pattern for files to be
_ignored_ in this context?

Motivation:

  1. I program in Haskell (sometimes).

  2. Haskell source files have the suffix .hs (eg foo.hs)

  3. A by-product of their compilation are .hi files (eg foo.hi), in
     the same directory.

  4. .hi files are not something I would ever, ever, want to load into
     emacs.

  5. Thus, I'd like to ignore them when trying to open a file.

At the moment, given a directory containing a mix of .hs and .hi
files, find-file's tab completion will typically get as far as ".h"
(eg "foo.h") but then it has a choice between foo.hs and foo.hi, so it
stops and I have to explicitly enter the "s".  This is annoying
because:

  a) I never want the .hi file, so it's a pointless question which I
     would hope could be avoided;

  b) If I forget, and just hit return, it tries to open "foo.h", which
     almost certainly doesn't exist, so I get an empty buffer which I
     then have to close before reattemting the find-file.

Surely this is a common thing to want to do?  Is this a solved
problem?

Thanks!

-Andy

-- 
Andy Gimblett
Computer Science Department
University of Wales Swansea
http://www.cs.swan.ac.uk/~csandy/

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

* Re: Ignore patterns for find-file tab completion?
  2006-10-29 17:58 Ignore patterns for find-file tab completion? Andy Gimblett
@ 2006-10-29 18:04 ` Leo
  2006-10-29 18:38 ` Drew Adams
  1 sibling, 0 replies; 4+ messages in thread
From: Leo @ 2006-10-29 18:04 UTC (permalink / raw)


On Sun, 29/10/06, Andy Gimblett wrote:

> Hi there,
>
> I've been using emacs for about five years now; I know my way around
> reasonably well, but haven't done any elisp programming other than
> very simple stuff in my .emacs (a couple of lines at most).  I've just
> joined this list in order to ask a question regarding tab completion
> when opening a file using find-file (ie just with C-x C-f).
>
> In short: is it possible to specify a pattern for files to be
> _ignored_ in this context?
>
> Motivation:
>
>   1. I program in Haskell (sometimes).
>
>   2. Haskell source files have the suffix .hs (eg foo.hs)
>
>   3. A by-product of their compilation are .hi files (eg foo.hi), in
>      the same directory.
>
>   4. .hi files are not something I would ever, ever, want to load into
>      emacs.
>
>   5. Thus, I'd like to ignore them when trying to open a file.
>
> At the moment, given a directory containing a mix of .hs and .hi
> files, find-file's tab completion will typically get as far as ".h"
> (eg "foo.h") but then it has a choice between foo.hs and foo.hi, so it
> stops and I have to explicitly enter the "s".  This is annoying
> because:
>
>   a) I never want the .hi file, so it's a pointless question which I
>      would hope could be avoided;
>
>   b) If I forget, and just hit return, it tries to open "foo.h", which
>      almost certainly doesn't exist, so I get an empty buffer which I
>      then have to close before reattemting the find-file.
>
> Surely this is a common thing to want to do?  Is this a solved
> problem?
>
> Thanks!
>
> -Andy

It seems ido well suits your needs. it is located in
'emacs/23.0.0/lisp/ido.el.gz' in my system.

-- 
Leo

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

* RE: Ignore patterns for find-file tab completion?
  2006-10-29 17:58 Ignore patterns for find-file tab completion? Andy Gimblett
  2006-10-29 18:04 ` Leo
@ 2006-10-29 18:38 ` Drew Adams
  2006-10-29 19:44   ` Andy Gimblett
  1 sibling, 1 reply; 4+ messages in thread
From: Drew Adams @ 2006-10-29 18:38 UTC (permalink / raw)


    .hi files are not something I would ever, ever, want to load into
    emacs. Thus, I'd like to ignore them when trying to open a file.

    Surely this is a common thing to want to do?  Is this a solved
    problem?

Yes, it is a common thing to do. You can customize option
`completion-ignored-extensions' so that files with a given extension (e.g.
hi) are ignored for completion. That should do exactly what you want.

FYI - If you use Icicles (http://www.emacswiki.org/cgi-bin/wiki/Icicles),
you can, in addition, exclude completion candidates in a few additional
ways.

1. You can use `C-~' on the fly to complement the current set of completion
candidates (file names, buffer names, etc.). For example, type `C-x b foo'
and then `C-~' to match all buffers that do not start with `foo' (or do not
contain `foo', if you complete with `S-TAB').

2. You can exclude any number of different patterns by combining `C-~' with
`M-*', which lets you match against additional patterns. For example, to
exclude all completion candidates that match `toto', `titi', or `foobar',
you would type this:
  `toto C-~ M-* titi C-~ M-* foobar'

This is useful for apropos completion (`S-TAB'), where your input is matched
against any part of a candidate name (actually, your input is taken as a
regexp).

3. If you often want to exclude certain buffers as candidates, you can
create and save a buffer configuration that uses variable
`icicle-no-match-regexp' to exclude those buffers whenever that
configuration is used. See commands `icicle-add-buffer-config' and
`icicle-buffer-config'.

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

* Re: Ignore patterns for find-file tab completion?
  2006-10-29 18:38 ` Drew Adams
@ 2006-10-29 19:44   ` Andy Gimblett
  0 siblings, 0 replies; 4+ messages in thread
From: Andy Gimblett @ 2006-10-29 19:44 UTC (permalink / raw)


On Sun, Oct 29, 2006 at 10:38:27AM -0800, Drew Adams wrote:
> 
> Yes, it is a common thing to do. You can customize option
> `completion-ignored-extensions' so that files with a given extension
> (e.g.  hi) are ignored for completion. That should do exactly what
> you want.

Perfect.  Many thanks - that is indeed exactly what I wanted.

Thanks!

-Andy

-- 
Andy Gimblett
Computer Science Department
University of Wales Swansea
http://www.cs.swan.ac.uk/~csandy/

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

end of thread, other threads:[~2006-10-29 19:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-29 17:58 Ignore patterns for find-file tab completion? Andy Gimblett
2006-10-29 18:04 ` Leo
2006-10-29 18:38 ` Drew Adams
2006-10-29 19:44   ` Andy Gimblett

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).