bug#34776: 27.0.50; Some questions about choose-completion-string-functions

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

bug#34776: 27.0.50; Some questions about choose-completion-string-functions

Eric Abrahamsen-2

I'm trying to use `choose-completion-string-functions' to do some
"stuff" after the user finishes a completion, and have two questions:

1. The docstring of this variable says it is called with three
   arguments, but in fact it's called with four: the fourth is passed as
   nil, and is only there for backward compatibility, apparently. But
   still, you can't use a function that only accepts three args. I can
   provide a patch for the docstring if this is correct.
2. The code in `choose-completion-string' behaves as though the above
   variable is buffer local, but it is never declared to be so. I'm not
   sure if this is a bug (ie, we should be using `defvar-local'), or
   whether I should be adding functions here using the (local 'SYMBOL)
   convention of `add-function'. If that's the case, that's probably
   also a docstring bug, as we should warn users that they'll want to
   specify a local variable.

WDYT?

Eric



Reply | Threaded
Open this post in threaded view
|

bug#34776: Acknowledgement (27.0.50; Some questions about choose-completion-string-functions)

Eric Abrahamsen-2
Actually it looks like I was wrong about using add-function with
choose-completion-string-functions, it's just a plain list you stick
functions into. I think it has to be an error not to declare it
buffer-local... I've worked around this with `make-local-variable', but
I'm halfway sure this should be a defvar-local...?



Reply | Threaded
Open this post in threaded view
|

bug#34776: Acknowledgement (27.0.50; Some questions about choose-completion-string-functions)

Glenn Morris-3
Eric Abrahamsen wrote:

> Actually it looks like I was wrong about using add-function with
> choose-completion-string-functions, it's just a plain list you stick
> functions into. I think it has to be an error not to declare it
> buffer-local... I've worked around this with `make-local-variable', but
> I'm halfway sure this should be a defvar-local...?

The two uses in the Emacs code-base use add-hook without LOCAL.
completing-read-multiple and ido-common-initialization.



Reply | Threaded
Open this post in threaded view
|

bug#34776: Acknowledgement (27.0.50; Some questions about choose-completion-string-functions)

Eric Abrahamsen-2

On 03/08/19 21:07 PM, Glenn Morris wrote:

> Eric Abrahamsen wrote:
>
>> Actually it looks like I was wrong about using add-function with
>> choose-completion-string-functions, it's just a plain list you stick
>> functions into. I think it has to be an error not to declare it
>> buffer-local... I've worked around this with `make-local-variable', but
>> I'm halfway sure this should be a defvar-local...?
>
> The two uses in the Emacs code-base use add-hook without LOCAL.
> completing-read-multiple and ido-common-initialization.
You're right, I was misinterpreting the code and comments as saying the
functions should be buffer local, when it just meant they *could* be
buffer local. I'll use add-hook with LOCAL.

So never mind! But I'd still like to add something like the attached, as
functions following the current docstring will raise an error.

Eric


patch.txt (603 bytes) Download Attachment