[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Completion
From: |
Stefan Monnier |
Subject: |
Re: Completion |
Date: |
Sat, 01 Sep 2018 11:14:59 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
> Let's say the set is '("foo" "zot") and the string is "fo". Then
> there's one match, and it's unique, of course. But it's not exact? So
> should it return nil, then?
It should return "foo".
> 2) The entire `completing-read' machinery is based on prefix, matches
> and nothing else; is that right?
No. The *completion tables* (i.e. the "objects" that define what
completions are available) only offer methods that work for prefixes.
But `completing-read` uses completion commands which do a lot more than
just let the completion tables do the completion for them.
> That is, if you want to do completion on words inside strings (for
> instance, if you want "foo" to have a match in a collection string
> like "zot foo bar", then there is no built-in machinery in Emacs
> for this?
There's completion-try-completion and completion-all-completions, both
of which offer completions according to completion-styles.
> 3) The completion selection machinery in simple.el is nice, but it would
> be nice to be able to pass more information about the strings into it
> and get it all back after the user has chosen something. The obvious
> thing is to put a text property on the strings, and that almost, almost
> works, except for this:
>
> (defun choose-completion (&optional event)
> "Choose the completion at point.
> If EVENT, use EVENT's position to determine the starting position."
>
> [...]
>
> (setq end (or (next-single-property-change end 'mouse-face)
> (point-max)))
> (buffer-substring-no-properties beg end)))))
>
> If that had been just `buffer-substring', then the information would
> survive back to the caller.
>
> `minibuffer-allow-text-properties' exists. Would it make sense to add a
> new variable, like `completion-allow-text-properties', to handle this
> case as well?
We could, I guess. What's your use case?
Stefan