Re: A dynamic pattern-matching

From:

Stefan Monnier

Subject:

Re: A dynamic pattern-matching

Date:

Tue, 03 Mar 2009 14:16:28 -0500

User-agent:

Gnus/5.13 (Gnus v5.13) Emacs/23.0.90 (gnu/linux)

> I wrote a dynamic pattern-matching that restricts in real-time the
> display of a list of items to the ones matching the typed
> pattern. Since it uses a standard buffer it shows the said list over a
> large visual space, which is very practical.
So, IIUC, it could be described as:
like icomplete-mode except that
1- the list of completions is shown in a separate buffer.
2- that the cursor is shown in that separate buffer rather
than in the minibuffer.
3- that the current pattern is not shown in the minibuffer but in the
header-line (or mode-line).
4- that the completion is based on "substring match" rather than
"prefix match".
5- that you can specify an AND pattern.
6- the API is slightly different from completing-read.
It looks interesting. It'd be good to try and integrate it better with
the current completion code:
- it'd be easy to write a variant of icomplete-mode that addresses point
1 by using a separate buffer (which we'd call "*Completions*").
- I don't think point 3 is important, right?
- I guess point 2 is also somewhat secondary, tho it's important to have
a notion of "the currently selected entry" (this is also used in
ido/ibuffer and is somewhat missing in the default completion code)
- point 4 can be simulated by adding a "*" at the beginning of
the pattern. Or we could add a `substring' completion-style.
- point 5 hopefully can be implemented as a completion-style.
- point 6... not sure: it seems like the difference might be important,
along with the fact that the user may like to use this style of
selection for some commands but not all.
WDPT?
Stefan
PS: FWIW, when I tried
(add-hook 'minibuffer-setup-hook 'sm-minibuffer-setup-hook)
(defun sm-minibuffer-setup-hook ()
(add-hook 'post-command-hook 'sm-completions-update nil t))
(defun sm-completions-update ()
(if (and minibuffer-completion-table
(get-buffer-window "*Completions*" 'visible))
(minibuffer-completion-help)))
it seemed too slow to be bearable, so it would require some efforts to
speed things up.