[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Enable derived modes to run their own very-early 'change-major-mode-
Re: Enable derived modes to run their own very-early 'change-major-mode-hook' code
Sun, 21 Apr 2019 09:23:18 +0300
[I'm moving this to emacs-devel, as the bug tracker doesn't sound
appropriate for such discussions. Please send any followups here.]
> From: Phil Sainty <address@hidden>
> Date: Sun, 21 Apr 2019 14:35:35 +1200
> The library I'm working on (so-long.el) defines a major mode
> which needs to remember various buffer-local values as they were
> in the original mode, *before* my major mode takes effect.
> I'm currently using `change-major-mode-hook' for this, but it has
> occurred to me that it would be nicer if this hook code of mine
> only ever ran in the case where it is useful (i.e. the major mode
> being changed to is in fact my mode). `change-major-mode-hook'
> has no knowledge of the mode which has just been invoked, so it
> must necessarily run for *every* mode change -- which isn't
> relevant to my library in the vast majority of cases.
> I think `change-major-mode-hook' would more commonly be used by
> modes to handle any subsequent 'unloading' needs of that same
> mode in case it gets replaced later on (i.e. the mode body could
> set a buffer-local hook value), so my scenario of the new mode
> wanting to know things about the previous mode is doubtless a bit
> of a niche case; but I thought I'd raise it for discussion.
Did you consider using major-mode-suspend and major-mode-restore?
|[Prev in Thread]
||[Next in Thread]|
- Re: Enable derived modes to run their own very-early 'change-major-mode-hook' code,
Eli Zaretskii <=