From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#6830: widget-complete bad completions in :type 'file Date: Wed, 07 Mar 2012 17:09:56 -0500 Message-ID: References: <871v99wgb1.fsf@stupidchicken.com> <87tym5ufk0.fsf@stupidchicken.com> <83ty2grpn0.fsf@gnu.org> <87d393zj1l.fsf@gnu.org> <83linrs8rj.fsf@gnu.org> <87sjhoiu4q.fsf@gnu.org> <83zkbw9tyv.fsf@gnu.org> <87boobd9tr.fsf@gnu.org> <83linf9cup.fsf@gnu.org> <83ipii9ylf.fsf@gnu.org> <83d38pa0yl.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1331158302 1540 80.91.229.3 (7 Mar 2012 22:11:42 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 7 Mar 2012 22:11:42 +0000 (UTC) Cc: 6830@debbugs.gnu.org, cyd@gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Mar 07 23:11:40 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1S5P59-000283-9i for geb-bug-gnu-emacs@m.gmane.org; Wed, 07 Mar 2012 23:11:39 +0100 Original-Received: from localhost ([::1]:56761 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S5P58-0005sd-H9 for geb-bug-gnu-emacs@m.gmane.org; Wed, 07 Mar 2012 17:11:38 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:54439) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S5P54-0005rX-DW for bug-gnu-emacs@gnu.org; Wed, 07 Mar 2012 17:11:35 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S5P52-0004wf-HH for bug-gnu-emacs@gnu.org; Wed, 07 Mar 2012 17:11:33 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:59457) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S5P52-0004wL-64 for bug-gnu-emacs@gnu.org; Wed, 07 Mar 2012 17:11:32 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1S5P5W-0004bM-HR for bug-gnu-emacs@gnu.org; Wed, 07 Mar 2012 17:12:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 07 Mar 2012 22:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 6830 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 6830-submit@debbugs.gnu.org id=B6830.133115828217615 (code B ref 6830); Wed, 07 Mar 2012 22:12:02 +0000 Original-Received: (at 6830) by debbugs.gnu.org; 7 Mar 2012 22:11:22 +0000 Original-Received: from localhost ([127.0.0.1]:38049 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1S5P4q-0004Zp-6Z for submit@debbugs.gnu.org; Wed, 07 Mar 2012 17:11:21 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:2761) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1S5P4V-0004Z2-4E for 6830@debbugs.gnu.org; Wed, 07 Mar 2012 17:11:09 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AicFAKU/KE9FxJvl/2dsb2JhbACBX5x7eYhwnhmGGQSGUJRJhAs X-IronPort-AV: E=Sophos;i="4.73,1,1325480400"; d="scan'208";a="166553640" Original-Received: from 69-196-155-229.dsl.teksavvy.com (HELO fmsmemgm.homelinux.net) ([69.196.155.229]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 07 Mar 2012 17:09:57 -0500 Original-Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id C65906002; Wed, 7 Mar 2012 17:09:56 -0500 (EST) In-Reply-To: <83d38pa0yl.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 06 Mar 2012 23:12:02 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.94 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:57559 Archived-At: > The value of `field' on MS-Windows is neither `boundary' nor nil. > It is the value of the widget itself. Here's just its beginning, as an > illustration: Oh, I think I see, now. There are 2 overlays defining a field: one if the setup by the completion code, the other by the widget code. both cover the same text area, so using either would be fine. Now since both overlays cover the exact same area, and have no `priority', none has priority over the other, so which of the two is used depends on arbitrary details, e.g. implementation of the `sort' function. Now, until here, there's still no bug because indeed it doesn't matter which overlay we use to determine the field. The bug comes up because one overlay is used to get `field' and the other is used to get `before_field'. I.e. the "arbitrary details" end up making a different choice. This is probably due to the presence of the boundary overlay, so `before_field' is computed based on the two main overlays only (because at that position, the boundary overlay is absent), whereas for `field', we take the overlays at the end pos, where we have the two main overlays plus the boundary overlay, so the sort is applied to a different list of overlays, resulting in a different ordering of the two overlays we care about. Does the patch below fix the problem? Stefan === modified file 'src/buffer.c' --- src/buffer.c 2012-03-02 15:57:16 +0000 +++ src/buffer.c 2012-03-07 22:08:13 +0000 @@ -2864,7 +2864,11 @@ return s1->beg < s2->beg ? -1 : 1; if (s1->end != s2->end) return s2->end < s1->end ? -1 : 1; - return 0; + /* Avoid the non-determinism of qsort by choosing an arbitrary ordering + between "equal" overlays. The result can still change between + invocations of Emacs, but it won't change in the middle of + `find_field' (bug#6830). */ + return XHASH (s1->overlay) < XHASH (s2->overlay) ? -1 : 1; } /* Sort an array of overlays by priority. The array is modified in place.