emacs-devel
[Top][All Lists]
Advanced

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

Re: CVS directories in completion-ignored-extensions


From: Miles Bader
Subject: Re: CVS directories in completion-ignored-extensions
Date: 06 Jan 2004 09:08:25 +0900

Richard Stallman <address@hidden> writes:
> > I've always thought it would be nice, instead of having multiple
> > variables each of which contain a different types of entry, to have
> > something like `completion-ignored-names', where each element could
> > be either: a string (which is matched using just `equal'), or a list
> > like (regexp REGEXP), which the matcher would treat accordingly.
> 
> That is a good idea.

Ok, how about something like:

   (defun string-matcher-member (string matcher)
     "Return non-nil if STRING is matched by the `string matcher' MATCHER.
   MATCHER should be a list, where each element is either a string,
   which will be compared with STRING using `equal', or a cons of the
   form (regexp REGEXP), in which case REGEXP will be compared with
   STRING using `string-match'.  The actual return value is the first
   element of MATCHER that matches."
     (let (test)
       (while matcher
         (setq test (pop matcher))
         (if (cond ((stringp test) 
                    (equal string test))
                   ((eq (car-safe test) 'regexp)
                    (if (consp (cdr test))
                        (string-match (car-safe (cdr-safe test)) string)
                      (string-match (cdr-safe test) string))))
             (setq matcher nil)
           (setq test nil)))
       test))

The name `string-matcher-member' is kind of ugly, but at least it
seems fairly clear; maybe someone can think of a better name.

The nice thing is that this is basically backward-compatible with existing
lists of strings that are matched exactly, so perhaps some of them could
be retro-fitted accordingly (e.g.  `dabbrev-ignored-buffer-names').

[`special-display-buffer-names' is similar (it has a corresponding
`special-display-regexps'), but because it itself gives special treatment
to list members that are cons-cells, doesn't fit exactly into such a
scheme (maybe it could be finessed, I don't know).]

-Miles
-- 
`Suppose Korea goes to the World Cup final against Japan and wins,' Moon said.
`All the past could be forgiven.'   [NYT]





reply via email to

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