annotate lisp/font-core.el @ 110410:f2e111723c3a

Merge changes made in Gnus trunk. Reimplement nnimap, and do tweaks to the rest of the code to support that. * gnus-int.el (gnus-finish-retrieve-group-infos) (gnus-retrieve-group-data-early): New functions. * gnus-range.el (gnus-range-nconcat): New function. * gnus-start.el (gnus-get-unread-articles): Support early retrieval of data. (gnus-read-active-for-groups): Support finishing the early retrieval of data. * gnus-sum.el (gnus-summary-move-article): Pass the move-to group name if the move is internal, so that nnimap can do fast internal moves. * gnus.el (gnus-article-special-mark-lists): Add uid/active tuples, for nnimap usage. * nnimap.el: Rewritten. * nnmail.el (nnmail-inhibit-default-split-group): New internal variable to allow the mail splitting to not return a default group. This is useful for nnimap, which will leave unmatched mail in the inbox. * utf7.el (utf7-encode): Autoload. Implement shell connection. * nnimap.el (nnimap-open-shell-stream): New function. (nnimap-open-connection): Use it. Get the number of lines by using BODYSTRUCTURE. (nnimap-transform-headers): Get the number of lines in each message. (nnimap-retrieve-headers): Query for BODYSTRUCTURE so that we get the number of lines. Not all servers return UIDNEXT. Work past this problem. Remove junk from end of file. Fix typo in "bogus" section. Make capabilties be case-insensitive. Require cl when compiling. Don't bug out if the LIST command doesn't have any parameters. 2010-09-17 Knut Anders Hatlen <kahatlen@gmail.com> (tiny change) * nnimap.el (nnimap-get-groups): Don't bug out if the LIST command doesn't have any parameters. (mm-text-html-renderer): Document gnus-article-html. 2010-09-17 Julien Danjou <julien@danjou.info> (tiny fix) * mm-decode.el (mm-text-html-renderer): Document gnus-article-html. * dgnushack.el: Define netrc-credentials. If the user doesn't have a /etc/services, supply some sensible port defaults. Have `unseen-or-unread' select an unread unseen article first. (nntp-open-server): Return whether the open was successful or not. Throughout all files, replace (save-excursion (set-buffer ...)) with (with-current-buffer ... ). Save result so that it doesn't say "failed" all the time. Add ~/.authinfo to the default, since that's probably most useful for users. Don't use the "finish" method when we're reading from the agent. Add some more nnimap-relevant agent stuff to nnagent.el. * nnimap.el (nnimap-with-process-buffer): Removed. Revert one line that was changed by mistake in the last checkin. (nnimap-open-connection): Don't error out when we can't make a connection nnimap-related changes to avoid bugging out if we can't contact a server. * gnus-start.el (gnus-get-unread-articles): Don't try to scan groups from methods that are denied. * nnimap.el (nnimap-possibly-change-group): Return nil if we can't log in. (nnimap-finish-retrieve-group-infos): Make sure we're not waiting for nothing. * gnus-sum.el (gnus-select-newsgroup): Indent.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Sat, 18 Sep 2010 10:02:19 +0000
parents 280c8ae2476d
children 3f3735eed163
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
45440
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
1 ;;; font-core.el --- Core interface to font-lock
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
2
59871
83af8894e534 (font-lock-default-function): Handle the rare case where
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
3 ;; Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 105609
diff changeset
4 ;; 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
105609
bdcd73244f19 Convert comments about autoloads into autoload comments.
Glenn Morris <rgm@gnu.org>
parents: 104990
diff changeset
5 ;; Free Software Foundation, Inc.
45440
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
6
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
7 ;; Maintainer: FSF
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
8 ;; Keywords: languages, faces
110015
280c8ae2476d Add "Package:" file headers to denote built-in packages.
Chong Yidong <cyd@stupidchicken.com>
parents: 109008
diff changeset
9 ;; Package: emacs
45440
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
10
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
11 ;; This file is part of GNU Emacs.
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
12
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94156
diff changeset
13 ;; GNU Emacs is free software: you can redistribute it and/or modify
45440
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
14 ;; it under the terms of the GNU General Public License as published by
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94156
diff changeset
15 ;; the Free Software Foundation, either version 3 of the License, or
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94156
diff changeset
16 ;; (at your option) any later version.
45440
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
17
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
21 ;; GNU General Public License for more details.
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
22
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94156
diff changeset
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
45440
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
25
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
26 ;;; Code:
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
27
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
28 ;; This variable is used by mode packages that support Font Lock mode by
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
29 ;; defining their own keywords to use for `font-lock-keywords'. (The mode
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
30 ;; command should make it buffer-local and set it to provide the set up.)
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
31 (defvar font-lock-defaults nil
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
32 "Defaults for Font Lock mode specified by the major mode.
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
33 Defaults should be of the form:
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
34
61825
eb334300d039 (font-lock-defaults): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents: 61270
diff changeset
35 (KEYWORDS [KEYWORDS-ONLY [CASE-FOLD [SYNTAX-ALIST [SYNTAX-BEGIN ...]]]])
45440
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
36
100387
35f1ab86f203 (font-lock-defaults): Doc fix: mention levels; refer to elisp manual.
Glenn Morris <rgm@gnu.org>
parents: 100171
diff changeset
37 KEYWORDS may be a symbol (a variable or function whose value is the keywords
35f1ab86f203 (font-lock-defaults): Doc fix: mention levels; refer to elisp manual.
Glenn Morris <rgm@gnu.org>
parents: 100171
diff changeset
38 to use for fontification) or a list of symbols (specifying different levels
35f1ab86f203 (font-lock-defaults): Doc fix: mention levels; refer to elisp manual.
Glenn Morris <rgm@gnu.org>
parents: 100171
diff changeset
39 of fontification).
35f1ab86f203 (font-lock-defaults): Doc fix: mention levels; refer to elisp manual.
Glenn Morris <rgm@gnu.org>
parents: 100171
diff changeset
40
35f1ab86f203 (font-lock-defaults): Doc fix: mention levels; refer to elisp manual.
Glenn Morris <rgm@gnu.org>
parents: 100171
diff changeset
41 If KEYWORDS-ONLY is non-nil, syntactic fontification (strings and
35f1ab86f203 (font-lock-defaults): Doc fix: mention levels; refer to elisp manual.
Glenn Morris <rgm@gnu.org>
parents: 100171
diff changeset
42 comments) is not performed.
35f1ab86f203 (font-lock-defaults): Doc fix: mention levels; refer to elisp manual.
Glenn Morris <rgm@gnu.org>
parents: 100171
diff changeset
43
45440
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
44 If CASE-FOLD is non-nil, the case of the keywords is ignored when fontifying.
100387
35f1ab86f203 (font-lock-defaults): Doc fix: mention levels; refer to elisp manual.
Glenn Morris <rgm@gnu.org>
parents: 100171
diff changeset
45
45440
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
46 If SYNTAX-ALIST is non-nil, it should be a list of cons pairs of the form
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
47 \(CHAR-OR-STRING . STRING) used to set the local Font Lock syntax table, for
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
48 keyword and syntactic fontification (see `modify-syntax-entry').
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
49
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
50 If SYNTAX-BEGIN is non-nil, it should be a function with no args used to move
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
51 backwards outside any enclosing syntactic block, for syntactic fontification.
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
52 Typical values are `beginning-of-line' (i.e., the start of the line is known to
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
53 be outside a syntactic block), or `beginning-of-defun' for programming modes or
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
54 `backward-paragraph' for textual modes (i.e., the mode-dependent function is
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
55 known to move outside a syntactic block). If nil, the beginning of the buffer
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
56 is used as a position outside of a syntactic block, in the worst case.
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
57
100387
35f1ab86f203 (font-lock-defaults): Doc fix: mention levels; refer to elisp manual.
Glenn Morris <rgm@gnu.org>
parents: 100171
diff changeset
58 \(See also Info node `(elisp)Font Lock Basics'.)
35f1ab86f203 (font-lock-defaults): Doc fix: mention levels; refer to elisp manual.
Glenn Morris <rgm@gnu.org>
parents: 100171
diff changeset
59
45440
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
60 These item elements are used by Font Lock mode to set the variables
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
61 `font-lock-keywords', `font-lock-keywords-only',
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
62 `font-lock-keywords-case-fold-search', `font-lock-syntax-table' and
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
63 `font-lock-beginning-of-syntax-function', respectively.
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
64
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
65 Further item elements are alists of the form (VARIABLE . VALUE) and are in no
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
66 particular order. Each VARIABLE is made buffer-local before set to VALUE.
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
67
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
68 Currently, appropriate variables include `font-lock-mark-block-function'.
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
69 If this is non-nil, it should be a function with no args used to mark any
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
70 enclosing block of text, for fontification via \\[font-lock-fontify-block].
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
71 Typical values are `mark-defun' for programming modes or `mark-paragraph' for
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
72 textual modes (i.e., the mode-dependent function is known to put point and mark
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
73 around a text block relevant to that mode).
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
74
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
75 Other variables include that for syntactic keyword fontification,
61825
eb334300d039 (font-lock-defaults): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents: 61270
diff changeset
76 `font-lock-syntactic-keywords' and those for buffer-specialized fontification
eb334300d039 (font-lock-defaults): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents: 61270
diff changeset
77 functions, `font-lock-fontify-buffer-function',
eb334300d039 (font-lock-defaults): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents: 61270
diff changeset
78 `font-lock-unfontify-buffer-function', `font-lock-fontify-region-function',
eb334300d039 (font-lock-defaults): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents: 61270
diff changeset
79 `font-lock-unfontify-region-function', and `font-lock-inhibit-thing-lock'.")
105609
bdcd73244f19 Convert comments about autoloads into autoload comments.
Glenn Morris <rgm@gnu.org>
parents: 104990
diff changeset
80 ;;;###autoload
104612
c220a29e75fd Define risky-local-variable property here rather than in files.el.
Glenn Morris <rgm@gnu.org>
parents: 103490
diff changeset
81 (put 'font-lock-defaults 'risky-local-variable t)
45440
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
82 (make-variable-buffer-local 'font-lock-defaults)
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
83
51719
1963828b8333 (font-lock-defaults-alist): Remove obsolete entries.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50595
diff changeset
84 (defvar font-lock-defaults-alist nil
45440
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
85 "Alist of fall-back Font Lock defaults for major modes.
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
86
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
87 Each item should be a list of the form:
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
88
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
89 (MAJOR-MODE . FONT-LOCK-DEFAULTS)
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
90
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
91 where MAJOR-MODE is a symbol and FONT-LOCK-DEFAULTS is a list of default
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
92 settings. See the variable `font-lock-defaults', which takes precedence.")
94156
eea76bfceb7c (font-lock-defaults-alist): Add WHEN to obsolescence declaration.
Juanma Barranquero <lekktu@gmail.com>
parents: 87649
diff changeset
93 (make-obsolete-variable 'font-lock-defaults-alist 'font-lock-defaults "21.1")
45440
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
94
45476
e1671f561407 (font-lock-function): New variable.
Colin Walters <walters@gnu.org>
parents: 45440
diff changeset
95 (defvar font-lock-function 'font-lock-default-function
e1671f561407 (font-lock-function): New variable.
Colin Walters <walters@gnu.org>
parents: 45440
diff changeset
96 "A function which is called when `font-lock-mode' is toggled.
e1671f561407 (font-lock-function): New variable.
Colin Walters <walters@gnu.org>
parents: 45440
diff changeset
97 It will be passed one argument, which is the current value of
e1671f561407 (font-lock-function): New variable.
Colin Walters <walters@gnu.org>
parents: 45440
diff changeset
98 `font-lock-mode'.")
e1671f561407 (font-lock-function): New variable.
Colin Walters <walters@gnu.org>
parents: 45440
diff changeset
99
63024
ed96547a88b1 (font-lock-mode-major-mode): Compiler defvar.
Luc Teirlinck <teirllm@auburn.edu>
parents: 62636
diff changeset
100 ;; The mode for which font-lock was initialized, or nil if none.
109008
646e914bd0fd * lisp/font-lock.el (font-lock-major-mode): Rename from
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
101 (defvar font-lock-major-mode)
45440
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
102 (define-minor-mode font-lock-mode
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
103 "Toggle Font Lock mode.
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
104 With arg, turn Font Lock mode off if and only if arg is a non-positive
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
105 number; if arg is nil, toggle Font Lock mode; anything else turns Font
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
106 Lock on.
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
107 \(Font Lock is also known as \"syntax highlighting\".)
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
108
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
109 When Font Lock mode is enabled, text is fontified as you type it:
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
110
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
111 - Comments are displayed in `font-lock-comment-face';
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
112 - Strings are displayed in `font-lock-string-face';
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
113 - Certain other expressions are displayed in other faces according to the
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
114 value of the variable `font-lock-keywords'.
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
115
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
116 To customize the faces (colors, fonts, etc.) used by Font Lock for
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
117 fontifying different parts of buffer text, use \\[customize-face].
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
118
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
119 You can enable Font Lock mode in any major mode automatically by turning on in
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
120 the major mode's hook. For example, put in your ~/.emacs:
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
121
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
122 (add-hook 'c-mode-hook 'turn-on-font-lock)
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
123
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
124 Alternatively, you can use Global Font Lock mode to automagically turn on Font
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
125 Lock mode in buffers whose major mode supports it and whose major mode is one
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
126 of `font-lock-global-modes'. For example, put in your ~/.emacs:
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
127
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
128 (global-font-lock-mode t)
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
129
66213
32398ccbc506 (font-lock-mode): Doc fix.
Romain Francoise <romain@orebokech.com>
parents: 64762
diff changeset
130 Where major modes support different levels of fontification, you can use
32398ccbc506 (font-lock-mode): Doc fix.
Romain Francoise <romain@orebokech.com>
parents: 64762
diff changeset
131 the variable `font-lock-maximum-decoration' to specify which level you
32398ccbc506 (font-lock-mode): Doc fix.
Romain Francoise <romain@orebokech.com>
parents: 64762
diff changeset
132 generally prefer. When you turn Font Lock mode on/off the buffer is
32398ccbc506 (font-lock-mode): Doc fix.
Romain Francoise <romain@orebokech.com>
parents: 64762
diff changeset
133 fontified/defontified, though fontification occurs only if the buffer is
32398ccbc506 (font-lock-mode): Doc fix.
Romain Francoise <romain@orebokech.com>
parents: 64762
diff changeset
134 less than `font-lock-maximum-size'.
45440
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
135
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
136 To add your own highlighting for some major mode, and modify the highlighting
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
137 selected automatically via the variable `font-lock-maximum-decoration', you can
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
138 use `font-lock-add-keywords'.
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
139
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
140 To fontify a buffer, without turning on Font Lock mode and regardless of buffer
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
141 size, you can use \\[font-lock-fontify-buffer].
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
142
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
143 To fontify a block (the function or paragraph containing point, or a number of
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
144 lines around point), perhaps because modification on the current line caused
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
145 syntactic change on other lines, you can use \\[font-lock-fontify-block].
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
146
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
147 See the variable `font-lock-defaults-alist' for the Font Lock mode default
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
148 settings. You can set your own default settings for some mode, by setting a
45476
e1671f561407 (font-lock-function): New variable.
Colin Walters <walters@gnu.org>
parents: 45440
diff changeset
149 buffer local value for `font-lock-defaults', via its mode hook.
e1671f561407 (font-lock-function): New variable.
Colin Walters <walters@gnu.org>
parents: 45440
diff changeset
150
e1671f561407 (font-lock-function): New variable.
Colin Walters <walters@gnu.org>
parents: 45440
diff changeset
151 The above is the default behavior of `font-lock-mode'; you may specify
e1671f561407 (font-lock-function): New variable.
Colin Walters <walters@gnu.org>
parents: 45440
diff changeset
152 your own function which is called when `font-lock-mode' is toggled via
e1671f561407 (font-lock-function): New variable.
Colin Walters <walters@gnu.org>
parents: 45440
diff changeset
153 `font-lock-function'. "
67306
0ec2c0df96f6 (font-lock-mode): Replace `:group font-lock' with `nil nil nil'.
Juri Linkov <juri@jurta.org>
parents: 67304
diff changeset
154 nil nil nil
45440
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
155 ;; Don't turn on Font Lock mode if we don't have a display (we're running a
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
156 ;; batch job) or if the buffer is invisible (the name starts with a space).
74228
6081cf49eb34 (font-lock-mode): "?\ " -> "?\s".
Juanma Barranquero <lekktu@gmail.com>
parents: 72233
diff changeset
157 (when (or noninteractive (eq (aref (buffer-name) 0) ?\s))
45440
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
158 (setq font-lock-mode nil))
46906
421ce085a3cc (font-lock-mode): Add font-lock-unfontify-buffer
Richard M. Stallman <rms@gnu.org>
parents: 46899
diff changeset
159 (funcall font-lock-function font-lock-mode)
421ce085a3cc (font-lock-mode): Add font-lock-unfontify-buffer
Richard M. Stallman <rms@gnu.org>
parents: 46899
diff changeset
160 ;; Arrange to unfontify this buffer if we change major mode later.
421ce085a3cc (font-lock-mode): Add font-lock-unfontify-buffer
Richard M. Stallman <rms@gnu.org>
parents: 46899
diff changeset
161 (if font-lock-mode
46975
93d9d4da05cd (font-lock-change-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46932
diff changeset
162 (add-hook 'change-major-mode-hook 'font-lock-change-mode nil t)
109008
646e914bd0fd * lisp/font-lock.el (font-lock-major-mode): Rename from
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
163 (remove-hook 'change-major-mode-hook 'font-lock-change-mode t)))
46975
93d9d4da05cd (font-lock-change-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46932
diff changeset
164
93d9d4da05cd (font-lock-change-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46932
diff changeset
165 ;; Get rid of fontification for the old major mode.
93d9d4da05cd (font-lock-change-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46932
diff changeset
166 ;; We do this when changing major modes.
93d9d4da05cd (font-lock-change-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46932
diff changeset
167 (defun font-lock-change-mode ()
47359
9da6d2e1b2ee (font-lock-change-mode): Just turn off font-lock-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47176
diff changeset
168 (font-lock-mode -1))
45440
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
169
47374
78178028d987 (font-lock-defontify): New function.
Richard M. Stallman <rms@gnu.org>
parents: 47359
diff changeset
170 (defun font-lock-defontify ()
78178028d987 (font-lock-defontify): New function.
Richard M. Stallman <rms@gnu.org>
parents: 47359
diff changeset
171 "Clear out all `font-lock-face' properties in current buffer.
50595
7633f45262ae (font-lock-maximum-size, font-lock-verbose): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49692
diff changeset
172 A major mode that uses `font-lock-face' properties might want to put
47374
78178028d987 (font-lock-defontify): New function.
Richard M. Stallman <rms@gnu.org>
parents: 47359
diff changeset
173 this function onto `change-major-mode-hook'."
78178028d987 (font-lock-defontify): New function.
Richard M. Stallman <rms@gnu.org>
parents: 47359
diff changeset
174 (let ((modp (buffer-modified-p))
78178028d987 (font-lock-defontify): New function.
Richard M. Stallman <rms@gnu.org>
parents: 47359
diff changeset
175 (inhibit-read-only t))
78178028d987 (font-lock-defontify): New function.
Richard M. Stallman <rms@gnu.org>
parents: 47359
diff changeset
176 (save-restriction
78178028d987 (font-lock-defontify): New function.
Richard M. Stallman <rms@gnu.org>
parents: 47359
diff changeset
177 (widen)
78178028d987 (font-lock-defontify): New function.
Richard M. Stallman <rms@gnu.org>
parents: 47359
diff changeset
178 (remove-list-of-text-properties (point-min) (point-max)
78178028d987 (font-lock-defontify): New function.
Richard M. Stallman <rms@gnu.org>
parents: 47359
diff changeset
179 '(font-lock-face)))
49692
1713a3efdd23 (font-lock-defontify): Use restore-buffer-modified-p.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49588
diff changeset
180 (restore-buffer-modified-p modp)))
47374
78178028d987 (font-lock-defontify): New function.
Richard M. Stallman <rms@gnu.org>
parents: 47359
diff changeset
181
63024
ed96547a88b1 (font-lock-mode-major-mode): Compiler defvar.
Luc Teirlinck <teirllm@auburn.edu>
parents: 62636
diff changeset
182 (defvar font-lock-set-defaults)
47359
9da6d2e1b2ee (font-lock-change-mode): Just turn off font-lock-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47176
diff changeset
183 (defun font-lock-default-function (mode)
45440
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
184 ;; Turn on Font Lock mode.
47359
9da6d2e1b2ee (font-lock-change-mode): Just turn off font-lock-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47176
diff changeset
185 (when mode
45686
25d73d0e2b98 (font-lock-category-alist): Delete.
Colin Walters <walters@gnu.org>
parents: 45481
diff changeset
186 (set (make-local-variable 'char-property-alias-alist)
25d73d0e2b98 (font-lock-category-alist): Delete.
Colin Walters <walters@gnu.org>
parents: 45481
diff changeset
187 (copy-tree char-property-alias-alist))
25d73d0e2b98 (font-lock-category-alist): Delete.
Colin Walters <walters@gnu.org>
parents: 45481
diff changeset
188 ;; Add `font-lock-face' as an alias for the `face' property.
25d73d0e2b98 (font-lock-category-alist): Delete.
Colin Walters <walters@gnu.org>
parents: 45481
diff changeset
189 (let ((elt (assq 'face char-property-alias-alist)))
25d73d0e2b98 (font-lock-category-alist): Delete.
Colin Walters <walters@gnu.org>
parents: 45481
diff changeset
190 (if elt
25d73d0e2b98 (font-lock-category-alist): Delete.
Colin Walters <walters@gnu.org>
parents: 45481
diff changeset
191 (unless (memq 'font-lock-face (cdr elt))
25d73d0e2b98 (font-lock-category-alist): Delete.
Colin Walters <walters@gnu.org>
parents: 45481
diff changeset
192 (setcdr elt (nconc (cdr elt) (list 'font-lock-face))))
50595
7633f45262ae (font-lock-maximum-size, font-lock-verbose): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49692
diff changeset
193 (push (list 'face 'font-lock-face) char-property-alias-alist))))
45440
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
194 ;; Turn off Font Lock mode.
47359
9da6d2e1b2ee (font-lock-change-mode): Just turn off font-lock-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47176
diff changeset
195 (unless mode
45686
25d73d0e2b98 (font-lock-category-alist): Delete.
Colin Walters <walters@gnu.org>
parents: 45481
diff changeset
196 ;; Remove `font-lock-face' as an alias for the `face' property.
25d73d0e2b98 (font-lock-category-alist): Delete.
Colin Walters <walters@gnu.org>
parents: 45481
diff changeset
197 (set (make-local-variable 'char-property-alias-alist)
25d73d0e2b98 (font-lock-category-alist): Delete.
Colin Walters <walters@gnu.org>
parents: 45481
diff changeset
198 (copy-tree char-property-alias-alist))
25d73d0e2b98 (font-lock-category-alist): Delete.
Colin Walters <walters@gnu.org>
parents: 45481
diff changeset
199 (let ((elt (assq 'face char-property-alias-alist)))
25d73d0e2b98 (font-lock-category-alist): Delete.
Colin Walters <walters@gnu.org>
parents: 45481
diff changeset
200 (when elt
25d73d0e2b98 (font-lock-category-alist): Delete.
Colin Walters <walters@gnu.org>
parents: 45481
diff changeset
201 (setcdr elt (remq 'font-lock-face (cdr elt)))
25d73d0e2b98 (font-lock-category-alist): Delete.
Colin Walters <walters@gnu.org>
parents: 45481
diff changeset
202 (when (null (cdr elt))
50595
7633f45262ae (font-lock-maximum-size, font-lock-verbose): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49692
diff changeset
203 (setq char-property-alias-alist
7633f45262ae (font-lock-maximum-size, font-lock-verbose): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49692
diff changeset
204 (delq elt char-property-alias-alist))))))
7633f45262ae (font-lock-maximum-size, font-lock-verbose): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49692
diff changeset
205
7633f45262ae (font-lock-maximum-size, font-lock-verbose): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49692
diff changeset
206 ;; Only do hard work if the mode has specified stuff in
7633f45262ae (font-lock-maximum-size, font-lock-verbose): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49692
diff changeset
207 ;; `font-lock-defaults'.
7633f45262ae (font-lock-maximum-size, font-lock-verbose): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49692
diff changeset
208 (when (or font-lock-defaults
63024
ed96547a88b1 (font-lock-mode-major-mode): Compiler defvar.
Luc Teirlinck <teirllm@auburn.edu>
parents: 62636
diff changeset
209 (if (boundp 'font-lock-keywords) font-lock-keywords)
60005
6e156606b5c5 (font-lock-default-function): Use with-no-warnings.
Richard M. Stallman <rms@gnu.org>
parents: 59871
diff changeset
210 (with-no-warnings
63024
ed96547a88b1 (font-lock-mode-major-mode): Compiler defvar.
Luc Teirlinck <teirllm@auburn.edu>
parents: 62636
diff changeset
211 (cdr (assq major-mode font-lock-defaults-alist)))
ed96547a88b1 (font-lock-mode-major-mode): Compiler defvar.
Luc Teirlinck <teirllm@auburn.edu>
parents: 62636
diff changeset
212 (and mode
ed96547a88b1 (font-lock-mode-major-mode): Compiler defvar.
Luc Teirlinck <teirllm@auburn.edu>
parents: 62636
diff changeset
213 (boundp 'font-lock-set-defaults)
ed96547a88b1 (font-lock-mode-major-mode): Compiler defvar.
Luc Teirlinck <teirllm@auburn.edu>
parents: 62636
diff changeset
214 font-lock-set-defaults
109008
646e914bd0fd * lisp/font-lock.el (font-lock-major-mode): Rename from
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
215 font-lock-major-mode
646e914bd0fd * lisp/font-lock.el (font-lock-major-mode): Rename from
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
216 (not (eq font-lock-major-mode major-mode))))
50595
7633f45262ae (font-lock-maximum-size, font-lock-verbose): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49692
diff changeset
217 (font-lock-mode-internal mode)))
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47374
diff changeset
218
45440
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
219 (defun turn-on-font-lock ()
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
220 "Turn on Font Lock mode (only if the terminal can display it)."
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
221 (unless font-lock-mode
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
222 (font-lock-mode)))
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
223
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
224 ;;; Global Font Lock mode.
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
225
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
226 ;; A few people have hassled in the past for a way to make it easier to turn on
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
227 ;; Font Lock mode, without the user needing to know for which modes s/he has to
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
228 ;; turn it on, perhaps the same way hilit19.el/hl319.el does. I've always
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
229 ;; balked at that way, as I see it as just re-moulding the same problem in
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
230 ;; another form. That is; some person would still have to keep track of which
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
231 ;; modes (which may not even be distributed with Emacs) support Font Lock mode.
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
232 ;; The list would always be out of date. And that person might have to be me.
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
233
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
234 ;; Implementation.
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
235 ;;
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
236 ;; In a previous discussion the following hack came to mind. It is a gross
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
237 ;; hack, but it generally works. We use the convention that major modes start
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
238 ;; by calling the function `kill-all-local-variables', which in turn runs
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
239 ;; functions on the hook variable `change-major-mode-hook'. We attach our
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
240 ;; function `font-lock-change-major-mode' to that hook. Of course, when this
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
241 ;; hook is run, the major mode is in the process of being changed and we do not
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
242 ;; know what the final major mode will be. So, `font-lock-change-major-mode'
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
243 ;; only (a) notes the name of the current buffer, and (b) adds our function
85449
1cafaf44a9b9 (turn-on-font-lock-if-desired):
Richard M. Stallman <rms@gnu.org>
parents: 78236
diff changeset
244 ;; `turn-on-font-lock-if-desired' to the hook variables
62636
1db2bedaa05e Update comment.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61825
diff changeset
245 ;; `after-change-major-mode-hook' and `post-command-hook' (for modes
1db2bedaa05e Update comment.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61825
diff changeset
246 ;; that do not yet run `after-change-major-mode-hook'). By the time
45440
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
247 ;; the functions on the first of these hooks to be run are run, the new major
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
248 ;; mode is assumed to be in place. This way we get a Font Lock function run
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
249 ;; when a major mode is turned on, without knowing major modes or their hooks.
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
250 ;;
62636
1db2bedaa05e Update comment.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61825
diff changeset
251 ;; Naturally this requires that major modes run `kill-all-local-variables'
1db2bedaa05e Update comment.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61825
diff changeset
252 ;; and `after-change-major-mode-hook', as they are supposed to. For modes
1db2bedaa05e Update comment.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61825
diff changeset
253 ;; that do not run `after-change-major-mode-hook' yet, `post-command-hook'
1db2bedaa05e Update comment.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61825
diff changeset
254 ;; takes care of things if the mode is set directly or indirectly by
1db2bedaa05e Update comment.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61825
diff changeset
255 ;; an interactive command; however, problems can occur if the mode is
1db2bedaa05e Update comment.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61825
diff changeset
256 ;; set by a timer or process: in that case, proper handling of Font Lock mode
1db2bedaa05e Update comment.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61825
diff changeset
257 ;; may be delayed until the next interactive command.
45440
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
258
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
259 ;; User interface.
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
260 ;;
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
261 ;; Although Global Font Lock mode is a pseudo-mode, I think that the user
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
262 ;; interface should conform to the usual Emacs convention for modes, i.e., a
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
263 ;; command to toggle the feature (`global-font-lock-mode') with a variable for
96376
c3309dba6542 American English spelling fix.
Glenn Morris <rgm@gnu.org>
parents: 94678
diff changeset
264 ;; finer control of the mode's behavior (`font-lock-global-modes').
45440
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
265 ;;
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
266 ;; The feature should not be enabled by loading font-lock.el, since other
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
267 ;; mechanisms for turning on Font Lock mode, such as M-x font-lock-mode RET or
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
268 ;; (add-hook 'c-mode-hook 'turn-on-font-lock), would cause Font Lock mode to be
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
269 ;; turned on everywhere. That would not be intuitive or informative because
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
270 ;; loading a file tells you nothing about the feature or how to control it. It
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
271 ;; would also be contrary to the Principle of Least Surprise. sm.
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
272
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
273 (defcustom font-lock-global-modes t
100171
d42aff5ca541 * align.el:
Lute Kamstra <lute@gnu.org>
parents: 96376
diff changeset
274 "Modes for which Font Lock mode is automagically turned on.
45440
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
275 Global Font Lock mode is controlled by the command `global-font-lock-mode'.
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
276 If nil, means no modes have Font Lock mode automatically turned on.
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
277 If t, all modes that support Font Lock mode have it automatically turned on.
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
278 If a list, it should be a list of `major-mode' symbol names for which Font Lock
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
279 mode should be automatically turned on. The sense of the list is negated if it
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
280 begins with `not'. For example:
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
281 (c-mode c++-mode)
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
282 means that Font Lock mode is turned on for buffers in C and C++ modes only."
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
283 :type '(choice (const :tag "none" nil)
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
284 (const :tag "all" t)
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
285 (set :menu-tag "mode specific" :tag "modes"
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
286 :value (not)
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
287 (const :tag "Except" not)
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
288 (repeat :inline t (symbol :tag "mode"))))
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
289 :group 'font-lock)
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
290
85449
1cafaf44a9b9 (turn-on-font-lock-if-desired):
Richard M. Stallman <rms@gnu.org>
parents: 78236
diff changeset
291 (defun turn-on-font-lock-if-desired ()
1cafaf44a9b9 (turn-on-font-lock-if-desired):
Richard M. Stallman <rms@gnu.org>
parents: 78236
diff changeset
292 (when (cond ((eq font-lock-global-modes t)
1cafaf44a9b9 (turn-on-font-lock-if-desired):
Richard M. Stallman <rms@gnu.org>
parents: 78236
diff changeset
293 t)
1cafaf44a9b9 (turn-on-font-lock-if-desired):
Richard M. Stallman <rms@gnu.org>
parents: 78236
diff changeset
294 ((eq (car-safe font-lock-global-modes) 'not)
1cafaf44a9b9 (turn-on-font-lock-if-desired):
Richard M. Stallman <rms@gnu.org>
parents: 78236
diff changeset
295 (not (memq major-mode (cdr font-lock-global-modes))))
103490
63c3de728507 * font-core.el (turn-on-font-lock-if-desired): Correctly handle
Chong Yidong <cyd@stupidchicken.com>
parents: 100908
diff changeset
296 (t (memq major-mode font-lock-global-modes)))
45440
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
297 (let (inhibit-quit)
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
298 (turn-on-font-lock))))
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
299
75638
a9000bb51801 (global-font-lock-mode): define-global-minor-mode changed to
Chong Yidong <cyd@stupidchicken.com>
parents: 75347
diff changeset
300 (define-globalized-minor-mode global-font-lock-mode
85449
1cafaf44a9b9 (turn-on-font-lock-if-desired):
Richard M. Stallman <rms@gnu.org>
parents: 78236
diff changeset
301 font-lock-mode turn-on-font-lock-if-desired
104990
f0794252d960 * mail/sendmail.el (send-mail-function):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 104612
diff changeset
302 ;; What was this :extra-args thingy for? --Stef
f0794252d960 * mail/sendmail.el (send-mail-function):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 104612
diff changeset
303 ;; :extra-args (dummy)
f0794252d960 * mail/sendmail.el (send-mail-function):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 104612
diff changeset
304 :initialize 'custom-initialize-delay
67289
cf2274237464 (global-font-lock-mode): Use define-global-minor-mode
Juri Linkov <juri@jurta.org>
parents: 66912
diff changeset
305 :init-value (not (or noninteractive emacs-basic-display))
cf2274237464 (global-font-lock-mode): Use define-global-minor-mode
Juri Linkov <juri@jurta.org>
parents: 66912
diff changeset
306 :group 'font-lock
cf2274237464 (global-font-lock-mode): Use define-global-minor-mode
Juri Linkov <juri@jurta.org>
parents: 66912
diff changeset
307 :version "22.1")
45440
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
308
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
309 ;;; End of Global Font Lock mode.
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
310
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
311 (provide 'font-core)
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
312
59871
83af8894e534 (font-lock-default-function): Handle the rare case where
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
313 ;; arch-tag: f8c286e1-02f7-41d9-b89b-1b67780aed71
45440
e879dd65b980 New file, broken out from font-lock.el.
Colin Walters <walters@gnu.org>
parents:
diff changeset
314 ;;; font-core.el ends here