[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Questions about the `completing-read-function' interface

From: Stefan Monnier
Subject: Re: Questions about the `completing-read-function' interface
Date: Fri, 17 Apr 2015 11:31:48 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

>> So far we haven't tried to enforce this and if require-match is not set,
>> then I don't think we should require it.
> I agree for the case of
>     (memq require-match '(nil confirm confirm-after-completion))
> What about the other cases?

If require is t I think it'd be OK for the completing-read function to
ignore any DEF argument which is not in COLLECTION.

For the same reason, M-p should arguably skip history members which
aren't in COLLECTION (or which are rejected by PRED).

But there are some issues: even if DEF (or history elements) would be
rejected by require-match when you hit RET, it might still be a useful
string to get via M-n (which the user then completes before hitting RET).

> 1. all minor modes subscribe with `set-completing-read-function'
> 2. user calls M-x mode-1. mode-1 is active and subscribes.
> 3. user calls M-x mode-2. Emacs sends a message to mode-1 to shut
> down. mode-2 is active and subscribes.
> 4. and so on.

But this extra complexity only "solves" the very narrow problem you're
facing, while introducing non-trivial issues: what about minor modes
that override completing-read-function but which only apply to some
cases?  There can be several such minor modes active at the same time
without conflict.

> There's no way to end up in a worse state than is now.

Well yes, there is: increase code complexity for little benefit is
a worse state.

>> I agree that there are potential for actual problems if the
>> completing-read-function is not properly reverted when the modes are
>> disabled.  For that reason I recommend you use `add-function' and
>> `remove-function' rather than `setq'.
> I don't understand. Can you give an example?

M-x ivy-mode RET
M-x helm-mode RET
M-x ivy-mode RET

You should now have helm-mode active and working properly, yet with your
current code, helm-mode will be "enabled by inactive".  If you use
add/remove-function this case will be handled correctly.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]