From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Luc Teirlinck Newsgroups: gmane.emacs.devel Subject: Re: org-mode and mode hooks. Date: Wed, 1 Jun 2005 18:55:13 -0500 (CDT) Message-ID: <200506012355.j51NtDF26624@raven.dms.auburn.edu> References: <87y8a3mnz8.fsf@xs4all.nl> <200505252135.j4PLZvt26969@raven.dms.auburn.edu> <87hdgrufcl.fsf-monnier+emacs@gnu.org> <200505260359.j4Q3xbj28809@raven.dms.auburn.edu> <87is16rsid.fsf-monnier+emacs@gnu.org> <200505261501.j4QF17h00246@raven.dms.auburn.edu> <87psveq60w.fsf-monnier+emacs@gnu.org> <200505271717.j4RHHGD07067@raven.dms.auburn.edu> <200505290157.j4T1vus10117@raven.dms.auburn.edu> <200505292354.j4TNsTE13354@raven.dms.auburn.edu> <200505311544.j4VFijq17680@raven.dms.auburn.edu> <200506011911.j51JBR025269@raven.dms.auburn.edu> <87oeap231t.fsf-monnier+emacs@gnu.org> <200506012242.j51MgBj26277@raven.dms.auburn.edu> <87r7flpubg.fsf-monnier+emacs@gnu.org> <200506012326 NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1117670049 2896 80.91.229.2 (1 Jun 2005 23:54:09 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 1 Jun 2005 23:54:09 +0000 (UTC) Cc: emacs-devel@gnu.org, rms@gnu.org, mmaug@yahoo.com, Lute.Kamstra.lists@xs4all.nl, dominik@science.uva.nl Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jun 02 01:53:59 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Ddd1Z-0002Vw-4w for ged-emacs-devel@m.gmane.org; Thu, 02 Jun 2005 01:53:25 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ddd6w-0008Tp-Ma for ged-emacs-devel@m.gmane.org; Wed, 01 Jun 2005 19:58:58 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ddd6h-0008RG-Ax for emacs-devel@gnu.org; Wed, 01 Jun 2005 19:58:43 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ddd6e-0008Oz-7M for emacs-devel@gnu.org; Wed, 01 Jun 2005 19:58:41 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ddd6d-0008Oe-NO for emacs-devel@gnu.org; Wed, 01 Jun 2005 19:58:39 -0400 Original-Received: from [131.204.53.104] (helo=manatee.dms.auburn.edu) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Ddd62-00007B-3U; Wed, 01 Jun 2005 19:58:02 -0400 Original-Received: from raven.dms.auburn.edu (raven.dms.auburn.edu [131.204.53.29]) by manatee.dms.auburn.edu (8.12.10/8.12.10) with ESMTP id j51NtpCK004715; Wed, 1 Jun 2005 18:55:51 -0500 (CDT) Original-Received: (from teirllm@localhost) by raven.dms.auburn.edu (8.11.7p1+Sun/8.11.7) id j51NtDF26624; Wed, 1 Jun 2005 18:55:13 -0500 (CDT) X-Authentication-Warning: raven.dms.auburn.edu: teirllm set sender to teirllm@dms.auburn.edu using -f Original-To: monnier@iro.umontreal.ca In-reply-to: <87fyw1ps0a.fsf-monnier+emacs@gnu.org> (message from Stefan Monnier on Wed, 01 Jun 2005 19:43:37 -0400) 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:38027 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:38027 My previous patch called add-hook in the wrong way. Corrected patch: ===File ~/font-lock-b-diff================================== *** font-lock.el 29 May 2005 09:15:38 -0500 1.259 --- font-lock.el 01 Jun 2005 18:39:50 -0500 *************** *** 683,691 **** adds two fontification patterns for C mode, to fontify `FIXME:' words, even in comments, and to fontify `and', `or' and `not' words as keywords. ! When used from a Lisp program (such as a minor mode), it is recommended to ! use nil for MODE (and place the call on a hook) to avoid subtle problems ! due to details of the implementation. Note that some modes have specialized support for additional patterns, e.g., see the variables `c-font-lock-extra-types', `c++-font-lock-extra-types', --- 683,704 ---- adds two fontification patterns for C mode, to fontify `FIXME:' words, even in comments, and to fontify `and', `or' and `not' words as keywords. ! The above procedure will only add the keywords for C mode, not ! for modes derived from C mode. To add them for derived modes too, ! pass nil for MODE and add the call to c-mode-hook. ! ! For example:" ! ! (add-hook 'c-mode-hook ! (lambda () ! (font-lock-add-keywords 'c-mode ! '((\"\\\\\\=<\\\\(FIXME\\\\):\" 1 font-lock-warning-face prepend) ! (\"\\\\\\=<\\\\(and\\\\|or\\\\|not\\\\)\\\\\\=>\" . ! font-lock-keyword-face))))) ! ! "The above procedure may fail to add keywords to derived modes if ! some involved major mode does not follow the standard conventions. ! File a bug report if this happens, so the major mode can be corrected. Note that some modes have specialized support for additional patterns, e.g., see the variables `c-font-lock-extra-types', `c++-font-lock-extra-types', *************** *** 704,710 **** (font-lock-update-removed-keyword-alist mode keywords append)) (t ;; Otherwise set or add the keywords now. ! ;; This is a no-op if it has been done already in this buffer. (font-lock-set-defaults) (let ((was-compiled (eq (car font-lock-keywords) t))) ;; Bring back the user-level (uncompiled) keywords. --- 717,724 ---- (font-lock-update-removed-keyword-alist mode keywords append)) (t ;; Otherwise set or add the keywords now. ! ;; This is a no-op if it has been done already in this buffer ! ;; for the correct major mode. (font-lock-set-defaults) (let ((was-compiled (eq (car font-lock-keywords) t))) ;; Bring back the user-level (uncompiled) keywords. *************** *** 774,782 **** MODE should be a symbol, the major mode command name, such as `c-mode' or nil. If nil, highlighting keywords are removed for the current buffer. ! When used from a Lisp program (such as a minor mode), it is recommended to ! use nil for MODE (and place the call on a hook) to avoid subtle problems ! due to details of the implementation." (cond (mode ;; Remove one keyword at the time. (dolist (keyword keywords) --- 788,798 ---- MODE should be a symbol, the major mode command name, such as `c-mode' or nil. If nil, highlighting keywords are removed for the current buffer. ! To make the removal apply to modes derived from MODE as well, ! pass nil for MODE and add the call to MODE-hook. This may fail ! for some derived modes if some involved major mode does not ! follow the standard conventions. File a bug report if this ! happens, so the major mode can be corrected." (cond (mode ;; Remove one keyword at the time. (dolist (keyword keywords) *************** *** 1571,1582 **** (defvar font-lock-set-defaults nil) ; Whether we have set up defaults. (defun font-lock-set-defaults () "Set fontification defaults appropriately for this mode. Sets various variables using `font-lock-defaults' (or, if nil, using `font-lock-defaults-alist') and `font-lock-maximum-decoration'." ! ;; Set fontification defaults iff not previously set. ! (unless font-lock-set-defaults (set (make-local-variable 'font-lock-set-defaults) t) (make-local-variable 'font-lock-fontified) (make-local-variable 'font-lock-multiline) --- 1587,1600 ---- (defvar font-lock-set-defaults nil) ; Whether we have set up defaults. + (defvar font-lock-mode-stored-mode) (defun font-lock-set-defaults () "Set fontification defaults appropriately for this mode. Sets various variables using `font-lock-defaults' (or, if nil, using `font-lock-defaults-alist') and `font-lock-maximum-decoration'." ! ;; Set fontification defaults iff not previously set for correct major mode. ! (unless (and font-lock-set-defaults ! (eq font-lock-mode-stored-mode major-mode)) (set (make-local-variable 'font-lock-set-defaults) t) (make-local-variable 'font-lock-fontified) (make-local-variable 'font-lock-multiline) ============================================================