emacs-devel
[Top][All Lists]
Advanced

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

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


From: Oleh Krehel
Subject: Re: Questions about the `completing-read-function' interface
Date: Fri, 17 Apr 2015 20:15:23 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Stefan Monnier <address@hidden> writes:

>>> 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.
>> I meant to give an example of how `add-function' helps here.
>
> That's exactly what the example does, AFAIK.
>
>> Also, with your sequence of commands, starting from nothing, we have
>> ivy-mode set to "t" and having the `completing-read-function'
>
> No, the idea of this example is that after the second line ivy-mode is
> still t but completing-read-function is now set to use the helm version.
> After the 3rd line, with `setq' completing-read-function would be reset
> to the default value, whereas with remove-function
> completing-read-function would still continue using the helm version.
>
>> I've also seen this type of code: ido-vertical-mode stores the variable
>> `ido-decorations' of ido-mode and modifies it.  When you turn off
>> ido-vertical-mode, it restores `ido-decorations'.  But what if other
>> code has changed `ido-decorations' in the meantime, while
>> ido-vertical-mode is still on?  Any way you put it, the result is
>> incorrect. Unless there's a robust system behind it all that manages the
>> `ido-decorations' variable.
>
> That's exactly what add-function aims to solve.

You mean to use code like this:

(if ivy-mode
    (add-function :override completing-read-function 'ivy-completing-read)
  (remove-function completing-read-function 'ivy-completing-read))

This can solve the problem if all packages adhere to this rule
simultaneously. I mean that now this sequence works:

- helm-mode
- ivy-mode
- ivy-mode

But this sequence doesn't:

- ivy-mode
- helm-mode
- helm-mode

Since which Emacs version is `add-function` available?
Would you recommend the above approach, possibly in the manual?

Oleh





reply via email to

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