Subject: bug#6830: widget-complete bad completions in :type 'file

From: Eli Zaretskii <[email-masked]>
Date: Sun, 04 Mar 2012 19:06:16 +0200

> From: Chong Yidong <[email-masked]>
> Cc: [email-masked],  [email-masked]
> Date: Sun, 04 Mar 2012 17:37:57 +0800
> 
> As far as the completion code is concerned, the correct field to use is
> the `completion' field assigned by completion-in-region.  In this case,
> it's a mistake to pay attention to the underlying widget field.  So why
> doesn't it work to give the `completion' overlay a higher priority?

See this fragment from 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;

What do you get on GNU/Linux for the values of `field',
`before_field', and `after_field'?

> FWIW, increasing the priority of the `completion' overlay does not cause
> widget file name completion to fail on GNU/Linux.  Could you try on
> Windows?

Give me a patch to try, and I will.