emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r107297: Updates to Font Lock docs in


From: Chong Yidong
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r107297: Updates to Font Lock docs in Lisp manual.
Date: Thu, 16 Feb 2012 14:04:38 +0800
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 107297
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Thu 2012-02-16 14:04:38 +0800
message:
  Updates to Font Lock docs in Lisp manual.
  
  * doc/lispref/modes.texi (Minor Modes): Update how mode commands should treat
  arguments now.
  (Mode Line Basics): Clarify force-mode-line-update.
  (Mode Line Top): Note that the example is not realistic.
  (Mode Line Variables, Mode Line Data, %-Constructs, Header Lines)
  (Emulating Mode Line): Use "mode line" instead of "mode-line", and
  "mode line construct" instead of "mode line specification".
  (Syntactic Font Lock): Remove mention of obsolete variable
  font-lock-syntactic-keywords.
  (Setting Syntax Properties): Node deleted.
  (Font Lock Mode): Note that Font Lock mode is a minor mode.
  (Font Lock Basics): Note that syntactic fontification falls back
  on `syntax-table'.
  (Search-based Fontification): Emphasize that font-lock-keywords
  should not be set directly.
  (Faces for Font Lock): Avoid some confusing terminology.
  (Syntactic Font Lock): Minor clarifications.
modified:
  doc/lispref/ChangeLog
  doc/lispref/elisp.texi
  doc/lispref/modes.texi
  doc/lispref/syntax.texi
  doc/lispref/vol1.texi
  doc/lispref/vol2.texi
=== modified file 'doc/lispref/ChangeLog'
--- a/doc/lispref/ChangeLog     2012-02-15 13:45:02 +0000
+++ b/doc/lispref/ChangeLog     2012-02-16 06:04:38 +0000
@@ -1,3 +1,23 @@
+2012-02-16  Chong Yidong  <address@hidden>
+
+       * modes.texi (Minor Modes): Update how mode commands should treat
+       arguments now.
+       (Mode Line Basics): Clarify force-mode-line-update.
+       (Mode Line Top): Note that the example is not realistic.
+       (Mode Line Variables, Mode Line Data, %-Constructs, Header Lines)
+       (Emulating Mode Line): Use "mode line" instead of "mode-line", and
+       "mode line construct" instead of "mode line specification".
+       (Syntactic Font Lock): Remove mention of obsolete variable
+       font-lock-syntactic-keywords.
+       (Setting Syntax Properties): Node deleted.
+       (Font Lock Mode): Note that Font Lock mode is a minor mode.
+       (Font Lock Basics): Note that syntactic fontification falls back
+       on `syntax-table'.
+       (Search-based Fontification): Emphasize that font-lock-keywords
+       should not be set directly.
+       (Faces for Font Lock): Avoid some confusing terminology.
+       (Syntactic Font Lock): Minor clarifications.
+
 2012-02-15  Chong Yidong  <address@hidden>
 
        * minibuf.texi (Basic Completion): Define "completion table".
@@ -9,6 +29,10 @@
        (Setting Hooks): Update minor mode usage example.
        (Major Mode Conventions): Note that completion-at-point-functions
        should be altered locally.  Add xref to Completion in Buffers.
+       Remove duplicate tip about auto-mode-alist.
+       (Minor Modes): Rewrite introduction.
+       (Minor Mode Conventions): Copyedits.  Don't recommend
+       variable-only minor modes since few minor modes are like that.
 
 2012-02-15  Glenn Morris  <address@hidden>
 

=== modified file 'doc/lispref/elisp.texi'
--- a/doc/lispref/elisp.texi    2012-02-15 13:45:02 +0000
+++ b/doc/lispref/elisp.texi    2012-02-16 06:04:38 +0000
@@ -814,8 +814,6 @@
                                   contents can also specify how to fontify it.
 * Faces for Font Lock::     Special faces specifically for Font Lock.
 * Syntactic Font Lock::     Fontification based on syntax tables.
-* Setting Syntax Properties::   Defining character syntax based on context
-                                  using the Font Lock mechanism.
 * Multiline Font Lock::     How to coerce Font Lock into properly
                               highlighting multiline constructs.
 

=== modified file 'doc/lispref/modes.texi'
--- a/doc/lispref/modes.texi    2012-02-15 13:45:02 +0000
+++ b/doc/lispref/modes.texi    2012-02-16 06:04:38 +0000
@@ -464,11 +464,6 @@
 @code{completion-at-point-functions}.  @xref{Completion in Buffers}.
 
 @item
-Use @code{defvar} or @code{defcustom} to set mode-related variables, so
-that they are not reinitialized if they already have a value.  (Such
-reinitialization could discard customizations made by the user.)
-
address@hidden
 @cindex buffer-local variables in modes
 To make a buffer-local binding for an Emacs customization variable, use
 @code{make-local-variable} in the major mode command, not
@@ -546,15 +541,13 @@
 the file that contains the mode definition.
 
 @item
-In the comments that document the file, you should provide a sample
address@hidden form and an example of how to add to
address@hidden, that users can include in their init files
-(@pxref{Init File}).
-
address@hidden
 @cindex mode loading
 The top-level forms in the file defining the mode should be written so
 that they may be evaluated more than once without adverse consequences.
+For instance, use @code{defvar} or @code{defcustom} to set mode-related
+variables, so that they are not reinitialized if they already have a
+value (@pxref{Defining Variables}).
+
 @end itemize
 
 @node Auto Major Mode
@@ -1201,27 +1194,20 @@
 @section Minor Modes
 @cindex minor mode
 
-  A @dfn{minor mode} provides features that users may enable or disable
-independently of the choice of major mode.  Minor modes can be enabled
-individually or in combination.  Minor modes would be better named
-``generally available, optional feature modes,'' except that such a name
-would be unwieldy.
-
-  A minor mode is not usually meant as a variation of a single major mode.
-Usually they are general and can apply to many major modes.  For
-example, Auto Fill mode works with any major mode that permits text
-insertion.  To be general, a minor mode must be effectively independent
-of the things major modes do.
-
-  A minor mode is often much more difficult to implement than a major
-mode.  One reason is that you should be able to activate and deactivate
-minor modes in any order.  A minor mode should be able to have its
-desired effect regardless of the major mode and regardless of the other
-minor modes in effect.
-
-  Often the biggest problem in implementing a minor mode is finding a
-way to insert the necessary hook into the rest of Emacs.  Minor mode
-keymaps make this easier than it used to be.
+  A @dfn{minor mode} provides optional features that users may enable or
+disable independently of the choice of major mode.  Minor modes can be
+enabled individually or in combination.
+
+  Most minor modes implement features that are independent of the major
+mode, and can thus be used with most major modes.  For example, Auto
+Fill mode works with any major mode that permits text insertion.  A few
+minor modes, however, are specific to a particular major mode.  For
+example, Diff Auto Refine mode is a minor mode that is intended to be
+used only with Diff mode.
+
+  Ideally, a minor mode should have its desired effect regardless of the
+other minor modes in effect.  It should be possible to activate and
+deactivate minor modes in any order.
 
 @defvar minor-mode-list
 The value of this variable is a list of all minor mode commands.
@@ -1239,60 +1225,76 @@
 @cindex conventions for writing minor modes
 
   There are conventions for writing minor modes just as there are for
-major modes.  Several of the major mode conventions apply to minor
-modes as well: those regarding the name of the mode initialization
-function, the names of global symbols, the use of a hook at the end of
-the initialization function, and the use of keymaps and other tables.
-
-  In addition, there are several conventions that are specific to
-minor modes.  (The easiest way to follow all the conventions is to use
-the macro @code{define-minor-mode}; @ref{Defining Minor Modes}.)
+major modes.  These conventions are described below.  The easiest way to
+follow them is to use the macro @code{define-minor-mode}.
address@hidden Minor Modes}.
 
 @itemize @bullet
 @item
 @cindex mode variable
-Make a variable whose name ends in @samp{-mode} to control the minor
-mode.  We call this the @dfn{mode variable}.  The minor mode command
-should set this variable (@code{nil} to disable; anything else to
-enable).
-
-If possible, implement the mode so that setting the variable
-automatically enables or disables the mode.  Then the minor mode command
-does not need to do anything except set the variable.
+Define a variable whose name ends in @samp{-mode}.  We call this the
address@hidden variable}.  The minor mode command should set this variable.
+The value will be @code{nil} is the mode is disabled, and address@hidden
+if the mode is enabled.  The variable should be buffer-local if the
+minor mode is buffer-local.
 
 This variable is used in conjunction with the @code{minor-mode-alist} to
-display the minor mode name in the mode line.  It can also enable
-or disable a minor mode keymap.  Individual commands or hooks can also
-check the variable's value.
-
-If you want the minor mode to be enabled separately in each buffer,
-make the variable buffer-local.
+display the minor mode name in the mode line.  It also determines
+whether the minor mode keymap is active, via @code{minor-mode-map-alist}
+(@pxref{Controlling Active Maps}).  Individual commands or hooks can
+also check its value.
 
 @item
-Define a command whose name is the same as the mode variable.
-Its job is to enable and disable the mode by setting the variable.
-
-The command should accept one optional argument.  If the argument is
address@hidden, it should toggle the mode (turn it on if it is off, and
-off if it is on).  It should turn the mode on if the argument is a
-positive integer, the symbol @code{t}, or a list whose @sc{car} is one
-of those.  It should turn the mode off if the argument is a negative
-integer or zero, the symbol @code{-}, or a list whose @sc{car} is a
-negative integer or zero.  The meaning of other arguments is not
-specified.
-
-Here is an example taken from the definition of @code{transient-mark-mode}.
-It shows the use of @code{transient-mark-mode} as a variable that enables or
-disables the mode's behavior, and also shows the proper way to toggle,
-enable or disable the minor mode based on the raw prefix argument value.
-
address@hidden
address@hidden
-(setq transient-mark-mode
-      (if (null arg) (not transient-mark-mode)
-        (> (prefix-numeric-value arg) 0)))
address@hidden group
address@hidden smallexample
+Define a command, called the @dfn{mode command}, whose name is the same
+as the mode variable.  Its job is to set the value of the mode variable,
+plus anything else that needs to be done to actually enable or disable
+the mode's features.
+
+The mode command should accept one optional argument.  If called
+interactively with no prefix argument, it should toggle the mode
+(i.e.@: enable if it is disabled, and disable if it is enabled).  If
+called interactively with a prefix argument, it should enable the mode
+if the argument is positive and disable it otherwise.
+
+If the mode command is called from Lisp (i.e.@: non-interactively), it
+should enable the mode if the argument is omitted or @code{nil}; it
+should toggle the mode if the argument is the symbol @code{toggle};
+otherwise it should treat the argument in the same way as for an
+interactive call with a numeric prefix argument, as described above.
+
+The following example shows how to implement this behavior (it is
+similar to the code generated by the @code{define-minor-mode} macro):
+
address@hidden
+(interactive (list (or current-prefix-arg 'toggle)))
+(let ((enable (if (eq arg 'toggle)
+                  (not foo-mode) ; @r{this mode's mode variable}
+                (> (prefix-numeric-value arg) 0))))
+  (if enable
+      @var{do-enable}
+    @var{do-disable}))
address@hidden example
+
+The reason for this somewhat complex behavior is that it lets users
+easily toggle the minor mode interactively, and also lets the minor mode
+be easily enabled in a mode hook, like this:
+
address@hidden
+(add-hook 'text-mode-hook 'foo-mode)
address@hidden example
+
address@hidden
+This behaves correctly whether or not @code{foo-mode} was already
+enabled, since the @code{foo-mode} mode command unconditionally enables
+the minor mode when it is called from Lisp with no argument.  Disabling
+a minor mode in a mode hook is a little uglier:
+
address@hidden
+(add-hook 'text-mode-hook (lambda () (foo-mode -1)))
address@hidden example
+
address@hidden
+However, this is not very commonly done.
 
 @item
 Add an element to @code{minor-mode-alist} for each minor mode
@@ -1315,8 +1317,7 @@
 @smallexample
 @group
 (unless (assq 'leif-mode minor-mode-alist)
-  (setq minor-mode-alist
-        (cons '(leif-mode " Leif") minor-mode-alist)))
+  (push '(leif-mode " Leif") minor-mode-alist))
 @end group
 @end smallexample
 
@@ -1330,25 +1331,24 @@
 @end smallexample
 @end itemize
 
-  Global minor modes distributed with Emacs should if possible support
-enabling and disabling via Custom (@pxref{Customization}).  To do this,
-the first step is to define the mode variable with @code{defcustom}, and
-specify @code{:type 'boolean}.
+  In addition, several major mode conventions apply to minor modes as
+well: those regarding the names of global symbols, the use of a hook at
+the end of the initialization function, and the use of keymaps and other
+tables.
 
-  If just setting the variable is not sufficient to enable the mode, you
+  The minor mode should, if possible, support enabling and disabling via
+Custom (@pxref{Customization}).  To do this, the mode variable should be
+defined with @code{defcustom}, usually with @code{:type 'boolean}.  If
+just setting the variable is not sufficient to enable the mode, you
 should also specify a @code{:set} method which enables the mode by
-invoking the mode command.  Note in the variable's documentation string that
-setting the variable other than via Custom may not take effect.
-
-  Also mark the definition with an autoload cookie (@pxref{autoload cookie}),
-and specify a @code{:require} so that customizing the variable will load
-the library that defines the mode.  This will copy suitable definitions
-into @file{loaddefs.el} so that users can use @code{customize-option} to
-enable the mode.  For example:
+invoking the mode command.  Note in the variable's documentation string
+that setting the variable other than via Custom may not take effect.
+Also, mark the definition with an autoload cookie (@pxref{autoload
+cookie}), and specify a @code{:require} so that customizing the variable
+will load the library that defines the mode.  For example:
 
 @smallexample
 @group
-
 ;;;###autoload
 (defcustom msb-mode nil
   "Toggle msb-mode.
@@ -1578,7 +1578,7 @@
 
 
 @node Mode Line Format
address@hidden Mode-Line Format
address@hidden Mode Line Format
 @cindex mode line
 
   Each Emacs window (aside from minibuffer windows) typically has a mode
@@ -1608,61 +1608,59 @@
 @node Mode Line Basics
 @subsection Mode Line Basics
 
-  @code{mode-line-format} is a buffer-local variable that holds a
address@hidden line construct}, a kind of template, which controls what is
-displayed on the mode line of the current buffer.  The value of
address@hidden specifies the buffer's header line in the
-same way.  All windows for the same buffer use the same
+  The contents of each mode line are specified by the buffer-local
+variable @code{mode-line-format} (@pxref{Mode Line Top}).  This variable
+holds a @dfn{mode line construct}: a template that controls what is
+displayed on the buffer's mode line.  The value of
address@hidden specifies the buffer's header line in the same
+way.  All windows for the same buffer use the same
 @code{mode-line-format} and @code{header-line-format}.
 
-  For efficiency, Emacs does not continuously recompute the mode
-line and header line of a window.  It does so when circumstances
-appear to call for it---for instance, if you change the window
-configuration, switch buffers, narrow or widen the buffer, scroll, or
-change the buffer's modification status.  If you modify any of the
-variables referenced by @code{mode-line-format} (@pxref{Mode Line
-Variables}), or any other variables and data structures that affect
-how text is displayed (@pxref{Display}), you may want to force an
-update of the mode line so as to display the new information or
-display it in the new way.
+  For efficiency, Emacs does not continuously recompute each window's
+mode line and header line.  It does so when circumstances appear to call
+for it---for instance, if you change the window configuration, switch
+buffers, narrow or widen the buffer, scroll, or modify the buffer.  If
+you alter any of the variables referenced by @code{mode-line-format} or
address@hidden (@pxref{Mode Line Variables}), or any other
+data structures that affect how text is displayed (@pxref{Display}), you
+should use the function @code{force-mode-line-update} to update the
+display.
 
 @defun force-mode-line-update &optional all
-Force redisplay of the current buffer's mode line and header line.
-The next redisplay will update the mode line and header line based on
-the latest values of all relevant variables.  With optional
address@hidden @var{all}, force redisplay of all mode lines and header
-lines.
+This function forces Emacs to update the current buffer's mode line and
+header line, based on the latest values of all relevant variables,
+during its next redisplay cycle.  If the optional argument @var{all} is
address@hidden, it forces an update for all mode lines and header lines.
 
-This function also forces recomputation of the menu bar menus
-and the frame title.
+This function also forces an update of the menu bar and frame title.
 @end defun
 
   The selected window's mode line is usually displayed in a different
-color using the face @code{mode-line}.  Other windows' mode lines
-appear in the face @code{mode-line-inactive} instead.  @xref{Faces}.
+color using the face @code{mode-line}.  Other windows' mode lines appear
+in the face @code{mode-line-inactive} instead.  @xref{Faces}.
 
 @node Mode Line Data
 @subsection The Data Structure of the Mode Line
address@hidden mode-line construct
address@hidden mode line construct
 
-  The mode-line contents are controlled by a data structure called a
address@hidden construct}, made up of lists, strings, symbols, and
+  The mode line contents are controlled by a data structure called a
address@hidden line construct}, made up of lists, strings, symbols, and
 numbers kept in buffer-local variables.  Each data type has a specific
-meaning for the mode-line appearance, as described below.  The same
-data structure is used for constructing frame titles (@pxref{Frame
-Titles}) and header lines (@pxref{Header Lines}).
+meaning for the mode line appearance, as described below.  The same data
+structure is used for constructing frame titles (@pxref{Frame Titles})
+and header lines (@pxref{Header Lines}).
 
-  A mode-line construct may be as simple as a fixed string of text,
+  A mode line construct may be as simple as a fixed string of text,
 but it usually specifies how to combine fixed strings with variables'
 values to construct the text.  Many of these variables are themselves
-defined to have mode-line constructs as their values.
+defined to have mode line constructs as their values.
 
-  Here are the meanings of various data types as mode-line constructs:
+  Here are the meanings of various data types as mode line constructs:
 
 @table @code
 @cindex percent symbol in mode line
 @item @var{string}
-A string as a mode-line construct appears verbatim except for
+A string as a mode line construct appears verbatim except for
 @address@hidden in it.  These stand for substitution of
 other data; see @ref{%-Constructs}.
 
@@ -1675,8 +1673,8 @@
 special meanings.  @xref{Properties in Mode}.
 
 @item @var{symbol}
-A symbol as a mode-line construct stands for its value.  The value of
address@hidden is used as a mode-line construct, in place of @var{symbol}.
+A symbol as a mode line construct stands for its value.  The value of
address@hidden is used as a mode line construct, in place of @var{symbol}.
 However, the symbols @code{t} and @code{nil} are ignored, as is any
 symbol whose value is void.
 
@@ -1685,17 +1683,17 @@
 
 Unless @var{symbol} is marked as ``risky'' (i.e., it has a
 address@hidden @code{risky-local-variable} property), all text
-properties specified in @var{symbol}'s value are ignored.  This
-includes the text properties of strings in @var{symbol}'s value, as
-well as all @code{:eval} and @code{:propertize} forms in it.  (The
-reason for this is security: non-risky variables could be set
-automatically from file variables without prompting the user.)
+properties specified in @var{symbol}'s value are ignored.  This includes
+the text properties of strings in @var{symbol}'s value, as well as all
address@hidden:eval} and @code{:propertize} forms in it.  (The reason for this
+is security: non-risky variables could be set automatically from file
+variables without prompting the user.)
 
 @item (@var{string} @address@hidden)
 @itemx (@var{list} @address@hidden)
 A list whose first element is a string or list means to process all the
 elements recursively and concatenate the results.  This is the most
-common form of mode-line construct.
+common form of mode line construct.
 
 @item (:eval @var{form})
 A list whose first element is the symbol @code{:eval} says to evaluate
@@ -1705,24 +1703,24 @@
 
 @item (:propertize @var{elt} @address@hidden)
 A list whose first element is the symbol @code{:propertize} says to
-process the mode-line construct @var{elt} recursively, then add the text
+process the mode line construct @var{elt} recursively, then add the text
 properties specified by @var{props} to the result.  The argument
 @var{props} should consist of zero or more pairs @var{text-property}
address@hidden  (This feature is new as of Emacs 22.1.)
address@hidden
 
 @item (@var{symbol} @var{then} @var{else})
 A list whose first element is a symbol that is not a keyword specifies
 a conditional.  Its meaning depends on the value of @var{symbol}.  If
 @var{symbol} has a address@hidden value, the second element,
address@hidden, is processed recursively as a mode-line element.
address@hidden, is processed recursively as a mode line element.
 Otherwise, the third element, @var{else}, is processed recursively.
-You may omit @var{else}; then the mode-line element displays nothing
+You may omit @var{else}; then the mode line element displays nothing
 if the value of @var{symbol} is @code{nil} or void.
 
 @item (@var{width} @address@hidden)
 A list whose first element is an integer specifies truncation or
 padding of the results of @var{rest}.  The remaining elements
address@hidden are processed recursively as mode-line constructs and
address@hidden are processed recursively as mode line constructs and
 concatenated together.  When @var{width} is positive, the result is
 space filled on the right if its width is less than @var{width}.  When
 @var{width} is negative, the result is truncated on the right to
@@ -1739,12 +1737,12 @@
 @code{mode-line-format}.
 
 @defopt mode-line-format
-The value of this variable is a mode-line construct that controls the
+The value of this variable is a mode line construct that controls the
 contents of the mode-line.  It is always buffer-local in all buffers.
 
-If you set this variable to @code{nil} in a buffer, that buffer does
-not have a mode line.  (A window that is just one line tall never
-displays a mode line.)
+If you set this variable to @code{nil} in a buffer, that buffer does not
+have a mode line.  (A window that is just one line tall also does not
+display a mode line.)
 @end defopt
 
   The default value of @code{mode-line-format} is designed to use the
@@ -1762,9 +1760,9 @@
 the user or by Lisp programs (such as @code{display-time} and major
 modes) via changes to those variables remain effective.
 
-  Here is an example of a @code{mode-line-format} that might be
-useful for @code{shell-mode}, since it contains the host name and default
-directory.
+  Here is a hypothetical example of a @code{mode-line-format} that might
+be useful for Shell mode (in reality, Shell mode does not set
address@hidden):
 
 @example
 @group
@@ -1777,7 +1775,7 @@
 @end group
 @group
    ;; @r{Note that this is evaluated while making the list.}
-   ;; @r{It makes a mode-line construct which is just a string.}
+   ;; @r{It makes a mode line construct which is just a string.}
    (getenv "HOST")
 @end group
    ":"
@@ -1794,8 +1792,7 @@
    '(which-func-mode ("" which-func-format "--"))
    '(line-number-mode "L%l--")
    '(column-number-mode "C%c--")
-   '(-3 "%p")
-   "-%-"))
+   '(-3 "%p")))
 @end group
 @end example
 
@@ -1807,23 +1804,23 @@
 @node Mode Line Variables
 @subsection Variables Used in the Mode Line
 
-  This section describes variables incorporated by the standard value
-of @code{mode-line-format} into the text of the mode line.  There is
+  This section describes variables incorporated by the standard value of
address@hidden into the text of the mode line.  There is
 nothing inherently special about these variables; any other variables
-could have the same effects on the mode line if
address@hidden's value were changed to use them.  However,
-various parts of Emacs set these variables on the understanding that
-they will control parts of the mode line; therefore, practically
-speaking, it is essential for the mode line to use them.
+could have the same effects on the mode line if the value of
address@hidden is changed to use them.  However, various parts
+of Emacs set these variables on the understanding that they will control
+parts of the mode line; therefore, practically speaking, it is essential
+for the mode line to use them.
 
 @defvar mode-line-mule-info
-This variable holds the value of the mode-line construct that displays
+This variable holds the value of the mode line construct that displays
 information about the language environment, buffer coding system, and
 current input method.  @xref{Non-ASCII Characters}.
 @end defvar
 
 @defvar mode-line-modified
-This variable holds the value of the mode-line construct that displays
+This variable holds the value of the mode line construct that displays
 whether the current buffer is modified.  Its default value displays
 @samp{**} if the buffer is modified, @samp{--} if the buffer is not
 modified, @samp{%%} if the buffer is read only, and @samp{%*} if the
@@ -1886,7 +1883,7 @@
 @end defvar
 
 @defvar mode-line-process
-This buffer-local variable contains the mode-line information on process
+This buffer-local variable contains the mode line information on process
 status in modes used for communicating with subprocesses.  It is
 displayed immediately following the major mode name, with no intervening
 space.  For example, its value in the @samp{*shell*} buffer is
@@ -1905,12 +1902,12 @@
 (@var{minor-mode-variable} @var{mode-line-string})
 @end example
 
-More generally, @var{mode-line-string} can be any mode-line spec.  It
-appears in the mode line when the value of @var{minor-mode-variable}
+More generally, @var{mode-line-string} can be any mode line construct.
+It appears in the mode line when the value of @var{minor-mode-variable}
 is address@hidden, and not otherwise.  These strings should begin with
 spaces so that they don't run together.  Conventionally, the
address@hidden for a specific mode is set to a
address@hidden value when that minor mode is activated.
address@hidden for a specific mode is set to a address@hidden
+value when that minor mode is activated.
 
 @code{minor-mode-alist} itself is not buffer-local.  Each variable
 mentioned in the alist should be buffer-local if its minor mode can be
@@ -1918,12 +1915,12 @@
 @end defvar
 
 @defvar global-mode-string
-This variable holds a mode-line spec that, by default, appears in the
-mode line just after the @code{which-func-mode} minor mode if set,
-else after @code{mode-line-modes}.  The command @code{display-time}
-sets @code{global-mode-string} to refer to the variable
address@hidden, which holds a string containing the time
-and load information.
+This variable holds a mode line construct that, by default, appears in
+the mode line just after the @code{which-func-mode} minor mode if set,
+else after @code{mode-line-modes}.  The command @code{display-time} sets
address@hidden to refer to the variable
address@hidden, which holds a string containing the time and
+load information.
 
 The @samp{%M} construct substitutes the value of
 @code{global-mode-string}, but that is obsolete, since the variable is
@@ -1957,7 +1954,7 @@
 @node %-Constructs
 @subsection @code{%}-Constructs in the Mode Line
 
-  Strings used as mode-line constructs can use certain
+  Strings used as mode line constructs can use certain
 @code{%}-constructs to substitute various kinds of data.  Here is a
 list of the defined @code{%}-constructs, and what they mean.  In any
 construct except @samp{%%}, you can add a decimal integer after the
@@ -2003,8 +2000,8 @@
 
 @item %p
 The percentage of the buffer text above the @strong{top} of window, or
address@hidden, @samp{Bottom} or @samp{All}.  Note that the default
-mode-line specification truncates this to three characters.
address@hidden, @samp{Bottom} or @samp{All}.  Note that the default mode
+line construct truncates this to three characters.
 
 @item %P
 The percentage of the buffer text that is above the @strong{bottom} of
@@ -2084,11 +2081,11 @@
 
 @enumerate
 @item
-Put a string with a text property directly into the mode-line data
+Put a string with a text property directly into the mode line data
 structure.
 
 @item
-Put a text property on a mode-line %-construct such as @samp{%12b}; then
+Put a text property on a mode line %-construct such as @samp{%12b}; then
 the expansion of the %-construct will have that same text property.
 
 @item
@@ -2096,7 +2093,7 @@
 give @var{elt} a text property specified by @var{props}.
 
 @item
-Use a list containing @code{:eval @var{form}} in the mode-line data
+Use a list containing @code{:eval @var{form}} in the mode line data
 structure, and make @var{form} evaluate to a string that has a text
 property.
 @end enumerate
@@ -2118,10 +2115,10 @@
 @cindex header line (of a window)
 @cindex window header line
 
-  A window can have a @dfn{header line} at the
-top, just as it can have a mode line at the bottom.  The header line
-feature works just like the mode-line feature, except that it's
-controlled by different variables.
+  A window can have a @dfn{header line} at the top, just as it can have
+a mode line at the bottom.  The header line feature works just like the
+mode line feature, except that it's controlled by
address@hidden:
 
 @defvar header-line-format
 This variable, local in every buffer, specifies how to display the
@@ -2136,11 +2133,11 @@
 header line.
 
 @node Emulating Mode Line
address@hidden Emulating Mode-Line Formatting
address@hidden Emulating Mode Line Formatting
 
-  You can use the function @code{format-mode-line} to compute
-the text that would appear in a mode line or header line
-based on a certain mode-line specification.
+  You can use the function @code{format-mode-line} to compute the text
+that would appear in a mode line or header line based on a certain
+mode line construct.
 
 @defun format-mode-line format &optional face window buffer
 This function formats a line of text according to @var{format} as if it
@@ -2374,12 +2371,12 @@
 @section Font Lock Mode
 @cindex Font Lock mode
 
-  @dfn{Font Lock mode} is a feature that automatically attaches
address@hidden properties to certain parts of the buffer based on their
-syntactic role.  How it parses the buffer depends on the major mode;
-most major modes define syntactic criteria for which faces to use in
-which contexts.  This section explains how to customize Font Lock for a
-particular major mode.
+  @dfn{Font Lock mode} is a buffer-local minor mode that automatically
+attaches @code{face} properties to certain parts of the buffer based on
+their syntactic role.  How it parses the buffer depends on the major
+mode; most major modes define syntactic criteria for which faces to use
+in which contexts.  This section explains how to customize Font Lock for
+a particular major mode.
 
   Font Lock mode finds text to highlight in two ways: through
 syntactic parsing based on the syntax table, and through searching
@@ -2398,8 +2395,6 @@
                                   contents can also specify how to fontify it.
 * Faces for Font Lock::         Special faces specifically for Font Lock.
 * Syntactic Font Lock::         Fontification based on syntax tables.
-* Setting Syntax Properties::   Defining character syntax based on context
-                                  using the Font Lock mechanism.
 * Multiline Font Lock::         How to coerce Font Lock into properly
                                   highlighting multiline constructs.
 @end menu
@@ -2414,12 +2409,12 @@
 Lock mode is enabled, to set all the other variables.
 
 @defvar font-lock-defaults
-This variable is set by major modes, as a buffer-local variable, to
-specify how to fontify text in that mode.  It automatically becomes
-buffer-local when you set it.  If its value is @code{nil}, Font-Lock
-mode does no highlighting, and you can use the @samp{Faces} menu
-(under @samp{Edit} and then @samp{Text Properties} in the menu bar) to
-assign faces explicitly to text in the buffer.
+This variable is set by major modes to specify how to fontify text in
+that mode.  It automatically becomes buffer-local when set.  If its
+value is @code{nil}, Font Lock mode does no highlighting, and you can
+use the @samp{Faces} menu (under @samp{Edit} and then @samp{Text
+Properties} in the menu bar) to assign faces explicitly to text in the
+buffer.
 
 If address@hidden, the value should look like this:
 
@@ -2442,19 +2437,20 @@
 The second element, @var{keywords-only}, specifies the value of the
 variable @code{font-lock-keywords-only}.  If this is omitted or
 @code{nil}, syntactic fontification (of strings and comments) is also
-performed.  If this is address@hidden, such fontification is not
+performed.  If this is address@hidden, syntactic fontification is not
 performed.  @xref{Syntactic Font Lock}.
 
 The third element, @var{case-fold}, specifies the value of
 @code{font-lock-keywords-case-fold-search}.  If it is address@hidden,
-Font Lock mode ignores case when searching as directed by
address@hidden
+Font Lock mode ignores case during search-based fontification.
 
-If the fourth element, @var{syntax-alist}, is address@hidden, it
-should be a list of cons cells of the form @code{(@var{char-or-string}
-. @var{string})}.  These are used to set up a syntax table for
-syntactic fontification (@pxref{Syntax Table Functions}).  The
-resulting syntax table is stored in @code{font-lock-syntax-table}.
+If the fourth element, @var{syntax-alist}, is address@hidden, it should
+be a list of cons cells of the form @code{(@var{char-or-string}
+. @var{string})}.  These are used to set up a syntax table for syntactic
+fontification; the resulting syntax table is stored in
address@hidden  If @var{syntax-alist} is omitted or
address@hidden, syntactic fontification uses the syntax table returned by
+the @code{syntax-table} function.  @xref{Syntax Table Functions}.
 
 The fifth element, @var{syntax-begin}, specifies the value of
 @code{font-lock-beginning-of-syntax-function}.  We recommend setting
@@ -2480,15 +2476,17 @@
 @node Search-based Fontification
 @subsection Search-based Fontification
 
-  The most important variable for customizing Font Lock mode is
address@hidden  It specifies the search criteria for
-search-based fontification.  You should specify the value of this
-variable with @var{keywords} in @code{font-lock-defaults}.
+  The variable which directly controls search-based fontification is
address@hidden, which is typically specified via the
address@hidden element in @code{font-lock-defaults}.
 
 @defvar font-lock-keywords
-This variable's value is a list of the keywords to highlight.  Be
-careful when composing regular expressions for this list; a poorly
-written pattern can dramatically slow things down!
+The value of this variable is a list of the keywords to highlight.  Lisp
+programs should not set this variable directly.  Normally, the value is
+automatically set by Font Lock mode, using the @var{keywords} element in
address@hidden  The value can also be altered using the
+functions @code{font-lock-add-keywords} and
address@hidden (@pxref{Customizing Keywords}).
 @end defvar
 
   Each element of @code{font-lock-keywords} specifies how to find
@@ -2513,9 +2511,10 @@
 "\\<foo\\>"
 @end example
 
-The function @code{regexp-opt} (@pxref{Regexp Functions}) is useful
-for calculating optimal regular expressions to match a number of
-different keywords.
+Be careful when composing these regular expressions; a poorly written
+pattern can dramatically slow things down!  The function
address@hidden (@pxref{Regexp Functions}) is useful for calculating
+optimal regular expressions to match several keywords.
 
 @item @var{function}
 Find text by calling @var{function}, and highlight the matches
@@ -2740,7 +2739,7 @@
 @code{c-font-lock-extra-types}, @code{c++-font-lock-extra-types},
 and @code{java-font-lock-extra-types}, for example.
 
address@hidden:} major mode commands must not call
address@hidden:} Major mode commands must not call
 @code{font-lock-add-keywords} under any circumstances, either directly
 or indirectly, except through their mode hooks.  (Doing so would lead to
 incorrect behavior for some minor modes.)  They should set up their
@@ -2756,7 +2755,10 @@
 @code{font-lock-add-keywords} apply here too.
 @end defun
 
-  For example, this code
+  For example, the following code adds two fontification patterns for C
+mode: one to fontify the word @samp{FIXME}, even in comments, and
+another to fontify the words @samp{and}, @samp{or} and @samp{not} as
+keywords.
 
 @smallexample
 (font-lock-add-keywords 'c-mode
@@ -2765,13 +2767,8 @@
 @end smallexample
 
 @noindent
-adds two fontification patterns for C mode: one to fontify the word
address@hidden, even in comments, and another to fontify the words
address@hidden, @samp{or} and @samp{not} as keywords.
-
address@hidden
-That example affects only C mode proper.  To add the same patterns to
-C mode @emph{and} all modes derived from it, do this instead:
+This example affects only C mode proper.  To add the same patterns to C
+mode @emph{and} all modes derived from it, do this instead:
 
 @smallexample
 (add-hook 'c-mode-hook
@@ -2858,13 +2855,13 @@
 @node Levels of Font Lock
 @subsection Levels of Font Lock
 
-  Many major modes offer three different levels of fontification.  You
+  Some major modes offer three different levels of fontification.  You
 can define multiple levels by using a list of symbols for @var{keywords}
 in @code{font-lock-defaults}.  Each symbol specifies one level of
 fontification; it is up to the user to choose one of these levels,
 normally by setting @code{font-lock-maximum-decoration} (@pxref{Font
-Lock,,, emacs, the GNU Emacs Manual}).  The chosen level's symbol
-value is used to initialize @code{font-lock-keywords}.
+Lock,,, emacs, the GNU Emacs Manual}).  The chosen level's symbol value
+is used to initialize @code{font-lock-keywords}.
 
   Here are the conventions for how to define the levels of
 fontification:
@@ -2912,10 +2909,10 @@
 @cindex font lock faces
 
   Font Lock mode can highlight using any face, but Emacs defines several
-faces specifically for syntactic highlighting.  These @dfn{Font Lock
-faces} are listed below.  They can also be used by major modes for
-syntactic highlighting outside of Font Lock mode (@pxref{Major Mode
-Conventions}).
+faces specifically for Font Lock to use to highlight text.  These
address@hidden Lock faces} are listed below.  They can also be used by major
+modes for syntactic highlighting outside of Font Lock mode (@pxref{Major
+Mode Conventions}).
 
   Each of these symbols is both a face name, and a variable whose
 default value is the symbol itself.  Thus, the default value of
@@ -2990,128 +2987,60 @@
 @subsection Syntactic Font Lock
 @cindex syntactic font lock
 
-Syntactic fontification uses the syntax table to find comments and
-string constants (@pxref{Syntax Tables}).  It highlights them using
address@hidden and @code{font-lock-string-face}
-(@pxref{Faces for Font Lock}), or whatever
address@hidden chooses.  There are several
-variables that affect syntactic fontification; you should set them by
-means of @code{font-lock-defaults} (@pxref{Font Lock Basics}).
+Syntactic fontification uses a syntax table (@pxref{Syntax Tables}) to
+find and highlight syntactically relevant text.  If enabled, it runs
+prior to search-based fontification.  The variable
address@hidden, documented below, determines
+which syntactic constructs to highlight.  There are several variables
+that affect syntactic fontification; you should set them by means of
address@hidden (@pxref{Font Lock Basics}).
 
 @defvar font-lock-keywords-only
address@hidden means Font Lock should not do syntactic fontification;
-it should only fontify based on @code{font-lock-keywords}.  The normal
-way for a mode to set this variable to @code{t} is with
address@hidden in @code{font-lock-defaults}.
+If the value of this variable is address@hidden, Font Lock does not do
+syntactic fontification, only search-based fontification based on
address@hidden  It is normally set by Font Lock mode based
+on the @var{keywords-only} element in @code{font-lock-defaults}.
 @end defvar
 
 @defvar font-lock-syntax-table
 This variable holds the syntax table to use for fontification of
-comments and strings.  Specify it using @var{syntax-alist} in
address@hidden  If this is @code{nil}, fontification uses
-the buffer's syntax table.
+comments and strings.  It is normally set by Font Lock mode based on the
address@hidden element in @code{font-lock-defaults}.  If this value
+is @code{nil}, syntactic fontification uses the buffer's syntax table
+(the value returned by the function @code{syntax-table}; @pxref{Syntax
+Table Functions}).
 @end defvar
 
 @defvar font-lock-beginning-of-syntax-function
 If this variable is address@hidden, it should be a function to move
 point back to a position that is syntactically at ``top level'' and
-outside of strings or comments.  Font Lock uses this when necessary
-to get the right results for syntactic fontification.
-
-This function is called with no arguments.  It should leave point at
-the beginning of any enclosing syntactic block.  Typical values are
address@hidden (used when the start of the line is known to
-be outside a syntactic block), or @code{beginning-of-defun} for
+outside of strings or comments.  The value is normally set through an
address@hidden element in @code{font-lock-defaults}.  If it is
address@hidden, Font Lock uses @code{syntax-begin-function} to move back
+outside of any comment, string, or sexp (@pxref{Position Parse}).
+
+This variable is semi-obsolete; we usually recommend setting
address@hidden instead.  One of its uses is to tune the
+behavior of syntactic fontification, e.g.@: to ensure that different
+kinds of strings or comments are highlighted differently.
+
+The specified function is called with no arguments.  It should leave
+point at the beginning of any enclosing syntactic block.  Typical values
+are @code{beginning-of-line} (used when the start of the line is known
+to be outside a syntactic block), or @code{beginning-of-defun} for
 programming modes, or @code{backward-paragraph} for textual modes.
-
-If the value is @code{nil}, Font Lock uses
address@hidden to move back outside of any comment,
-string, or sexp.  This variable is semi-obsolete; we recommend setting
address@hidden instead.
-
-Specify this variable using @var{syntax-begin} in
address@hidden
 @end defvar
 
 @defvar font-lock-syntactic-face-function
-A function to determine which face to use for a given syntactic
-element (a string or a comment).  The function is called with one
-argument, the parse state at point returned by
address@hidden, and should return a face.  The default
-value returns @code{font-lock-comment-face} for comments and
address@hidden for strings.
-
-This can be used to highlighting different kinds of strings or
-comments differently.  It is also sometimes abused together with
address@hidden to highlight constructs that span
-multiple lines, but this is too esoteric to document here.
-
-Specify this variable using @var{other-vars} in
address@hidden
address@hidden defvar
-
address@hidden Setting Syntax Properties
address@hidden Setting Syntax Properties
-
-  Font Lock mode can be used to update @code{syntax-table} properties
-automatically (@pxref{Syntax Properties}).  This is useful in
-languages for which a single syntax table by itself is not sufficient.
-
address@hidden font-lock-syntactic-keywords
-This variable enables and controls updating @code{syntax-table}
-properties by Font Lock.  Its value should be a list of elements of
-this form:
-
address@hidden
-(@var{matcher} @var{subexp} @var{syntax} @var{override} @var{laxmatch})
address@hidden example
-
-The parts of this element have the same meanings as in the corresponding
-sort of element of @code{font-lock-keywords},
-
address@hidden
-(@var{matcher} @var{subexp} @var{facespec} @var{override} @var{laxmatch})
address@hidden example
-
-However, instead of specifying the value @var{facespec} to use for the
address@hidden property, it specifies the value @var{syntax} to use for
-the @code{syntax-table} property.  Here, @var{syntax} can be a string
-(as taken by @code{modify-syntax-entry}), a syntax table, a cons cell
-(as returned by @code{string-to-syntax}), or an expression whose value
-is one of those two types.  @var{override} cannot be @code{prepend} or
address@hidden
-
-For example, an element of the form:
-
address@hidden
-("\\$\\(#\\)" 1 ".")
address@hidden example
-
-highlights syntactically a hash character when following a dollar
-character, with a SYNTAX of @code{"."} (meaning punctuation syntax).
-Assuming that the buffer syntax table specifies hash characters to
-have comment start syntax, the element will only highlight hash
-characters that do not follow dollar characters as comments
-syntactically.
-
-An element of the form:
-
address@hidden
- ("\\('\\).\\('\\)"
-  (1 "\"")
-  (2 "\""))
address@hidden example
-
-highlights syntactically both single quotes which surround a single
-character, with a SYNTAX of @code{"\""} (meaning string quote syntax).
-Assuming that the buffer syntax table does not specify single quotes
-to have quote syntax, the element will only highlight single quotes of
-the form @samp{'@var{c}'} as strings syntactically.  Other forms, such
-as @samp{foo'bar} or @samp{'fubar'}, will not be highlighted as
-strings.
-
-Major modes normally set this variable with @var{other-vars} in
address@hidden
+If this variable is address@hidden, it should be a function to determine
+which face to use for a given syntactic element (a string or a comment).
+The value is normally set through an @var{other-vars} element in
address@hidden
+
+The function is called with one argument, the parse state at point
+returned by @code{parse-partial-sexp}, and should return a face.  The
+default value returns @code{font-lock-comment-face} for comments and
address@hidden for strings (@pxref{Faces for Font Lock}).
 @end defvar
 
 @node Multiline Font Lock
@@ -3220,18 +3149,17 @@
 
   The @code{font-lock-multiline} property is meant to ensure proper
 refontification; it does not automatically identify new multiline
-constructs.  Identifying the requires that Font-Lock operate on large
-enough chunks at a time.  This will happen by accident on many cases,
-which may give the impression that multiline constructs magically work.
-If you set the @code{font-lock-multiline} variable address@hidden,
-this impression will be even stronger, since the highlighting of those
-constructs which are found will be properly updated from then on.
-But that does not work reliably.
+constructs.  Identifying the requires that Font Lock mode operate on
+large enough chunks at a time.  This will happen by accident on many
+cases, which may give the impression that multiline constructs magically
+work.  If you set the @code{font-lock-multiline} variable
address@hidden, this impression will be even stronger, since the
+highlighting of those constructs which are found will be properly
+updated from then on.  But that does not work reliably.
 
-  To find multiline constructs reliably, you must either manually
-place the @code{font-lock-multiline} property on the text before
-Font-Lock looks at it, or use
address@hidden
+  To find multiline constructs reliably, you must either manually place
+the @code{font-lock-multiline} property on the text before Font Lock
+mode looks at it, or use @code{font-lock-fontify-region-function}.
 
 @node Region to Refontify
 @subsubsection Region to Fontify after a Buffer Change
@@ -3246,8 +3174,8 @@
 the following variable:
 
 @defvar font-lock-extend-after-change-region-function
-This buffer-local variable is either @code{nil} or a function for
-Font-Lock to call to determine the region to scan and fontify.
+This buffer-local variable is either @code{nil} or a function for Font
+Lock mode to call to determine the region to scan and fontify.
 
 The function is given three parameters, the standard @var{beg},
 @var{end}, and @var{old-len} from @code{after-change-functions}

=== modified file 'doc/lispref/syntax.texi'
--- a/doc/lispref/syntax.texi   2012-01-31 06:51:33 +0000
+++ b/doc/lispref/syntax.texi   2012-02-16 06:04:38 +0000
@@ -536,9 +536,7 @@
 When the syntax table is not flexible enough to specify the syntax of
 a language, you can use @code{syntax-table} text properties to
 override the syntax table for specific character occurrences in the
-buffer.  @xref{Text Properties}.  You can use Font Lock mode to set
address@hidden text properties.  @xref{Setting Syntax
-Properties}.
+buffer.  @xref{Text Properties}.
 
 The valid values of @code{syntax-table} text property are:
 

=== modified file 'doc/lispref/vol1.texi'
--- a/doc/lispref/vol1.texi     2012-02-15 13:45:02 +0000
+++ b/doc/lispref/vol1.texi     2012-02-16 06:04:38 +0000
@@ -835,8 +835,6 @@
                                   contents can also specify how to fontify it.
 * Faces for Font Lock::     Special faces specifically for Font Lock.
 * Syntactic Font Lock::     Fontification based on syntax tables.
-* Setting Syntax Properties::   Defining character syntax based on context
-                                  using the Font Lock mechanism.
 * Multiline Font Lock::     How to coerce Font Lock into properly
                               highlighting multiline constructs.
 

=== modified file 'doc/lispref/vol2.texi'
--- a/doc/lispref/vol2.texi     2012-02-15 13:45:02 +0000
+++ b/doc/lispref/vol2.texi     2012-02-16 06:04:38 +0000
@@ -834,8 +834,6 @@
                                   contents can also specify how to fontify it.
 * Faces for Font Lock::     Special faces specifically for Font Lock.
 * Syntactic Font Lock::     Fontification based on syntax tables.
-* Setting Syntax Properties::   Defining character syntax based on context
-                                  using the Font Lock mechanism.
 * Multiline Font Lock::     How to coerce Font Lock into properly
                               highlighting multiline constructs.
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]