From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel 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 Message-ID: References: <87haxoyff9.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1331918444 32547 80.91.229.3 (16 Mar 2012 17:20:44 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 16 Mar 2012 17:20:44 +0000 (UTC) Cc: emacs-devel@gnu.org To: Vitalie Spinu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Mar 16 18:20:43 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1S8apW-0002aq-Nq for ged-emacs-devel@m.gmane.org; Fri, 16 Mar 2012 18:20:42 +0100 Original-Received: from localhost ([::1]:46021 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S8apW-0000eU-2d for ged-emacs-devel@m.gmane.org; Fri, 16 Mar 2012 13:20:42 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:55745) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S8apO-0000Za-Q3 for emacs-devel@gnu.org; Fri, 16 Mar 2012 13:20:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S8apB-00026T-EY for emacs-devel@gnu.org; Fri, 16 Mar 2012 13:20:34 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:21846) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S8apB-000261-Bi for emacs-devel@gnu.org; Fri, 16 Mar 2012 13:20:21 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AicFAKU/KE9soXdS/2dsb2JhbACBX5x7eYhwnhmGGQSbGYQJ X-IronPort-AV: E=Sophos;i="4.73,1,1325480400"; d="scan'208";a="168383351" Original-Received: from 108-161-119-82.dsl.teksavvy.com (HELO fmsmemgm.homelinux.net) ([108.161.119.82]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 16 Mar 2012 13:20:19 -0400 Original-Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 2B3DAAE30D; Fri, 16 Mar 2012 13:20:19 -0400 (EDT) In-Reply-To: <87haxoyff9.fsf@gmail.com> (Vitalie Spinu's message of "Fri, 16 Mar 2012 12:05:14 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.94 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.181 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:149102 Archived-At: > 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 (=3D end (point)) > (list beg end (list "aaaa" "aaaaaaa" "bbbb" "truncat") :exclusive 'no)))= )) > (add-to-list 'completion-at-point-functions 'foo-completion)=20 > ;; 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=20 > 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 =E0 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