GNU bug report logs - #14061
24.3.50; Globbing in completion not working correctly

Previous Next

Package: emacs;

Reported by: Michael Heerdegen <michael_heerdegen <at> web.de>

Date: Tue, 26 Mar 2013 22:41:02 UTC

Severity: normal

Found in version 24.3.50

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 14061 in the body.
You can then email your comments to 14061 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#14061; Package emacs. (Tue, 26 Mar 2013 22:41:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Michael Heerdegen <michael_heerdegen <at> web.de>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 26 Mar 2013 22:41:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.3.50; Globbing in completion not working correctly
Date: Tue, 26 Mar 2013 23:37:29 +0100
Hi,

In emacs -Q, eval

  (require 'bytecomp) ; just for the defvar

Now 

   C-h v *compil*warn* TAB TAB

"byte-compile-warnings" should be among the matches, but that's not
the case.


Thanks,

Michael.




In GNU Emacs 24.3.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.4.2)
 of 2013-03-17 on dex, modified by Debian
 (emacs-snapshot package, version 2:20130317-1)
Windowing system distributor `The X.Org Foundation', version 11.0.10707000
System Description:	Debian GNU/Linux 7.0 (wheezy)





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14061; Package emacs. (Wed, 27 Mar 2013 00:48:02 GMT) Full text and rfc822 format available.

Message #8 received at 14061 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: 14061 <at> debbugs.gnu.org
Subject: Re: bug#14061: 24.3.50; Globbing in completion not working correctly
Date: Wed, 27 Mar 2013 01:44:39 +0100
Michael Heerdegen <michael_heerdegen <at> web.de> writes:

>    C-h v *compil*warn* TAB TAB
>
> "byte-compile-warnings" should be among the matches, but that's not
> the case.

Looks like `completion-pcm--merge-completions' is introducing the error:

(completion-pcm--merge-completions
 '("byte-compile-error-on-warn"
   "byte-compile-warning-types"
   "byte-compile-warnings"
   "byte-compile-last-warned-form")
 '(star "compil" star "warn"))

==>

(any "warn" "-" star "compile-" "byte-")
             ^               ^
Note the two hyphens.


Regards,

Michael




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14061; Package emacs. (Wed, 27 Mar 2013 02:53:02 GMT) Full text and rfc822 format available.

Message #11 received at 14061 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: 14061 <at> debbugs.gnu.org
Subject: Re: bug#14061: 24.3.50; Globbing in completion not working correctly
Date: Wed, 27 Mar 2013 03:49:38 +0100
Michael Heerdegen <michael_heerdegen <at> web.de> writes:

> >    C-h v *compil*warn* TAB TAB
> >
> > "byte-compile-warnings" should be among the matches, but that's not
> > the case.
>
> Looks like `completion-pcm--merge-completions' is introducing the error:
>
> (completion-pcm--merge-completions
>  '("byte-compile-error-on-warn"
>    "byte-compile-warning-types"
>    "byte-compile-warnings"
>    "byte-compile-last-warned-form")
>  '(star "compil" star "warn"))
>
> ==>
>
> (any "warn" "-" star "compile-" "byte-")

Some more thoughts:

In the definition of `completion-pcm--merge-completions', we have

  (when (memq elem '(star point prefix))
    ;; Extract common suffix additionally to common prefix.
    ;; Only do it for `point', `star', and `prefix' since for
    ;; `any' it could lead to a merged completion that
    ;; doesn't itself match the candidates.
    (let ((suffix (completion--common-suffix comps)))
      (cl-assert (stringp suffix))
      (unless (equal suffix "")
        (push suffix res))))

In the pathological cases, the `suffix' includes a hyphen that is
already included in the prefix:

  (completion-pcm--merge-completions
   '("byte-compile-error-on-warn"
     "byte-compile-warning-types"
     "byte-compile-warnings"
     "byte-compile-last-warned-form")
   '(star "compil" star "warn"))       ;; suffix == "-"

  (completion-pcm--merge-completions
   '("byte-compile-a-warning-types"
     "byte-compile-a-test-warning-types")
   '(star "compile" star "types"))     ;; suffix == "-warning-"

but not all cases where `suffix' starts with "-" are problematic:

  (completion-pcm--merge-completions
   '("byte-compile-a-c-b-warning-types"
     "byte-compile-a-test-b-warning-types")
   '(star "compile" star "types"))

so it would be wrong to remove a leading "-" from `suffix'
unconditionally.

Dunno what a good fix would look like.  It tried

  (let* ((pre-length (length prefix))
         (suffix (completion--common-suffix
                  (mapcar (lambda (comp) (substring comp pre-length))
                          comps))))
    (cl-assert (stringp suffix))
    (unless (equal suffix "")
      (push suffix res)))

which seems to work, but my insight in this code is limited.


HTH,

Michael.




Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Wed, 27 Mar 2013 14:44:02 GMT) Full text and rfc822 format available.

Notification sent to Michael Heerdegen <michael_heerdegen <at> web.de>:
bug acknowledged by developer. (Wed, 27 Mar 2013 14:44:02 GMT) Full text and rfc822 format available.

Message #16 received at 14061-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 14061-done <at> debbugs.gnu.org
Subject: Re: bug#14061: 24.3.50; Globbing in completion not working correctly
Date: Wed, 27 Mar 2013 10:41:21 -0400
> Dunno what a good fix would look like.  It tried

>   (let* ((pre-length (length prefix))
>          (suffix (completion--common-suffix
>                   (mapcar (lambda (comp) (substring comp pre-length))
>                           comps))))
>     (cl-assert (stringp suffix))
>     (unless (equal suffix "")
>       (push suffix res)))

> which seems to work, but my insight in this code is limited.

You were right on the money.  I installed a slightly refined fix, which
tries to optimize away a few cases.
Thank you,


        Stefan




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 25 Apr 2013 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 56 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.