unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Luc Teirlinck <teirllm@dms.auburn.edu>
Cc: emacs-devel@gnu.org, rms@gnu.org, mmaug@yahoo.com,
	Lute.Kamstra.lists@xs4all.nl, dominik@science.uva.nl
Subject: Re: org-mode and mode hooks.
Date: Wed, 1 Jun 2005 18:49:30 -0500 (CDT)	[thread overview]
Message-ID: <200506012349.j51NnUA26352@raven.dms.auburn.edu> (raw)
In-Reply-To: <87r7flpubg.fsf-monnier+emacs@gnu.org> (message from Stefan Monnier on Wed, 01 Jun 2005 18:55:21 -0400)

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)
============================================================

  parent reply	other threads:[~2005-06-01 23:49 UTC|newest]

Thread overview: 121+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-25 13:31 org-mode and mode hooks Lute Kamstra
2005-05-25 14:45 ` Stefan Monnier
2005-05-25 15:20   ` Carsten Dominik
2005-05-25 15:44   ` Lute Kamstra
2005-05-25 16:36     ` Luc Teirlinck
2005-05-25 17:01       ` Lute Kamstra
2005-05-25 17:12         ` Luc Teirlinck
2005-05-25 17:28           ` Lute Kamstra
2005-05-25 17:45             ` Luc Teirlinck
2005-05-25 16:24   ` Luc Teirlinck
2005-05-26  6:00     ` Richard Stallman
2005-05-26 10:31       ` Lute Kamstra
2005-05-26 17:31         ` Lute Kamstra
2005-05-27 14:18           ` Richard Stallman
2005-06-27  8:25             ` Lute Kamstra
2005-06-28  4:16               ` Richard M. Stallman
2005-05-27  3:39         ` Richard Stallman
2005-05-27  8:07           ` Juri Linkov
2005-06-27  8:28             ` Lute Kamstra
2005-05-25 17:30   ` Luc Teirlinck
2005-05-25 21:35   ` Luc Teirlinck
2005-05-25 22:15     ` Stefan Monnier
2005-05-26  3:59       ` Luc Teirlinck
2005-05-26 14:08         ` Stefan Monnier
2005-05-26 15:01           ` Luc Teirlinck
2005-05-26 17:04             ` Stefan Monnier
2005-05-27 17:17               ` Luc Teirlinck
2005-05-27 17:27                 ` Luc Teirlinck
2005-05-28 11:53                 ` Richard Stallman
2005-05-29  1:57                   ` Luc Teirlinck
2005-05-29 12:04                     ` Richard Stallman
2005-05-29 23:54                       ` Luc Teirlinck
2005-05-31  4:18                         ` Richard Stallman
2005-05-31 15:44                           ` Luc Teirlinck
2005-05-31 19:08                             ` Stefan Monnier
2005-06-01  3:50                               ` Luc Teirlinck
2005-06-01 17:22                               ` Richard Stallman
2005-06-01 19:11                                 ` Luc Teirlinck
2005-06-01 21:21                                   ` Stefan Monnier
2005-06-01 22:42                                     ` Luc Teirlinck
2005-06-01 22:55                                       ` Stefan Monnier
2005-06-01 23:26                                         ` Luc Teirlinck
2005-06-01 23:43                                           ` Stefan Monnier
2005-06-01 23:55                                             ` Luc Teirlinck
2005-06-01 23:57                                             ` Luc Teirlinck
2005-06-01 23:58                                             ` David Kastrup
2005-06-02  0:15                                             ` Luc Teirlinck
2005-06-01 23:49                                         ` Luc Teirlinck [this message]
2005-06-03  8:01                                           ` Richard Stallman
2005-06-03 14:59                                             ` Luc Teirlinck
2005-06-03 15:05                                             ` Luc Teirlinck
2005-06-04 10:16                                               ` Richard Stallman
2005-06-04 14:54                                                 ` Luc Teirlinck
2005-06-04 16:33                                                   ` Stefan Monnier
2005-06-04 17:48                                                     ` Luc Teirlinck
2005-06-05  0:36                                                       ` David Kastrup
2005-06-05  9:47                                                   ` Richard Stallman
2005-06-07  0:23                                                     ` Luc Teirlinck
2005-06-04 15:17                                                 ` Luc Teirlinck
2005-06-05  9:47                                                   ` Richard Stallman
2005-06-06 23:28                                                     ` Luc Teirlinck
2005-06-07 18:15                                                       ` Stefan Monnier
2005-06-07 19:08                                                         ` Luc Teirlinck
2005-06-07 22:10                                                           ` Stefan Monnier
2005-06-08  1:36                                                             ` Luc Teirlinck
2005-06-08 16:15                                                               ` Stefan Monnier
2005-06-09  1:06                                                                 ` Luc Teirlinck
2005-06-08 12:02                                                       ` Richard Stallman
2005-06-02  6:15                                   ` Carsten Dominik
2005-06-01 19:14                                 ` Luc Teirlinck
2005-06-01 19:19                                 ` Luc Teirlinck
2005-06-01 21:24                                 ` Stefan Monnier
2005-05-31 16:30                           ` Luc Teirlinck
2005-06-01  2:33                           ` Luc Teirlinck
2005-06-01 17:23                             ` Richard Stallman
2005-06-01 17:48                               ` Luc Teirlinck
2005-06-01  2:42                           ` Luc Teirlinck
2005-06-01 17:23                             ` Richard Stallman
2005-06-01 18:05                               ` Luc Teirlinck
2005-06-01  2:47                           ` Luc Teirlinck
2005-06-01 17:23                             ` Richard Stallman
2005-06-02  3:21                               ` Luc Teirlinck
2005-06-03 22:32                                 ` Richard Stallman
2005-06-03 23:08                                   ` Luc Teirlinck
2005-06-04 18:00                                     ` Richard Stallman
2005-06-01  3:01                           ` Luc Teirlinck
2005-05-30  1:43                       ` Luc Teirlinck
2005-05-30  2:50                       ` Luc Teirlinck
2005-05-30 15:31                         ` Luc Teirlinck
2005-05-30 16:52                           ` Luc Teirlinck
2005-05-30 17:24                             ` Luc Teirlinck
2005-05-30  3:35                       ` Luc Teirlinck
2005-05-29  2:20                   ` Luc Teirlinck
2005-05-29 12:04                     ` Richard Stallman
2005-05-30  0:42                       ` Luc Teirlinck
2005-05-30  1:58                       ` Luc Teirlinck
2005-05-28  1:58               ` Luc Teirlinck
2005-05-27 14:49             ` Michael Mauger
2005-05-27 15:35               ` Luc Teirlinck
2005-05-27 16:40               ` Luc Teirlinck
2005-05-27 17:15               ` Stefan Monnier
2005-05-27 19:13               ` Luc Teirlinck
2005-05-31 18:25                 ` Michael Mauger
2005-05-27 19:43               ` Luc Teirlinck
2005-05-28 11:53                 ` Richard Stallman
2005-05-28 18:48                   ` Luc Teirlinck
2005-06-07  1:19                   ` Luc Teirlinck
2005-06-07  1:49                     ` Miles Bader
2005-06-07  1:55                       ` Luc Teirlinck
2005-06-07  2:01                         ` Miles Bader
2005-06-07 18:23                           ` Stefan Monnier
2005-06-07 18:17                       ` Stefan Monnier
2005-06-08 12:01                       ` Richard Stallman
2005-05-26 14:53         ` Richard Stallman
2005-05-26 15:06           ` Luc Teirlinck
2005-05-26  4:16       ` Luc Teirlinck
2005-05-25 22:22     ` Lute Kamstra
     [not found] ` <17044.33688.784219.190965@sam.science.uva.nl>
2005-05-25 15:37   ` Lute Kamstra
2005-05-25 15:49     ` Carsten Dominik
2005-05-26  5:59 ` Richard Stallman
     [not found] <87sm07o3oz.fsf-monnier+emacs@gnu.org>
2005-05-29  2:00 ` Luc Teirlinck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200506012349.j51NnUA26352@raven.dms.auburn.edu \
    --to=teirllm@dms.auburn.edu \
    --cc=Lute.Kamstra.lists@xs4all.nl \
    --cc=dominik@science.uva.nl \
    --cc=emacs-devel@gnu.org \
    --cc=mmaug@yahoo.com \
    --cc=rms@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).