[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Redundant (harmful) duplication of run-hooks in define-globalized-mi
From: |
Alan Mackenzie |
Subject: |
Re: Redundant (harmful) duplication of run-hooks in define-globalized-minor-mode [patch] |
Date: |
Fri, 18 Jan 2013 17:09:24 +0000 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Hello, Stefan.
On Thu, Jan 17, 2013 at 01:31:32PM -0500, Stefan Monnier wrote:
> > I'm still trying to come up with a reason somebody might want to turn on
> > the minor mode _before_ the major mode's hook has been run.
> The issue is how to locally turn off the globalized minor mode from
> a major-mode hook. If the globalized mode is enabled after the
> major-mode hook, you basically can't do it without resorting to
> ugly gymnastics.
Ah, OK.
> I'm not completely sure what happens (and what should happen instead) in
> your scenario, but for the case described by João, where you don't just
> want to disable it in some modes, but you want to prevent it from ever
> being enabled in such modes, obviously the current approach
> fails similarly.
> A simple solution is to activate the minor mode late, and provide
> a `disable-foo-mode' variable, that can be set in the major mode hook.
> But it's kind of ugly because it requires another var and the user needs
> to know about that magic var.
Not enabling a globally-enabled mode in particular buffers is essentially
ugly, so whatever solution we come up with will be ugly too.
> Maybe we could do it this way:
> for a globalized minor mode `foo', before running the major-mode hook, a magic
> `disable-foo-mode' is set to nil. A function is added to `foo-mode-hook'
> which sets this var to t when foo-mode is disabled. And after running
> the major-mode hook, the globalized minor mode code checks the magic var
> to decide whether to enable the minor mode.
!!!!!!!!!!!!!!!
> This way, the user doesn't need to know about the extra magic var; she
> can just call (foo-mode -1) in her major-mode hook as she can now, but
> the minor-mode is really only activated late.
> It's also kind of ugly because of all the magic, but it's the best I can
> come up with so far.
I can't come up with anything better at the moment, either, but I can't
help feeling that there's something more fundamental about global minor
modes that we're missing.
> Stefan
--
Alan Mackenzie (Nuremberg, Germany).
- Re: Redundant (harmful) duplication of run-hooks in define-globalized-minor-mode, (continued)
- Re: Redundant (harmful) duplication of run-hooks in define-globalized-minor-mode, Dmitry Gutov, 2013/01/13
- Re: Redundant (harmful) duplication of run-hooks in define-globalized-minor-mode [patch], Alan Mackenzie, 2013/01/14
- emacs24/auctex bug, Camm Maguire, 2013/01/14
- Re: Redundant (harmful) duplication of run-hooks in define-globalized-minor-mode [patch], Stefan Monnier, 2013/01/14
- Re: Redundant (harmful) duplication of run-hooks in define-globalized-minor-mode [patch], Alan Mackenzie, 2013/01/15
- Re: Redundant (harmful) duplication of run-hooks in define-globalized-minor-mode [patch], João Távora, 2013/01/17
- Re: Redundant (harmful) duplication of run-hooks in define-globalized-minor-mode [patch], Alan Mackenzie, 2013/01/17
- Re: Redundant (harmful) duplication of run-hooks in define-globalized-minor-mode [patch], Stefan Monnier, 2013/01/17
- Re: Redundant (harmful) duplication of run-hooks in define-globalized-minor-mode [patch], João Távora, 2013/01/18
- Re: Redundant (harmful) duplication of run-hooks in define-globalized-minor-mode [patch],
Alan Mackenzie <=
- Re: Redundant (harmful) duplication of run-hooks in define-globalized-minor-mode [patch-2], Alan Mackenzie, 2013/01/31
- Re: Redundant (harmful) duplication of run-hooks in define-globalized-minor-mode [patch-2], Stefan Monnier, 2013/01/31