aboutsummaryrefslogtreecommitdiffstats
path: root/lispref
diff options
context:
space:
mode:
authorMiles Bader2006-08-16 14:08:49 +0000
committerMiles Bader2006-08-16 14:08:49 +0000
commitde20e0ccdb039a2ac27e5bbd3e06ab70c4e7bb65 (patch)
tree80243ce02b52cbf7945c614bd213dd63142b861a /lispref
parent7a5c2a42040b12b037940a067aee6ac6fde01680 (diff)
parent5ebdc2990a95cc38b21f772eea4de3ceee149e54 (diff)
downloademacs-de20e0ccdb039a2ac27e5bbd3e06ab70c4e7bb65.tar.gz
emacs-de20e0ccdb039a2ac27e5bbd3e06ab70c4e7bb65.zip
Merge from emacs--devo--0
Patches applied: * emacs--devo--0 (patch 382-398) - Update from CVS - Update from erc--emacs--22 - Fix ERC bug introduced in last patch - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 123-125) - Update from CVS Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-101
Diffstat (limited to 'lispref')
-rw-r--r--lispref/ChangeLog79
-rw-r--r--lispref/commands.texi9
-rw-r--r--lispref/customize.texi39
-rw-r--r--lispref/keymaps.texi9
-rw-r--r--lispref/modes.texi834
-rw-r--r--lispref/os.texi18
-rw-r--r--lispref/strings.texi15
-rw-r--r--lispref/text.texi126
8 files changed, 622 insertions, 507 deletions
diff --git a/lispref/ChangeLog b/lispref/ChangeLog
index f64f9eb56df..d09689ce637 100644
--- a/lispref/ChangeLog
+++ b/lispref/ChangeLog
@@ -1,3 +1,62 @@
12006-08-16 Richard Stallman <rms@gnu.org>
2
3 * keymaps.texi (Extended Menu Items): Show format of cached
4 bindings in extended menu items.
5
6 * customize.texi (Variable Definitions): Explain when the
7 standard value expression is evaluated.
8
92006-08-15 Chong Yidong <cyd@stupidchicken.com>
10
11 * commands.texi (Reading One Event): Explain idleness in
12 `read-event'.
13
142006-08-12 Chong Yidong <cyd@stupidchicken.com>
15
16 * text.texi (Near Point): Say "cursor" not "terminal cursor".
17 (Commands for Insertion): Removed split-line since it's not
18 relevant for Lisp programming.
19 (Yank Commands): Rewrite introduction.
20 (Undo): Clarify.
21 (Maintaining Undo): Clarify. Document undo-ask-before-discard.
22 (Filling): Remove redundant comment. Clarify return value of
23 current-justification.
24 (Margins): Minor clarifications.
25 (Adaptive Fill): Update default value of adaptive-fill-regexp.
26 (Sorting): Update definition of sort-lines.
27 (Columns): Clarify behavior of sort-columns.
28 (Indent Tabs): Link to Tab Stops in Emacs manual.
29 (Special Properties): Clarify.
30 (Clickable Text): Mention Buttons package.
31
322006-08-12 Kevin Ryde <user42@zip.com.au>
33
34 * os.texi (Time Parsing): Add %z to description of
35 format-time-string, as per docstring. Add cross reference to
36 glibc manual for strftime.
37
382006-08-08 Richard Stallman <rms@gnu.org>
39
40 * modes.texi: Clean up wording in previous change.
41
422006-08-07 Chong Yidong <cyd@stupidchicken.com>
43
44 * modes.texi (Hooks): Clarify.
45 (Major Mode Basics): Mention define-derived-mode explicitly.
46 (Major Mode Conventions): Rebinding RET is OK for some modes.
47 Mention change-major-mode-hook and after-change-major-mode-hook.
48 (Example Major Modes): Moved to end of Modes section.
49 (Mode Line Basics): Clarify.
50 (Mode Line Data): Mention help-echo and local-map in strings.
51 Explain reason for treatment of non-risky variables.
52 (Properties in Mode): Clarify.
53 (Faces for Font Lock): Add font-lock-negation-char-face.
54
552006-08-04 Eli Zaretskii <eliz@gnu.org>
56
57 * strings.texi (Formatting Strings): Warn against arbitrary
58 strings as first arg to `format'.
59
12006-07-31 Thien-Thi Nguyen <ttn@gnu.org> 602006-07-31 Thien-Thi Nguyen <ttn@gnu.org>
2 61
3 * text.texi (Clickable Text): Mention `help-echo' text property. 62 * text.texi (Clickable Text): Mention `help-echo' text property.
@@ -290,7 +349,7 @@
290 349
291 * anti.texi, customize.texi, display.texi, internals.texi: 350 * anti.texi, customize.texi, display.texi, internals.texi:
292 * minibuf.texi, modes.texi, tips.texi: 351 * minibuf.texi, modes.texi, tips.texi:
293 Fix overfull/underfull boxes. 352 Fix overfull/underfull boxes.
294 353
2952006-07-05 Thien-Thi Nguyen <ttn@gnu.org> 3542006-07-05 Thien-Thi Nguyen <ttn@gnu.org>
296 355
@@ -367,7 +426,7 @@
367 426
3682006-06-09 Aidan Kehoe <kehoea@parhasard.net> 4272006-06-09 Aidan Kehoe <kehoea@parhasard.net>
369 428
370 * objects.texi (Character Type): Describe the\uABCD and \U00ABCDEF 429 * objects.texi (Character Type): Describe the \uABCD and \U00ABCDEF
371 syntax. 430 syntax.
372 431
3732006-06-07 Eli Zaretskii <eliz@gnu.org> 4322006-06-07 Eli Zaretskii <eliz@gnu.org>
@@ -679,7 +738,7 @@
6792006-04-13 Bill Wohler <wohler@newt.com> 7382006-04-13 Bill Wohler <wohler@newt.com>
680 739
681 * customize.texi (Common Keywords): Use dotted notation for 740 * customize.texi (Common Keywords): Use dotted notation for
682 :package-version value. Specify its values. Improve documentation 741 :package-version value. Specify its values. Improve documentation
683 for customize-package-emacs-version-alist. 742 for customize-package-emacs-version-alist.
684 743
6852006-04-12 Bill Wohler <wohler@newt.com> 7442006-04-12 Bill Wohler <wohler@newt.com>
@@ -1724,7 +1783,7 @@
1724 (Jumping): Clarify description of `h' command. 1783 (Jumping): Clarify description of `h' command.
1725 Eliminate redundant @ref. 1784 Eliminate redundant @ref.
1726 (Breaks): New node. 1785 (Breaks): New node.
1727 (Breakpoints): is now a subsubsection. 1786 (Breakpoints): Is now a subsubsection.
1728 (Global Break Condition): Mention `C-x X X'. 1787 (Global Break Condition): Mention `C-x X X'.
1729 (Edebug Views): Clarify `v' and `p'. Mention `C-x X w'. 1788 (Edebug Views): Clarify `v' and `p'. Mention `C-x X w'.
1730 (Trace Buffer): Clarify STRING arg of `edebug-tracing'. 1789 (Trace Buffer): Clarify STRING arg of `edebug-tracing'.
@@ -2974,7 +3033,7 @@
2974 3033
29752004-10-24 Jason Rumney <jasonr@gnu.org> 30342004-10-24 Jason Rumney <jasonr@gnu.org>
2976 3035
2977 * commands.texi (Misc Events): Remove mouse-wheel. Add wheel-up 3036 * commands.texi (Misc Events): Remove mouse-wheel. Add wheel-up
2978 and wheel-down. 3037 and wheel-down.
2979 3038
29802004-10-24 Kai Grossjohann <kai.grossjohann@gmx.net> 30392004-10-24 Kai Grossjohann <kai.grossjohann@gmx.net>
@@ -3203,7 +3262,7 @@
3203 except while processing `frame-title-format' or `icon-title-format'. 3262 except while processing `frame-title-format' or `icon-title-format'.
3204 (Deleting Frames): Correct description of `delete-frame'. 3263 (Deleting Frames): Correct description of `delete-frame'.
3205 Non-nil return values of `frame-live-p' are like those of `framep'. 3264 Non-nil return values of `frame-live-p' are like those of `framep'.
3206 (Frames and Windows): mention return value of 3265 (Frames and Windows): Mention return value of
3207 `set-frame-selected-window'. 3266 `set-frame-selected-window'.
3208 (Visibility of Frames): Mention `force' argument to 3267 (Visibility of Frames): Mention `force' argument to
3209 `make-frame-invisible'. `frame-visible-p' returns t for all 3268 `make-frame-invisible'. `frame-visible-p' returns t for all
@@ -3530,7 +3589,7 @@
3530 3589
35312004-03-07 Thien-Thi Nguyen <ttn@gnu.org> 35902004-03-07 Thien-Thi Nguyen <ttn@gnu.org>
3532 3591
3533 * customize.texi: Fix typo. Remove eol whitespace. 3592 * customize.texi: Fix typo. Remove eol whitespace.
3534 3593
35352004-03-04 Richard M. Stallman <rms@gnu.org> 35942004-03-04 Richard M. Stallman <rms@gnu.org>
3536 3595
@@ -3566,7 +3625,7 @@
3566 * text.texi: Various small changes in addition to the following: 3625 * text.texi: Various small changes in addition to the following:
3567 (User-Level Deletion): Mention optional BACKWARD-ONLY argument 3626 (User-Level Deletion): Mention optional BACKWARD-ONLY argument
3568 to delete-horizontal-space. 3627 to delete-horizontal-space.
3569 (Kill Functions, Yanking, Low-Level Kill Ring): clarify and correct 3628 (Kill Functions, Yanking, Low-Level Kill Ring): Clarify and correct
3570 description of yank-handler text property at various places. 3629 description of yank-handler text property at various places.
3571 3630
3572 * frames.texi (Window System Selections): Add anchor. 3631 * frames.texi (Window System Selections): Add anchor.
@@ -4593,7 +4652,7 @@
4593 * loading.texi (Unloading): Fix recent change for load-history. 4652 * loading.texi (Unloading): Fix recent change for load-history.
4594 4653
4595 * customize.texi (Simple Types): Clarify description of custom 4654 * customize.texi (Simple Types): Clarify description of custom
4596 type 'number. Describe new custom type 'float. 4655 type 'number. Describe new custom type 'float.
4597 4656
45982002-12-04 Markus Rost <rost@math.ohio-state.edu> 46572002-12-04 Markus Rost <rost@math.ohio-state.edu>
4599 4658
@@ -5123,7 +5182,7 @@ Mon Apr 17 18:56:50 1989 Robert J. Chassell (bob@rice-chex.ai.mit.edu)
5123Tue Apr 11 12:23:28 1989 Robert J. Chassell (bob@rice-chex.ai.mit.edu) 5182Tue Apr 11 12:23:28 1989 Robert J. Chassell (bob@rice-chex.ai.mit.edu)
5124 5183
5125 * Applied Karl Berry's patches to *.texinfo files, but not to 5184 * Applied Karl Berry's patches to *.texinfo files, but not to
5126 texinfo.tex; those diffs are in `berry-texinfo-tex-diffs'. (Karl's 5185 texinfo.tex; those diffs are in `berry-texinfo-tex-diffs'. (Karl's
5127 new title page format is also not applied, since it requires 5186 new title page format is also not applied, since it requires
5128 texinfo.tex changes.) 5187 texinfo.tex changes.)
5129 5188
diff --git a/lispref/commands.texi b/lispref/commands.texi
index 8e34fe360bf..2a091524bed 100644
--- a/lispref/commands.texi
+++ b/lispref/commands.texi
@@ -2229,6 +2229,15 @@ number of seconds; on these systems, @var{seconds} is rounded down.
2229If @var{seconds} is @code{nil}, @code{read-event} waits as long as 2229If @var{seconds} is @code{nil}, @code{read-event} waits as long as
2230necessary for input to arrive. 2230necessary for input to arrive.
2231 2231
2232If @var{seconds} is @code{nil}, Emacs is considered idle while waiting
2233for user input to arrive. Idle timers---those created with
2234@code{run-with-idle-timer} (@pxref{Timers})---can run during this
2235period. However, if @var{seconds} is non-@code{nil}, the state of
2236idleness remains unchanged. If Emacs is non-idle when
2237@code{read-event} is called, it remains non-idle throughout the
2238operation of @code{read-event}; if Emacs is idle (which can happen if
2239the call happens inside an idle timer), it remains idle.
2240
2232If @code{read-event} gets an event that is defined as a help character, 2241If @code{read-event} gets an event that is defined as a help character,
2233then in some cases @code{read-event} processes the event directly without 2242then in some cases @code{read-event} processes the event directly without
2234returning. @xref{Help Functions}. Certain other events, called 2243returning. @xref{Help Functions}. Certain other events, called
diff --git a/lispref/customize.texi b/lispref/customize.texi
index e3e78c46bb4..9e10e547b56 100644
--- a/lispref/customize.texi
+++ b/lispref/customize.texi
@@ -251,19 +251,30 @@ turn this feature back on, if someone would like to do the work.
251 251
252 Use @code{defcustom} to declare user-editable variables. 252 Use @code{defcustom} to declare user-editable variables.
253 253
254@defmac defcustom option default doc [keyword value]@dots{} 254@defmac defcustom option standard doc [keyword value]@dots{}
255Declare @var{option} as a customizable user option variable. Do not 255This construct declares @var{option} as a customizable user option
256quote @var{option}. The argument @var{doc} specifies the documentation 256variable. You should not quote @var{option}. The argument @var{doc}
257string for the variable. There is no need to start it with a @samp{*} 257specifies the documentation string for the variable. There is no need
258because @code{defcustom} automatically marks @var{option} as a 258to start it with a @samp{*}, because @code{defcustom} automatically
259@dfn{user option} (@pxref{Defining Variables}). 259marks @var{option} as a @dfn{user option} (@pxref{Defining
260 260Variables}).
261If @var{option} is void, @code{defcustom} initializes it to 261
262@var{default}. @var{default} should be an expression to compute the 262The argument @var{standard} is an expression that specifies the
263value; be careful in writing it, because it can be evaluated on more 263standard value for @var{option}. Evaluating the @code{defcustom} form
264than one occasion. You should normally avoid using backquotes in 264evaluates @var{standard}, but does not necessarily install the
265@var{default} because they are not expanded when editing the value, 265standard value. If @var{option} already has a default value,
266causing list values to appear to have the wrong structure. 266@code{defcustom} does not change it. If the user has saved a
267customization for @var{option}, @code{defcustom} installs the user's
268customized value as @var{option}'s default value. If neither of those
269cases applies, @code{defcustom} installs the result of evaluating
270@var{standard} as the default value.
271
272The expression @var{standard} can be evaluated at various other times,
273too---whenever the customization facility needs to know @var{option}'s
274standard value. So be sure to use an expression which is harmless to
275evaluate at any time. We recommend avoiding backquotes in
276@var{standard}, because they are not expanded when editing the value,
277so list values will appear to have the wrong structure.
267 278
268If you specify the @code{:set} option, to make the variable take other 279If you specify the @code{:set} option, to make the variable take other
269special actions when set through the customization buffer, the 280special actions when set through the customization buffer, the
@@ -406,7 +417,7 @@ type of @var{symbol}.
406@end defun 417@end defun
407 418
408Internally, @code{defcustom} uses the symbol property 419Internally, @code{defcustom} uses the symbol property
409@code{standard-value} to record the expression for the default value, 420@code{standard-value} to record the expression for the standard value,
410and @code{saved-value} to record the value saved by the user with the 421and @code{saved-value} to record the value saved by the user with the
411customization buffer. Both properties are actually lists whose car is 422customization buffer. Both properties are actually lists whose car is
412an expression which evaluates to the value. 423an expression which evaluates to the value.
diff --git a/lispref/keymaps.texi b/lispref/keymaps.texi
index 44b92ddfcb8..13f4550a082 100644
--- a/lispref/keymaps.texi
+++ b/lispref/keymaps.texi
@@ -2016,7 +2016,7 @@ binding, like this:
2016 2016
2017@c This line is not too long--rms. 2017@c This line is not too long--rms.
2018@example 2018@example
2019(@var{item-string} @r{[}@var{help-string}@r{]} (@var{key-binding-data}) . @var{real-binding}) 2019(@var{item-string} @r{[}@var{help}@r{]} (@var{key-binding-data}) . @var{real-binding})
2020@end example 2020@end example
2021 2021
2022@noindent 2022@noindent
@@ -2140,6 +2140,13 @@ operates on menu data structures, so you should write it so it can
2140safely be called at any time. 2140safely be called at any time.
2141@end table 2141@end table
2142 2142
2143 When an equivalent key binding is cached, the binding looks like this.
2144
2145@example
2146(menu-item @var{item-name} @var{real-binding} (@var{key-binding-data})
2147 . @var{item-property-list})
2148@end example
2149
2143@node Menu Separators 2150@node Menu Separators
2144@subsubsection Menu Separators 2151@subsubsection Menu Separators
2145@cindex menu separators 2152@cindex menu separators
diff --git a/lispref/modes.texi b/lispref/modes.texi
index 38227633c6b..f8afcd8a829 100644
--- a/lispref/modes.texi
+++ b/lispref/modes.texi
@@ -43,18 +43,19 @@ up in the init file (@pxref{Init File}), but Lisp programs can set them also.
43 43
44@cindex normal hook 44@cindex normal hook
45 Most of the hooks in Emacs are @dfn{normal hooks}. These variables 45 Most of the hooks in Emacs are @dfn{normal hooks}. These variables
46contain lists of functions to be called with no arguments. When the 46contain lists of functions to be called with no arguments. By
47hook name ends in @samp{-hook}, that tells you it is normal. We try to 47convention, whenever the hook name ends in @samp{-hook}, that tells
48make all hooks normal, as much as possible, so that you can use them in 48you it is normal. We try to make all hooks normal, as much as
49a uniform way. 49possible, so that you can use them in a uniform way.
50 50
51 Every major mode function is supposed to run a normal hook called the 51 Every major mode function is supposed to run a normal hook called
52@dfn{mode hook} as the last step of initialization. This makes it easy 52the @dfn{mode hook} as the one of the last steps of initialization.
53for a user to customize the behavior of the mode, by overriding the 53This makes it easy for a user to customize the behavior of the mode,
54buffer-local variable assignments already made by the mode. Most 54by overriding the buffer-local variable assignments already made by
55minor modes also run a mode hook at their end. But hooks are used in 55the mode. Most minor mode functions also run a mode hook at the end.
56other contexts too. For example, the hook @code{suspend-hook} runs 56But hooks are used in other contexts too. For example, the hook
57just before Emacs suspends itself (@pxref{Suspending Emacs}). 57@code{suspend-hook} runs just before Emacs suspends itself
58(@pxref{Suspending Emacs}).
58 59
59 The recommended way to add a hook function to a normal hook is by 60 The recommended way to add a hook function to a normal hook is by
60calling @code{add-hook} (see below). The hook functions may be any of 61calling @code{add-hook} (see below). The hook functions may be any of
@@ -65,20 +66,16 @@ globally or buffer-locally with @code{add-hook}.
65 66
66@cindex abnormal hook 67@cindex abnormal hook
67 If the hook variable's name does not end with @samp{-hook}, that 68 If the hook variable's name does not end with @samp{-hook}, that
68indicates it is probably an @dfn{abnormal hook}. Then you should look at its 69indicates it is probably an @dfn{abnormal hook}. That means the hook
69documentation to see how to use the hook properly. 70functions are called with arguments, or their return values are used
71in some way. The hook's documentation says how the functions are
72called. You can use @code{add-hook} to add a function to an abnormal
73hook, but you must write the function to follow the hook's calling
74convention.
70 75
71 If the variable's name ends in @samp{-functions} or @samp{-hooks}, 76 By convention, abnormal hook names end in @samp{-functions} or
72then the value is a list of functions, but it is abnormal in that either 77@samp{-hooks}. If the variable's name ends in @samp{-function}, then
73these functions are called with arguments or their values are used in 78its value is just a single function, not a list of functions.
74some way. You can use @code{add-hook} to add a function to the list,
75but you must take care in writing the function. (A few of these
76variables, notably those ending in @samp{-hooks}, are actually
77normal hooks which were named before we established the convention of
78using @samp{-hook} for them.)
79
80 If the variable's name ends in @samp{-function}, then its value
81is just a single function, not a list of functions.
82 79
83 Here's an example that uses a mode hook to turn on Auto Fill mode when 80 Here's an example that uses a mode hook to turn on Auto Fill mode when
84in Lisp Interaction mode: 81in Lisp Interaction mode:
@@ -96,12 +93,13 @@ arguments, and runs each hook in turn. Each argument should be a
96symbol that is a normal hook variable. These arguments are processed 93symbol that is a normal hook variable. These arguments are processed
97in the order specified. 94in the order specified.
98 95
99If a hook variable has a non-@code{nil} value, that value may be a 96If a hook variable has a non-@code{nil} value, that value should be a
100function or a list of functions. (The former option is considered 97list of functions. @code{run-hooks} calls all the functions, one by
101obsolete.) If the value is a function (either a lambda expression or 98one, with no arguments.
102a symbol with a function definition), it is called. If it is a list 99
103that isn't a function, its elements are called, consecutively. All 100The hook variable's value can also be a single function---either a
104the hook functions are called with no arguments. 101lambda expression or a symbol with a function definition---which
102@code{run-hooks} calls. But this usage is obsolete.
105@end defun 103@end defun
106 104
107@defun run-hook-with-args hook &rest args 105@defun run-hook-with-args hook &rest args
@@ -187,7 +185,6 @@ to another major mode in the same buffer.
187@menu 185@menu
188* Major Mode Basics:: 186* Major Mode Basics::
189* Major Mode Conventions:: Coding conventions for keymaps, etc. 187* Major Mode Conventions:: Coding conventions for keymaps, etc.
190* Example Major Modes:: Text mode and Lisp modes.
191* Auto Major Mode:: How Emacs chooses the major mode automatically. 188* Auto Major Mode:: How Emacs chooses the major mode automatically.
192* Mode Help:: Finding out how to use a mode. 189* Mode Help:: Finding out how to use a mode.
193* Derived Modes:: Defining a new major mode based on another major 190* Derived Modes:: Defining a new major mode based on another major
@@ -195,6 +192,7 @@ to another major mode in the same buffer.
195* Generic Modes:: Defining a simple major mode that supports 192* Generic Modes:: Defining a simple major mode that supports
196 comment syntax and Font Lock mode. 193 comment syntax and Font Lock mode.
197* Mode Hooks:: Hooks run at the end of major mode functions. 194* Mode Hooks:: Hooks run at the end of major mode functions.
195* Example Major Modes:: Text mode and Lisp modes.
198@end menu 196@end menu
199 197
200@node Major Mode Basics 198@node Major Mode Basics
@@ -214,14 +212,14 @@ specialized editing task, creating a new major mode is usually a good
214idea. In practice, writing a major mode is easy (in contrast to 212idea. In practice, writing a major mode is easy (in contrast to
215writing a minor mode, which is often difficult). 213writing a minor mode, which is often difficult).
216 214
217 If the new mode is similar to an old one, it is often unwise to modify 215 If the new mode is similar to an old one, it is often unwise to
218the old one to serve two purposes, since it may become harder to use and 216modify the old one to serve two purposes, since it may become harder
219maintain. Instead, copy and rename an existing major mode definition 217to use and maintain. Instead, copy and rename an existing major mode
220and alter the copy---or define a @dfn{derived mode} (@pxref{Derived 218definition and alter the copy---or use @code{define-derived-mode} to
221Modes}). For example, Rmail Edit mode, which is in 219define a @dfn{derived mode} (@pxref{Derived Modes}). For example,
222@file{emacs/lisp/mail/rmailedit.el}, is a major mode that is very similar to 220Rmail Edit mode is a major mode that is very similar to Text mode
223Text mode except that it provides two additional commands. Its 221except that it provides two additional commands. Its definition is
224definition is distinct from that of Text mode, but uses that of Text mode. 222distinct from that of Text mode, but uses that of Text mode.
225 223
226 Even if the new mode is not an obvious derivative of any other mode, 224 Even if the new mode is not an obvious derivative of any other mode,
227it is convenient to use @code{define-derived-mode} with a @code{nil} 225it is convenient to use @code{define-derived-mode} with a @code{nil}
@@ -287,8 +285,10 @@ Documentation}.
287 285
288@item 286@item
289The major mode command should start by calling 287The major mode command should start by calling
290@code{kill-all-local-variables}. This is what gets rid of the 288@code{kill-all-local-variables}. This runs the normal hook
291buffer-local variables of the major mode previously in effect. 289@code{change-major-mode-hook}, then gets rid of the buffer-local
290variables of the major mode previously in effect. @xref{Creating
291Buffer-Local}.
292 292
293@item 293@item
294The major mode command should set the variable @code{major-mode} to the 294The major mode command should set the variable @code{major-mode} to the
@@ -355,9 +355,11 @@ Rmail that do not allow self-insertion of text can reasonably redefine
355letters and other printing characters as special commands. 355letters and other printing characters as special commands.
356 356
357@item 357@item
358Major modes must not define @key{RET} to do anything other than insert 358Major modes modes for editing text should not define @key{RET} to do
359a newline. The command to insert a newline and then indent is 359anything other than insert a newline. However, it is ok for
360@kbd{C-j}. Please keep this distinction uniform for all major modes. 360specialized modes for text that users don't directly edit, such as
361Dired and Info modes, to redefine @key{RET} to do something entirely
362different.
361 363
362@item 364@item
363Major modes should not alter options that are primarily a matter of user 365Major modes should not alter options that are primarily a matter of user
@@ -427,10 +429,11 @@ other packages would interfere with them.
427@item 429@item
428@cindex mode hook 430@cindex mode hook
429@cindex major mode hook 431@cindex major mode hook
430Each major mode should have a @dfn{mode hook} named 432Each major mode should have a normal @dfn{mode hook} named
431@code{@var{modename}-mode-hook}. The major mode command should run that 433@code{@var{modename}-mode-hook}. The very last thing the major mode command
432hook, with @code{run-mode-hooks}, as the very last thing it 434should do is to call @code{run-mode-hooks}. This runs the mode hook,
433does. @xref{Mode Hooks}. 435and then runs the normal hook @code{after-change-major-mode-hook}.
436@xref{Mode Hooks}.
434 437
435@item 438@item
436The major mode command may start by calling some other major mode 439The major mode command may start by calling some other major mode
@@ -488,281 +491,6 @@ that they may be evaluated more than once without adverse consequences.
488Even if you never load the file more than once, someone else will. 491Even if you never load the file more than once, someone else will.
489@end itemize 492@end itemize
490 493
491@node Example Major Modes
492@subsection Major Mode Examples
493
494 Text mode is perhaps the simplest mode besides Fundamental mode.
495Here are excerpts from @file{text-mode.el} that illustrate many of
496the conventions listed above:
497
498@smallexample
499@group
500;; @r{Create the syntax table for this mode.}
501(defvar text-mode-syntax-table
502 (let ((st (make-syntax-table)))
503 (modify-syntax-entry ?\" ". " st)
504 (modify-syntax-entry ?\\ ". " st)
505 ;; Add `p' so M-c on `hello' leads to `Hello', not `hello'.
506 (modify-syntax-entry ?' "w p" st)
507 st)
508 "Syntax table used while in `text-mode'.")
509@end group
510
511;; @r{Create the keymap for this mode.}
512@group
513(defvar text-mode-map
514 (let ((map (make-sparse-keymap)))
515 (define-key map "\e\t" 'ispell-complete-word)
516 (define-key map "\es" 'center-line)
517 (define-key map "\eS" 'center-paragraph)
518 map)
519 "Keymap for `text-mode'.
520Many other modes, such as Mail mode, Outline mode
521and Indented Text mode, inherit all the commands
522defined in this map.")
523@end group
524@end smallexample
525
526 Here is how the actual mode command is defined now:
527
528@smallexample
529@group
530(define-derived-mode text-mode nil "Text"
531 "Major mode for editing text written for humans to read.
532In this mode, paragraphs are delimited only by blank or white lines.
533You can thus get the full benefit of adaptive filling
534 (see the variable `adaptive-fill-mode').
535\\@{text-mode-map@}
536Turning on Text mode runs the normal hook `text-mode-hook'."
537@end group
538@group
539 (make-local-variable 'text-mode-variant)
540 (setq text-mode-variant t)
541 ;; @r{These two lines are a feature added recently.}
542 (set (make-local-variable 'require-final-newline)
543 mode-require-final-newline)
544 (set (make-local-variable 'indent-line-function) 'indent-relative))
545@end group
546@end smallexample
547
548 But here is how it was defined formerly, before
549@code{define-derived-mode} existed:
550
551@smallexample
552@group
553;; @r{This isn't needed nowadays, since @code{define-derived-mode} does it.}
554(defvar text-mode-abbrev-table nil
555 "Abbrev table used while in text mode.")
556(define-abbrev-table 'text-mode-abbrev-table ())
557@end group
558
559@group
560(defun text-mode ()
561 "Major mode for editing text intended for humans to read...
562 Special commands: \\@{text-mode-map@}
563@end group
564@group
565Turning on text-mode runs the hook `text-mode-hook'."
566 (interactive)
567 (kill-all-local-variables)
568 (use-local-map text-mode-map)
569@end group
570@group
571 (setq local-abbrev-table text-mode-abbrev-table)
572 (set-syntax-table text-mode-syntax-table)
573@end group
574@group
575 ;; @r{These four lines are absent from the current version}
576 ;; @r{not because this is done some other way, but rather}
577 ;; @r{because nowadays Text mode uses the normal definition of paragraphs.}
578 (make-local-variable 'paragraph-start)
579 (setq paragraph-start (concat "[ \t]*$\\|" page-delimiter))
580 (make-local-variable 'paragraph-separate)
581 (setq paragraph-separate paragraph-start)
582 (make-local-variable 'indent-line-function)
583 (setq indent-line-function 'indent-relative-maybe)
584@end group
585@group
586 (setq mode-name "Text")
587 (setq major-mode 'text-mode)
588 (run-mode-hooks 'text-mode-hook)) ; @r{Finally, this permits the user to}
589 ; @r{customize the mode with a hook.}
590@end group
591@end smallexample
592
593@cindex @file{lisp-mode.el}
594 The three Lisp modes (Lisp mode, Emacs Lisp mode, and Lisp
595Interaction mode) have more features than Text mode and the code is
596correspondingly more complicated. Here are excerpts from
597@file{lisp-mode.el} that illustrate how these modes are written.
598
599@cindex syntax table example
600@smallexample
601@group
602;; @r{Create mode-specific table variables.}
603(defvar lisp-mode-syntax-table nil "")
604(defvar lisp-mode-abbrev-table nil "")
605@end group
606
607@group
608(defvar emacs-lisp-mode-syntax-table
609 (let ((table (make-syntax-table)))
610 (let ((i 0))
611@end group
612
613@group
614 ;; @r{Set syntax of chars up to @samp{0} to say they are}
615 ;; @r{part of symbol names but not words.}
616 ;; @r{(The digit @samp{0} is @code{48} in the @acronym{ASCII} character set.)}
617 (while (< i ?0)
618 (modify-syntax-entry i "_ " table)
619 (setq i (1+ i)))
620 ;; @r{@dots{} similar code follows for other character ranges.}
621@end group
622@group
623 ;; @r{Then set the syntax codes for characters that are special in Lisp.}
624 (modify-syntax-entry ? " " table)
625 (modify-syntax-entry ?\t " " table)
626 (modify-syntax-entry ?\f " " table)
627 (modify-syntax-entry ?\n "> " table)
628@end group
629@group
630 ;; @r{Give CR the same syntax as newline, for selective-display.}
631 (modify-syntax-entry ?\^m "> " table)
632 (modify-syntax-entry ?\; "< " table)
633 (modify-syntax-entry ?` "' " table)
634 (modify-syntax-entry ?' "' " table)
635 (modify-syntax-entry ?, "' " table)
636@end group
637@group
638 ;; @r{@dots{}likewise for many other characters@dots{}}
639 (modify-syntax-entry ?\( "() " table)
640 (modify-syntax-entry ?\) ")( " table)
641 (modify-syntax-entry ?\[ "(] " table)
642 (modify-syntax-entry ?\] ")[ " table))
643 table))
644@end group
645@group
646;; @r{Create an abbrev table for lisp-mode.}
647(define-abbrev-table 'lisp-mode-abbrev-table ())
648@end group
649@end smallexample
650
651 Much code is shared among the three Lisp modes. The following
652function sets various variables; it is called by each of the major Lisp
653mode functions:
654
655@smallexample
656@group
657(defun lisp-mode-variables (lisp-syntax)
658 (when lisp-syntax
659 (set-syntax-table lisp-mode-syntax-table))
660 (setq local-abbrev-table lisp-mode-abbrev-table)
661 @dots{}
662@end group
663@end smallexample
664
665 Functions such as @code{forward-paragraph} use the value of the
666@code{paragraph-start} variable. Since Lisp code is different from
667ordinary text, the @code{paragraph-start} variable needs to be set
668specially to handle Lisp. Also, comments are indented in a special
669fashion in Lisp and the Lisp modes need their own mode-specific
670@code{comment-indent-function}. The code to set these variables is the
671rest of @code{lisp-mode-variables}.
672
673@smallexample
674@group
675 (make-local-variable 'paragraph-start)
676 (setq paragraph-start (concat page-delimiter "\\|$" ))
677 (make-local-variable 'paragraph-separate)
678 (setq paragraph-separate paragraph-start)
679 @dots{}
680@end group
681@group
682 (make-local-variable 'comment-indent-function)
683 (setq comment-indent-function 'lisp-comment-indent))
684 @dots{}
685@end group
686@end smallexample
687
688 Each of the different Lisp modes has a slightly different keymap. For
689example, Lisp mode binds @kbd{C-c C-z} to @code{run-lisp}, but the other
690Lisp modes do not. However, all Lisp modes have some commands in
691common. The following code sets up the common commands:
692
693@smallexample
694@group
695(defvar shared-lisp-mode-map ()
696 "Keymap for commands shared by all sorts of Lisp modes.")
697
698;; @r{Putting this @code{if} after the @code{defvar} is an older style.}
699(if shared-lisp-mode-map
700 ()
701 (setq shared-lisp-mode-map (make-sparse-keymap))
702 (define-key shared-lisp-mode-map "\e\C-q" 'indent-sexp)
703 (define-key shared-lisp-mode-map "\177"
704 'backward-delete-char-untabify))
705@end group
706@end smallexample
707
708@noindent
709And here is the code to set up the keymap for Lisp mode:
710
711@smallexample
712@group
713(defvar lisp-mode-map ()
714 "Keymap for ordinary Lisp mode...")
715
716(if lisp-mode-map
717 ()
718 (setq lisp-mode-map (make-sparse-keymap))
719 (set-keymap-parent lisp-mode-map shared-lisp-mode-map)
720 (define-key lisp-mode-map "\e\C-x" 'lisp-eval-defun)
721 (define-key lisp-mode-map "\C-c\C-z" 'run-lisp))
722@end group
723@end smallexample
724
725 Finally, here is the complete major mode function definition for
726Lisp mode.
727
728@smallexample
729@group
730(defun lisp-mode ()
731 "Major mode for editing Lisp code for Lisps other than GNU Emacs Lisp.
732Commands:
733Delete converts tabs to spaces as it moves back.
734Blank lines separate paragraphs. Semicolons start comments.
735\\@{lisp-mode-map@}
736Note that `run-lisp' may be used either to start an inferior Lisp job
737or to switch back to an existing one.
738@end group
739
740@group
741Entry to this mode calls the value of `lisp-mode-hook'
742if that value is non-nil."
743 (interactive)
744 (kill-all-local-variables)
745@end group
746@group
747 (use-local-map lisp-mode-map) ; @r{Select the mode's keymap.}
748 (setq major-mode 'lisp-mode) ; @r{This is how @code{describe-mode}}
749 ; @r{finds out what to describe.}
750 (setq mode-name "Lisp") ; @r{This goes into the mode line.}
751 (lisp-mode-variables t) ; @r{This defines various variables.}
752 (make-local-variable 'comment-start-skip)
753 (setq comment-start-skip
754 "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\)\\(;+\\|#|\\) *")
755 (make-local-variable 'font-lock-keywords-case-fold-search)
756 (setq font-lock-keywords-case-fold-search t)
757@end group
758@group
759 (setq imenu-case-fold-search t)
760 (set-syntax-table lisp-mode-syntax-table)
761 (run-mode-hooks 'lisp-mode-hook)) ; @r{This permits the user to use a}
762 ; @r{hook to customize the mode.}
763@end group
764@end smallexample
765
766@node Auto Major Mode 494@node Auto Major Mode
767@subsection How Emacs Chooses a Major Mode 495@subsection How Emacs Chooses a Major Mode
768 496
@@ -1073,104 +801,365 @@ Do not write an @code{interactive} spec in the definition;
1073@subsection Generic Modes 801@subsection Generic Modes
1074@cindex generic mode 802@cindex generic mode
1075 803
1076@dfn{Generic modes} are simple major modes with basic support for 804 @dfn{Generic modes} are simple major modes with basic support for
1077comment syntax and Font Lock mode. They are primarily useful for 805comment syntax and Font Lock mode. To define a generic mode, use the
1078configuration files. To define a generic mode, use the macro 806macro @code{define-generic-mode}. See the file @file{generic-x.el}
1079@code{define-generic-mode}. See the file @file{generic-x.el} for some 807for some examples of the use of @code{define-generic-mode}.
1080examples of the use of @code{define-generic-mode}.
1081 808
1082@defmac define-generic-mode mode comment-list keyword-list font-lock-list auto-mode-list function-list &optional docstring 809@defmac define-generic-mode mode comment-list keyword-list font-lock-list auto-mode-list function-list &optional docstring
1083This macro creates a new generic mode. The argument @var{mode} (an 810This macro defines a generic mode command named @var{mode} (a symbol,
1084unquoted symbol) is the major mode command. The optional argument 811not quoted). The optional argument @var{docstring} is the
1085@var{docstring} is the documentation for the mode command. If you do 812documentation for the mode command. If you do not supply it,
1086not supply it, @code{define-generic-mode} uses a default documentation 813@code{define-generic-mode} generates one by default.
1087string instead. 814
1088 815The argument @var{comment-list} is a list in which each element is
1089@var{comment-list} is a list in which each element is either a 816either a character, a string of one or two characters, or a cons cell.
1090character, a string of one or two characters, or a cons cell. A 817A character or a string is set up in the mode's syntax table as a
1091character or a string is set up in the mode's syntax table as a
1092``comment starter.'' If the entry is a cons cell, the @sc{car} is set 818``comment starter.'' If the entry is a cons cell, the @sc{car} is set
1093up as a ``comment starter'' and the @sc{cdr} as a ``comment ender.'' 819up as a ``comment starter'' and the @sc{cdr} as a ``comment ender.''
1094(Use @code{nil} for the latter if you want comments to end at the end 820(Use @code{nil} for the latter if you want comments to end at the end
1095of the line.) Note that the syntax table has limitations about what 821of the line.) Note that the syntax table mechanism has limitations
1096comment starters and enders are actually possible. @xref{Syntax 822about what comment starters and enders are actually possible.
1097Tables}. 823@xref{Syntax Tables}.
1098 824
1099@var{keyword-list} is a list of keywords to highlight with 825The argument @var{keyword-list} is a list of keywords to highlight
1100@code{font-lock-keyword-face}. Each keyword should be a string. 826with @code{font-lock-keyword-face}. Each keyword should be a string.
1101@var{font-lock-list} is a list of additional expressions to highlight. 827Meanwhile, @var{font-lock-list} is a list of additional expressions to
1102Each element of this list should have the same form as an element of 828highlight. Each element of this list should have the same form as an
1103@code{font-lock-keywords}. @xref{Search-based Fontification}. 829element of @code{font-lock-keywords}. @xref{Search-based
1104 830Fontification}.
1105@var{auto-mode-list} is a list of regular expressions to add to the 831
1106variable @code{auto-mode-alist}. These regular expressions are added 832The argument @var{auto-mode-list} is a list of regular expressions to
1107when Emacs runs the macro expansion. 833add to the variable @code{auto-mode-alist}. They are added by the execution
1108 834of the @code{define-generic-mode} form, not by expanding the macro call.
1109@var{function-list} is a list of functions to call to do some 835
1110additional setup. The mode command calls these functions just before 836Finally, @var{function-list} is a list of functions for the mode
1111it runs the mode hook variable @code{@var{mode}-hook}. 837command to call for additional setup. It calls these functions just
838before it runs the mode hook variable @code{@var{mode}-hook}.
1112@end defmac 839@end defmac
1113 840
1114@node Mode Hooks 841@node Mode Hooks
1115@subsection Mode Hooks 842@subsection Mode Hooks
1116 843
1117 The two last things a major mode function should do is run its mode 844 Every major mode function should finish by running its mode hook and
1118hook and finally the mode independent normal hook 845the mode-independent normal hook @code{after-change-major-mode-hook}.
1119@code{after-change-major-mode-hook}. If the major mode is a derived 846It does this by calling @code{run-mode-hooks}. If the major mode is a
1120mode, that is if it calls another major mode (the parent mode) in its 847derived mode, that is if it calls another major mode (the parent mode)
1121body, then the parent's mode hook is run just before the derived 848in its body, it should do this inside @code{delay-mode-hooks} so that
1122mode's hook. Neither the parent's mode hook nor 849the parent won't run these hooks itself. Instead, the derived mode's
1123@code{after-change-major-mode-hook} are run at the end of the actual 850call to @code{run-mode-hooks} runs the parent's mode hook too.
1124call to the parent mode. This applies recursively if the parent mode 851@xref{Major Mode Conventions}.
1125has itself a parent. That is, the mode hooks of all major modes 852
1126called directly or indirectly by the major mode function are all run 853 Emacs versions before Emacs 22 did not have @code{delay-mode-hooks}.
1127in sequence at the end, just before 854When user-implemented major modes have not been updated to use it,
1128@code{after-change-major-mode-hook}. 855they won't entirely follow these conventions: they may run the
1129 856parent's mode hook too early, or fail to run
1130 These conventions are new in Emacs 22, and some major modes 857@code{after-change-major-mode-hook}. If you encounter such a major
1131implemented by users do not follow them yet. So if you put a function 858mode, please correct it to follow these conventions.
1132onto @code{after-change-major-mode-hook}, keep in mind that some modes
1133will fail to run it. If a user complains about that, you can respond,
1134``That major mode fails to follow Emacs conventions, and that's why it
1135fails to work. Please fix the major mode.'' In most cases, that is
1136good enough, so go ahead and use @code{after-change-major-mode-hook}.
1137However, if a certain feature needs to be completely reliable,
1138it should not use @code{after-change-major-mode-hook} as of yet.
1139 859
1140 When you defined a major mode using @code{define-derived-mode}, it 860 When you defined a major mode using @code{define-derived-mode}, it
1141automatically makes sure these conventions are followed. If you 861automatically makes sure these conventions are followed. If you
1142define a major mode ``from scratch,'' not using 862define a major mode ``by hand,'' not using @code{define-derived-mode},
1143@code{define-derived-mode}, make sure the major mode command follows 863use the following functions to handle these conventions automatically.
1144these and other conventions. @xref{Major Mode Conventions}. You use
1145these functions to do it properly.
1146 864
1147@defun run-mode-hooks &rest hookvars 865@defun run-mode-hooks &rest hookvars
1148Major modes should run their mode hook using this function. It is 866Major modes should run their mode hook using this function. It is
1149similar to @code{run-hooks} (@pxref{Hooks}), but it also runs 867similar to @code{run-hooks} (@pxref{Hooks}), but it also runs
1150@code{after-change-major-mode-hook}. 868@code{after-change-major-mode-hook}.
1151 869
1152When the call to this function is dynamically inside a 870When this function is called during the execution of a
1153@code{delay-mode-hooks} form, this function does not run any hooks. 871@code{delay-mode-hooks} form, it does not run the hooks immediately.
1154Instead, it arranges for the next call to @code{run-mode-hooks} to run 872Instead, it arranges for the next call to @code{run-mode-hooks} to run
1155@var{hookvars}. 873them.
1156@end defun 874@end defun
1157 875
1158@defmac delay-mode-hooks body@dots{} 876@defmac delay-mode-hooks body@dots{}
1159This macro executes @var{body} like @code{progn}, but all calls to 877When one major mode command calls another, it should do so inside of
1160@code{run-mode-hooks} inside @var{body} delay running their hooks. 878@code{delay-mode-hooks}.
1161They will be run by the first call to @code{run-mode-hooks} after exit 879
1162from @code{delay-mode-hooks}. This is the proper way for a major mode 880This macro executes @var{body}, but tells all @code{run-mode-hooks}
1163command to invoke its parent mode. 881calls during the execution of @var{body} to delay running their hooks.
882The hooks will actually run during the next call to
883@code{run-mode-hooks} after the end of the @code{delay-mode-hooks}
884construct.
1164@end defmac 885@end defmac
1165 886
1166@defvar after-change-major-mode-hook 887@defvar after-change-major-mode-hook
1167Every major mode function should run this normal hook at its very end. 888This is a normal hook run by @code{run-mode-hooks}. It is run at the
1168It normally does not need to do so explicitly. Indeed, a major mode 889very end of every properly-written major mode function.
1169function should normally run its mode hook with @code{run-mode-hooks}
1170as the very last thing it does, and the last thing
1171@code{run-mode-hooks} does is run @code{after-change-major-mode-hook}.
1172@end defvar 890@end defvar
1173 891
892@node Example Major Modes
893@subsection Major Mode Examples
894
895 Text mode is perhaps the simplest mode besides Fundamental mode.
896Here are excerpts from @file{text-mode.el} that illustrate many of
897the conventions listed above:
898
899@smallexample
900@group
901;; @r{Create the syntax table for this mode.}
902(defvar text-mode-syntax-table
903 (let ((st (make-syntax-table)))
904 (modify-syntax-entry ?\" ". " st)
905 (modify-syntax-entry ?\\ ". " st)
906 ;; Add `p' so M-c on `hello' leads to `Hello', not `hello'.
907 (modify-syntax-entry ?' "w p" st)
908 st)
909 "Syntax table used while in `text-mode'.")
910@end group
911
912;; @r{Create the keymap for this mode.}
913@group
914(defvar text-mode-map
915 (let ((map (make-sparse-keymap)))
916 (define-key map "\e\t" 'ispell-complete-word)
917 (define-key map "\es" 'center-line)
918 (define-key map "\eS" 'center-paragraph)
919 map)
920 "Keymap for `text-mode'.
921Many other modes, such as Mail mode, Outline mode
922and Indented Text mode, inherit all the commands
923defined in this map.")
924@end group
925@end smallexample
926
927 Here is how the actual mode command is defined now:
928
929@smallexample
930@group
931(define-derived-mode text-mode nil "Text"
932 "Major mode for editing text written for humans to read.
933In this mode, paragraphs are delimited only by blank or white lines.
934You can thus get the full benefit of adaptive filling
935 (see the variable `adaptive-fill-mode').
936\\@{text-mode-map@}
937Turning on Text mode runs the normal hook `text-mode-hook'."
938@end group
939@group
940 (make-local-variable 'text-mode-variant)
941 (setq text-mode-variant t)
942 ;; @r{These two lines are a feature added recently.}
943 (set (make-local-variable 'require-final-newline)
944 mode-require-final-newline)
945 (set (make-local-variable 'indent-line-function) 'indent-relative))
946@end group
947@end smallexample
948
949 But here is how it was defined formerly, before
950@code{define-derived-mode} existed:
951
952@smallexample
953@group
954;; @r{This isn't needed nowadays, since @code{define-derived-mode} does it.}
955(defvar text-mode-abbrev-table nil
956 "Abbrev table used while in text mode.")
957(define-abbrev-table 'text-mode-abbrev-table ())
958@end group
959
960@group
961(defun text-mode ()
962 "Major mode for editing text intended for humans to read...
963 Special commands: \\@{text-mode-map@}
964@end group
965@group
966Turning on text-mode runs the hook `text-mode-hook'."
967 (interactive)
968 (kill-all-local-variables)
969 (use-local-map text-mode-map)
970@end group
971@group
972 (setq local-abbrev-table text-mode-abbrev-table)
973 (set-syntax-table text-mode-syntax-table)
974@end group
975@group
976 ;; @r{These four lines are absent from the current version}
977 ;; @r{not because this is done some other way, but rather}
978 ;; @r{because nowadays Text mode uses the normal definition of paragraphs.}
979 (make-local-variable 'paragraph-start)
980 (setq paragraph-start (concat "[ \t]*$\\|" page-delimiter))
981 (make-local-variable 'paragraph-separate)
982 (setq paragraph-separate paragraph-start)
983 (make-local-variable 'indent-line-function)
984 (setq indent-line-function 'indent-relative-maybe)
985@end group
986@group
987 (setq mode-name "Text")
988 (setq major-mode 'text-mode)
989 (run-mode-hooks 'text-mode-hook)) ; @r{Finally, this permits the user to}
990 ; @r{customize the mode with a hook.}
991@end group
992@end smallexample
993
994@cindex @file{lisp-mode.el}
995 The three Lisp modes (Lisp mode, Emacs Lisp mode, and Lisp
996Interaction mode) have more features than Text mode and the code is
997correspondingly more complicated. Here are excerpts from
998@file{lisp-mode.el} that illustrate how these modes are written.
999
1000@cindex syntax table example
1001@smallexample
1002@group
1003;; @r{Create mode-specific table variables.}
1004(defvar lisp-mode-syntax-table nil "")
1005(defvar lisp-mode-abbrev-table nil "")
1006@end group
1007
1008@group
1009(defvar emacs-lisp-mode-syntax-table
1010 (let ((table (make-syntax-table)))
1011 (let ((i 0))
1012@end group
1013
1014@group
1015 ;; @r{Set syntax of chars up to @samp{0} to say they are}
1016 ;; @r{part of symbol names but not words.}
1017 ;; @r{(The digit @samp{0} is @code{48} in the @acronym{ASCII} character set.)}
1018 (while (< i ?0)
1019 (modify-syntax-entry i "_ " table)
1020 (setq i (1+ i)))
1021 ;; @r{@dots{} similar code follows for other character ranges.}
1022@end group
1023@group
1024 ;; @r{Then set the syntax codes for characters that are special in Lisp.}
1025 (modify-syntax-entry ? " " table)
1026 (modify-syntax-entry ?\t " " table)
1027 (modify-syntax-entry ?\f " " table)
1028 (modify-syntax-entry ?\n "> " table)
1029@end group
1030@group
1031 ;; @r{Give CR the same syntax as newline, for selective-display.}
1032 (modify-syntax-entry ?\^m "> " table)
1033 (modify-syntax-entry ?\; "< " table)
1034 (modify-syntax-entry ?` "' " table)
1035 (modify-syntax-entry ?' "' " table)
1036 (modify-syntax-entry ?, "' " table)
1037@end group
1038@group
1039 ;; @r{@dots{}likewise for many other characters@dots{}}
1040 (modify-syntax-entry ?\( "() " table)
1041 (modify-syntax-entry ?\) ")( " table)
1042 (modify-syntax-entry ?\[ "(] " table)
1043 (modify-syntax-entry ?\] ")[ " table))
1044 table))
1045@end group
1046@group
1047;; @r{Create an abbrev table for lisp-mode.}
1048(define-abbrev-table 'lisp-mode-abbrev-table ())
1049@end group
1050@end smallexample
1051
1052 The three modes for Lisp share much of their code. For instance,
1053each calls the following function to set various variables:
1054
1055@smallexample
1056@group
1057(defun lisp-mode-variables (lisp-syntax)
1058 (when lisp-syntax
1059 (set-syntax-table lisp-mode-syntax-table))
1060 (setq local-abbrev-table lisp-mode-abbrev-table)
1061 @dots{}
1062@end group
1063@end smallexample
1064
1065 In Lisp and most programming languages, we want the paragraph
1066commands to treat only blank lines as paragraph separators. And the
1067modes should undestand the Lisp conventions for comments. The rest of
1068@code{lisp-mode-variables} sets this up:
1069
1070@smallexample
1071@group
1072 (make-local-variable 'paragraph-start)
1073 (setq paragraph-start (concat page-delimiter "\\|$" ))
1074 (make-local-variable 'paragraph-separate)
1075 (setq paragraph-separate paragraph-start)
1076 @dots{}
1077@end group
1078@group
1079 (make-local-variable 'comment-indent-function)
1080 (setq comment-indent-function 'lisp-comment-indent))
1081 @dots{}
1082@end group
1083@end smallexample
1084
1085 Each of the different Lisp modes has a slightly different keymap. For
1086example, Lisp mode binds @kbd{C-c C-z} to @code{run-lisp}, but the other
1087Lisp modes do not. However, all Lisp modes have some commands in
1088common. The following code sets up the common commands:
1089
1090@smallexample
1091@group
1092(defvar shared-lisp-mode-map ()
1093 "Keymap for commands shared by all sorts of Lisp modes.")
1094
1095;; @r{Putting this @code{if} after the @code{defvar} is an older style.}
1096(if shared-lisp-mode-map
1097 ()
1098 (setq shared-lisp-mode-map (make-sparse-keymap))
1099 (define-key shared-lisp-mode-map "\e\C-q" 'indent-sexp)
1100 (define-key shared-lisp-mode-map "\177"
1101 'backward-delete-char-untabify))
1102@end group
1103@end smallexample
1104
1105@noindent
1106And here is the code to set up the keymap for Lisp mode:
1107
1108@smallexample
1109@group
1110(defvar lisp-mode-map ()
1111 "Keymap for ordinary Lisp mode...")
1112
1113(if lisp-mode-map
1114 ()
1115 (setq lisp-mode-map (make-sparse-keymap))
1116 (set-keymap-parent lisp-mode-map shared-lisp-mode-map)
1117 (define-key lisp-mode-map "\e\C-x" 'lisp-eval-defun)
1118 (define-key lisp-mode-map "\C-c\C-z" 'run-lisp))
1119@end group
1120@end smallexample
1121
1122 Finally, here is the complete major mode function definition for
1123Lisp mode.
1124
1125@smallexample
1126@group
1127(defun lisp-mode ()
1128 "Major mode for editing Lisp code for Lisps other than GNU Emacs Lisp.
1129Commands:
1130Delete converts tabs to spaces as it moves back.
1131Blank lines separate paragraphs. Semicolons start comments.
1132\\@{lisp-mode-map@}
1133Note that `run-lisp' may be used either to start an inferior Lisp job
1134or to switch back to an existing one.
1135@end group
1136
1137@group
1138Entry to this mode calls the value of `lisp-mode-hook'
1139if that value is non-nil."
1140 (interactive)
1141 (kill-all-local-variables)
1142@end group
1143@group
1144 (use-local-map lisp-mode-map) ; @r{Select the mode's keymap.}
1145 (setq major-mode 'lisp-mode) ; @r{This is how @code{describe-mode}}
1146 ; @r{finds out what to describe.}
1147 (setq mode-name "Lisp") ; @r{This goes into the mode line.}
1148 (lisp-mode-variables t) ; @r{This defines various variables.}
1149 (make-local-variable 'comment-start-skip)
1150 (setq comment-start-skip
1151 "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\)\\(;+\\|#|\\) *")
1152 (make-local-variable 'font-lock-keywords-case-fold-search)
1153 (setq font-lock-keywords-case-fold-search t)
1154@end group
1155@group
1156 (setq imenu-case-fold-search t)
1157 (set-syntax-table lisp-mode-syntax-table)
1158 (run-mode-hooks 'lisp-mode-hook)) ; @r{This permits the user to use a}
1159 ; @r{hook to customize the mode.}
1160@end group
1161@end smallexample
1162
1174@node Minor Modes 1163@node Minor Modes
1175@section Minor Modes 1164@section Minor Modes
1176@cindex minor mode 1165@cindex minor mode
@@ -1533,16 +1522,14 @@ minor modes.
1533@subsection Mode Line Basics 1522@subsection Mode Line Basics
1534 1523
1535 @code{mode-line-format} is a buffer-local variable that holds a 1524 @code{mode-line-format} is a buffer-local variable that holds a
1536@dfn{mode line construct}, a kind of template, which controls the 1525@dfn{mode line construct}, a kind of template, which controls what is
1537display the mode line of the current buffer. All windows for the same 1526displayed on the mode line of the current buffer. The value of
1538buffer use the same @code{mode-line-format}, so their mode lines 1527@code{header-line-format} specifies the buffer's header line in the
1539appear the same---except for scrolling percentages, and line and 1528same way. All windows for the same buffer use the same
1540column numbers, since those depend on point and on how the window is 1529@code{mode-line-format} and @code{header-line-format}.
1541scrolled. The value of @code{header-line-format} specifies the 1530
1542buffer's header line in the same way, with a mode line construct. 1531 For efficiency, Emacs does not continuously recompute the mode
1543 1532line and header line of a window. It does so when circumstances
1544 For efficiency, Emacs does not recompute the mode line and header
1545line of a window in every redisplay. It does so when circumstances
1546appear to call for it---for instance, if you change the window 1533appear to call for it---for instance, if you change the window
1547configuration, switch buffers, narrow or widen the buffer, scroll, or 1534configuration, switch buffers, narrow or widen the buffer, scroll, or
1548change the buffer's modification status. If you modify any of the 1535change the buffer's modification status. If you modify any of the
@@ -1552,7 +1539,6 @@ how text is displayed (@pxref{Display}), you may want to force an
1552update of the mode line so as to display the new information or 1539update of the mode line so as to display the new information or
1553display it in the new way. 1540display it in the new way.
1554 1541
1555@c Emacs 19 feature
1556@defun force-mode-line-update &optional all 1542@defun force-mode-line-update &optional all
1557Force redisplay of the current buffer's mode line and header line. 1543Force redisplay of the current buffer's mode line and header line.
1558The next redisplay will update the mode line and header line based on 1544The next redisplay will update the mode line and header line based on
@@ -1589,15 +1575,17 @@ defined to have mode-line constructs as their values.
1589@table @code 1575@table @code
1590@cindex percent symbol in mode line 1576@cindex percent symbol in mode line
1591@item @var{string} 1577@item @var{string}
1592A string as a mode-line construct appears verbatim in the mode line 1578A string as a mode-line construct appears verbatim except for
1593except for @dfn{@code{%}-constructs} in it. These stand for 1579@dfn{@code{%}-constructs} in it. These stand for substitution of
1594substitution of other data; see @ref{%-Constructs}. 1580other data; see @ref{%-Constructs}.
1595 1581
1596If the string has @code{face} properties, they are copied into the 1582If parts of the string have @code{face} properties, they control
1597mode line contents too (@pxref{Properties in Mode}). Any characters 1583display of the text just as they would text in the buffer. Any
1598in the mode line which have no @code{face} properties are displayed, 1584characters which have no @code{face} properties are displayed, by
1599by default, in the face @code{mode-line} or @code{mode-line-inactive} 1585default, in the face @code{mode-line} or @code{mode-line-inactive}
1600(@pxref{Standard Faces,,, emacs, The GNU Emacs Manual}). 1586(@pxref{Standard Faces,,, emacs, The GNU Emacs Manual}). The
1587@code{help-echo} and @code{local-map} properties in @var{string} have
1588special meanings. @xref{Properties in Mode}.
1601 1589
1602@item @var{symbol} 1590@item @var{symbol}
1603A symbol as a mode-line construct stands for its value. The value of 1591A symbol as a mode-line construct stands for its value. The value of
@@ -1612,7 +1600,9 @@ Unless @var{symbol} is marked as ``risky'' (i.e., it has a
1612non-@code{nil} @code{risky-local-variable} property), all text 1600non-@code{nil} @code{risky-local-variable} property), all text
1613properties specified in @var{symbol}'s value are ignored. This 1601properties specified in @var{symbol}'s value are ignored. This
1614includes the text properties of strings in @var{symbol}'s value, as 1602includes the text properties of strings in @var{symbol}'s value, as
1615well as all @code{:eval} and @code{:propertize} forms in it. 1603well as all @code{:eval} and @code{:propertize} forms in it. (The
1604reason for this is security: non-risky variables could be set
1605automatically from file variables without prompting the user.)
1616 1606
1617@item (@var{string} @var{rest}@dots{}) 1607@item (@var{string} @var{rest}@dots{})
1618@itemx (@var{list} @var{rest}@dots{}) 1608@itemx (@var{list} @var{rest}@dots{})
@@ -2055,10 +2045,10 @@ structure, and make @var{form} evaluate to a string that has a text
2055property. 2045property.
2056@end enumerate 2046@end enumerate
2057 2047
2058 You use the @code{local-map} property to specify a keymap. Like any 2048 You can use the @code{local-map} property to specify a keymap. This
2059keymap, it can bind character keys and function keys; but that has no 2049keymap only takes real effect for mouse clicks; binding character keys
2060effect, since it is impossible to move point into the mode line. This 2050and function keys to it has no effect, since it is impossible to move
2061keymap can only take real effect for mouse clicks. 2051point into the mode line.
2062 2052
2063 When the mode line refers to a variable which does not have a 2053 When the mode line refers to a variable which does not have a
2064non-@code{nil} @code{risky-local-variable} property, any text 2054non-@code{nil} @code{risky-local-variable} property, any text
@@ -2889,6 +2879,10 @@ Used (typically) for constant names.
2889@vindex font-lock-preprocessor-face 2879@vindex font-lock-preprocessor-face
2890Used (typically) for preprocessor commands. 2880Used (typically) for preprocessor commands.
2891 2881
2882@item font-lock-negation-char-face
2883@vindex font-lock-negation-char-face
2884Used (typically) for easily-overlooked negation characters.
2885
2892@item font-lock-warning-face 2886@item font-lock-warning-face
2893@vindex font-lock-warning-face 2887@vindex font-lock-warning-face
2894Used (typically) for constructs that are peculiar, or that greatly 2888Used (typically) for constructs that are peculiar, or that greatly
@@ -3057,7 +3051,7 @@ so that the scanned text never starts or ends in the middle of a
3057multiline construct. 3051multiline construct.
3058@item 3052@item
3059Add a function to @code{font-lock-extend-region-functions} that does 3053Add a function to @code{font-lock-extend-region-functions} that does
3060the \emph{identification} and extends the scan so that the scanned 3054the @emph{identification} and extends the scan so that the scanned
3061text never starts or ends in the middle of a multiline construct. 3055text never starts or ends in the middle of a multiline construct.
3062@end itemize 3056@end itemize
3063 3057
diff --git a/lispref/os.texi b/lispref/os.texi
index 30f66889387..ab277afdce6 100644
--- a/lispref/os.texi
+++ b/lispref/os.texi
@@ -1256,7 +1256,9 @@ This stands for the year without century (00-99).
1256@item %Y 1256@item %Y
1257This stands for the year with century. 1257This stands for the year with century.
1258@item %Z 1258@item %Z
1259This stands for the time zone abbreviation. 1259This stands for the time zone abbreviation (e.g., @samp{EST}).
1260@item %z
1261This stands for the time zone numerical offset (e.g., @samp{-0500}).
1260@end table 1262@end table
1261 1263
1262You can also specify the field width and type of padding for any of 1264You can also specify the field width and type of padding for any of
@@ -1286,12 +1288,14 @@ If @var{universal} is non-@code{nil}, that means to describe the time as
1286Universal Time; @code{nil} means describe it using what Emacs believes 1288Universal Time; @code{nil} means describe it using what Emacs believes
1287is the local time zone (see @code{current-time-zone}). 1289is the local time zone (see @code{current-time-zone}).
1288 1290
1289This function uses the C library function @code{strftime} to do most of 1291This function uses the C library function @code{strftime}
1290the work. In order to communicate with that function, it first encodes 1292(@pxref{Formatting Calendar Time,,, libc, The GNU C Library Reference
1291its argument using the coding system specified by 1293Manual}) to do most of the work. In order to communicate with that
1292@code{locale-coding-system} (@pxref{Locales}); after @code{strftime} 1294function, it first encodes its argument using the coding system
1293returns the resulting string, @code{format-time-string} decodes the 1295specified by @code{locale-coding-system} (@pxref{Locales}); after
1294string using that same coding system. 1296@code{strftime} returns the resulting string,
1297@code{format-time-string} decodes the string using that same coding
1298system.
1295@end defun 1299@end defun
1296 1300
1297@defun seconds-to-time seconds 1301@defun seconds-to-time seconds
diff --git a/lispref/strings.texi b/lispref/strings.texi
index 46c01982f32..17a62b546b4 100644
--- a/lispref/strings.texi
+++ b/lispref/strings.texi
@@ -700,8 +700,8 @@ in the copy with encodings of the corresponding @var{objects}. The
700arguments @var{objects} are the computed values to be formatted. 700arguments @var{objects} are the computed values to be formatted.
701 701
702The characters in @var{string}, other than the format specifications, 702The characters in @var{string}, other than the format specifications,
703are copied directly into the output; if they have text properties, 703are copied directly into the output, including their text properties,
704these are copied into the output also. 704if any.
705@end defun 705@end defun
706 706
707@cindex @samp{%} in format 707@cindex @samp{%} in format
@@ -719,6 +719,17 @@ For example:
719@end group 719@end group
720@end example 720@end example
721 721
722 Since @code{format} interprets @samp{%} characters as format
723specifications, you should @emph{never} pass an arbitrary string as
724the first argument. This is particularly true when the string is
725generated by some Lisp code. Unless the string is @emph{known} to
726never include any @samp{%} characters, pass @code{"%s"}, described
727below, as the first argument, and the string as the second, like this:
728
729@example
730 (format "%s" @var{arbitrary-string})
731@end example
732
722 If @var{string} contains more than one format specification, the 733 If @var{string} contains more than one format specification, the
723format specifications correspond to successive values from 734format specifications correspond to successive values from
724@var{objects}. Thus, the first format specification in @var{string} 735@var{objects}. Thus, the first format specification in @var{string}
diff --git a/lispref/text.texi b/lispref/text.texi
index 08e55f18f05..4d2f278bee8 100644
--- a/lispref/text.texi
+++ b/lispref/text.texi
@@ -103,9 +103,9 @@ This function returns the character following point in the current
103buffer. This is similar to @code{(char-after (point))}. However, if 103buffer. This is similar to @code{(char-after (point))}. However, if
104point is at the end of the buffer, then @code{following-char} returns 0. 104point is at the end of the buffer, then @code{following-char} returns 0.
105 105
106Remember that point is always between characters, and the terminal 106Remember that point is always between characters, and the cursor
107cursor normally appears over the character following point. Therefore, 107normally appears over the character following point. Therefore, the
108the character returned by @code{following-char} is the character the 108character returned by @code{following-char} is the character the
109cursor is over. 109cursor is over.
110 110
111In this example, point is between the @samp{a} and the @samp{c}. 111In this example, point is between the @samp{a} and the @samp{c}.
@@ -526,16 +526,6 @@ The value returned is @code{nil}. In an interactive call, @var{count}
526is the numeric prefix argument. 526is the numeric prefix argument.
527@end deffn 527@end deffn
528 528
529@deffn Command split-line
530This command splits the current line, moving the portion of the line
531after point down vertically so that it is on the next line directly
532below where it was before. Whitespace is inserted as needed at the
533beginning of the lower line, using the @code{indent-to} function.
534@code{split-line} returns the position of point.
535
536Programs hardly ever use this function.
537@end deffn
538
539@defvar overwrite-mode 529@defvar overwrite-mode
540This variable controls whether overwrite mode is in effect. The value 530This variable controls whether overwrite mode is in effect. The value
541should be @code{overwrite-mode-textual}, @code{overwrite-mode-binary}, 531should be @code{overwrite-mode-textual}, @code{overwrite-mode-binary},
@@ -978,8 +968,11 @@ the @var{undo} value.
978@comment node-name, next, previous, up 968@comment node-name, next, previous, up
979@subsection Functions for Yanking 969@subsection Functions for Yanking
980 970
981 @dfn{Yanking} means reinserting an entry of previously killed text 971 This section describes higher-level commands for yanking, which are
982from the kill ring. The text properties are copied too. 972intended primarily for the user but useful also in Lisp programs.
973Both @code{yank} and @code{yank-pop} honor the
974@code{yank-excluded-properties} variable and @code{yank-handler} text
975property (@pxref{Yanking}).
983 976
984@deffn Command yank &optional arg 977@deffn Command yank &optional arg
985@cindex inserting killed text 978@cindex inserting killed text
@@ -1213,7 +1206,7 @@ value for @code{kill-ring-max} is 60.
1213to the buffer's text so that they can be undone. (The buffers that 1206to the buffer's text so that they can be undone. (The buffers that
1214don't have one are usually special-purpose buffers for which Emacs 1207don't have one are usually special-purpose buffers for which Emacs
1215assumes that undoing is not useful. In particular, any buffer whose 1208assumes that undoing is not useful. In particular, any buffer whose
1216name begins with a space has its undo recording off by default, 1209name begins with a space has its undo recording off by default;
1217see @ref{Buffer Names}.) All the primitives that modify the 1210see @ref{Buffer Names}.) All the primitives that modify the
1218text in the buffer automatically add elements to the front of the undo 1211text in the buffer automatically add elements to the front of the undo
1219list, which is in the variable @code{buffer-undo-list}. 1212list, which is in the variable @code{buffer-undo-list}.
@@ -1318,8 +1311,7 @@ they're being called for the sake of undoing.
1318@defun primitive-undo count list 1311@defun primitive-undo count list
1319This is the basic function for undoing elements of an undo list. 1312This is the basic function for undoing elements of an undo list.
1320It undoes the first @var{count} elements of @var{list}, returning 1313It undoes the first @var{count} elements of @var{list}, returning
1321the rest of @var{list}. You could write this function in Lisp, 1314the rest of @var{list}.
1322but it is convenient to have it in C.
1323 1315
1324@code{primitive-undo} adds elements to the buffer's undo list when it 1316@code{primitive-undo} adds elements to the buffer's undo list when it
1325changes the buffer. Undo commands avoid confusion by saving the undo 1317changes the buffer. Undo commands avoid confusion by saving the undo
@@ -1372,7 +1364,9 @@ them back to size limits you can set. (For this purpose, the ``size''
1372of an undo list measures the cons cells that make up the list, plus the 1364of an undo list measures the cons cells that make up the list, plus the
1373strings of deleted text.) Three variables control the range of acceptable 1365strings of deleted text.) Three variables control the range of acceptable
1374sizes: @code{undo-limit}, @code{undo-strong-limit} and 1366sizes: @code{undo-limit}, @code{undo-strong-limit} and
1375@code{undo-outer-limit}. 1367@code{undo-outer-limit}. In these variables, size is counted as the
1368number of bytes occupied, which includes both saved text and other
1369data.
1376 1370
1377@defopt undo-limit 1371@defopt undo-limit
1378This is the soft limit for the acceptable size of an undo list. The 1372This is the soft limit for the acceptable size of an undo list. The
@@ -1392,6 +1386,17 @@ exceeds this limit, Emacs discards the info and displays a warning.
1392This is a last ditch limit to prevent memory overflow. 1386This is a last ditch limit to prevent memory overflow.
1393@end defopt 1387@end defopt
1394 1388
1389@defopt undo-ask-before-discard
1390If this variable is non-@code{nil}, when the undo info exceeds
1391@code{undo-outer-limit}, Emacs asks in the echo area whether to
1392discard the info. The default value is @code{nil}, which means to
1393discard it automatically.
1394
1395This option is mainly intended for debugging. Garbage collection is
1396inhibited while the question is asked, which means that Emacs might
1397leak memory if the user waits too long before answering the question.
1398@end defopt
1399
1395@node Filling 1400@node Filling
1396@comment node-name, next, previous, up 1401@comment node-name, next, previous, up
1397@section Filling 1402@section Filling
@@ -1481,8 +1486,6 @@ it. If the region was made up of many paragraphs, the blank lines
1481between paragraphs are removed. This function justifies as well as 1486between paragraphs are removed. This function justifies as well as
1482filling when @var{justify} is non-@code{nil}. 1487filling when @var{justify} is non-@code{nil}.
1483 1488
1484In an interactive call, any prefix argument requests justification.
1485
1486If @var{nosqueeze} is non-@code{nil}, that means to leave whitespace 1489If @var{nosqueeze} is non-@code{nil}, that means to leave whitespace
1487other than line breaks untouched. If @var{squeeze-after} is 1490other than line breaks untouched. If @var{squeeze-after} is
1488non-@code{nil}, it specifies a position in the region, and means don't 1491non-@code{nil}, it specifies a position in the region, and means don't
@@ -1522,6 +1525,11 @@ values are @code{left}, @code{right}, @code{full}, @code{center}, or
1522@defun current-justification 1525@defun current-justification
1523This function returns the proper justification style to use for filling 1526This function returns the proper justification style to use for filling
1524the text around point. 1527the text around point.
1528
1529This returns the value of the @code{justification} text property at
1530point, or the variable @var{default-justification} if there is no such
1531text property. However, it returns @code{nil} rather than @code{none}
1532to mean ``don't justify''.
1525@end defun 1533@end defun
1526 1534
1527@defopt sentence-end-double-space 1535@defopt sentence-end-double-space
@@ -1569,14 +1577,14 @@ newlines'' act as paragraph separators.
1569@section Margins for Filling 1577@section Margins for Filling
1570 1578
1571@defopt fill-prefix 1579@defopt fill-prefix
1572This buffer-local variable specifies a string of text that appears at 1580This buffer-local variable, if non-@code{nil}, specifies a string of
1573the beginning 1581text that appears at the beginning of normal text lines and should be
1574of normal text lines and should be disregarded when filling them. Any 1582disregarded when filling them. Any line that fails to start with the
1575line that fails to start with the fill prefix is considered the start of 1583fill prefix is considered the start of a paragraph; so is any line
1576a paragraph; so is any line that starts with the fill prefix followed by 1584that starts with the fill prefix followed by additional whitespace.
1577additional whitespace. Lines that start with the fill prefix but no 1585Lines that start with the fill prefix but no additional whitespace are
1578additional whitespace are ordinary text lines that can be filled 1586ordinary text lines that can be filled together. The resulting filled
1579together. The resulting filled lines also start with the fill prefix. 1587lines also start with the fill prefix.
1580 1588
1581The fill prefix follows the left margin whitespace, if any. 1589The fill prefix follows the left margin whitespace, if any.
1582@end defopt 1590@end defopt
@@ -1661,12 +1669,11 @@ becomes buffer-local when set in any fashion.
1661 1669
1662@defvar fill-nobreak-predicate 1670@defvar fill-nobreak-predicate
1663This variable gives major modes a way to specify not to break a line 1671This variable gives major modes a way to specify not to break a line
1664at certain places. Its value should be a list of functions, but a 1672at certain places. Its value should be a list of functions. Whenever
1665single function is also supported for compatibility. Whenever filling 1673filling considers breaking the line at a certain place in the buffer,
1666considers breaking the line at a certain place in the buffer, it calls 1674it calls each of these functions with no arguments and with point
1667each of these functions with no arguments and with point located at 1675located at that place. If any of the functions returns
1668that place. If any of the functions returns non-@code{nil}, then the 1676non-@code{nil}, then the line won't be broken there.
1669line won't be broken there.
1670@end defvar 1677@end defvar
1671 1678
1672@node Adaptive Fill 1679@node Adaptive Fill
@@ -1733,7 +1740,7 @@ Adaptive Fill mode matches this regular expression against the text
1733starting after the left margin whitespace (if any) on a line; the 1740starting after the left margin whitespace (if any) on a line; the
1734characters it matches are that line's candidate for the fill prefix. 1741characters it matches are that line's candidate for the fill prefix.
1735 1742
1736@w{@code{"[ \t]*\\([-|#;>*]+[ \t]*\\|(?[0-9]+[.)][ \t]*\\)*"}} is the 1743@w{@code{"[ \t]*\\([-!|#%;>*·•‣⁃◦]+[ \t]*\\|(?[0-9]+[.)][ \t]*\\)*"}} is the
1737default value. This matches a number enclosed in parentheses or 1744default value. This matches a number enclosed in parentheses or
1738followed by a period, or certain punctuation characters, or any 1745followed by a period, or certain punctuation characters, or any
1739sequence of these intermingled with whitespace. In particular, it 1746sequence of these intermingled with whitespace. In particular, it
@@ -1898,7 +1905,8 @@ the sort order."
1898 (save-restriction 1905 (save-restriction
1899 (narrow-to-region beg end) 1906 (narrow-to-region beg end)
1900 (goto-char (point-min)) 1907 (goto-char (point-min))
1901 (sort-subr reverse 'forward-line 'end-of-line)))) 1908 (let ((inhibit-field-text-motion t))
1909 (sort-subr reverse 'forward-line 'end-of-line)))))
1902@end group 1910@end group
1903@end example 1911@end example
1904 1912
@@ -2054,9 +2062,12 @@ One unusual thing about this command is that the entire line
2054containing position @var{beg}, and the entire line containing position 2062containing position @var{beg}, and the entire line containing position
2055@var{end}, are included in the region sorted. 2063@var{end}, are included in the region sorted.
2056 2064
2057Note that @code{sort-columns} uses the @code{sort} utility program, 2065Note that @code{sort-columns} rejects text that contains tabs, because
2058and so cannot work properly on text containing tab characters. Use 2066tabs could be split across the specified columns. Use @kbd{M-x
2059@kbd{M-x untabify} to convert tabs to spaces before sorting. 2067untabify} to convert tabs to spaces before sorting.
2068
2069When possible, this command actually works by calling the @code{sort}
2070utility program.
2060@end deffn 2071@end deffn
2061 2072
2062@node Columns 2073@node Columns
@@ -2391,6 +2402,7 @@ spaces and tab characters to reach the next tab stop column; it does not
2391affect the display of tab characters in the buffer (@pxref{Usual 2402affect the display of tab characters in the buffer (@pxref{Usual
2392Display}). Note that the @key{TAB} character as input uses this tab 2403Display}). Note that the @key{TAB} character as input uses this tab
2393stop feature only in a few major modes, such as Text mode. 2404stop feature only in a few major modes, such as Text mode.
2405@xref{Tab Stops,,, emacs, The GNU Emacs Manual}.
2394 2406
2395@deffn Command tab-to-tab-stop 2407@deffn Command tab-to-tab-stop
2396This command inserts spaces or tabs before point, up to the next tab 2408This command inserts spaces or tabs before point, up to the next tab
@@ -3079,22 +3091,23 @@ This feature is used in the mode line and for other active text.
3079@cindex keymap of character 3091@cindex keymap of character
3080@kindex keymap @r{(text property)} 3092@kindex keymap @r{(text property)}
3081The @code{keymap} property specifies an additional keymap for 3093The @code{keymap} property specifies an additional keymap for
3082commands. The property's value for the character before point applies 3094commands. When this keymap applies, it is used for key lookup before
3083if it is non-@code{nil} and rear-sticky, and the property's value for 3095the minor mode keymaps and before the buffer's local map.
3084the character after point applies if it is non-@code{nil} and 3096@xref{Active Keymaps}. If the property value is a symbol, the
3097symbol's function definition is used as the keymap.
3098
3099The property's value for the character before point applies if it is
3100non-@code{nil} and rear-sticky, and the property's value for the
3101character after point applies if it is non-@code{nil} and
3085front-sticky. (For mouse clicks, the position of the click is used 3102front-sticky. (For mouse clicks, the position of the click is used
3086instead of the position of point.) If the property value is a symbol, 3103instead of the position of point.)
3087the symbol's function definition is used as the keymap.
3088
3089When this keymap applies, it is used for key lookup before the minor
3090mode keymaps and before the buffer's local map. @xref{Active
3091Keymaps}.
3092 3104
3093@item local-map 3105@item local-map
3094@kindex local-map @r{(text property)} 3106@kindex local-map @r{(text property)}
3095This property works like @code{keymap} except that it specifies a 3107This property works like @code{keymap} except that it specifies a
3096keymap to use @emph{instead of} the buffer's local map. For most 3108keymap to use @emph{instead of} the buffer's local map. For most
3097purposes (perhaps all purposes), the @code{keymap} is superior. 3109purposes (perhaps all purposes), it is better to use the @code{keymap}
3110property.
3098 3111
3099@item syntax-table 3112@item syntax-table
3100The @code{syntax-table} property overrides what the syntax table says 3113The @code{syntax-table} property overrides what the syntax table says
@@ -3479,9 +3492,16 @@ being called over and over for the same text.
3479@subsection Defining Clickable Text 3492@subsection Defining Clickable Text
3480@cindex clickable text 3493@cindex clickable text
3481 3494
3482 There are two parts of setting up @dfn{clickable text} in a buffer: 3495 @dfn{Clickable text} is text that can be clicked, with either the
3483(1) to indicate clickability when the mouse moves over the text, and (2) 3496the mouse or via keyboard commands, to produce some result. Many
3484to make a mouse button do something when you click on that text. 3497major modes use clickable text to implement features such as
3498hyper-links. The @code{button} package provides an easy way to insert
3499and manipulate clickable text. @xref{Buttons}.
3500
3501 In this section, we will explain how to manually set up clickable
3502text in a buffer using text properties. This involves two things: (1)
3503indicating clickability when the mouse moves over the text, and (2)
3504making @kbd{RET} or a mouse click on that text do something.
3485 3505
3486 Indicating clickability usually involves highlighting the text, and 3506 Indicating clickability usually involves highlighting the text, and
3487often involves displaying helpful information about the action, such 3507often involves displaying helpful information about the action, such