From: Oleh Krehel <ohwoeowho@gmail.com>
To: Stefan Monnier <monnier@IRO.UMontreal.CA>
Cc: emacs-devel@gnu.org
Subject: Re: Questions about the `completing-read-function' interface
Date: Fri, 17 Apr 2015 17:40:18 +0200 [thread overview]
Message-ID: <87bnimn4pp.fsf@gmail.com> (raw)
In-Reply-To: <jwvy4lqvkvt.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Fri, 17 Apr 2015 11:31:48 -0400")
Stefan Monnier <monnier@IRO.UMontreal.CA> writes:
>>> 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.
It's not that much more complex. Currently, we have this behavior for
major modes. When one is activated, Emacs deactivates the second one.
We could get the same feature for themes, or company-mode/auto-complete,
there are plenty of use cases.
>>> 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.
I meant to give an example of how `add-function' helps here. Also, with
your sequence of commands, starting from nothing, we have ivy-mode set
to "t" and having the `completing-read-function' resource,
while `helm-mode' is also "t" and may think that it has the resource,
but it doesn't.
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.
Oleh
next prev parent reply other threads:[~2015-04-17 15:40 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-17 9:59 Questions about the `completing-read-function' interface Oleh Krehel
2015-04-17 14:10 ` Drew Adams
2015-04-17 14:32 ` Oleh Krehel
2015-04-17 15:06 ` Drew Adams
2015-04-17 14:18 ` Stefan Monnier
2015-04-17 14:47 ` Oleh Krehel
2015-04-17 15:31 ` Stefan Monnier
2015-04-17 15:40 ` Oleh Krehel [this message]
2015-04-17 18:04 ` Stefan Monnier
2015-04-17 18:15 ` Oleh Krehel
2015-04-17 19:05 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bnimn4pp.fsf@gmail.com \
--to=ohwoeowho@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=monnier@IRO.UMontreal.CA \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).