From: Eli Zaretskii <eliz@gnu.org>
To: Phil Sainty <psainty@orcon.net.nz>
Cc: emacs-devel@gnu.org
Subject: Re: Enable derived modes to run their own very-early 'change-major-mode-hook' code
Date: Sun, 21 Apr 2019 09:23:18 +0300 [thread overview]
Message-ID: <83ftqbanc9.fsf@gnu.org> (raw)
In-Reply-To: <85237c18-768d-089b-221a-fe70b0ba4379@orcon.net.nz> (message from Phil Sainty on Sun, 21 Apr 2019 14:35:35 +1200)
[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 <psainty@orcon.net.nz>
> 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?
parent reply other threads:[~2019-04-21 6:23 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <85237c18-768d-089b-221a-fe70b0ba4379@orcon.net.nz>]
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=83ftqbanc9.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=psainty@orcon.net.nz \
/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).