all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: font-lock basics?
Date: Mon, 31 Jan 2005 11:29:52 -0500	[thread overview]
Message-ID: <87k6pt36zo.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <uk6pteh7o.fsf@world.std.com> (Francis Litterio's message of "Mon, 31 Jan 2005 10:43:12 -0500")

>>> (progn
>>> (font-lock-mode -1)
>>> (kill-all-local-variables)
>>> (font-lock-add-keywords nil '(("high" . font-lock-keyword-face)))
>>> (font-lock-mode t))
>> 
>> Try to set font-lock-defaults instead.

> That begs the question: What is wrong with the above code?  According to
> the docstrings for the functions called above, it should work.  Why
> doesn't it?

Actually the docstrings are sufficiently vague that it's not clear whether
it should work or not.  In any case one of the problems is that
font-lock-add-keywords is meant to add to a *preexisting* list of keywords.
So the above only makes sense if the font-lock-add-keywords is called from
some minor mode which simply assumes that the major mode has setup
font-lock-defaults.  And even that doesn't work so well because the minor
mode has no control over font-lock-case-fold-search.

Maybe the patch below papers over this particular manifestation of the more
general problem.

Miles, what is the context of your question?


        Stefan


Index: font-core.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/font-core.el,v
retrieving revision 1.23
diff -u -u -b -r1.23 font-core.el
--- font-core.el	1 Sep 2003 15:45:12 -0000	1.23
+++ font-core.el	31 Jan 2005 16:24:56 -0000
@@ -1,7 +1,7 @@
 ;;; font-core.el --- Core interface to font-lock
 
-;; Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 1999, 2000, 2001, 02, 2003
-;;  Free Software Foundation, Inc.
+;; Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+;;   2002, 2003, 2005  Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: languages, faces
@@ -202,6 +202,7 @@
   ;; Only do hard work if the mode has specified stuff in
   ;; `font-lock-defaults'.
   (when (or font-lock-defaults
+	    (and (boundp 'font-lock-keywords) font-lock-keywords)
 	    (cdr (assq major-mode font-lock-defaults-alist)))
     (font-lock-mode-internal mode)))
 
@@ -295,6 +296,5 @@
 
 (provide 'font-core)
 
+;; arch-tag: f8c286e1-02f7-41d9-b89b-1b67780aed71
 ;;; font-core.el ends here
-
-;;; arch-tag: f8c286e1-02f7-41d9-b89b-1b67780aed71

  parent reply	other threads:[~2005-01-31 16:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-31  4:03 font-lock basics? Miles Bader
2005-01-31 13:36 ` Stefan Monnier
2005-01-31 15:43   ` Francis Litterio
2005-01-31 16:14     ` Francis Litterio
2005-01-31 16:29     ` Stefan Monnier [this message]
2005-01-31 17:31       ` Francis Litterio

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

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

  git send-email \
    --in-reply-to=87k6pt36zo.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.