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 19:15:03 -0500 (CDT) Message-ID: <200506020015.j520F3j27033@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 1117671537 6125 80.91.229.2 (2 Jun 2005 00:18:57 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 2 Jun 2005 00:18:57 +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 02:18:55 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DddPX-0004Ss-BM for ged-emacs-devel@m.gmane.org; Thu, 02 Jun 2005 02:18:11 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DddUv-00061g-5W for ged-emacs-devel@m.gmane.org; Wed, 01 Jun 2005 20:23:45 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DddUk-00061L-W1 for emacs-devel@gnu.org; Wed, 01 Jun 2005 20:23:35 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DddUj-00060b-Oh for emacs-devel@gnu.org; Wed, 01 Jun 2005 20:23:34 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DddUj-0005zu-IJ for emacs-devel@gnu.org; Wed, 01 Jun 2005 20:23:33 -0400 Original-Received: from [131.204.53.104] (helo=manatee.dms.auburn.edu) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DddPE-0001Yy-84; Wed, 01 Jun 2005 20:17:52 -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 j520FfCK004817; Wed, 1 Jun 2005 19:15:41 -0500 (CDT) Original-Received: (from teirllm@localhost) by raven.dms.auburn.edu (8.11.7p1+Sun/8.11.7) id j520F3j27033; Wed, 1 Jun 2005 19:15:03 -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:38030 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:38030 And my second patch contained stray punctuation. This should finally be correct: ===File ~/font-lock-b-diff================================== *** font-lock.el 29 May 2005 09:15:38 -0500 1.259 --- font-lock.el 01 Jun 2005 18:59:56 -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) ============================================================