From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lute Kamstra Newsgroups: gmane.emacs.devel Subject: Re: org-mode and mode hooks. Date: Wed, 25 May 2005 17:37:17 +0200 Message-ID: <873bsbmi4y.fsf@xs4all.nl> References: <87y8a3mnz8.fsf@xs4all.nl> <17044.33688.784219.190965@sam.science.uva.nl> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1117035791 19330 80.91.229.2 (25 May 2005 15:43:11 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 25 May 2005 15:43:11 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed May 25 17:43:09 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Day1y-0004yi-DV for ged-emacs-devel@m.gmane.org; Wed, 25 May 2005 17:42:50 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Day5r-0007yL-Gd for ged-emacs-devel@m.gmane.org; Wed, 25 May 2005 11:46:51 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Day1q-0006IG-Jc for emacs-devel@gnu.org; Wed, 25 May 2005 11:42:43 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Day1g-0006CK-2C for emacs-devel@gnu.org; Wed, 25 May 2005 11:42:34 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Day1f-0006A5-9T for emacs-devel@gnu.org; Wed, 25 May 2005 11:42:31 -0400 Original-Received: from [194.109.24.23] (helo=smtp-vbr3.xs4all.nl) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Daxx3-0000R1-8X for emacs-devel@gnu.org; Wed, 25 May 2005 11:37:45 -0400 Original-Received: from pijl (a80-127-67-124.adsl.xs4all.nl [80.127.67.124]) by smtp-vbr3.xs4all.nl (8.13.3/8.13.3) with ESMTP id j4PFbHXI096476; Wed, 25 May 2005 17:37:17 +0200 (CEST) (envelope-from Lute.Kamstra@xs4all.nl) Original-Received: from lute by pijl with local (Exim 3.36 #1 (Debian)) id 1Daxwb-0001mO-00; Wed, 25 May 2005 17:37:17 +0200 Original-To: Carsten Dominik In-Reply-To: <17044.33688.784219.190965@sam.science.uva.nl> (Carsten Dominik's message of "Wed, 25 May 2005 15:54:32 +0200") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) Original-Lines: 52 X-Virus-Scanned: by XS4ALL Virus Scanner X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:37619 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:37619 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. With my patch, running outline-mode's mode hook (and after-change-major-mode-hook) is delayed; it is run at the end of org-mode. So it introduces the problem that a mode hook will fail 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. 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? My problem is not with outline-mode-hook but with after-change-major-mode-hook. In Emacs, global-font-lock-mode (and any other global minor mode defined with define-global-minor-mode) adds one function to change-major-mode-hook and a second function to after-change-major-mode-hook to enable Font Lock mode. The first functions adds the current buffer to a list variable. The second function enables Font Lock mode for all buffers in that list and clears the list. change-major-mode-hook is run by kill-all-local-variables and after-change-major-mode-hook is run by run-mode-hooks. So normally, a major mode calls the first function once as the first thing it does and the second function once as the last thing it does. However, org-mode calls the second function halfway, before it sets up its own Font-Lock stuff. As a result Font Lock doesn't work properly for org-mode. Lute. PS. Putting the second function on after-change-major-mode-hook is a recent change, it used to be on find-file-hook.