unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Chong Yidong <cyd@gnu.org>
Cc: 6830@debbugs.gnu.org
Subject: bug#6830: widget-complete bad completions in :type 'file
Date: Sat, 25 Feb 2012 08:54:24 +0200	[thread overview]
Message-ID: <83linrs8rj.fsf@gnu.org> (raw)
In-Reply-To: <87d393zj1l.fsf@gnu.org>

> From: Chong Yidong <cyd@gnu.org>
> Cc: Glenn Morris <rgm@gnu.org>,  6830@debbugs.gnu.org
> Date: Sat, 25 Feb 2012 11:30:30 +0800
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > On GNU/Linux, the first overlay in the sorted array happens to be the
> > one whose `field' value is equal to the text property, so find_field
> > works.  On MS-Windows, the first overlay is the one whose value is
> > `completion', so find_field decides that the field begins and ends at
> > the same position.  The rest, as they say, is history.
> 
> Interesting.  The overlays code should be independent of operating
> system.  Any idea what causes the sort order to be different?

I think it's quite clear: the internal details of how qsort is
implemented on each system.

> Does the problem go away if in
> 
>     (let ((minibuffer-completion-table collection)
>           (minibuffer-completion-predicate predicate)
>           (ol (make-overlay start end nil nil t)))
>       (overlay-put ol 'field 'completion)
> 
> you also specify a `priority' of (say) 5?

I didn't try, but I don't see how this would help.  The above overlay
_is_ the cause of the problem: it causes find_field to fail work as
expected.  Here's the relevant fragment of find_field:

  before_field
    = (XFASTINT (pos) > BEGV
       ? get_char_property_and_overlay (make_number (XINT (pos) - 1),
					Qfield, Qnil, NULL)
       /* Using nil here would be a more obvious choice, but it would
          fail when the buffer starts with a non-sticky field.  */
       : after_field);

  /* See if we need to handle the case where MERGE_AT_BOUNDARY is nil
     and POS is at beginning of a field, which can also be interpreted
     as the end of the previous field.  Note that the case where if
     MERGE_AT_BOUNDARY is non-nil (see function comment) is actually the
     more natural one; then we avoid treating the beginning of a field
     specially.  */
  if (NILP (merge_at_boundary))
    {
      Lisp_Object field = get_pos_property (pos, Qfield, Qnil);
      if (!EQ (field, after_field))
	at_field_end = 1;
      if (!EQ (field, before_field))
	at_field_start = 1;

The last comparison of `field' with `before_field' is the culprit: to
work correctly, they must be equal, but the above overlay causes
get_char_property_and_overlay to return `completion' instead of the
expected field value, so find_field decides we are both at the
beginning and at the end of the field, i.e. the field is empty.

Having the priority of the above overlay higher will just cause the
completion fail on GNU/Linux as well, AFAIU.  We would need this
overlay to have a _lower_ priority, for the code to DTRT, but (a) the
ELisp manual says not to use negative priorities, and (b) doing so
might very well cause trouble elsewhere, if the completion code calls
get-char-property-and-overlay and expects to get the `completion'
thing back.





  parent reply	other threads:[~2012-02-25  6:54 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-09 11:45 bug#6830: widget-complete bad completions in :type 'file Lennart Borgman
2010-09-04 17:48 ` Chong Yidong
2010-09-04 22:16   ` Lennart Borgman
2010-09-05  1:47     ` Chong Yidong
2012-02-22 21:33       ` Glenn Morris
2012-02-22 23:02         ` Drew Adams
2012-02-22 23:51           ` Drew Adams
2012-02-23  3:57           ` Glenn Morris
2012-02-23 15:27             ` Drew Adams
2012-02-24 19:38               ` Eli Zaretskii
2012-02-25 12:16                 ` Richard Stallman
2012-02-24 19:35         ` Eli Zaretskii
2012-02-24 19:47           ` Drew Adams
2012-02-25  3:30           ` Chong Yidong
2012-02-25  5:26             ` Stefan Monnier
2012-02-25  7:45               ` Eli Zaretskii
2012-02-25  6:54             ` Eli Zaretskii [this message]
2012-03-04  9:37               ` Chong Yidong
2012-03-04 17:06                 ` Eli Zaretskii
2012-03-05  3:07                   ` Chong Yidong
2012-03-05 17:28                     ` Eli Zaretskii
2012-03-05 21:28                       ` Stefan Monnier
2012-03-06  3:50                         ` Eli Zaretskii
2012-03-06 20:45                           ` Stefan Monnier
2012-03-06 21:12                             ` Eli Zaretskii
2012-03-07 22:09                               ` Stefan Monnier
2012-03-09  9:14                                 ` Eli Zaretskii
2012-03-09 16:35                                   ` Stefan Monnier
2012-03-09 16:46                                   ` Stefan Monnier
2012-03-12  8:36 ` Paul Eggert

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=83linrs8rj.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=6830@debbugs.gnu.org \
    --cc=cyd@gnu.org \
    /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).