[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Should mode commands be idempotent?
From: |
Herring, Davis |
Subject: |
Re: Should mode commands be idempotent? |
Date: |
Tue, 10 Oct 2017 23:15:57 +0000 |
[Sorry this is so late: I only caught up on this upon seeing the manual patch.]
> The statement I made only applies if the command is called in immediate
> succession. That is, the function is *itself* idempotent; it doesn't guarantee
> that intervening effects are somehow negated.
There is a reasonable candidate condition, at least for minor modes, that is
broader than this: if a minor mode has state, that state should not be
reinitialized if the minor mode was already enabled before it is "enabled
again". For example, according to this principle compilation-minor-mode should
not discard its markers if it is called again -- precisely because of other
changes made between the calls.
For major modes, kill-all-local-variables tends to prevent this sort of
idempotence. This is not really a problem: since only one major mode can be
active at a time, it makes sense to consider a second call to actually
_replace_ the previous "instance" of the major mode. There also isn't much
reason to call major mode functions from places like hooks that might
unexpectedly re-execute them.
Davis