all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#14061: 24.3.50; Globbing in completion not working correctly
@ 2013-03-26 22:37 Michael Heerdegen
  2013-03-27  0:44 ` Michael Heerdegen
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Heerdegen @ 2013-03-26 22:37 UTC (permalink / raw)
  To: 14061


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)






^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#14061: 24.3.50; Globbing in completion not working correctly
  2013-03-26 22:37 bug#14061: 24.3.50; Globbing in completion not working correctly Michael Heerdegen
@ 2013-03-27  0:44 ` Michael Heerdegen
  2013-03-27  2:49   ` Michael Heerdegen
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Heerdegen @ 2013-03-27  0:44 UTC (permalink / raw)
  To: 14061

Michael Heerdegen <michael_heerdegen@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





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#14061: 24.3.50; Globbing in completion not working correctly
  2013-03-27  0:44 ` Michael Heerdegen
@ 2013-03-27  2:49   ` Michael Heerdegen
  2013-03-27 14:41     ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Heerdegen @ 2013-03-27  2:49 UTC (permalink / raw)
  To: 14061

Michael Heerdegen <michael_heerdegen@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.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#14061: 24.3.50; Globbing in completion not working correctly
  2013-03-27  2:49   ` Michael Heerdegen
@ 2013-03-27 14:41     ` Stefan Monnier
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2013-03-27 14:41 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: 14061-done

> 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





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-03-27 14:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-26 22:37 bug#14061: 24.3.50; Globbing in completion not working correctly Michael Heerdegen
2013-03-27  0:44 ` Michael Heerdegen
2013-03-27  2:49   ` Michael Heerdegen
2013-03-27 14:41     ` Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.