emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: org-mode and mode hooks.


From: Carsten Dominik
Subject: Re: org-mode and mode hooks.
Date: Wed, 25 May 2005 17:49:47 +0200


Hi Lute,

OK, I see now what the problem is, and I will switch to
define-derived-mode, and to run-mode-hooks (for org-agenda-mode).
This will indeed create a problem if someone uses outline-mode-hook to
modify one of the three outline menus (Headings, Show, Hide).  We will
just have to see if anyone gets biten by this.  I will implement the
change tomorrow - need to do some testing first.

- Carsten



>>>>> "LK" == Lute Kamstra <address@hidden> writes:

LK> Hi Carsten,
>> I remember trying to do define-derived mode, but not doing it for a
>> number of reasons which I do not exactly remember.  The argument was
>> one reason.  Another was that older versions of define-derived-mode
>> did not allow a BODY arguments which I needed.

>> A third one was that org-mode hacks away the Show and Hide menus of
>> outline mode, and I did not want a mode hood to fail because is
>> tries to add entries to non-existing menus.

LK> With my patch, running outline-mode's mode hook (and
LK> after-change-major-mode-hook) is delayed; it is run at the end of
LK> org-mode.  So it introduces the problem that a mode hook will fail
LK> when it tries to change those menus.

>> An important problem always is that I am writing code for Emacs and
>> XEmacs, so my code needs to be compatible with both distributions.

LK> AFAIK, XEmacs has delay-mode-hooks and run-mode-hooks as well.

>> I did not know about delay-mode-hooks and run-mode-hooks - I'll check
>> it out.
>> 
>> What is actually the problem created by the current setup?  What are
>> you trying to do in the outline-mode-hook, and how does it interfer
>> with what org-mode is doing?

LK> My problem is not with outline-mode-hook but with
LK> after-change-major-mode-hook.

LK> In Emacs, global-font-lock-mode (and any other global minor mode
LK> defined with define-global-minor-mode) adds one function to
LK> change-major-mode-hook and a second function to
LK> after-change-major-mode-hook to enable Font Lock mode.  The first
LK> functions adds the current buffer to a list variable.  The second
LK> function enables Font Lock mode for all buffers in that list and
LK> clears the list.

LK> change-major-mode-hook is run by kill-all-local-variables and
LK> after-change-major-mode-hook is run by run-mode-hooks.  So normally, a
LK> major mode calls the first function once as the first thing it does
LK> and the second function once as the last thing it does.  However,
LK> org-mode calls the second function halfway, before it sets up its own
LK> Font-Lock stuff.  As a result Font Lock doesn't work properly for
LK> org-mode.

LK> Lute.


LK> PS.  Putting the second function on after-change-major-mode-hook is a
LK>      recent change, it used to be on find-file-hook.

-- 
Carsten Dominik <address@hidden>        \ _ /
Sterrenkundig Instituut "Anton Pannekoek"        |X|               _
Kruislaan 403; NL-1098 SJ Amsterdam             /| |\   _  _     _/ \
phone +31 (20) 525-7477; FAX +31 (20) 525-7484 __|o|___/ ~~ \___/    ~~~




reply via email to

[Prev in Thread] Current Thread [Next in Thread]