annotate man/lispref/text.texi @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children c9fe270a4101
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 @c -*-texinfo-*-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 @c This is part of the XEmacs Lisp Reference Manual.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 @c Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 @c See the file lispref.texi for copying conditions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 @setfilename ../../info/text.info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 @node Text, Searching and Matching, Markers, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 @chapter Text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 @cindex text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 This chapter describes the functions that deal with the text in a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 buffer. Most examine, insert, or delete text in the current buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 often in the vicinity of point. Many are interactive. All the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 functions that change the text provide for undoing the changes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 (@pxref{Undo}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 Many text-related functions operate on a region of text defined by two
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 buffer positions passed in arguments named @var{start} and @var{end}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 These arguments should be either markers (@pxref{Markers}) or numeric
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 character positions (@pxref{Positions}). The order of these arguments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 does not matter; it is all right for @var{start} to be the end of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 region and @var{end} the beginning. For example, @code{(delete-region 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 10)} and @code{(delete-region 10 1)} are equivalent. An
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 @code{args-out-of-range} error is signaled if either @var{start} or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 @var{end} is outside the accessible portion of the buffer. In an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 interactive call, point and the mark are used for these arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 @cindex buffer contents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 Throughout this chapter, ``text'' refers to the characters in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 buffer, together with their properties (when relevant).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 * Near Point:: Examining text in the vicinity of point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 * Buffer Contents:: Examining text in a general fashion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 * Comparing Text:: Comparing substrings of buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 * Insertion:: Adding new text to a buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 * Commands for Insertion:: User-level commands to insert text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 * Deletion:: Removing text from a buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 * User-Level Deletion:: User-level commands to delete text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 * The Kill Ring:: Where removed text sometimes is saved for later use.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 * Undo:: Undoing changes to the text of a buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 * Maintaining Undo:: How to enable and disable undo information.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 How to control how much information is kept.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 * Filling:: Functions for explicit filling.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 * Margins:: How to specify margins for filling commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 * Auto Filling:: How auto-fill mode is implemented to break lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 * Sorting:: Functions for sorting parts of the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 * Columns:: Computing horizontal positions, and using them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 * Indentation:: Functions to insert or adjust indentation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 * Case Changes:: Case conversion of parts of the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 * Text Properties:: Assigning Lisp property lists to text characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 * Substitution:: Replacing a given character wherever it appears.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 * Registers:: How registers are implemented. Accessing the text or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 position stored in a register.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 * Transposition:: Swapping two portions of a buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 * Change Hooks:: Supplying functions to be run when text is changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 @node Near Point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 @section Examining Text Near Point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 Many functions are provided to look at the characters around point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 Several simple functions are described here. See also @code{looking-at}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 in @ref{Regexp Search}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 Many of these functions take an optional @var{buffer} argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 In all such cases, the current buffer will be used if this argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 is omitted. (In FSF Emacs, and earlier versions of XEmacs, these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 functions usually did not have these optional @var{buffer} arguments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 and always operated on the current buffer.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 @defun char-after position &optional buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 This function returns the character in the buffer at (i.e.,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 immediately after) position @var{position}. If @var{position} is out of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 range for this purpose, either before the beginning of the buffer, or at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 or beyond the end, then the value is @code{nil}. If optional argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 @var{buffer} is @code{nil}, the current buffer is assumed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 In the following example, assume that the first character in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 buffer is @samp{@@}:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (char-to-string (char-after 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 @result{} "@@"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 @defun following-char &optional buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 This function returns the character following point in the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 This is similar to @code{(char-after (point))}. However, if point is at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 the end of the buffer, then the result of @code{following-char} is 0.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 If optional argument @var{buffer} is @code{nil}, the current buffer is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 assumed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 Remember that point is always between characters, and the terminal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 cursor normally appears over the character following point. Therefore,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 the character returned by @code{following-char} is the character the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 cursor is over.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 In this example, point is between the @samp{a} and the @samp{c}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ---------- Buffer: foo ----------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 Gentlemen may cry ``Pea@point{}ce! Peace!,''
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 but there is no peace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ---------- Buffer: foo ----------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (char-to-string (preceding-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 @result{} "a"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (char-to-string (following-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 @result{} "c"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 @defun preceding-char &optional buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 This function returns the character preceding point in the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 See above, under @code{following-char}, for an example. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 point is at the beginning of the buffer, @code{preceding-char} returns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 0. If optional argument @var{buffer} is @code{nil}, the current buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 is assumed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 @defun bobp &optional buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 This function returns @code{t} if point is at the beginning of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 buffer. If narrowing is in effect, this means the beginning of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 accessible portion of the text. If optional argument @var{buffer} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 @code{nil}, the current buffer is assumed. See also @code{point-min} in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 @ref{Point}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 @defun eobp &optional buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 This function returns @code{t} if point is at the end of the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 If narrowing is in effect, this means the end of accessible portion of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 the text. If optional argument @var{buffer} is @code{nil}, the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 buffer is assumed. See also @code{point-max} in @xref{Point}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 @defun bolp &optional buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 This function returns @code{t} if point is at the beginning of a line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 If optional argument @var{buffer} is @code{nil}, the current buffer is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 assumed. @xref{Text Lines}. The beginning of the buffer (or its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 accessible portion) always counts as the beginning of a line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 @defun eolp &optional buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 This function returns @code{t} if point is at the end of a line. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 end of the buffer is always considered the end of a line. If optional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 argument @var{buffer} is @code{nil}, the current buffer is assumed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 The end of the buffer (or of its accessible portion) is always considered
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 the end of a line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 @node Buffer Contents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 @section Examining Buffer Contents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 This section describes two functions that allow a Lisp program to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 convert any portion of the text in the buffer into a string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 @defun buffer-substring start end &optional buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 @defunx buffer-string start end &optional buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 These functions are equivalent and return a string containing a copy of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 the text of the region defined by positions @var{start} and @var{end} in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 the buffer. If the arguments are not positions in the accessible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 portion of the buffer, @code{buffer-substring} signals an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 @code{args-out-of-range} error. If optional argument @var{buffer} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 @code{nil}, the current buffer is assumed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 @c XEmacs feature.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 If the region delineated by @var{start} and @var{end} contains
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 duplicable extents, they will be remembered in the string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 @xref{Duplicable Extents}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 It is not necessary for @var{start} to be less than @var{end}; the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 arguments can be given in either order. But most often the smaller
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 argument is written first.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ---------- Buffer: foo ----------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 This is the contents of buffer foo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 ---------- Buffer: foo ----------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (buffer-substring 1 10)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 @result{} "This is t"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (buffer-substring (point-max) 10)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 @result{} "he contents of buffer foo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 @ignore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 @c `equal' in XEmacs does not compare text properties on strings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 @defun buffer-substring-without-properties start end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 This is like @code{buffer-substring}, except that it does not copy text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 properties, just the characters themselves. @xref{Text Properties}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 Here's an example of using this function to get a word to look up in an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 alist:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (setq flammable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (assoc (buffer-substring start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 '(("wood" . t) ("paper" . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 ("steel" . nil) ("asbestos" . nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 If this were written using @code{buffer-substring} instead, it would not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 work reliably; any text properties that happened to be in the word
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 copied from the buffer would make the comparisons fail.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 @end ignore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 @node Comparing Text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 @section Comparing Text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 @cindex comparing buffer text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 This function lets you compare portions of the text in a buffer, without
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 copying them into strings first.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 @defun compare-buffer-substrings buffer1 start1 end1 buffer2 start2 end2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 This function lets you compare two substrings of the same buffer or two
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 different buffers. The first three arguments specify one substring,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 giving a buffer and two positions within the buffer. The last three
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 arguments specify the other substring in the same way. You can use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 @code{nil} for @var{buffer1}, @var{buffer2}, or both to stand for the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 The value is negative if the first substring is less, positive if the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 first is greater, and zero if they are equal. The absolute value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 the result is one plus the index of the first differing characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 within the substrings.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 This function ignores case when comparing characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 if @code{case-fold-search} is non-@code{nil}. It always ignores
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 text properties.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 Suppose the current buffer contains the text @samp{foobarbar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 haha!rara!}; then in this example the two substrings are @samp{rbar }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 and @samp{rara!}. The value is 2 because the first substring is greater
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 at the second character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (compare-buffer-substring nil 6 11 nil 16 21)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 @result{} 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 @node Insertion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 @section Inserting Text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 @cindex insertion of text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 @cindex text insertion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 @dfn{Insertion} means adding new text to a buffer. The inserted text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 goes at point---between the character before point and the character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 after point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 Insertion relocates markers that point at positions after the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 insertion point, so that they stay with the surrounding text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (@pxref{Markers}). When a marker points at the place of insertion,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 insertion normally doesn't relocate the marker, so that it points to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 beginning of the inserted text; however, certain special functions such
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 as @code{insert-before-markers} relocate such markers to point after the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 inserted text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 @cindex insertion before point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 @cindex before point, insertion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 Some insertion functions leave point before the inserted text, while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 other functions leave it after. We call the former insertion @dfn{after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 point} and the latter insertion @dfn{before point}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 @c XEmacs feature.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 If a string with non-@code{nil} extent data is inserted, the remembered
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 extents will also be inserted. @xref{Duplicable Extents}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 Insertion functions signal an error if the current buffer is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 read-only.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 These functions copy text characters from strings and buffers along
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 with their properties. The inserted characters have exactly the same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 properties as the characters they were copied from. By contrast,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 characters specified as separate arguments, not part of a string or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 buffer, inherit their text properties from the neighboring text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 @defun insert &rest args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 This function inserts the strings and/or characters @var{args} into the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 current buffer, at point, moving point forward. In other words, it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 inserts the text before point. An error is signaled unless all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 @var{args} are either strings or characters. The value is @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 @defun insert-before-markers &rest args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 This function inserts the strings and/or characters @var{args} into the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 current buffer, at point, moving point forward. An error is signaled
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 unless all @var{args} are either strings or characters. The value is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 This function is unlike the other insertion functions in that it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 relocates markers initially pointing at the insertion point, to point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 after the inserted text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 @defun insert-string string &optional buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 This function inserts @var{string} into @var{buffer} before point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 @var{buffer} defaults to the current buffer if omitted. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 function is chiefly useful if you want to insert a string in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 a buffer other than the current one (otherwise you could just
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 use @code{insert}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 @defun insert-char character count &optional buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 This function inserts @var{count} instances of @var{character} into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 @var{buffer} before point. @var{count} must be a number, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 @var{character} must be a character. The value is @code{nil}. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 optional argument @var{buffer} is @code{nil}, the current buffer is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 assumed. (In FSF Emacs, the third argument is called @var{inherit}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 and refers to text properties.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 @defun insert-buffer-substring from-buffer-or-name &optional start end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 This function inserts a portion of buffer @var{from-buffer-or-name}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (which must already exist) into the current buffer before point. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 text inserted is the region from @var{start} and @var{end}. (These
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 arguments default to the beginning and end of the accessible portion of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 that buffer.) This function returns @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 In this example, the form is executed with buffer @samp{bar} as the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 current buffer. We assume that buffer @samp{bar} is initially empty.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 ---------- Buffer: foo ----------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 We hold these truths to be self-evident, that all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 ---------- Buffer: foo ----------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (insert-buffer-substring "foo" 1 20)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 @result{} nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 ---------- Buffer: bar ----------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 We hold these truth@point{}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 ---------- Buffer: bar ----------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 @node Commands for Insertion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 @section User-Level Insertion Commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 This section describes higher-level commands for inserting text,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 commands intended primarily for the user but useful also in Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 programs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 @deffn Command insert-buffer from-buffer-or-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 This command inserts the entire contents of @var{from-buffer-or-name}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (which must exist) into the current buffer after point. It leaves
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 the mark after the inserted text. The value is @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 @deffn Command self-insert-command count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 @cindex character insertion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 @cindex self-insertion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 This command inserts the last character typed; it does so @var{count}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 times, before point, and returns @code{nil}. Most printing characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 are bound to this command. In routine use, @code{self-insert-command}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 is the most frequently called function in XEmacs, but programs rarely use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 it except to install it on a keymap.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 In an interactive call, @var{count} is the numeric prefix argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 This command calls @code{auto-fill-function} whenever that is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 non-@code{nil} and the character inserted is a space or a newline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (@pxref{Auto Filling}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 @c Cross refs reworded to prevent overfull hbox. --rjc 15mar92
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 This command performs abbrev expansion if Abbrev mode is enabled and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 the inserted character does not have word-constituent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 syntax. (@xref{Abbrevs}, and @ref{Syntax Class Table}.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 This is also responsible for calling @code{blink-paren-function} when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 the inserted character has close parenthesis syntax (@pxref{Blinking}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 @deffn Command newline &optional number-of-newlines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 This command inserts newlines into the current buffer before point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 If @var{number-of-newlines} is supplied, that many newline characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 are inserted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 @cindex newline and Auto Fill mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 This function calls @code{auto-fill-function} if the current column
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 number is greater than the value of @code{fill-column} and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 @var{number-of-newlines} is @code{nil}. Typically what
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 @code{auto-fill-function} does is insert a newline; thus, the overall
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 result in this case is to insert two newlines at different places: one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 at point, and another earlier in the line. @code{newline} does not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 auto-fill if @var{number-of-newlines} is non-@code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 This command indents to the left margin if that is not zero.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 @xref{Margins}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 The value returned is @code{nil}. In an interactive call, @var{count}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 is the numeric prefix argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 @deffn Command split-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 This command splits the current line, moving the portion of the line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 after point down vertically so that it is on the next line directly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 below where it was before. Whitespace is inserted as needed at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 beginning of the lower line, using the @code{indent-to} function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 @code{split-line} returns the position of point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 Programs hardly ever use this function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 @defvar overwrite-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 This variable controls whether overwrite mode is in effect: a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 non-@code{nil} value enables the mode. It is automatically made
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 buffer-local when set in any fashion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 @node Deletion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 @section Deleting Text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 @cindex deletion vs killing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 Deletion means removing part of the text in a buffer, without saving
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 it in the kill ring (@pxref{The Kill Ring}). Deleted text can't be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 yanked, but can be reinserted using the undo mechanism (@pxref{Undo}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 Some deletion functions do save text in the kill ring in some special
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 cases.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 All of the deletion functions operate on the current buffer, and all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 return a value of @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 @defun erase-buffer &optional buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 This function deletes the entire text of @var{buffer}, leaving it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 empty. If the buffer is read-only, it signals a @code{buffer-read-only}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 error. Otherwise, it deletes the text without asking for any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 confirmation. It returns @code{nil}. @var{buffer} defaults to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 current buffer if omitted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 Normally, deleting a large amount of text from a buffer inhibits further
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 auto-saving of that buffer ``because it has shrunk''. However,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 @code{erase-buffer} does not do this, the idea being that the future
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 text is not really related to the former text, and its size should not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 be compared with that of the former text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 @deffn Command delete-region start end &optional buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 This command deletes the text in @var{buffer} in the region defined by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 @var{start} and @var{end}. The value is @code{nil}. If optional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 argument @var{buffer} is @code{nil}, the current buffer is assumed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 @deffn Command delete-char count &optional killp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 This command deletes @var{count} characters directly after point, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 before point if @var{count} is negative. If @var{killp} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 non-@code{nil}, then it saves the deleted characters in the kill ring.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 In an interactive call, @var{count} is the numeric prefix argument, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 @var{killp} is the unprocessed prefix argument. Therefore, if a prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 argument is supplied, the text is saved in the kill ring. If no prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 argument is supplied, then one character is deleted, but not saved in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 the kill ring.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 The value returned is always @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 @deffn Command delete-backward-char count &optional killp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 @cindex delete previous char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 This command deletes @var{count} characters directly before point, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 after point if @var{count} is negative. If @var{killp} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 non-@code{nil}, then it saves the deleted characters in the kill ring.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 In an interactive call, @var{count} is the numeric prefix argument, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 @var{killp} is the unprocessed prefix argument. Therefore, if a prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 argument is supplied, the text is saved in the kill ring. If no prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 argument is supplied, then one character is deleted, but not saved in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 the kill ring.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 The value returned is always @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 @deffn Command backward-delete-char-untabify count &optional killp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 @cindex tab deletion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 This command deletes @var{count} characters backward, changing tabs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 into spaces. When the next character to be deleted is a tab, it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 first replaced with the proper number of spaces to preserve alignment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 and then one of those spaces is deleted instead of the tab. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 @var{killp} is non-@code{nil}, then the command saves the deleted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 characters in the kill ring.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 Conversion of tabs to spaces happens only if @var{count} is positive.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 If it is negative, exactly @minus{}@var{count} characters after point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 are deleted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 In an interactive call, @var{count} is the numeric prefix argument, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 @var{killp} is the unprocessed prefix argument. Therefore, if a prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 argument is supplied, the text is saved in the kill ring. If no prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 argument is supplied, then one character is deleted, but not saved in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 the kill ring.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 The value returned is always @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 @node User-Level Deletion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 @section User-Level Deletion Commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 This section describes higher-level commands for deleting text,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 commands intended primarily for the user but useful also in Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 programs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 @deffn Command delete-horizontal-space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 @cindex deleting whitespace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 This function deletes all spaces and tabs around point. It returns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 In the following examples, we call @code{delete-horizontal-space} four
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 times, once on each line, with point between the second and third
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 characters on the line each time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 ---------- Buffer: foo ----------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 I @point{}thought
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 I @point{} thought
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 We@point{} thought
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 Yo@point{}u thought
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 ---------- Buffer: foo ----------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (delete-horizontal-space) ; @r{Four times.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 @result{} nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 ---------- Buffer: foo ----------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 Ithought
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 Ithought
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 Wethought
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 You thought
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 ---------- Buffer: foo ----------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 @deffn Command delete-indentation &optional join-following-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 This function joins the line point is on to the previous line, deleting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 any whitespace at the join and in some cases replacing it with one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 space. If @var{join-following-p} is non-@code{nil},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 @code{delete-indentation} joins this line to the following line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 instead. The value is @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 If there is a fill prefix, and the second of the lines being joined
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 starts with the prefix, then @code{delete-indentation} deletes the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 fill prefix before joining the lines. @xref{Margins}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 In the example below, point is located on the line starting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 @samp{events}, and it makes no difference if there are trailing spaces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 in the preceding line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 @smallexample
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 ---------- Buffer: foo ----------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 When in the course of human
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 @point{} events, it becomes necessary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 ---------- Buffer: foo ----------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (delete-indentation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 @result{} nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 ---------- Buffer: foo ----------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 When in the course of human@point{} events, it becomes necessary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 ---------- Buffer: foo ----------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 @end smallexample
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 After the lines are joined, the function @code{fixup-whitespace} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 responsible for deciding whether to leave a space at the junction.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 @defun fixup-whitespace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 This function replaces all the white space surrounding point with either
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 one space or no space, according to the context. It returns @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 At the beginning or end of a line, the appropriate amount of space is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 none. Before a character with close parenthesis syntax, or after a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 character with open parenthesis or expression-prefix syntax, no space is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 also appropriate. Otherwise, one space is appropriate. @xref{Syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 Class Table}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 In the example below, @code{fixup-whitespace} is called the first time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 with point before the word @samp{spaces} in the first line. For the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 second invocation, point is directly after the @samp{(}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 @smallexample
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 ---------- Buffer: foo ----------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 This has too many @point{}spaces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 This has too many spaces at the start of (@point{} this list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 ---------- Buffer: foo ----------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (fixup-whitespace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 @result{} nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (fixup-whitespace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 @result{} nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 ---------- Buffer: foo ----------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 This has too many spaces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 This has too many spaces at the start of (this list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 ---------- Buffer: foo ----------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 @end smallexample
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 @deffn Command just-one-space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 @comment !!SourceFile simple.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 This command replaces any spaces and tabs around point with a single
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 space. It returns @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 @deffn Command delete-blank-lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 This function deletes blank lines surrounding point. If point is on a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 blank line with one or more blank lines before or after it, then all but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 one of them are deleted. If point is on an isolated blank line, then it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 is deleted. If point is on a nonblank line, the command deletes all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 blank lines following it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 A blank line is defined as a line containing only tabs and spaces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 @code{delete-blank-lines} returns @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 @node The Kill Ring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 @section The Kill Ring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 @cindex kill ring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 @dfn{Kill} functions delete text like the deletion functions, but save
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 it so that the user can reinsert it by @dfn{yanking}. Most of these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 functions have @samp{kill-} in their name. By contrast, the functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 whose names start with @samp{delete-} normally do not save text for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 yanking (though they can still be undone); these are ``deletion''
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 Most of the kill commands are primarily for interactive use, and are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 not described here. What we do describe are the functions provided for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 use in writing such commands. You can use these functions to write
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 commands for killing text. When you need to delete text for internal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 purposes within a Lisp function, you should normally use deletion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 functions, so as not to disturb the kill ring contents.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 @xref{Deletion}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 Killed text is saved for later yanking in the @dfn{kill ring}. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 is a list that holds a number of recent kills, not just the last text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 kill. We call this a ``ring'' because yanking treats it as having
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 elements in a cyclic order. The list is kept in the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 @code{kill-ring}, and can be operated on with the usual functions for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 lists; there are also specialized functions, described in this section,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 that treat it as a ring.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 Some people think this use of the word ``kill'' is unfortunate, since
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 it refers to operations that specifically @emph{do not} destroy the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 entities ``killed''. This is in sharp contrast to ordinary life, in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 which death is permanent and ``killed'' entities do not come back to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 life. Therefore, other metaphors have been proposed. For example, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 term ``cut ring'' makes sense to people who, in pre-computer days, used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 scissors and paste to cut up and rearrange manuscripts. However, it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 would be difficult to change the terminology now.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 * Kill Ring Concepts:: What text looks like in the kill ring.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 * Kill Functions:: Functions that kill text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 * Yank Commands:: Commands that access the kill ring.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 * Low-Level Kill Ring:: Functions and variables for kill ring access.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 * Internals of Kill Ring:: Variables that hold kill-ring data.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 @node Kill Ring Concepts
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 @subsection Kill Ring Concepts
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 The kill ring records killed text as strings in a list, most recent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 first. A short kill ring, for example, might look like this:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 ("some text" "a different piece of text" "even older text")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 When the list reaches @code{kill-ring-max} entries in length, adding a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 new entry automatically deletes the last entry.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 When kill commands are interwoven with other commands, each kill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 command makes a new entry in the kill ring. Multiple kill commands in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 succession build up a single entry in the kill ring, which would be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 yanked as a unit; the second and subsequent consecutive kill commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 add text to the entry made by the first one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 For yanking, one entry in the kill ring is designated the ``front'' of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 the ring. Some yank commands ``rotate'' the ring by designating a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 different element as the ``front.'' But this virtual rotation doesn't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 change the list itself---the most recent entry always comes first in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 @node Kill Functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 @subsection Functions for Killing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 @code{kill-region} is the usual subroutine for killing text. Any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 command that calls this function is a ``kill command'' (and should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 probably have @samp{kill} in its name). @code{kill-region} puts the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 newly killed text in a new element at the beginning of the kill ring or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 adds it to the most recent element. It uses the @code{last-command}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 variable to determine whether the previous command was a kill command,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 and if so appends the killed text to the most recent entry.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 @deffn Command kill-region start end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 This function kills the text in the region defined by @var{start} and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 @var{end}. The text is deleted but saved in the kill ring, along with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 its text properties. The value is always @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 In an interactive call, @var{start} and @var{end} are point and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 the mark.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 @c Emacs 19 feature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 If the buffer is read-only, @code{kill-region} modifies the kill ring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 just the same, then signals an error without modifying the buffer. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 is convenient because it lets the user use all the kill commands to copy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 text into the kill ring from a read-only buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 @deffn Command copy-region-as-kill start end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 This command saves the region defined by @var{start} and @var{end} on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 the kill ring (including text properties), but does not delete the text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 from the buffer. It returns @code{nil}. It also indicates the extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 of the text copied by moving the cursor momentarily, or by displaying a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 message in the echo area.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 The command does not set @code{this-command} to @code{kill-region}, so a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 subsequent kill command does not append to the same kill ring entry.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 Don't call @code{copy-region-as-kill} in Lisp programs unless you aim to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 support Emacs 18. For Emacs 19, it is better to use @code{kill-new} or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 @code{kill-append} instead. @xref{Low-Level Kill Ring}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 @node Yank Commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 @subsection Functions for Yanking
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 @dfn{Yanking} means reinserting an entry of previously killed text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 from the kill ring. The text properties are copied too.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 @deffn Command yank &optional arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 @cindex inserting killed text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 This command inserts before point the text in the first entry in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 kill ring. It positions the mark at the beginning of that text, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 point at the end.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 If @var{arg} is a list (which occurs interactively when the user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 types @kbd{C-u} with no digits), then @code{yank} inserts the text as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 described above, but puts point before the yanked text and puts the mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 after it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 If @var{arg} is a number, then @code{yank} inserts the @var{arg}th most
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 recently killed text---the @var{arg}th element of the kill ring list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 @code{yank} does not alter the contents of the kill ring or rotate it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 It returns @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 @deffn Command yank-pop arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 This command replaces the just-yanked entry from the kill ring with a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 different entry from the kill ring.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 This is allowed only immediately after a @code{yank} or another
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 @code{yank-pop}. At such a time, the region contains text that was just
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 inserted by yanking. @code{yank-pop} deletes that text and inserts in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 its place a different piece of killed text. It does not add the deleted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 text to the kill ring, since it is already in the kill ring somewhere.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 If @var{arg} is @code{nil}, then the replacement text is the previous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 element of the kill ring. If @var{arg} is numeric, the replacement is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 the @var{arg}th previous kill. If @var{arg} is negative, a more recent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 kill is the replacement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 The sequence of kills in the kill ring wraps around, so that after the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 oldest one comes the newest one, and before the newest one goes the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 oldest.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 The value is always @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 @node Low-Level Kill Ring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 @subsection Low-Level Kill Ring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 These functions and variables provide access to the kill ring at a lower
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 level, but still convenient for use in Lisp programs. They take care of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 interaction with X Window selections. They do not exist in Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 version 18.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 @defun current-kill n &optional do-not-move
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 The function @code{current-kill} rotates the yanking pointer which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 designates the ``front'' of the kill ring by @var{n} places (from newer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 kills to older ones), and returns the text at that place in the ring.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 If the optional second argument @var{do-not-move} is non-@code{nil},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 then @code{current-kill} doesn't alter the yanking pointer; it just
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 returns the @var{n}th kill, counting from the current yanking pointer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 If @var{n} is zero, indicating a request for the latest kill,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 @code{current-kill} calls the value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 @code{interprogram-paste-function} (documented below) before consulting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 the kill ring.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 @defun kill-new string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 This function puts the text @var{string} into the kill ring as a new
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 entry at the front of the ring. It discards the oldest entry if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 appropriate. It also invokes the value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 @code{interprogram-cut-function} (see below).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 @defun kill-append string before-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 This function appends the text @var{string} to the first entry in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 kill ring. Normally @var{string} goes at the end of the entry, but if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 @var{before-p} is non-@code{nil}, it goes at the beginning. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 function also invokes the value of @code{interprogram-cut-function} (see
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 below).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 @defvar interprogram-paste-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 This variable provides a way of transferring killed text from other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 programs, when you are using a window system. Its value should be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 @code{nil} or a function of no arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 If the value is a function, @code{current-kill} calls it to get the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 ``most recent kill''. If the function returns a non-@code{nil} value,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 then that value is used as the ``most recent kill''. If it returns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 @code{nil}, then the first element of @code{kill-ring} is used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 The normal use of this hook is to get the X server's primary selection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 as the most recent kill, even if the selection belongs to another X
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 client. @xref{X Selections}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 @defvar interprogram-cut-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 This variable provides a way of communicating killed text to other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 programs, when you are using a window system. Its value should be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 @code{nil} or a function of one argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 If the value is a function, @code{kill-new} and @code{kill-append} call
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 it with the new first element of the kill ring as an argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 The normal use of this hook is to set the X server's primary selection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 to the newly killed text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 @node Internals of Kill Ring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 @subsection Internals of the Kill Ring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 The variable @code{kill-ring} holds the kill ring contents, in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 form of a list of strings. The most recent kill is always at the front
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 of the list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 The @code{kill-ring-yank-pointer} variable points to a link in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 kill ring list, whose @sc{car} is the text to yank next. We say it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 identifies the ``front'' of the ring. Moving
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 @code{kill-ring-yank-pointer} to a different link is called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 @dfn{rotating the kill ring}. We call the kill ring a ``ring'' because
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 the functions that move the yank pointer wrap around from the end of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 list to the beginning, or vice-versa. Rotation of the kill ring is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 virtual; it does not change the value of @code{kill-ring}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 Both @code{kill-ring} and @code{kill-ring-yank-pointer} are Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 variables whose values are normally lists. The word ``pointer'' in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 name of the @code{kill-ring-yank-pointer} indicates that the variable's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 purpose is to identify one element of the list for use by the next yank
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 The value of @code{kill-ring-yank-pointer} is always @code{eq} to one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 of the links in the kill ring list. The element it identifies is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 @sc{car} of that link. Kill commands, which change the kill ring, also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 set this variable to the value of @code{kill-ring}. The effect is to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 rotate the ring so that the newly killed text is at the front.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 Here is a diagram that shows the variable @code{kill-ring-yank-pointer}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 pointing to the second entry in the kill ring @code{("some text" "a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 different piece of text" "yet older text")}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 kill-ring kill-ring-yank-pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 | ___ ___ ---> ___ ___ ___ ___
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 --> |___|___|------> |___|___|--> |___|___|--> nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 | | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 | | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 | | -->"yet older text"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 | |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 | --> "a different piece of text"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 --> "some text"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 This state of affairs might occur after @kbd{C-y} (@code{yank})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 immediately followed by @kbd{M-y} (@code{yank-pop}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 @defvar kill-ring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 This variable holds the list of killed text sequences, most recently
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 killed first.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 @defvar kill-ring-yank-pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 This variable's value indicates which element of the kill ring is at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 ``front'' of the ring for yanking. More precisely, the value is a tail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 of the value of @code{kill-ring}, and its @sc{car} is the kill string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 that @kbd{C-y} should yank.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 @defopt kill-ring-max
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 The value of this variable is the maximum length to which the kill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 ring can grow, before elements are thrown away at the end. The default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 value for @code{kill-ring-max} is 30.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 @end defopt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 @node Undo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 @section Undo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 @cindex redo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 Most buffers have an @dfn{undo list}, which records all changes made
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 to the buffer's text so that they can be undone. (The buffers that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 don't have one are usually special-purpose buffers for which XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 assumes that undoing is not useful.) All the primitives that modify the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 text in the buffer automatically add elements to the front of the undo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 list, which is in the variable @code{buffer-undo-list}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 @defvar buffer-undo-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 This variable's value is the undo list of the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 A value of @code{t} disables the recording of undo information.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 Here are the kinds of elements an undo list can have:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 @table @code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 @item @var{integer}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 This kind of element records a previous value of point. Ordinary cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 motion does not get any sort of undo record, but deletion commands use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 these entries to record where point was before the command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 @item (@var{beg} . @var{end})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 This kind of element indicates how to delete text that was inserted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 Upon insertion, the text occupied the range @var{beg}--@var{end} in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 @item (@var{text} . @var{position})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 This kind of element indicates how to reinsert text that was deleted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 The deleted text itself is the string @var{text}. The place to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 reinsert it is @code{(abs @var{position})}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 @item (t @var{high} . @var{low})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 This kind of element indicates that an unmodified buffer became
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 modified. The elements @var{high} and @var{low} are two integers, each
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 recording 16 bits of the visited file's modification time as of when it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 was previously visited or saved. @code{primitive-undo} uses those
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 values to determine whether to mark the buffer as unmodified once again;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 it does so only if the file's modification time matches those numbers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 @item (nil @var{property} @var{value} @var{beg} . @var{end})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 This kind of element records a change in a text property.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 Here's how you might undo the change:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 (put-text-property @var{beg} @var{end} @var{property} @var{value})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 @item @var{position}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 This element indicates where point was at an earlier time. Undoing this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 element sets point to @var{position}. Deletion normally creates an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 element of this kind as well as a reinsertion element.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 @item nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 This element is a boundary. The elements between two boundaries are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 called a @dfn{change group}; normally, each change group corresponds to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 one keyboard command, and undo commands normally undo an entire group as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 a unit.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 @defun undo-boundary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 This function places a boundary element in the undo list. The undo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 command stops at such a boundary, and successive undo commands undo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 to earlier and earlier boundaries. This function returns @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 The editor command loop automatically creates an undo boundary before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 each key sequence is executed. Thus, each undo normally undoes the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 effects of one command. Self-inserting input characters are an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 exception. The command loop makes a boundary for the first such
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 character; the next 19 consecutive self-inserting input characters do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 not make boundaries, and then the 20th does, and so on as long as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 self-inserting characters continue.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 All buffer modifications add a boundary whenever the previous undoable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 change was made in some other buffer. This way, a command that modifies
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 several buffers makes a boundary in each buffer it changes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 Calling this function explicitly is useful for splitting the effects of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 a command into more than one unit. For example, @code{query-replace}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 calls @code{undo-boundary} after each replacement, so that the user can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 undo individual replacements one by one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 @defun primitive-undo count list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 This is the basic function for undoing elements of an undo list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 It undoes the first @var{count} elements of @var{list}, returning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 the rest of @var{list}. You could write this function in Lisp,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 but it is convenient to have it in C.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 @code{primitive-undo} adds elements to the buffer's undo list when it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 changes the buffer. Undo commands avoid confusion by saving the undo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 list value at the beginning of a sequence of undo operations. Then the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 undo operations use and update the saved value. The new elements added
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 by undoing are not part of this saved value, so they don't interfere with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 continuing to undo.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 @node Maintaining Undo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 @section Maintaining Undo Lists
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 This section describes how to enable and disable undo information for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 a given buffer. It also explains how the undo list is truncated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 automatically so it doesn't get too big.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 Recording of undo information in a newly created buffer is normally
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 enabled to start with; but if the buffer name starts with a space, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 undo recording is initially disabled. You can explicitly enable or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 disable undo recording with the following two functions, or by setting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 @code{buffer-undo-list} yourself.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 @deffn Command buffer-enable-undo &optional buffer-or-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 This command enables recording undo information for buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 @var{buffer-or-name}, so that subsequent changes can be undone. If no
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 argument is supplied, then the current buffer is used. This function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 does nothing if undo recording is already enabled in the buffer. It
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 returns @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 In an interactive call, @var{buffer-or-name} is the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 You cannot specify any other buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 @defun buffer-disable-undo &optional buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 @defunx buffer-flush-undo &optional buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 @cindex disable undo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 This function discards the undo list of @var{buffer}, and disables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 further recording of undo information. As a result, it is no longer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 possible to undo either previous changes or any subsequent changes. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 the undo list of @var{buffer} is already disabled, this function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 has no effect.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 This function returns @code{nil}. It cannot be called interactively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 The name @code{buffer-flush-undo} is not considered obsolete, but the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 preferred name @code{buffer-disable-undo} is new as of Emacs versions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 19.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 As editing continues, undo lists get longer and longer. To prevent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 them from using up all available memory space, garbage collection trims
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 them back to size limits you can set. (For this purpose, the ``size''
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 of an undo list measures the cons cells that make up the list, plus the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 strings of deleted text.) Two variables control the range of acceptable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 sizes: @code{undo-limit} and @code{undo-strong-limit}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 @defvar undo-limit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 This is the soft limit for the acceptable size of an undo list. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 change group at which this size is exceeded is the last one kept.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 @defvar undo-strong-limit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 This is the upper limit for the acceptable size of an undo list. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 change group at which this size is exceeded is discarded itself (along
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 with all older change groups). There is one exception: the very latest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 change group is never discarded no matter how big it is.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 @node Filling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 @section Filling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 @cindex filling, explicit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 @dfn{Filling} means adjusting the lengths of lines (by moving the line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 breaks) so that they are nearly (but no greater than) a specified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 maximum width. Additionally, lines can be @dfn{justified}, which means
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 inserting spaces to make the left and/or right margins line up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 precisely. The width is controlled by the variable @code{fill-column}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 For ease of reading, lines should be no longer than 70 or so columns.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 You can use Auto Fill mode (@pxref{Auto Filling}) to fill text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 automatically as you insert it, but changes to existing text may leave
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 it improperly filled. Then you must fill the text explicitly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 Most of the commands in this section return values that are not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 meaningful. All the functions that do filling take note of the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 left margin, current right margin, and current justification style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 (@pxref{Margins}). If the current justification style is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 @code{none}, the filling functions don't actually do anything.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 Several of the filling functions have an argument @var{justify}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 If it is non-@code{nil}, that requests some kind of justification. It
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 can be @code{left}, @code{right}, @code{full}, or @code{center}, to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 request a specific style of justification. If it is @code{t}, that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 means to use the current justification style for this part of the text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 (see @code{current-justification}, below).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 When you call the filling functions interactively, using a prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 argument implies the value @code{full} for @var{justify}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 @deffn Command fill-paragraph justify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 @cindex filling a paragraph
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 This command fills the paragraph at or after point. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 @var{justify} is non-@code{nil}, each line is justified as well.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 It uses the ordinary paragraph motion commands to find paragraph
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 boundaries. @xref{Paragraphs,,, emacs, The XEmacs User's Manual}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 @deffn Command fill-region start end &optional justify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 This command fills each of the paragraphs in the region from @var{start}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 to @var{end}. It justifies as well if @var{justify} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 non-@code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 The variable @code{paragraph-separate} controls how to distinguish
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 paragraphs. @xref{Standard Regexps}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 @deffn Command fill-individual-paragraphs start end &optional justify mail-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 This command fills each paragraph in the region according to its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 individual fill prefix. Thus, if the lines of a paragraph were indented
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 with spaces, the filled paragraph will remain indented in the same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 fashion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 The first two arguments, @var{start} and @var{end}, are the beginning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 and end of the region to be filled. The third and fourth arguments,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 @var{justify} and @var{mail-flag}, are optional. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 @var{justify} is non-@code{nil}, the paragraphs are justified as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 well as filled. If @var{mail-flag} is non-@code{nil}, it means the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 function is operating on a mail message and therefore should not fill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 the header lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 Ordinarily, @code{fill-individual-paragraphs} regards each change in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 indentation as starting a new paragraph. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 @code{fill-individual-varying-indent} is non-@code{nil}, then only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 separator lines separate paragraphs. That mode can handle indented
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 paragraphs with additional indentation on the first line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 @defopt fill-individual-varying-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 This variable alters the action of @code{fill-individual-paragraphs} as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 described above.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 @end defopt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 @deffn Command fill-region-as-paragraph start end &optional justify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 This command considers a region of text as a paragraph and fills it. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 the region was made up of many paragraphs, the blank lines between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 paragraphs are removed. This function justifies as well as filling when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 @var{justify} is non-@code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 In an interactive call, any prefix argument requests justification.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 In Adaptive Fill mode, which is enabled by default,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 @code{fill-region-as-paragraph} on an indented paragraph when there is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 no fill prefix uses the indentation of the second line of the paragraph
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 as the fill prefix.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 @deffn Command justify-current-line how eop nosqueeze
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 This command inserts spaces between the words of the current line so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 that the line ends exactly at @code{fill-column}. It returns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 The argument @var{how}, if non-@code{nil} specifies explicitly the style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 of justification. It can be @code{left}, @code{right}, @code{full},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 @code{center}, or @code{none}. If it is @code{t}, that means to do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 follow specified justification style (see @code{current-justification},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 below). @code{nil} means to do full justification.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 If @var{eop} is non-@code{nil}, that means do left-justification when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 @code{current-justification} specifies full justification. This is used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 for the last line of a paragraph; even if the paragraph as a whole is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 fully justified, the last line should not be.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 If @var{nosqueeze} is non-@code{nil}, that means do not change interior
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 whitespace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 @defopt default-justification
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208 This variable's value specifies the style of justification to use for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 text that doesn't specify a style with a text property. The possible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 values are @code{left}, @code{right}, @code{full}, @code{center}, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 @code{none}. The default value is @code{left}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 @end defopt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 @defun current-justification
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 This function returns the proper justification style to use for filling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 the text around point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 @defvar fill-paragraph-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 This variable provides a way for major modes to override the filling of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 paragraphs. If the value is non-@code{nil}, @code{fill-paragraph} calls
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 this function to do the work. If the function returns a non-@code{nil}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 value, @code{fill-paragraph} assumes the job is done, and immediately
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 returns that value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 The usual use of this feature is to fill comments in programming
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 language modes. If the function needs to fill a paragraph in the usual
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 way, it can do so as follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 (let ((fill-paragraph-function nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 (fill-paragraph arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 @defvar use-hard-newlines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 If this variable is non-@code{nil}, the filling functions do not delete
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 newlines that have the @code{hard} text property. These ``hard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 newlines'' act as paragraph separators.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 @node Margins
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 @section Margins for Filling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 @defopt fill-prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 This variable specifies a string of text that appears at the beginning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 of normal text lines and should be disregarded when filling them. Any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 line that fails to start with the fill prefix is considered the start of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 a paragraph; so is any line that starts with the fill prefix followed by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 additional whitespace. Lines that start with the fill prefix but no
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 additional whitespace are ordinary text lines that can be filled
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 together. The resulting filled lines also start with the fill prefix.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 The fill prefix follows the left margin whitespace, if any.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 @end defopt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 @defopt fill-column
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 This buffer-local variable specifies the maximum width of filled
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 lines. Its value should be an integer, which is a number of columns.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 All the filling, justification and centering commands are affected by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 this variable, including Auto Fill mode (@pxref{Auto Filling}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 As a practical matter, if you are writing text for other people to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 read, you should set @code{fill-column} to no more than 70. Otherwise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 the line will be too long for people to read comfortably, and this can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 make the text seem clumsy.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 @end defopt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 @defvar default-fill-column
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 The value of this variable is the default value for @code{fill-column} in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 buffers that do not override it. This is the same as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 @code{(default-value 'fill-column)}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 The default value for @code{default-fill-column} is 70.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 @deffn Command set-left-margin from to margin
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 This sets the @code{left-margin} property on the text from @var{from} to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 @var{to} to the value @var{margin}. If Auto Fill mode is enabled, this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 command also refills the region to fit the new margin.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 @deffn Command set-right-margin from to margin
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 This sets the @code{right-margin} property on the text from @var{from}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 to @var{to} to the value @var{margin}. If Auto Fill mode is enabled,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 this command also refills the region to fit the new margin.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 @defun current-left-margin
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 This function returns the proper left margin value to use for filling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 the text around point. The value is the sum of the @code{left-margin}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 property of the character at the start of the current line (or zero if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 none), and the value of the variable @code{left-margin}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 @defun current-fill-column
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 This function returns the proper fill column value to use for filling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 the text around point. The value is the value of the @code{fill-column}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 variable, minus the value of the @code{right-margin} property of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 character after point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 @deffn Command move-to-left-margin &optional n force
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 This function moves point to the left margin of the current line. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 column moved to is determined by calling the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 @code{current-left-margin}. If the argument @var{n} is non-@code{nil},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307 @code{move-to-left-margin} moves forward @var{n}@minus{}1 lines first.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 If @var{force} is non-@code{nil}, that says to fix the line's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 indentation if that doesn't match the left margin value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313 @defun delete-to-left-margin from to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 This function removes left margin indentation from the text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315 between @var{from} and @var{to}. The amount of indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 to delete is determined by calling @code{current-left-margin}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 In no case does this function delete non-whitespace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 @defun indent-to-left-margin
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 This is the default @code{indent-line-function}, used in Fundamental
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322 mode, Text mode, etc. Its effect is to adjust the indentation at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 beginning of the current line to the value specified by the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 @code{left-margin}. This may involve either inserting or deleting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 whitespace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328 @defvar left-margin
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 This variable specifies the base left margin column. In Fundamental
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330 mode, @key{LFD} indents to this column. This variable automatically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 becomes buffer-local when set in any fashion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 @node Auto Filling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 @section Auto Filling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 @cindex filling, automatic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337 @cindex Auto Fill mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 Auto Fill mode is a minor mode that fills lines automatically as text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 is inserted. This section describes the hook used by Auto Fill mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341 For a description of functions that you can call explicitly to fill and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342 justify existing text, see @ref{Filling}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344 Auto Fill mode also enables the functions that change the margins and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 justification style to refill portions of the text. @xref{Margins}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 @defvar auto-fill-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 The value of this variable should be a function (of no arguments) to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 called after self-inserting a space or a newline. It may be @code{nil},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 in which case nothing special is done in that case.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 The value of @code{auto-fill-function} is @code{do-auto-fill} when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 Auto-Fill mode is enabled. That is a function whose sole purpose is to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 implement the usual strategy for breaking a line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 @quotation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 In older Emacs versions, this variable was named @code{auto-fill-hook},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 but since it is not called with the standard convention for hooks, it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 was renamed to @code{auto-fill-function} in version 19.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 @end quotation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 @node Sorting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 @section Sorting Text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 @cindex sorting text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 The sorting functions described in this section all rearrange text in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 a buffer. This is in contrast to the function @code{sort}, which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369 rearranges the order of the elements of a list (@pxref{Rearrangement}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 The values returned by these functions are not meaningful.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 @defun sort-subr reverse nextrecfun endrecfun &optional startkeyfun endkeyfun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 This function is the general text-sorting routine that divides a buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 into records and sorts them. Most of the commands in this section use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 this function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 To understand how @code{sort-subr} works, consider the whole accessible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 portion of the buffer as being divided into disjoint pieces called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 @dfn{sort records}. The records may or may not be contiguous; they may
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 not overlap. A portion of each sort record (perhaps all of it) is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 designated as the sort key. Sorting rearranges the records in order by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 their sort keys.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 Usually, the records are rearranged in order of ascending sort key.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 If the first argument to the @code{sort-subr} function, @var{reverse},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 is non-@code{nil}, the sort records are rearranged in order of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 descending sort key.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389 The next four arguments to @code{sort-subr} are functions that are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 called to move point across a sort record. They are called many times
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 from within @code{sort-subr}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 @enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 @var{nextrecfun} is called with point at the end of a record. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 function moves point to the start of the next record. The first record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 is assumed to start at the position of point when @code{sort-subr} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 called. Therefore, you should usually move point to the beginning of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 the buffer before calling @code{sort-subr}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401 This function can indicate there are no more sort records by leaving
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 point at the end of the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 @var{endrecfun} is called with point within a record. It moves point to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 the end of the record.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 @var{startkeyfun} is called to move point from the start of a record to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 the start of the sort key. This argument is optional; if it is omitted,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 the whole record is the sort key. If supplied, the function should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 either return a non-@code{nil} value to be used as the sort key, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413 return @code{nil} to indicate that the sort key is in the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 starting at point. In the latter case, @var{endkeyfun} is called to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415 find the end of the sort key.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 @var{endkeyfun} is called to move point from the start of the sort key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 to the end of the sort key. This argument is optional. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 @var{startkeyfun} returns @code{nil} and this argument is omitted (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421 @code{nil}), then the sort key extends to the end of the record. There
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 is no need for @var{endkeyfun} if @var{startkeyfun} returns a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 non-@code{nil} value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 @end enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 As an example of @code{sort-subr}, here is the complete function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427 definition for @code{sort-lines}:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431 ;; @r{Note that the first two lines of doc string}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432 ;; @r{are effectively one line when viewed by a user.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433 (defun sort-lines (reverse beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434 "Sort lines in region alphabetically.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435 Called from a program, there are three arguments:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 REVERSE (non-nil means reverse order),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439 and BEG and END (the region to sort)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440 (interactive "P\nr")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 (narrow-to-region beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444 (sort-subr reverse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 'forward-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 'end-of-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 Here @code{forward-line} moves point to the start of the next record,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 and @code{end-of-line} moves point to the end of record. We do not pass
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 the arguments @var{startkeyfun} and @var{endkeyfun}, because the entire
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 record is used as the sort key.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 The @code{sort-paragraphs} function is very much the same, except that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 its @code{sort-subr} call looks like this:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 (sort-subr reverse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 (skip-chars-forward "\n \t\f")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 'forward-paragraph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 @deffn Command sort-regexp-fields reverse record-regexp key-regexp start end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 This command sorts the region between @var{start} and @var{end}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471 alphabetically as specified by @var{record-regexp} and @var{key-regexp}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 If @var{reverse} is a negative integer, then sorting is in reverse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 order.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475 Alphabetical sorting means that two sort keys are compared by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 comparing the first characters of each, the second characters of each,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477 and so on. If a mismatch is found, it means that the sort keys are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 unequal; the sort key whose character is less at the point of first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 mismatch is the lesser sort key. The individual characters are compared
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 according to their numerical values. Since Emacs uses the @sc{ASCII}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481 character set, the ordering in that set determines alphabetical order.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 @c version 19 change
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 The value of the @var{record-regexp} argument specifies how to divide
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 the buffer into sort records. At the end of each record, a search is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 done for this regular expression, and the text that matches it is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 next record. For example, the regular expression @samp{^.+$}, which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488 matches lines with at least one character besides a newline, would make
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 each such line into a sort record. @xref{Regular Expressions}, for a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 description of the syntax and meaning of regular expressions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492 The value of the @var{key-regexp} argument specifies what part of each
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 record is the sort key. The @var{key-regexp} could match the whole
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 record, or only a part. In the latter case, the rest of the record has
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 no effect on the sorted order of records, but it is carried along when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 the record moves to its new position.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 The @var{key-regexp} argument can refer to the text matched by a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499 subexpression of @var{record-regexp}, or it can be a regular expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 on its own.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502 If @var{key-regexp} is:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 @table @asis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505 @item @samp{\@var{digit}}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506 then the text matched by the @var{digit}th @samp{\(...\)} parenthesis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 grouping in @var{record-regexp} is the sort key.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 @item @samp{\&}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 then the whole record is the sort key.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512 @item a regular expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 then @code{sort-regexp-fields} searches for a match for the regular
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514 expression within the record. If such a match is found, it is the sort
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 key. If there is no match for @var{key-regexp} within a record then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516 that record is ignored, which means its position in the buffer is not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 changed. (The other records may move around it.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 For example, if you plan to sort all the lines in the region by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521 first word on each line starting with the letter @samp{f}, you should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522 set @var{record-regexp} to @samp{^.*$} and set @var{key-regexp} to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523 @samp{\<f\w*\>}. The resulting expression looks like this:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1525 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527 (sort-regexp-fields nil "^.*$" "\\<f\\w*\\>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 (region-beginning)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 (region-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533 If you call @code{sort-regexp-fields} interactively, it prompts for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534 @var{record-regexp} and @var{key-regexp} in the minibuffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537 @deffn Command sort-lines reverse start end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538 This command alphabetically sorts lines in the region between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539 @var{start} and @var{end}. If @var{reverse} is non-@code{nil}, the sort
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540 is in reverse order.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 @deffn Command sort-paragraphs reverse start end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544 This command alphabetically sorts paragraphs in the region between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 @var{start} and @var{end}. If @var{reverse} is non-@code{nil}, the sort
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546 is in reverse order.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549 @deffn Command sort-pages reverse start end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550 This command alphabetically sorts pages in the region between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 @var{start} and @var{end}. If @var{reverse} is non-@code{nil}, the sort
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 is in reverse order.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 @deffn Command sort-fields field start end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 This command sorts lines in the region between @var{start} and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557 @var{end}, comparing them alphabetically by the @var{field}th field
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 of each line. Fields are separated by whitespace and numbered starting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559 from 1. If @var{field} is negative, sorting is by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 @w{@minus{}@var{field}th} field from the end of the line. This command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561 is useful for sorting tables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 @deffn Command sort-numeric-fields field start end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565 This command sorts lines in the region between @var{start} and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 @var{end}, comparing them numerically by the @var{field}th field of each
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567 line. The specified field must contain a number in each line of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568 region. Fields are separated by whitespace and numbered starting from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569 1. If @var{field} is negative, sorting is by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570 @w{@minus{}@var{field}th} field from the end of the line. This command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 is useful for sorting tables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 @deffn Command sort-columns reverse &optional beg end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 This command sorts the lines in the region between @var{beg} and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576 @var{end}, comparing them alphabetically by a certain range of columns.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577 The column positions of @var{beg} and @var{end} bound the range of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578 columns to sort on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580 If @var{reverse} is non-@code{nil}, the sort is in reverse order.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582 One unusual thing about this command is that the entire line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583 containing position @var{beg}, and the entire line containing position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584 @var{end}, are included in the region sorted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 Note that @code{sort-columns} uses the @code{sort} utility program,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587 and so cannot work properly on text containing tab characters. Use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 @kbd{M-x @code{untabify}} to convert tabs to spaces before sorting.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 @node Columns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592 @comment node-name, next, previous, up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 @section Counting Columns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 @cindex columns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595 @cindex counting columns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596 @cindex horizontal position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598 The column functions convert between a character position (counting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 characters from the beginning of the buffer) and a column position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 (counting screen characters from the beginning of a line).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602 A character counts according to the number of columns it occupies on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603 the screen. This means control characters count as occupying 2 or 4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 columns, depending upon the value of @code{ctl-arrow}, and tabs count as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605 occupying a number of columns that depends on the value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606 @code{tab-width} and on the column where the tab begins. @xref{Usual Display}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608 Column number computations ignore the width of the window and the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1609 amount of horizontal scrolling. Consequently, a column value can be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1610 arbitrarily high. The first (or leftmost) column is numbered 0.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612 @defun current-column
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613 This function returns the horizontal position of point, measured in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 columns, counting from 0 at the left margin. The column position is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615 sum of the widths of all the displayed representations of the characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1616 between the start of the current line and point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1617
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618 For an example of using @code{current-column}, see the description of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619 @code{count-lines} in @ref{Text Lines}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1621
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1622 @defun move-to-column column &optional force
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1623 This function moves point to @var{column} in the current line. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1624 calculation of @var{column} takes into account the widths of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1625 displayed representations of the characters between the start of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1626 line and point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1627
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628 If column @var{column} is beyond the end of the line, point moves to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629 end of the line. If @var{column} is negative, point moves to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630 beginning of the line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 If it is impossible to move to column @var{column} because that is in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633 the middle of a multicolumn character such as a tab, point moves to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634 end of that character. However, if @var{force} is non-@code{nil}, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635 @var{column} is in the middle of a tab, then @code{move-to-column}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636 converts the tab into spaces so that it can move precisely to column
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637 @var{column}. Other multicolumn characters can cause anomalies despite
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 @var{force}, since there is no way to split them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640 The argument @var{force} also has an effect if the line isn't long
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 enough to reach column @var{column}; in that case, it says to add
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642 whitespace at the end of the line to reach that column.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644 If @var{column} is not an integer, an error is signaled.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646 The return value is the column number actually moved to.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1647 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649 @node Indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650 @section Indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651 @cindex indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653 The indentation functions are used to examine, move to, and change
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654 whitespace that is at the beginning of a line. Some of the functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655 can also change whitespace elsewhere on a line. Columns and indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656 count from zero at the left margin.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1657
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1658 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659 * Primitive Indent:: Functions used to count and insert indentation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660 * Mode-Specific Indent:: Customize indentation for different modes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1661 * Region Indent:: Indent all the lines in a region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1662 * Relative Indent:: Indent the current line based on previous lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1663 * Indent Tabs:: Adjustable, typewriter-like tab stops.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1664 * Motion by Indent:: Move to first non-blank character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1665 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1666
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667 @node Primitive Indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1668 @subsection Indentation Primitives
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670 This section describes the primitive functions used to count and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671 insert indentation. The functions in the following sections use these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1672 primitives.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1673
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674 @defun current-indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1675 @comment !!Type Primitive Function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1676 @comment !!SourceFile indent.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677 This function returns the indentation of the current line, which is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1678 the horizontal position of the first nonblank character. If the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1679 contents are entirely blank, then this is the horizontal position of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1680 end of the line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1682
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1683 @deffn Command indent-to column &optional minimum
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1684 @comment !!Type Primitive Function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1685 @comment !!SourceFile indent.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1686 This function indents from point with tabs and spaces until @var{column}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687 is reached. If @var{minimum} is specified and non-@code{nil}, then at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1688 least that many spaces are inserted even if this requires going beyond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1689 @var{column}. Otherwise the function does nothing if point is already
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1690 beyond @var{column}. The value is the column at which the inserted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1691 indentation ends.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694 @defopt indent-tabs-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1695 @comment !!SourceFile indent.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1696 If this variable is non-@code{nil}, indentation functions can insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1697 tabs as well as spaces. Otherwise, they insert only spaces. Setting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 this variable automatically makes it local to the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1699 @end defopt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1700
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1701 @node Mode-Specific Indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1702 @subsection Indentation Controlled by Major Mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1703
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1704 An important function of each major mode is to customize the @key{TAB}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1705 key to indent properly for the language being edited. This section
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1706 describes the mechanism of the @key{TAB} key and how to control it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1707 The functions in this section return unpredictable values.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1708
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1709 @defvar indent-line-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1710 This variable's value is the function to be used by @key{TAB} (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1711 various commands) to indent the current line. The command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1712 @code{indent-according-to-mode} does no more than call this function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1713
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1714 In Lisp mode, the value is the symbol @code{lisp-indent-line}; in C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1715 mode, @code{c-indent-line}; in Fortran mode, @code{fortran-indent-line}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716 In Fundamental mode, Text mode, and many other modes with no standard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717 for indentation, the value is @code{indent-to-left-margin} (which is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718 default value).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1720
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1721 @deffn Command indent-according-to-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1722 This command calls the function in @code{indent-line-function} to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1723 indent the current line in a way appropriate for the current major mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1724 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1725
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1726 @deffn Command indent-for-tab-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1727 This command calls the function in @code{indent-line-function} to indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1728 the current line; except that if that function is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1729 @code{indent-to-left-margin}, it calls @code{insert-tab} instead. (That
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1730 is a trivial command that inserts a tab character.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1731 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1732
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1733 @deffn Command newline-and-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1734 @comment !!SourceFile simple.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1735 This function inserts a newline, then indents the new line (the one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736 following the newline just inserted) according to the major mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1738 It does indentation by calling the current @code{indent-line-function}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1739 In programming language modes, this is the same thing @key{TAB} does,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1740 but in some text modes, where @key{TAB} inserts a tab,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741 @code{newline-and-indent} indents to the column specified by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1742 @code{left-margin}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1743 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1744
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1745 @deffn Command reindent-then-newline-and-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1746 @comment !!SourceFile simple.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1747 This command reindents the current line, inserts a newline at point,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1748 and then reindents the new line (the one following the newline just
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1749 inserted).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1750
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1751 This command does indentation on both lines according to the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1752 major mode, by calling the current value of @code{indent-line-function}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1753 In programming language modes, this is the same thing @key{TAB} does,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1754 but in some text modes, where @key{TAB} inserts a tab,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1755 @code{reindent-then-newline-and-indent} indents to the column specified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756 by @code{left-margin}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1757 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1758
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759 @node Region Indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1760 @subsection Indenting an Entire Region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1762 This section describes commands that indent all the lines in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1763 region. They return unpredictable values.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1764
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1765 @deffn Command indent-region start end to-column
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766 This command indents each nonblank line starting between @var{start}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1767 (inclusive) and @var{end} (exclusive). If @var{to-column} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1768 @code{nil}, @code{indent-region} indents each nonblank line by calling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1769 the current mode's indentation function, the value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1770 @code{indent-line-function}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772 If @var{to-column} is non-@code{nil}, it should be an integer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1773 specifying the number of columns of indentation; then this function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1774 gives each line exactly that much indentation, by either adding or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1775 deleting whitespace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777 If there is a fill prefix, @code{indent-region} indents each line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1778 by making it start with the fill prefix.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1779 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1780
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1781 @defvar indent-region-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1782 The value of this variable is a function that can be used by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1783 @code{indent-region} as a short cut. You should design the function so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1784 that it will produce the same results as indenting the lines of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1785 region one by one, but presumably faster.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1786
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1787 If the value is @code{nil}, there is no short cut, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1788 @code{indent-region} actually works line by line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1789
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790 A short-cut function is useful in modes such as C mode and Lisp mode,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1791 where the @code{indent-line-function} must scan from the beginning of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1792 the function definition: applying it to each line would be quadratic in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1793 time. The short cut can update the scan information as it moves through
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1794 the lines indenting them; this takes linear time. In a mode where
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1795 indenting a line individually is fast, there is no need for a short cut.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1796
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1797 @code{indent-region} with a non-@code{nil} argument @var{to-column} has
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1798 a different meaning and does not use this variable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1799 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1800
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1801 @deffn Command indent-rigidly start end count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1802 @comment !!SourceFile indent.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1803 This command indents all lines starting between @var{start}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1804 (inclusive) and @var{end} (exclusive) sideways by @var{count} columns.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1805 This ``preserves the shape'' of the affected region, moving it as a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1806 rigid unit. Consequently, this command is useful not only for indenting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1807 regions of unindented text, but also for indenting regions of formatted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1808 code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1809
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1810 For example, if @var{count} is 3, this command adds 3 columns of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1811 indentation to each of the lines beginning in the region specified.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813 In Mail mode, @kbd{C-c C-y} (@code{mail-yank-original}) uses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1814 @code{indent-rigidly} to indent the text copied from the message being
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1815 replied to.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1816 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1817
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1818 @defun indent-code-rigidly start end columns &optional nochange-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1819 This is like @code{indent-rigidly}, except that it doesn't alter lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1820 that start within strings or comments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1821
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1822 In addition, it doesn't alter a line if @var{nochange-regexp} matches at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823 the beginning of the line (if @var{nochange-regexp} is non-@code{nil}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1824 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1825
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1826 @node Relative Indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1827 @subsection Indentation Relative to Previous Lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1828
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1829 This section describes two commands that indent the current line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1830 based on the contents of previous lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1831
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1832 @deffn Command indent-relative &optional unindented-ok
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1833 This command inserts whitespace at point, extending to the same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1834 column as the next @dfn{indent point} of the previous nonblank line. An
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1835 indent point is a non-whitespace character following whitespace. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1836 next indent point is the first one at a column greater than the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1837 column of point. For example, if point is underneath and to the left of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1838 the first non-blank character of a line of text, it moves to that column
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1839 by inserting whitespace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1840
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1841 If the previous nonblank line has no next indent point (i.e., none at a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1842 great enough column position), @code{indent-relative} either does
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1843 nothing (if @var{unindented-ok} is non-@code{nil}) or calls
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1844 @code{tab-to-tab-stop}. Thus, if point is underneath and to the right
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1845 of the last column of a short line of text, this command ordinarily
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1846 moves point to the next tab stop by inserting whitespace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1847
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1848 The return value of @code{indent-relative} is unpredictable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1849
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1850 In the following example, point is at the beginning of the second
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1851 line:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1852
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1853 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1854 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1855 This line is indented twelve spaces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1856 @point{}The quick brown fox jumped.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1857 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1858 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1859
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1860 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1861 Evaluation of the expression @code{(indent-relative nil)} produces the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1862 following:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1863
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1864 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1865 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1866 This line is indented twelve spaces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1867 @point{}The quick brown fox jumped.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1868 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1869 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1870
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1871 In this example, point is between the @samp{m} and @samp{p} of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1872 @samp{jumped}:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1873
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1874 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1875 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1876 This line is indented twelve spaces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1877 The quick brown fox jum@point{}ped.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1878 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1879 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1880
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1881 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1882 Evaluation of the expression @code{(indent-relative nil)} produces the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1883 following:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1884
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1885 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1886 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1887 This line is indented twelve spaces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1888 The quick brown fox jum @point{}ped.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1889 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1890 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1891 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1892
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1893 @deffn Command indent-relative-maybe
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1894 @comment !!SourceFile indent.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1895 This command indents the current line like the previous nonblank line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1896 It calls @code{indent-relative} with @code{t} as the @var{unindented-ok}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1897 argument. The return value is unpredictable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1898
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1899 If the previous nonblank line has no indent points beyond the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1900 column, this command does nothing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1901 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1902
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1903 @node Indent Tabs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1904 @subsection Adjustable ``Tab Stops''
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1905 @cindex tabs stops for indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1906
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1907 This section explains the mechanism for user-specified ``tab stops''
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1908 and the mechanisms that use and set them. The name ``tab stops'' is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1909 used because the feature is similar to that of the tab stops on a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1910 typewriter. The feature works by inserting an appropriate number of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1911 spaces and tab characters to reach the next tab stop column; it does not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1912 affect the display of tab characters in the buffer (@pxref{Usual
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1913 Display}). Note that the @key{TAB} character as input uses this tab
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1914 stop feature only in a few major modes, such as Text mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1915
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1916 @deffn Command tab-to-tab-stop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1917 This command inserts spaces or tabs up to the next tab stop column
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1918 defined by @code{tab-stop-list}. It searches the list for an element
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1919 greater than the current column number, and uses that element as the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1920 column to indent to. It does nothing if no such element is found.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1921 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1922
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1923 @defopt tab-stop-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1924 This variable is the list of tab stop columns used by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1925 @code{tab-to-tab-stops}. The elements should be integers in increasing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1926 order. The tab stop columns need not be evenly spaced.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1927
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1928 Use @kbd{M-x edit-tab-stops} to edit the location of tab stops
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1929 interactively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1930 @end defopt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1931
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1932 @node Motion by Indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1933 @subsection Indentation-Based Motion Commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1934
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1935 These commands, primarily for interactive use, act based on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1936 indentation in the text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1937
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1938 @deffn Command back-to-indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1939 @comment !!SourceFile simple.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1940 This command moves point to the first non-whitespace character in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1941 current line (which is the line in which point is located). It returns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1942 @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1943 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1944
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1945 @deffn Command backward-to-indentation arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1946 @comment !!SourceFile simple.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1947 This command moves point backward @var{arg} lines and then to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1948 first nonblank character on that line. It returns @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1949 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1950
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1951 @deffn Command forward-to-indentation arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1952 @comment !!SourceFile simple.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1953 This command moves point forward @var{arg} lines and then to the first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1954 nonblank character on that line. It returns @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1955 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1956
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1957 @node Case Changes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1958 @section Case Changes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1959 @cindex case changes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1960
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1961 The case change commands described here work on text in the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1962 buffer. @xref{Character Case}, for case conversion commands that work
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1963 on strings and characters. @xref{Case Tables}, for how to customize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1964 which characters are upper or lower case and how to convert them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1965
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1966 @deffn Command capitalize-region start end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1967 This function capitalizes all words in the region defined by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1968 @var{start} and @var{end}. To capitalize means to convert each word's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1969 first character to upper case and convert the rest of each word to lower
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1970 case. The function returns @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1971
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1972 If one end of the region is in the middle of a word, the part of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1973 word within the region is treated as an entire word.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1974
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1975 When @code{capitalize-region} is called interactively, @var{start} and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1976 @var{end} are point and the mark, with the smallest first.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1977
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1978 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1979 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1980 ---------- Buffer: foo ----------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1981 This is the contents of the 5th foo.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1982 ---------- Buffer: foo ----------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1983 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1984
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1985 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1986 (capitalize-region 1 44)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1987 @result{} nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1988
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1989 ---------- Buffer: foo ----------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1990 This Is The Contents Of The 5th Foo.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1991 ---------- Buffer: foo ----------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1992 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1993 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1994 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1996 @deffn Command downcase-region start end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1997 This function converts all of the letters in the region defined by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1998 @var{start} and @var{end} to lower case. The function returns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1999 @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2001 When @code{downcase-region} is called interactively, @var{start} and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2002 @var{end} are point and the mark, with the smallest first.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2003 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2004
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2005 @deffn Command upcase-region start end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2006 This function converts all of the letters in the region defined by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2007 @var{start} and @var{end} to upper case. The function returns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2008 @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2009
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2010 When @code{upcase-region} is called interactively, @var{start} and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2011 @var{end} are point and the mark, with the smallest first.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2012 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2013
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2014 @deffn Command capitalize-word count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2015 This function capitalizes @var{count} words after point, moving point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2016 over as it does. To capitalize means to convert each word's first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2017 character to upper case and convert the rest of each word to lower case.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2018 If @var{count} is negative, the function capitalizes the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2019 @minus{}@var{count} previous words but does not move point. The value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2020 is @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2021
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2022 If point is in the middle of a word, the part of the word before point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2023 is ignored when moving forward. The rest is treated as an entire word.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2024
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2025 When @code{capitalize-word} is called interactively, @var{count} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2026 set to the numeric prefix argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2027 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2028
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2029 @deffn Command downcase-word count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2030 This function converts the @var{count} words after point to all lower
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2031 case, moving point over as it does. If @var{count} is negative, it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2032 converts the @minus{}@var{count} previous words but does not move point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2033 The value is @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2034
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2035 When @code{downcase-word} is called interactively, @var{count} is set
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2036 to the numeric prefix argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2037 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2038
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2039 @deffn Command upcase-word count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2040 This function converts the @var{count} words after point to all upper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2041 case, moving point over as it does. If @var{count} is negative, it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2042 converts the @minus{}@var{count} previous words but does not move point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2043 The value is @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2044
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2045 When @code{upcase-word} is called interactively, @var{count} is set to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2046 the numeric prefix argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2047 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2048
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2049 @node Text Properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2050 @section Text Properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2051 @cindex text properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2052 @cindex attributes of text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2053 @cindex properties of text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2054
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2055 Text properties are an alternative interface to extents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2056 (@pxref{Extents}), and are built on top of them. They are useful when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2057 you want to view textual properties as being attached to the characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2058 themselves rather than to intervals of characters. The text property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2059 interface is compatible with FSF Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2060
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2061 Each character position in a buffer or a string can have a @dfn{text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2062 property list}, much like the property list of a symbol (@pxref{Property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2063 Lists}). The properties belong to a particular character at a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2064 particular place, such as, the letter @samp{T} at the beginning of this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2065 sentence or the first @samp{o} in @samp{foo}---if the same character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2066 occurs in two different places, the two occurrences generally have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2067 different properties.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2068
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2069 Each property has a name and a value. Both of these can be any Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2070 object, but the name is normally a symbol. The usual way to access the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2071 property list is to specify a name and ask what value corresponds to it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2072
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2073 @ignore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2074 If a character has a @code{category} property, we call it the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2075 @dfn{category} of the character. It should be a symbol. The properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2076 of the symbol serve as defaults for the properties of the character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2077 @end ignore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2078 Note that FSF Emacs also looks at the @code{category} property to find
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2079 defaults for text properties. We consider this too bogus to implement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2080
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2081 Copying text between strings and buffers preserves the properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2082 along with the characters; this includes such diverse functions as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2083 @code{substring}, @code{insert}, and @code{buffer-substring}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2084
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2085 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2086 * Examining Properties:: Looking at the properties of one character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2087 * Changing Properties:: Setting the properties of a range of text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2088 * Property Search:: Searching for where a property changes value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2089 * Special Properties:: Particular properties with special meanings.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2090 * Saving Properties:: Saving text properties in files, and reading
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2091 them back.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2092 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2093
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2094 @node Examining Properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2095 @subsection Examining Text Properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2096
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2097 The simplest way to examine text properties is to ask for the value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2098 a particular property of a particular character. For that, use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2099 @code{get-text-property}. Use @code{text-properties-at} to get the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2100 entire property list of a character. @xref{Property Search}, for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2101 functions to examine the properties of a number of characters at once.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2103 These functions handle both strings and buffers. (Keep in mind that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2104 positions in a string start from 0, whereas positions in a buffer start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2105 from 1.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2107 @defun get-text-property pos prop &optional object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2108 This function returns the value of the @var{prop} property of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2109 character after position @var{pos} in @var{object} (a buffer or string).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2110 The argument @var{object} is optional and defaults to the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2111 buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2112 @ignore @c Bogus as hell!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2113 If there is no @var{prop} property strictly speaking, but the character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2114 has a category that is a symbol, then @code{get-text-property} returns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2115 the @var{prop} property of that symbol.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2116 @end ignore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2117 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2119 @defun get-char-property pos prop &optional object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2120 This function is like @code{get-text-property}, except that it checks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2121 all extents, not just text-property extents.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2123 @ignore Does not apply in XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2124 The argument @var{object} may be a string, a buffer, or a window. If it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2125 is a window, then the buffer displayed in that window is used for text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2126 properties and overlays, but only the overlays active for that window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2127 are considered. If @var{object} is a buffer, then all overlays in that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2128 buffer are considered, as well as text properties. If @var{object} is a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2129 string, only text properties are considered, since strings never have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2130 overlays.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2131 @end ignore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2132 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2133
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2134 @defun text-properties-at position &optional object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2135 This function returns the entire property list of the character at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2136 @var{position} in the string or buffer @var{object}. If @var{object} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2137 @code{nil}, it defaults to the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2138 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2140 @defvar default-text-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2141 This variable holds a property list giving default values for text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2142 properties. Whenever a character does not specify a value for a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2143 property, the value stored in this list is used instead. Here is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2144 an example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2146 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2147 (setq default-text-properties '(foo 69))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2148 ;; @r{Make sure character 1 has no properties of its own.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2149 (set-text-properties 1 2 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2150 ;; @r{What we get, when we ask, is the default value.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2151 (get-text-property 1 'foo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2152 @result{} 69
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2153 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2154 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2155
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2156 @node Changing Properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2157 @subsection Changing Text Properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2158
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2159 The primitives for changing properties apply to a specified range of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2160 text. The function @code{set-text-properties} (see end of section) sets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2161 the entire property list of the text in that range; more often, it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2162 useful to add, change, or delete just certain properties specified by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2163 name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2165 Since text properties are considered part of the buffer's contents, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2166 can affect how the buffer looks on the screen, any change in the text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2167 properties is considered a buffer modification. Buffer text property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2168 changes are undoable (@pxref{Undo}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2169
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2170 @defun put-text-property start end prop value &optional object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2171 This function sets the @var{prop} property to @var{value} for the text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2172 between @var{start} and @var{end} in the string or buffer @var{object}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2173 If @var{object} is @code{nil}, it defaults to the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2174 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2176 @defun add-text-properties start end props &optional object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2177 This function modifies the text properties for the text between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2178 @var{start} and @var{end} in the string or buffer @var{object}. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2179 @var{object} is @code{nil}, it defaults to the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2180
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2181 The argument @var{props} specifies which properties to change. It
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2182 should have the form of a property list (@pxref{Property Lists}): a list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2183 whose elements include the property names followed alternately by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2184 corresponding values.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2185
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2186 The return value is @code{t} if the function actually changed some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2187 property's value; @code{nil} otherwise (if @var{props} is @code{nil} or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2188 its values agree with those in the text).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2189
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2190 For example, here is how to set the @code{comment} and @code{face}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2191 properties of a range of text:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2193 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2194 (add-text-properties @var{start} @var{end}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2195 '(comment t face highlight))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2196 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2197 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2199 @defun remove-text-properties start end props &optional object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2200 This function deletes specified text properties from the text between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2201 @var{start} and @var{end} in the string or buffer @var{object}. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2202 @var{object} is @code{nil}, it defaults to the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2203
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2204 The argument @var{props} specifies which properties to delete. It
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2205 should have the form of a property list (@pxref{Property Lists}): a list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2206 whose elements are property names alternating with corresponding values.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2207 But only the names matter---the values that accompany them are ignored.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2208 For example, here's how to remove the @code{face} property.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2210 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2211 (remove-text-properties @var{start} @var{end} '(face nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2212 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2214 The return value is @code{t} if the function actually changed some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2215 property's value; @code{nil} otherwise (if @var{props} is @code{nil} or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2216 if no character in the specified text had any of those properties).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2217 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2218
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2219 @defun set-text-properties start end props &optional object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2220 This function completely replaces the text property list for the text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2221 between @var{start} and @var{end} in the string or buffer @var{object}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2222 If @var{object} is @code{nil}, it defaults to the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2224 The argument @var{props} is the new property list. It should be a list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2225 whose elements are property names alternating with corresponding values.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2226
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2227 After @code{set-text-properties} returns, all the characters in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2228 specified range have identical properties.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2229
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2230 If @var{props} is @code{nil}, the effect is to get rid of all properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2231 from the specified range of text. Here's an example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2232
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2233 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2234 (set-text-properties @var{start} @var{end} nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2235 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2236 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2238 See also the function @code{buffer-substring-without-properties}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2239 (@pxref{Buffer Contents}) which copies text from the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2240 but does not copy its properties.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2242 @node Property Search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2243 @subsection Property Search Functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2244
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2245 In typical use of text properties, most of the time several or many
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2246 consecutive characters have the same value for a property. Rather than
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2247 writing your programs to examine characters one by one, it is much
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2248 faster to process chunks of text that have the same property value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2250 Here are functions you can use to do this. They use @code{eq} for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2251 comparing property values. In all cases, @var{object} defaults to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2252 current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2253
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2254 For high performance, it's very important to use the @var{limit}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2255 argument to these functions, especially the ones that search for a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2256 single property---otherwise, they may spend a long time scanning to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2257 end of the buffer, if the property you are interested in does not change.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2258
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2259 Remember that a position is always between two characters; the position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2260 returned by these functions is between two characters with different
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2261 properties.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2262
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2263 @defun next-property-change pos &optional object limit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2264 The function scans the text forward from position @var{pos} in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2265 string or buffer @var{object} till it finds a change in some text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2266 property, then returns the position of the change. In other words, it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2267 returns the position of the first character beyond @var{pos} whose
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2268 properties are not identical to those of the character just after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2269 @var{pos}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2270
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2271 If @var{limit} is non-@code{nil}, then the scan ends at position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2272 @var{limit}. If there is no property change before that point,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2273 @code{next-property-change} returns @var{limit}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2274
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2275 The value is @code{nil} if the properties remain unchanged all the way
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2276 to the end of @var{object} and @var{limit} is @code{nil}. If the value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2277 is non-@code{nil}, it is a position greater than or equal to @var{pos}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2278 The value equals @var{pos} only when @var{limit} equals @var{pos}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2279
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2280 Here is an example of how to scan the buffer by chunks of text within
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2281 which all properties are constant:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2282
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2283 @smallexample
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2284 (while (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2285 (let ((plist (text-properties-at (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2286 (next-change
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2287 (or (next-property-change (point) (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2288 (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2289 @r{Process text from point to @var{next-change}@dots{}}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2290 (goto-char next-change)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2291 @end smallexample
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2292 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2293
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2294 @defun next-single-property-change pos prop &optional object limit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2295 The function scans the text forward from position @var{pos} in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2296 string or buffer @var{object} till it finds a change in the @var{prop}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2297 property, then returns the position of the change. In other words, it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2298 returns the position of the first character beyond @var{pos} whose
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2299 @var{prop} property differs from that of the character just after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2300 @var{pos}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2302 If @var{limit} is non-@code{nil}, then the scan ends at position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2303 @var{limit}. If there is no property change before that point,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2304 @code{next-single-property-change} returns @var{limit}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2305
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2306 The value is @code{nil} if the property remains unchanged all the way to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2307 the end of @var{object} and @var{limit} is @code{nil}. If the value is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2308 non-@code{nil}, it is a position greater than or equal to @var{pos}; it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2309 equals @var{pos} only if @var{limit} equals @var{pos}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2310 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2311
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2312 @defun previous-property-change pos &optional object limit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2313 This is like @code{next-property-change}, but scans back from @var{pos}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2314 instead of forward. If the value is non-@code{nil}, it is a position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2315 less than or equal to @var{pos}; it equals @var{pos} only if @var{limit}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2316 equals @var{pos}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2317 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2318
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2319 @defun previous-single-property-change pos prop &optional object limit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2320 This is like @code{next-single-property-change}, but scans back from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2321 @var{pos} instead of forward. If the value is non-@code{nil}, it is a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2322 position less than or equal to @var{pos}; it equals @var{pos} only if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2323 @var{limit} equals @var{pos}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2324 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2325
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2326 @defun text-property-any start end prop value &optional object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2327 This function returns non-@code{nil} if at least one character between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2328 @var{start} and @var{end} has a property @var{prop} whose value is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2329 @var{value}. More precisely, it returns the position of the first such
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2330 character. Otherwise, it returns @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2331
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2332 The optional fifth argument, @var{object}, specifies the string or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2333 buffer to scan. Positions are relative to @var{object}. The default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2334 for @var{object} is the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2335 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2336
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2337 @defun text-property-not-all start end prop value &optional object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2338 This function returns non-@code{nil} if at least one character between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2339 @var{start} and @var{end} has a property @var{prop} whose value differs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2340 from @var{value}. More precisely, it returns the position of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2341 first such character. Otherwise, it returns @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2342
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2343 The optional fifth argument, @var{object}, specifies the string or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2344 buffer to scan. Positions are relative to @var{object}. The default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2345 for @var{object} is the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2346 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2347
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2348 @node Special Properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2349 @subsection Properties with Special Meanings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2350
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2351 The predefined properties are the same as those for extents.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2352 @xref{Extent Properties}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2353
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2354 @ignore Changed in XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2355 (deleted section describing FSF Emacs special text properties)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2356 @end ignore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2357
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2358 @node Saving Properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2359 @subsection Saving Text Properties in Files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2360 @cindex text properties in files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2361 @cindex saving text properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2363 You can save text properties in files, and restore text properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2364 when inserting the files, using these two hooks:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2365
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2366 @defvar write-region-annotate-functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2367 This variable's value is a list of functions for @code{write-region} to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2368 run to encode text properties in some fashion as annotations to the text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2369 being written in the file. @xref{Writing to Files}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2370
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2371 Each function in the list is called with two arguments: the start and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2372 end of the region to be written. These functions should not alter the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2373 contents of the buffer. Instead, they should return lists indicating
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2374 annotations to write in the file in addition to the text in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2375 buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2376
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2377 Each function should return a list of elements of the form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2378 @code{(@var{position} . @var{string})}, where @var{position} is an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2379 integer specifying the relative position in the text to be written, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2380 @var{string} is the annotation to add there.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2381
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2382 Each list returned by one of these functions must be already sorted in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2383 increasing order by @var{position}. If there is more than one function,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2384 @code{write-region} merges the lists destructively into one sorted list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2385
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2386 When @code{write-region} actually writes the text from the buffer to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2387 file, it intermixes the specified annotations at the corresponding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2388 positions. All this takes place without modifying the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2389 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2390
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2391 @defvar after-insert-file-functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2392 This variable holds a list of functions for @code{insert-file-contents}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2393 to call after inserting a file's contents. These functions should scan
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2394 the inserted text for annotations, and convert them to the text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2395 properties they stand for.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2396
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2397 Each function receives one argument, the length of the inserted text;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2398 point indicates the start of that text. The function should scan that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2399 text for annotations, delete them, and create the text properties that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2400 the annotations specify. The function should return the updated length
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2401 of the inserted text, as it stands after those changes. The value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2402 returned by one function becomes the argument to the next function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2403
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2404 These functions should always return with point at the beginning of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2405 the inserted text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2406
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2407 The intended use of @code{after-insert-file-functions} is for converting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2408 some sort of textual annotations into actual text properties. But other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2409 uses may be possible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2410 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2411
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2412 We invite users to write Lisp programs to store and retrieve text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2413 properties in files, using these hooks, and thus to experiment with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2414 various data formats and find good ones. Eventually we hope users
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2415 will produce good, general extensions we can install in Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2416
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2417 We suggest not trying to handle arbitrary Lisp objects as property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2418 names or property values---because a program that general is probably
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2419 difficult to write, and slow. Instead, choose a set of possible data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2420 types that are reasonably flexible, and not too hard to encode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2421
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2422 @xref{Format Conversion}, for a related feature.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2423
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2424 @node Substitution
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2425 @section Substituting for a Character Code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2426
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2427 The following functions replace characters within a specified region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2428 based on their character codes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2429
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2430 @defun subst-char-in-region start end old-char new-char &optional noundo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2431 @cindex replace characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2432 This function replaces all occurrences of the character @var{old-char}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2433 with the character @var{new-char} in the region of the current buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2434 defined by @var{start} and @var{end}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2435
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2436 @cindex Outline mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2437 @cindex undo avoidance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2438 If @var{noundo} is non-@code{nil}, then @code{subst-char-in-region} does
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2439 not record the change for undo and does not mark the buffer as modified.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2440 This feature is used for controlling selective display (@pxref{Selective
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2441 Display}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2442
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2443 @code{subst-char-in-region} does not move point and returns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2444 @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2445
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2446 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2447 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2448 ---------- Buffer: foo ----------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2449 This is the contents of the buffer before.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2450 ---------- Buffer: foo ----------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2451 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2452
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2453 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2454 (subst-char-in-region 1 20 ?i ?X)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2455 @result{} nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2456
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2457 ---------- Buffer: foo ----------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2458 ThXs Xs the contents of the buffer before.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2459 ---------- Buffer: foo ----------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2460 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2461 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2462 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2463
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2464 @defun translate-region start end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2465 This function applies a translation table to the characters in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2466 buffer between positions @var{start} and @var{end}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2467
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2468 The translation table @var{table} is a string; @code{(aref @var{table}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2469 @var{ochar})} gives the translated character corresponding to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2470 @var{ochar}. If the length of @var{table} is less than 256, any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2471 characters with codes larger than the length of @var{table} are not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2472 altered by the translation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2473
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2474 The return value of @code{translate-region} is the number of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2475 characters that were actually changed by the translation. This does
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2476 not count characters that were mapped into themselves in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2477 translation table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2478 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2479
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2480 @node Registers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2481 @section Registers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2482 @cindex registers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2483
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2484 A register is a sort of variable used in XEmacs editing that can hold a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2485 marker, a string, a rectangle, a window configuration (of one frame), or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2486 a frame configuration (of all frames). Each register is named by a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2487 single character. All characters, including control and meta characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2488 (but with the exception of @kbd{C-g}), can be used to name registers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2489 Thus, there are 255 possible registers. A register is designated in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2490 Emacs Lisp by a character that is its name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2491
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2492 The functions in this section return unpredictable values unless
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2493 otherwise stated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2494 @c Will change in version 19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2495
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2496 @defvar register-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2497 This variable is an alist of elements of the form @code{(@var{name} .
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2498 @var{contents})}. Normally, there is one element for each XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2499 register that has been used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2500
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2501 The object @var{name} is a character (an integer) identifying the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2502 register. The object @var{contents} is a string, marker, or list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2503 representing the register contents. A string represents text stored in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2504 the register. A marker represents a position. A list represents a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2505 rectangle; its elements are strings, one per line of the rectangle.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2506 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2507
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2508 @defun get-register reg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2509 This function returns the contents of the register
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2510 @var{reg}, or @code{nil} if it has no contents.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2511 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2512
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2513 @defun set-register reg value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2514 This function sets the contents of register @var{reg} to @var{value}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2515 A register can be set to any value, but the other register functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2516 expect only certain data types. The return value is @var{value}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2517 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2518
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2519 @deffn Command view-register reg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2520 This command displays what is contained in register @var{reg}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2521 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2522
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2523 @ignore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2524 @deffn Command point-to-register reg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2525 This command stores both the current location of point and the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2526 buffer in register @var{reg} as a marker.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2527 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2528
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2529 @deffn Command jump-to-register reg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2530 @deffnx Command register-to-point reg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2531 @comment !!SourceFile register.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2532 This command restores the status recorded in register @var{reg}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2533
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2534 If @var{reg} contains a marker, it moves point to the position stored in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2535 the marker. Since both the buffer and the location within the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2536 are stored by the @code{point-to-register} function, this command can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2537 switch you to another buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2538
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2539 If @var{reg} contains a window configuration or a frame configuration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2540 @code{jump-to-register} restores that configuration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2541 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2542 @end ignore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2543
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2544 @deffn Command insert-register reg &optional beforep
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2545 This command inserts contents of register @var{reg} into the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2546 buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2547
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2548 Normally, this command puts point before the inserted text, and the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2549 mark after it. However, if the optional second argument @var{beforep}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2550 is non-@code{nil}, it puts the mark before and point after.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2551 You can pass a non-@code{nil} second argument @var{beforep} to this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2552 function interactively by supplying any prefix argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2553
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2554 If the register contains a rectangle, then the rectangle is inserted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2555 with its upper left corner at point. This means that text is inserted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2556 in the current line and underneath it on successive lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2557
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2558 If the register contains something other than saved text (a string) or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2559 a rectangle (a list), currently useless things happen. This may be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2560 changed in the future.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2561 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2562
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2563 @ignore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2564 @deffn Command copy-to-register reg start end &optional delete-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2565 This command copies the region from @var{start} to @var{end} into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2566 register @var{reg}. If @var{delete-flag} is non-@code{nil}, it deletes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2567 the region from the buffer after copying it into the register.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2568 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2569
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2570 @deffn Command prepend-to-register reg start end &optional delete-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2571 This command prepends the region from @var{start} to @var{end} into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2572 register @var{reg}. If @var{delete-flag} is non-@code{nil}, it deletes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2573 the region from the buffer after copying it to the register.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2574 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2575
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2576 @deffn Command append-to-register reg start end &optional delete-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2577 This command appends the region from @var{start} to @var{end} to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2578 text already in register @var{reg}. If @var{delete-flag} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2579 non-@code{nil}, it deletes the region from the buffer after copying it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2580 to the register.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2581 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2582
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2583 @deffn Command copy-rectangle-to-register reg start end &optional delete-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2584 This command copies a rectangular region from @var{start} to @var{end}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2585 into register @var{reg}. If @var{delete-flag} is non-@code{nil}, it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2586 deletes the region from the buffer after copying it to the register.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2587 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2588
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2589 @deffn Command window-configuration-to-register reg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2590 This function stores the window configuration of the selected frame in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2591 register @var{reg}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2592 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2593
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2594 @deffn Command frame-configuration-to-register reg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2595 This function stores the current frame configuration in register
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2596 @var{reg}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2597 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2598 @end ignore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2599
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2600 @node Transposition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2601 @section Transposition of Text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2602
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2603 This subroutine is used by the transposition commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2604
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2605 @defun transpose-regions start1 end1 start2 end2 &optional leave-markers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2606 This function exchanges two nonoverlapping portions of the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2607 Arguments @var{start1} and @var{end1} specify the bounds of one portion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2608 and arguments @var{start2} and @var{end2} specify the bounds of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2609 other portion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2610
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2611 Normally, @code{transpose-regions} relocates markers with the transposed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2612 text; a marker previously positioned within one of the two transposed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2613 portions moves along with that portion, thus remaining between the same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2614 two characters in their new position. However, if @var{leave-markers}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2615 is non-@code{nil}, @code{transpose-regions} does not do this---it leaves
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2616 all markers unrelocated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2617 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2618
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2619 @node Change Hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2620 @section Change Hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2621 @cindex change hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2622 @cindex hooks for text changes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2623
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2624 These hook variables let you arrange to take notice of all changes in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2625 all buffers (or in a particular buffer, if you make them buffer-local).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2626 @ignore Not in XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2627 See also @ref{Special Properties}, for how to detect changes to specific
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2628 parts of the text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2629 @end ignore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2630
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2631 The functions you use in these hooks should save and restore the match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2632 data if they do anything that uses regular expressions; otherwise, they
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2633 will interfere in bizarre ways with the editing operations that call
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2634 them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2635
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2636 Buffer changes made while executing the following hooks don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2637 themselves cause any change hooks to be invoked.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2638
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2639 @defvar before-change-functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2640 This variable holds a list of a functions to call before any buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2641 modification. Each function gets two arguments, the beginning and end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2642 of the region that is about to change, represented as integers. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2643 buffer that is about to change is always the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2644 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2645
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2646 @defvar after-change-functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2647 This variable holds a list of a functions to call after any buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2648 modification. Each function receives three arguments: the beginning and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2649 end of the region just changed, and the length of the text that existed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2650 before the change. (To get the current length, subtract the region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2651 beginning from the region end.) All three arguments are integers. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2652 buffer that's about to change is always the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2653 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2654
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2655 @defvar before-change-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2656 This obsolete variable holds one function to call before any buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2657 modification (or @code{nil} for no function). It is called just like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2658 the functions in @code{before-change-functions}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2659 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2660
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2661 @defvar after-change-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2662 This obsolete variable holds one function to call after any buffer modification
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2663 (or @code{nil} for no function). It is called just like the functions in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2664 @code{after-change-functions}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2665 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2666
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2667 @defvar first-change-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2668 This variable is a normal hook that is run whenever a buffer is changed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2669 that was previously in the unmodified state.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2670 @end defvar