[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#35351: 27.0.50; Enable derived modes to run their own very-early 'ch
From: |
Stefan Monnier |
Subject: |
bug#35351: 27.0.50; Enable derived modes to run their own very-early 'change-major-mode-hook' code |
Date: |
Sun, 21 Apr 2019 16:54:55 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
> 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).
There's no need for a "hook" for that. You just need to put the code to
save the old values before calling kill-all-local-variables.
> (A vaguely analogous facility currently in `define-derived-mode'
> is the :after-hook keyword, for running code very *late* in the
> proceedings.)
Indeed what you're asking for is like a :before-hook symmetric (FWIW,
I think the "-hook" part of the name was probably not the best choice).
Usually this is done with something akin to:
(define-derived-mode my-actual-mode
...)
(defun my-mode ()
(my-save-local-vars)
(my-actual-mode))
or something similar (or not using define-derived-mode).
Of course, this comes with its own drawbacks.
Stefan
- bug#35351: 27.0.50; Enable derived modes to run their own very-early 'change-major-mode-hook' code, Phil Sainty, 2019/04/20
- bug#35351: 27.0.50; Enable derived modes to run their own very-early 'change-major-mode-hook' code, Phil Sainty, 2019/04/20
- bug#35351: 27.0.50; Enable derived modes to run their own very-early 'change-major-mode-hook' code,
Stefan Monnier <=
- bug#35351: 27.0.50; Enable derived modes to run their own very-early 'change-major-mode-hook' code, Phil Sainty, 2019/04/22
- bug#35351: 27.0.50; Enable derived modes to run their own very-early 'change-major-mode-hook' code, Stefan Monnier, 2019/04/22
- bug#35351: 27.0.50; Enable derived modes to run their own very-early 'change-major-mode-hook' code, Phil Sainty, 2019/04/22
- bug#35351: 27.0.50; Enable derived modes to run their own very-early 'change-major-mode-hook' code, Phil Sainty, 2019/04/22
- bug#35351: 27.0.50; Enable derived modes to run their own very-early 'change-major-mode-hook' code, Stefan Monnier, 2019/04/22
- bug#35351: 27.0.50; Enable derived modes to run their own very-early 'change-major-mode-hook' code, Phil Sainty, 2019/04/22
- bug#35351: 27.0.50; Enable derived modes to run their own very-early 'change-major-mode-hook' code, Stefan Monnier, 2019/04/23
- bug#35351: 27.0.50; Enable derived modes to run their own very-early 'change-major-mode-hook' code, Stefan Monnier, 2019/04/22