[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: completing-read return meta-information?
From: |
Stephen Leake |
Subject: |
Re: completing-read return meta-information? |
Date: |
Mon, 21 Sep 2015 11:46:50 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (windows-nt) |
Stefan Monnier <address@hidden> writes:
>> There is a desire to refactor this so that the only difference is inside
>> the completion table.
>
> I think the uniquification shouldn't be done in the completion table.
>
> All the fancy rewriting to make things shorter should be done in the
> completion-style, instead. The style code can choose to return different
> kinds of results for completion-all-completions (which gets displayed
> in *Completions*, in Company, or in Icomplete-mode and where we should
> try and reduce redundancy) and for completion-try-completion.
>
> So completion-all-completions can return names like "foo<bar>" while
> completion-try-completion can return "~/src/file/foo/toto/bar.agda".
Attached is code that implements this, together with ert test code for
it (helpful in getting the details right).
This achieves the goal of moving all of the uniquification code out of
the completion table; that required advice on test-completion.
It also achieves the goal of returning an absolute string from
completing-read; that required advice on completing-read-default to call
the new function completion-get-data-string.
Note that this does not handle completion on multiple fields (for
uniquifying directories); I was focusing on the changes to completion
needed to return an absolute file name. That will be added later, and
may require design changes
See the header comment in minibuffer-patches.el for some design notes.
This may be an acceptable implementation, but it would be better to
extend completion-style-alist to include slots for
completion-test-completion and completion-get-data-string. I think that
can be done in a backward-compatible way; if (nth 2
completion-style-alist) (for completion-test-completion) returns a
string, just call test-completion, and if (nth 3 completion-style-alist)
(for completion-get-data-string) returns nil just return the input
string.
Then we can change all uses of `test-completion' to call
`completion-test-completion'.
I'm not entirely sure where the call to completion-get-data-string
should be added; one place is in `completion--complete-and-exit', but
there may be others. (I didn't advise completion--complete-and-exit
directly because I didn't want to mix advice and signals).
To try this out, load minibuffer-patches, and call find-absfile
via M-: (find-absfile load-path).
Note that will not allow you to complete to ede/locate.el; that will
also be added later.
When you enter a string that does not match any filename, this gives an
error from one of the basic completion functions; I have not tried to
track that down yet.
--
-- Stephe
minibuffer-patches.el
Description: application/emacs-lisp
minibuffer-test.el
Description: application/emacs-lisp
- completing-read return meta-information?, Stephen Leake, 2015/09/16
- RE: completing-read return meta-information?, Drew Adams, 2015/09/16
- Re: completing-read return meta-information?, Stephen Leake, 2015/09/16
- Re: completing-read return meta-information?, Stephen Leake, 2015/09/16
- Re: completing-read return meta-information?, Stefan Monnier, 2015/09/16
- Re: completing-read return meta-information?, Stephen Leake, 2015/09/17
- Re: completing-read return meta-information?, Stefan Monnier, 2015/09/17
- Re: completing-read return meta-information?, Dmitry Gutov, 2015/09/17
- Re: completing-read return meta-information?, Stefan Monnier, 2015/09/17
- Re: completing-read return meta-information?,
Stephen Leake <=
- Re: completing-read return meta-information?, Stephen Leake, 2015/09/21
- Re: completing-read return meta-information?, Stefan Monnier, 2015/09/21
- Re: completing-read return meta-information?, Stephen Leake, 2015/09/22
- Re: completing-read return meta-information?, Stephen Leake, 2015/09/26
- Re: completing-read return meta-information?, Stefan Monnier, 2015/09/27
- Re: completing-read return meta-information?, Dmitry Gutov, 2015/09/28
- Re: completing-read return meta-information?, Stephen Leake, 2015/09/29
- Re: completing-read return meta-information?, Stephen Leake, 2015/09/29
- Re: completing-read return meta-information?, Stefan Monnier, 2015/09/29
- Re: completing-read return meta-information?, Dmitry Gutov, 2015/09/28