aboutsummaryrefslogtreecommitdiffstats
path: root/lispref/modes.texi
diff options
context:
space:
mode:
authorKaroly Lorentey2005-06-15 12:57:51 +0000
committerKaroly Lorentey2005-06-15 12:57:51 +0000
commitef85512e51f043d73788f00a2aed13cccde0682c (patch)
treefc1fa1378533250f260ef8eaa9a84ae882d9df84 /lispref/modes.texi
parent8736257554f49445f7b4402ac7a9436b38ce6452 (diff)
parentef88a9999004e6c26148c8d280d6a41f623d7249 (diff)
downloademacs-ef85512e51f043d73788f00a2aed13cccde0682c.tar.gz
emacs-ef85512e51f043d73788f00a2aed13cccde0682c.zip
Merged from miles@gnu.org--gnu-2005 (patch 80-82, 350-422)
Patches applied: * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-350 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-351 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-352 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-353 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-354 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-355 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-356 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-357 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-358 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-359 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-360 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-361 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-362 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-363 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-364 Remove "-face" suffix from widget faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-365 Remove "-face" suffix from custom faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-366 Remove "-face" suffix from change-log faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-367 Remove "-face" suffix from compilation faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-368 Remove "-face" suffix from diff-mode faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-369 lisp/longlines.el (longlines-visible-face): Face removed * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-370 Remove "-face" suffix from woman faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-371 Remove "-face" suffix from whitespace-highlight face * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372 Remove "-face" suffix from ruler-mode faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-373 Remove "-face" suffix from show-paren faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-374 Remove "-face" suffix from log-view faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-375 Remove "-face" suffix from smerge faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-376 Remove "-face" suffix from show-tabs faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-377 Remove "-face" suffix from highlight-changes faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-378 Remove "-face" suffix from and downcase info faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-379 Remove "-face" suffix from pcvs faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-380 Update uses of renamed pcvs faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-381 Tweak ChangeLog * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-382 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-383 Remove "-face" suffix from strokes-char face * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-384 Remove "-face" suffix from compare-windows face * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-385 Remove "-face" suffix from calendar faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-386 Remove "-face" suffix from diary-button face * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-387 Remove "-face" suffix from testcover faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-388 Remove "-face" suffix from viper faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-389 Remove "-face" suffix from org faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-390 Remove "-face" suffix from sgml-namespace face * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-391 Remove "-face" suffix from table-cell face * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-392 Remove "-face" suffix from tex-mode faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-393 Remove "-face" suffix from texinfo-heading face * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-394 Remove "-face" suffix from flyspell faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-395 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-396 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-397 Remove "-face" suffix from gomoku faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-398 Remove "-face" suffix from mpuz faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-399 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-400 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-401 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-402 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-403 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-404 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-405 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-406 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-407 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-408 Remove "-face" suffix from Buffer-menu-buffer face * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409 Remove "-face" suffix from antlr-mode faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-410 Remove "-face" suffix from ebrowse faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-411 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-412 Remove "-face" suffix from flymake faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-413 Remove "-face" suffix from idlwave faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-414 Remove "-face" suffix from sh-script faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-415 Remove "-face" suffix from vhdl-mode faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-416 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-417 Remove "-face" suffix from which-func face * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-418 Remove "-face" suffix from cperl-mode faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-419 Remove "-face" suffix from ld-script faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-420 Fix cperl-mode font-lock problem * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-421 Tweak which-func face * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-422 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-80 Merge from emacs--cvs-trunk--0 * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-81 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-82 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-350
Diffstat (limited to 'lispref/modes.texi')
-rw-r--r--lispref/modes.texi96
1 files changed, 60 insertions, 36 deletions
diff --git a/lispref/modes.texi b/lispref/modes.texi
index f8c1ae82a4e..2366fca5b96 100644
--- a/lispref/modes.texi
+++ b/lispref/modes.texi
@@ -1650,13 +1650,13 @@ properties specified by @var{props} to the result. The argument
1650@var{value}. (This feature is new as of Emacs 22.1.) 1650@var{value}. (This feature is new as of Emacs 22.1.)
1651 1651
1652@item (@var{symbol} @var{then} @var{else}) 1652@item (@var{symbol} @var{then} @var{else})
1653A list whose first element is a symbol that is not a keyword specifies a 1653A list whose first element is a symbol that is not a keyword specifies
1654conditional. Its meaning depends on the value of @var{symbol}. If the 1654a conditional. Its meaning depends on the value of @var{symbol}. If
1655value is non-@code{nil}, the second element, @var{then}, is processed 1655@var{symbol} has a non-@code{nil} value, the second element,
1656recursively as a mode-line element. But if the value of @var{symbol} is 1656@var{then}, is processed recursively as a mode-line element.
1657@code{nil}, the third element, @var{else}, is processed recursively. 1657Otherwise, the third element, @var{else}, is processed recursively.
1658You may omit @var{else}; then the mode-line element displays nothing if 1658You may omit @var{else}; then the mode-line element displays nothing
1659the value of @var{symbol} is @code{nil}. 1659if the value of @var{symbol} is @code{nil} or void.
1660 1660
1661@item (@var{width} @var{rest}@dots{}) 1661@item (@var{width} @var{rest}@dots{})
1662A list whose first element is an integer specifies truncation or 1662A list whose first element is an integer specifies truncation or
@@ -2319,6 +2319,7 @@ Search-based fontification happens second.
2319@menu 2319@menu
2320* Font Lock Basics:: Overview of customizing Font Lock. 2320* Font Lock Basics:: Overview of customizing Font Lock.
2321* Search-based Fontification:: Fontification based on regexps. 2321* Search-based Fontification:: Fontification based on regexps.
2322* Customizing Keywords:: Customizing search-based fontification.
2322* Other Font Lock Variables:: Additional customization facilities. 2323* Other Font Lock Variables:: Additional customization facilities.
2323* Levels of Font Lock:: Each mode can define alternative levels 2324* Levels of Font Lock:: Each mode can define alternative levels
2324 so that the user can select more or less. 2325 so that the user can select more or less.
@@ -2624,19 +2625,27 @@ Non-@code{nil} means that regular expression matching for the sake of
2624@code{font-lock-keywords} should be case-insensitive. 2625@code{font-lock-keywords} should be case-insensitive.
2625@end defvar 2626@end defvar
2626 2627
2627You can use @code{font-lock-add-keywords} to add additional 2628@node Customizing Keywords
2629@subsection Customizing Search-Based Fontification
2630
2631 You can use @code{font-lock-add-keywords} to add additional
2628search-based fontification rules to a major mode, and 2632search-based fontification rules to a major mode, and
2629@code{font-lock-remove-keywords} to removes rules. 2633@code{font-lock-remove-keywords} to removes rules.
2630 2634
2631@defun font-lock-add-keywords mode keywords &optional append 2635@defun font-lock-add-keywords mode keywords &optional append
2632This function adds highlighting @var{keywords} for @var{mode}. The 2636This function adds highlighting @var{keywords}, for the current buffer
2633argument @var{keywords} should be a list with the same format as the 2637or for major mode @var{mode}. The argument @var{keywords} should be a
2634variable @code{font-lock-keywords}. @var{mode} should be a symbol, 2638list with the same format as the variable @code{font-lock-keywords}.
2635the major mode command name, such as @code{c-mode}. When Font Lock 2639
2636mode is turned on in @var{mode}, it adds @var{keywords} to 2640If @var{mode} is a symbol which is a major mode command name, such as
2637@code{font-lock-keywords}. @var{mode} can also be @code{nil}; the 2641@code{c-mode}, the effect is that enabling Font Lock mode in
2638highlighting @var{keywords} are immediately added to 2642@var{mode} will add @var{keywords} to @code{font-lock-keywords}.
2639@code{font-lock-keywords} in the current buffer in that case. 2643Calling with a non-@code{nil} value of @var{mode} is correct only in
2644your @file{~/.emacs} file.
2645
2646If @var{mode} is @code{nil}, this function adds @var{keywords} to
2647@code{font-lock-keywords} in the current buffer. This way of calling
2648@code{font-lock-add-keywords} is usually used in mode hook functions.
2640 2649
2641By default, @var{keywords} are added at the beginning of 2650By default, @var{keywords} are added at the beginning of
2642@code{font-lock-keywords}. If the optional argument @var{append} is 2651@code{font-lock-keywords}. If the optional argument @var{append} is
@@ -2645,7 +2654,29 @@ By default, @var{keywords} are added at the beginning of
2645non-@code{nil} value, they are added at the end of 2654non-@code{nil} value, they are added at the end of
2646@code{font-lock-keywords}. 2655@code{font-lock-keywords}.
2647 2656
2648For example: 2657Some modes provide specialized support you can use in additional
2658highlighting patterns. See the variables
2659@code{c-font-lock-extra-types}, @code{c++-font-lock-extra-types},
2660@code{objc-font-lock-extra-types} and
2661@code{java-font-lock-extra-types}, for example.
2662
2663@strong{Warning:} major mode functions must not call
2664@code{font-lock-add-keywords} under any circumstances, either directly
2665or indirectly, except through their mode hooks. (Doing so would lead
2666to incorrect behavior for some minor modes.) They should set up their
2667rules for search-based fontification by setting
2668@code{font-lock-keywords}.
2669@end defun
2670
2671@defun font-lock-remove-keywords mode keywords
2672This function removes @var{keywords} from @code{font-lock-keywords}
2673for the current buffer or for major mode @var{mode}. As in
2674@code{font-lock-add-keywords}, @var{mode} should be a major mode
2675command name or @code{nil}. All the caveats and requirments for
2676@code{font-lock-add-keywords} apply here too.
2677@end defun
2678
2679 For example, this code
2649 2680
2650@smallexample 2681@smallexample
2651(font-lock-add-keywords 'c-mode 2682(font-lock-add-keywords 'c-mode
@@ -2653,30 +2684,23 @@ For example:
2653 ("\\<\\(and\\|or\\|not\\)\\>" . font-lock-keyword-face))) 2684 ("\\<\\(and\\|or\\|not\\)\\>" . font-lock-keyword-face)))
2654@end smallexample 2685@end smallexample
2655 2686
2687@noindent
2656adds two fontification patterns for C mode: one to fontify the word 2688adds two fontification patterns for C mode: one to fontify the word
2657@samp{FIXME}, even in comments, and another to fontify the words 2689@samp{FIXME}, even in comments, and another to fontify the words
2658@samp{and}, @samp{or} and @samp{not} as keywords. 2690@samp{and}, @samp{or} and @samp{not} as keywords.
2659 2691
2660Some modes have specialized support for additional patterns. See the 2692@noindent
2661variables @code{c-font-lock-extra-types}, 2693That example affects only C mode proper. To add the same patterns to
2662@code{c++-font-lock-extra-types}, @code{objc-font-lock-extra-types} 2694C mode @emph{and} all modes derived from it, do this instead:
2663and @code{java-font-lock-extra-types}, for example.
2664@end defun
2665
2666@defun font-lock-remove-keywords mode keywords
2667This function removes highlighting @var{keywords} for @var{mode}. As
2668in @code{font-lock-add-keywords}, @var{mode} should be a major mode
2669command name or @code{nil}. If @code{nil}, the highlighting
2670@var{keywords} are immediately removed in the current buffer.
2671@end defun
2672 2695
2673@strong{Warning:} Only use a non-@code{nil} @var{mode} argument when 2696@smallexample
2674you use @code{font-lock-add-keywords} or 2697(add-hook 'c-mode-hook
2675@code{font-lock-remove-keywords} in your @file{.emacs} file. When you 2698 (lambda ()
2676use these functions from a Lisp program (such as a minor mode), we 2699 (font-lock-add-keywords nil
2677recommend that you use @code{nil} for @var{mode} (and place the call 2700 '(("\\<\\(FIXME\\):" 1 font-lock-warning-face prepend)
2678on a hook) to avoid subtle problems due to the details of the 2701 ("\\<\\(and\\|or\\|not\\)\\>" .
2679implementation. 2702 font-lock-keyword-face)))))
2703@end smallexample
2680 2704
2681@node Other Font Lock Variables 2705@node Other Font Lock Variables
2682@subsection Other Font Lock Variables 2706@subsection Other Font Lock Variables