unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Vitalie Spinu <spinuvit@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: Completion with (:exclusive 'no) is called twice, and doesn't pass over on sole completion.
Date: Fri, 16 Mar 2012 13:20:19 -0400	[thread overview]
Message-ID: <jwv7gyklb5a.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87haxoyff9.fsf@gmail.com> (Vitalie Spinu's message of "Fri, 16 Mar 2012 12:05:14 +0100")

> The completion in Emacs 24 is called twice.  For example

> (defun foo-completion ()
>   (when (save-excursion (re-search-backward "\\<\\w*" (point-at-bol) t))
>     (let ((token (match-string-no-properties 0))
> 	  (beg (match-beginning 0))
> 	  (end (match-end 0)))
>       (message "%s:" token)
>       (when (= end (point))
> 	(list beg end (list "aaaa" "aaaaaaa" "bbbb" "truncat") :exclusive 'no)))))

> (add-to-list 'completion-at-point-functions 'foo-completion) 
> ;; it is now (foo-completion lisp-completion-at-point t)

> Place your point at the end of 'aaaa and you try to complete. I am
> getting 

> aaa:
> aaaa:

> in my message buffer.  Which means the completion is called twice.

Not sure why, but not terribly problematic either.

> I hope this is not an intended behavior, as it might seriously
> interfere with custom completion.  For example I might want to have
> a different behavior on the second consequent invocation of the
> completion (give a message, modify the candidates etc).

No, completion-at-point-functions should return completion data and
can't know what that data will be used for.  Could be for TAB
completion, for on-the-fly popup completion à la auto-complete, for
display of the *Completions* buffer, or to decide whether we're still in
the same completion field (so as to pop-down the *Completions* buffer
when we leave that field), ...

> Second problem is that if the completion is sole, the handling is not
> passed over.

That's expected: completion is only passed over if the text doesn't
match any candidate.


        Stefan



  parent reply	other threads:[~2012-03-16 17:20 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-16 11:05 Completion with (:exclusive 'no) is called twice, and doesn't pass over on sole completion Vitalie Spinu
2012-03-16 12:18 ` Vitalie Spinu
2012-03-16 17:20 ` Stefan Monnier [this message]
2012-03-16 19:33   ` Vitalie Spinu
2012-03-17 22:34     ` Stefan Monnier
2012-03-17 22:43       ` Lennart Borgman
2012-03-17 23:33       ` Vitalie Spinu
2012-03-18  2:03         ` Stefan Monnier
2012-03-18  9:35           ` Vitalie Spinu
2012-03-18 15:42             ` Stefan Monnier
2012-03-18 19:18               ` Vitalie Spinu
2012-03-19  0:53                 ` Stefan Monnier
2012-03-19  8:35                   ` Vitalie Spinu
2012-03-19 12:49                     ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwv7gyklb5a.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=spinuvit@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).