[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Should mode commands be idempotent?
From: |
Stefan Monnier |
Subject: |
Re: Should mode commands be idempotent? |
Date: |
Wed, 20 Sep 2017 18:30:47 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) |
> Also, is there a motivation for introducing this new requirement, seeing as
> how we've never had such a restriction in the past?
In the case of minor modes, I think a good implementation of a minor
mode should be idempotent, because it can easily happen that a minor
mode is enabled twice via different hooks, e.g.:
(add-hook 'text-mode-hook #'visual-line-mode)
(add-hook 'xml-mode-hook #'visual-line-mode)
If you know that xml-mode runs text-mode-hook, you can drop the second
line, but it's good if the second line is just redundant rather
than harmful (after all, some people prefer xml-mode not to run
text-mode-hook).
For major modes, I don't know what is the intention exactly, because I'm
not sure exactly what kind of non-idempotence there is out there.
I think for major modes a more significant issue is to make sure that
(with-temp-buffer (insert text) (funcall mode))
doesn't do anything undesirable (and currently, we're pretty far from
having such a guarantee, although we do have code like the above at
various places).
Stefan
- Should mode commands be idempotent?, Philipp Stephani, 2017/09/19
- Re: Should mode commands be idempotent?, Clément Pit-Claudel, 2017/09/19
- Re: Should mode commands be idempotent?, Stefan Monnier, 2017/09/19
- Re: Should mode commands be idempotent?, Clément Pit-Claudel, 2017/09/20
- Re: Should mode commands be idempotent?, John Wiegley, 2017/09/20
- Re: Should mode commands be idempotent?,
Stefan Monnier <=
- RE: Should mode commands be idempotent?, Drew Adams, 2017/09/20
- Re: Should mode commands be idempotent?, Stefan Monnier, 2017/09/20
- Re: Should mode commands be idempotent?, Clément Pit-Claudel, 2017/09/23
- Re: Should mode commands be idempotent?, Stefan Monnier, 2017/09/23
- Re: Should mode commands be idempotent?, Stefan Monnier, 2017/09/23
- RE: Should mode commands be idempotent?, Drew Adams, 2017/09/19