Subject: bug#51218: 28.0.60; python.el: Native completion strikes again

From: Stefan Kangas <[email-masked]>
Date: Sat, 30 Oct 2021 08:53:46 -0700

close 51218 28.1
thanks

Carlos Pita <[email-masked]> writes:

> here's another problem with native completion. If in ~/.inputrc you
> customize completion-prefix-display-length to, say, 5, then this won't
> work:
>
>     import numpy
>     numpy.<complete>
>
> while this still works:
>
>     import numpy as np
>     np.<complete>
>
> The reason is that readline will truncate a prefix of the dummy
> completions, throwing something like:
>
> ...my_completion__[0m[K  ...my_completion__[0m[K
>
> instead of:
>
> 0__dummy_completion__[0m[K  1__dummy_completion__[0m[K
>
> I can write a patch passing a different value to
> completion-prefix-display-length but this is getting tiresome and I
> reiterate my plea for removal of at least the native completion backend.
> I argued elsewhere for removal of all automagical stuff that depends on
> stdin/out manipulation (i.e. c-a-p and eldoc) but we can start small
> removing just the native part for now.

Yes, this makes sense, so I have now pushed your below patch to emacs-28
(commit 4a96f32def).

Carlos Pita <[email-masked]> writes:

> In any case, here is the patch to toggle that option off.
>
>>>From a8caf24c7af05d9d1f92f52632cfe7ccefd3f2dd Mon Sep 17 00:00:00 2001
> From: Carlos Pita <[email-masked]>
> Date: Thu, 14 Oct 2021 21:48:43 -0300
> Subject: [PATCH] Avoid replacing common prefix with ellipsis
>
> * lisp/progmodes/python.el
> (python-shell-completion-native-setup): Configure readline not to
> suppress common prefixes.
> ---
>  lisp/progmodes/python.el | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
> index 54e3789c66..1da7e18635 100644
> --- a/lisp/progmodes/python.el
> +++ b/lisp/progmodes/python.el
> @@ -3711,6 +3711,8 @@ python-shell-completion-native-setup
>              readline.parse_and_bind('tab: complete')
>              # Require just one tab to send output.
>              readline.parse_and_bind('set show-all-if-ambiguous on')
> +            # Avoid replacing common prefix with ellipsis.
> +            readline.parse_and_bind('set completion-prefix-display-length 0')
>
>          print ('python.el: native completion setup loaded')
>      except: