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:49:30 -0500 (CDT) Message-ID: <200506012349.j51NnUA26352@raven.dms.auburn.edu> References: <87y8a3mnz8.fsf@xs4all.nl> <87ll63weye.fsf-monnier+emacs@gnu.org> <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.fs NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1117669691 2204 80.91.229.2 (1 Jun 2005 23:48:11 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 1 Jun 2005 23:48:11 +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:48:09 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Ddcvz-00022X-7Z for ged-emacs-devel@m.gmane.org; Thu, 02 Jun 2005 01:47:39 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ddd1M-0001Vf-P8 for ged-emacs-devel@m.gmane.org; Wed, 01 Jun 2005 19:53:12 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ddd13-0001RP-6p for emacs-devel@gnu.org; Wed, 01 Jun 2005 19:52:53 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ddd0z-0001PI-OI for emacs-devel@gnu.org; Wed, 01 Jun 2005 19:52:50 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ddd0z-0001Ox-L7 for emacs-devel@gnu.org; Wed, 01 Jun 2005 19:52:49 -0400 Original-Received: from [131.204.53.104] (helo=manatee.dms.auburn.edu) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Ddd0V-0008AB-0u; Wed, 01 Jun 2005 19:52:19 -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 j51No8CK004698; Wed, 1 Jun 2005 18:50:08 -0500 (CDT) Original-Received: (from teirllm@localhost) by raven.dms.auburn.edu (8.11.7p1+Sun/8.11.7) id j51NnUA26352; Wed, 1 Jun 2005 18:49:30 -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: <87r7flpubg.fsf-monnier+emacs@gnu.org> (message from Stefan Monnier on Wed, 01 Jun 2005 18:55:21 -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:38025 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:38025 The only difference between the following patch to font-lock.el and the previous one are two doc fixes. After those doc fixes, everything should work as documented when my three patches are applied. I still have to look at Richard's comments about my easy-mmode 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:30:07 -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,703 ---- 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 ! (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. --- 716,723 ---- (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) --- 787,797 ---- 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) --- 1586,1599 ---- (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) ============================================================