[Top][All Lists]

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

Re: Completing with anything

From: Julien Danjou
Subject: Re: Completing with anything
Date: Mon, 21 Mar 2011 12:23:09 +0100
User-agent: Gnus/5.110016 (No Gnus v0.16) Emacs/24.0.50 (gnu/linux)

On Fri, Mar 18 2011, Stefan Monnier wrote:

> There's a misunderstanding: AFAIK the patch sent by Tassilo does not
> make the completion-at-point-function return a "function that performs
> completion" but does properly return completion data (i.e. region start,
> region end, and completion table), part of which happens to be
> represented by a function.
> I.e. this is not one of the discouraged cases.

You're right, indeed!

But I do not see anywhere the fact that the completion collection can be
a function.

I only found the sentence:

    "It would be consistent and clean for completion functions to allow
lambda expressions (lists that are functions) as well as function
symbols as COLLECTION, but this is impossible."

in (elisp) Programmed Completion.

Not sure it's really related to completion-at-point-functions, but well,
it's not making things clearer for me anyhow.

>> - Make completing code allows to replace the region being completed with
>>   somethig that does not match at all.
> AFAIK that's already the case, tho it depends on lots of factors, such
> as what you mean by "completing code".

I meant the code in minibuffer.el

To be clear, the things that disturbs me is that this simple test case
does not work as I would like it to:

#+begin_src emacs-lisp
(defun jd:completion-at-point-test ()
    (list (point-at-bol) (point) '("Steve" "John")))
(add-to-list 'completion-at-point-functions 'jd:completion-at-point-test)

If you run that code into a buffer, and then type in this same buffer:


And try to complete that "L" with M-x completion-at-point, it will say
"No match."

But if you do:
#+begin_src emacs-lisp
(defun jd:completion-at-point-test ()
    (list (point-at-bol) (point) '("Lionel" "Steve" "John")))
(add-to-list 'completion-at-point-functions 'jd:completion-at-point-test)

And try to complete a "L", it will complete to Lionel. Just because
completion-at-point is trying to be smarter than my function,
re-guessing which items from the collection are good candidates.
Something my function already does (well, not in this example, but in
real life).

This is why I'm (kindly) finger pointing the "completing code in
minibuffer.el", but I might be wrong (and hope to be! :-)).

Julien Danjou
❱ http://julien.danjou.info

Attachment: pgprujQu3552Y.pgp
Description: PGP signature

reply via email to

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