annotate man/lispref/markers.texi @ 394:7d59cb494b73 r21-2-12

Import from CVS: tag r21-2-12
author cvs
date Mon, 13 Aug 2007 11:11:37 +0200
parents cc15677e0335
children 74fd4e045ea6
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/markers.info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 @node Markers, Text, Positions, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 @chapter Markers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 @cindex markers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 A @dfn{marker} is a Lisp object used to specify a position in a buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 relative to the surrounding text. A marker changes its offset from the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 beginning of the buffer automatically whenever text is inserted or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 deleted, so that it stays with the two characters on either side of it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 * Overview of Markers:: The components of a marker, and how it relocates.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 * Predicates on Markers:: Testing whether an object is a marker.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 * Creating Markers:: Making empty markers or markers at certain places.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 * Information from Markers:: Finding the marker's buffer or character position.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 * Changing Markers:: Moving the marker to a new buffer or position.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 * The Mark:: How ``the mark'' is implemented with a marker.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 * The Region:: How to access ``the region''.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 @node Overview of Markers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 @section Overview of Markers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 A marker specifies a buffer and a position in that buffer. The marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 can be used to represent a position in the functions that require one,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 just as an integer could be used. @xref{Positions}, for a complete
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 description of positions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 A marker has two attributes: the marker position, and the marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 buffer. The marker position is an integer that is equivalent (at a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 given time) to the marker as a position in that buffer. But the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 marker's position value can change often during the life of the marker.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 Insertion and deletion of text in the buffer relocate the marker. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 idea is that a marker positioned between two characters remains between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 those two characters despite insertion and deletion elsewhere in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 buffer. Relocation changes the integer equivalent of the marker.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 @cindex marker relocation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 Deleting text around a marker's position leaves the marker between the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 characters immediately before and after the deleted text. Inserting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 text at the position of a marker normally leaves the marker in front of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 the new text---unless it is inserted with @code{insert-before-markers}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (@pxref{Insertion}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 @cindex marker garbage collection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 Insertion and deletion in a buffer must check all the markers and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 relocate them if necessary. This slows processing in a buffer with a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 large number of markers. For this reason, it is a good idea to make a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 marker point nowhere if you are sure you don't need it any more.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 Unreferenced markers are garbage collected eventually, but until then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 will continue to use time if they do point somewhere.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 @cindex markers as numbers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 Because it is common to perform arithmetic operations on a marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 position, most of the arithmetic operations (including @code{+} and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 @code{-}) accept markers as arguments. In such cases, the marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 stands for its current position.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 @cindex markers vs. extents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 Note that you can use extents to achieve the same functionality, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 more, as markers. (Markers were defined before extents, which is why
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 they both continue to exist.) A zero-length extent with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 @code{detachable} property removed is almost identical to a marker.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (@xref{Extent Endpoints}, for more information on zero-length extents.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 In particular:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 In order to get marker-like behavior in a zero-length extent, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 @code{detachable} property must be removed (otherwise, the extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 will disappear when text near it is deleted) and exactly one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 endpoint must be closed (if both endpoints are closed, the extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 will expand to contain text inserted where it is located).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 If a zero-length extent has the @code{end-open} property but not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 the @code{start-open} property (this is the default), text inserted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 at the extent's location causes the extent to move forward, just
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 like a marker.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 If a zero-length extent has the @code{start-open} property but not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 the @code{end-open} property, text inserted at the extent's location
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 causes the extent to remain before the text, like what happens to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 markers when @code{insert-before-markers} is used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 Markers end up after or before inserted text depending on whether
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 @code{insert} or @code{insert-before-markers} was called. These
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 functions do not affect zero-length extents differently; instead,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 the presence or absence of the @code{start-open} and @code{end-open}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 extent properties determines this, as just described.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 Markers are automatically removed from a buffer when they are no
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 longer in use. Extents remain around until explicitly removed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 from a buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 Many functions are provided for listing the extents in a buffer or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 in a region of a buffer. No such functions exist for markers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 Here are examples of creating markers, setting markers, and moving point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 to markers:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ;; @r{Make a new marker that initially does not point anywhere:}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (setq m1 (make-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 @result{} #<marker in no buffer>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ;; @r{Set @code{m1} to point between the 99th and 100th characters}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ;; @r{in the current buffer:}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (set-marker m1 100)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 @result{} #<marker at 100 in markers.texi>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ;; @r{Now insert one character at the beginning of the buffer:}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 @result{} 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (insert "Q")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 @result{} nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ;; @r{@code{m1} is updated appropriately.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 m1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 @result{} #<marker at 101 in markers.texi>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ;; @r{Two markers that point to the same position}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ;; @r{are not @code{eq}, but they are @code{equal}.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (setq m2 (copy-marker m1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 @result{} #<marker at 101 in markers.texi>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (eq m1 m2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 @result{} nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (equal m1 m2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 @result{} t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ;; @r{When you are finished using a marker, make it point nowhere.}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (set-marker m1 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 @result{} #<marker in no buffer>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 @node Predicates on Markers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 @section Predicates on Markers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 You can test an object to see whether it is a marker, or whether it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 either an integer or a marker or either an integer, a character, or a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 marker. The latter tests are useful in connection with the arithmetic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 functions that work with any of markers, integers, or characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 @defun markerp object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 This function returns @code{t} if @var{object} is a marker, @code{nil}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 otherwise. Note that integers are not markers, even though many
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 functions will accept either a marker or an integer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 @defun integer-or-marker-p object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 This function returns @code{t} if @var{object} is an integer or a marker,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 @code{nil} otherwise.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 @defun integer-char-or-marker-p object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 This function returns @code{t} if @var{object} is an integer, a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 character, or a marker, @code{nil} otherwise.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 @defun number-or-marker-p object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 This function returns @code{t} if @var{object} is a number (either kind)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 or a marker, @code{nil} otherwise.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 @defun number-char-or-marker-p object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 This function returns @code{t} if @var{object} is a number (either
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 kind), a character, or a marker, @code{nil} otherwise.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 @node Creating Markers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 @section Functions That Create Markers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 When you create a new marker, you can make it point nowhere, or point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 to the present position of point, or to the beginning or end of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 accessible portion of the buffer, or to the same place as another given
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 marker.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 @defun make-marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 This functions returns a newly created marker that does not point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 anywhere.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (make-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 @result{} #<marker in no buffer>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 @defun point-marker &optional dont-copy-p buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 This function returns a marker that points to the present position of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 point in @var{buffer}, which defaults to the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 @xref{Point}. For an example, see @code{copy-marker}, below.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 Internally, a marker corresponding to point is always maintained.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 Normally the marker returned by @code{point-marker} is a copy; you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 may modify it with reckless abandon. However, if optional argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 @var{dont-copy-p} is non-@code{nil}, then the real point-marker is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 returned; modifying the position of this marker will move point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 It is illegal to change the buffer of it, or make it point nowhere.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 @defun point-min-marker &optional buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 This function returns a new marker that points to the beginning of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 accessible portion of @var{buffer}, which defaults to the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 buffer. This will be the beginning of the buffer unless narrowing is in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 effect. @xref{Narrowing}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 @defun point-max-marker &optional buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 @cindex end of buffer marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 This function returns a new marker that points to the end of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 accessible portion of @var{buffer}, which defaults to the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 buffer. This will be the end of the buffer unless narrowing is in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 effect. @xref{Narrowing}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 Here are examples of this function and @code{point-min-marker}, shown in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 a buffer containing a version of the source file for the text of this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 chapter.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (point-min-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 @result{} #<marker at 1 in markers.texi>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (point-max-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 @result{} #<marker at 15573 in markers.texi>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (narrow-to-region 100 200)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 @result{} nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (point-min-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 @result{} #<marker at 100 in markers.texi>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (point-max-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 @result{} #<marker at 200 in markers.texi>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 @defun copy-marker marker-or-integer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 If passed a marker as its argument, @code{copy-marker} returns a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 new marker that points to the same place and the same buffer as does
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 @var{marker-or-integer}. If passed an integer as its argument,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 @code{copy-marker} returns a new marker that points to position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 @var{marker-or-integer} in the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 If passed an integer argument less than 1, @code{copy-marker} returns a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 new marker that points to the beginning of the current buffer. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 passed an integer argument greater than the length of the buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 @code{copy-marker} returns a new marker that points to the end of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 An error is signaled if @var{marker} is neither a marker nor an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 integer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (setq p (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 @result{} #<marker at 2139 in markers.texi>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (setq q (copy-marker p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 @result{} #<marker at 2139 in markers.texi>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (eq p q)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 @result{} nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (equal p q)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 @result{} t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 @result{} 2139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (set-marker p 3000)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 @result{} #<marker at 3000 in markers.texi>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 @result{} 2139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (setq p (point-marker t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 @result{} #<marker at 2139 in markers.texi>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (set-marker p 3000)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 @result{} #<marker at 3000 in markers.texi>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 @result{} 3000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (copy-marker 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 @result{} #<marker at 1 in markers.texi>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (copy-marker 20000)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 @result{} #<marker at 7572 in markers.texi>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 @node Information from Markers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 @section Information from Markers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 This section describes the functions for accessing the components of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 marker object.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 @defun marker-position marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 This function returns the position that @var{marker} points to, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 @code{nil} if it points nowhere.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 @defun marker-buffer marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 This function returns the buffer that @var{marker} points into, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 @code{nil} if it points nowhere.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (setq m (make-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 @result{} #<marker in no buffer>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (marker-position m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 @result{} nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (marker-buffer m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 @result{} nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (set-marker m 3770 (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 @result{} #<marker at 3770 in markers.texi>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (marker-buffer m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 @result{} #<buffer markers.texi>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (marker-position m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 @result{} 3770
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 Two distinct markers are considered @code{equal} (even though not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 @code{eq}) to each other if they have the same position and buffer, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 if they both point nowhere.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 @node Changing Markers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 @section Changing Marker Positions
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 section describes how to change the position of an existing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 marker. When you do this, be sure you know whether the marker is used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 outside of your program, and, if so, what effects will result from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 moving it---otherwise, confusing things may happen in other parts of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 @defun set-marker marker position &optional buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 This function moves @var{marker} to @var{position}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 in @var{buffer}. If @var{buffer} is not provided, it defaults to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 If @var{position} is less than 1, @code{set-marker} moves @var{marker}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 to the beginning of the buffer. If @var{position} is greater than the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 size of the buffer, @code{set-marker} moves marker to the end of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 buffer. If @var{position} is @code{nil} or a marker that points
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 nowhere, then @var{marker} is set to point nowhere.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 The value returned is @var{marker}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (setq m (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 @result{} #<marker at 4714 in markers.texi>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (set-marker m 55)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 @result{} #<marker at 55 in markers.texi>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (setq b (get-buffer "foo"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 @result{} #<buffer foo>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (set-marker m 0 b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 @result{} #<marker at 1 in foo>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 @defun move-marker marker position &optional buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 This is another name for @code{set-marker}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 @node The Mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 @section The Mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 @cindex mark, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 @cindex mark ring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 @cindex global mark ring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 One special marker in each buffer is designated @dfn{the mark}. It
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 records a position for the user for the sake of commands such as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 @kbd{C-w} and @kbd{C-x @key{TAB}}. Lisp programs should set the mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 only to values that have a potential use to the user, and never for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 their own internal purposes. For example, the @code{replace-regexp}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 command sets the mark to the value of point before doing any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 replacements, because this enables the user to move back there
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 conveniently after the replace is finished.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 Once the mark ``exists'' in a buffer, it normally never ceases to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 exist. However, it may become @dfn{inactive}, and usually does so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 after each command (other than simple motion commands and some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 commands that explicitly activate the mark). When the mark is active,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 the region between point and the mark is called the @dfn{active region}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 and is highlighted specially.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 Many commands are designed so that when called interactively they
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 operate on the text between point and the mark. Such commands work
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 only when an active region exists, i.e. when the mark is active.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (The reason for this is to prevent you from accidentally deleting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 or changing large chunks of your text.) If you are writing such
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 a command, don't examine the mark directly; instead, use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 @code{interactive} with the @samp{r} specification. This provides the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 values of point and the mark as arguments to the command in an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 interactive call, but permits other Lisp programs to specify arguments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 explicitly, and automatically signals an error if the command is called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 interactively when no active region exists. @xref{Interactive Codes}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 Each buffer has its own value of the mark that is independent of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 value of the mark in other buffers. (When a buffer is created, the mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 exists but does not point anywhere. We consider this state as ``the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 absence of a mark in that buffer.'') However, only one active region can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 exist at a time. Activating the mark in one buffer automatically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 deactivates an active mark in any other buffer. Note that the user can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 explicitly activate a mark at any time by using the command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 @code{activate-region} (normally bound to @kbd{M-C-z}) or by using the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 command @code{exchange-point-and-mark} (normally bound to @kbd{C-x C-x}),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 which has the side effect of activating the mark.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 Some people do not like active regions, so they disable this behavior
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 by setting the variable @code{zmacs-regions} to @code{nil}. This makes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 the mark always active (except when a buffer is just created and the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 mark points nowhere), and turns off the highlighting of the region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 between point and the mark. Commands that explicitly retrieve the value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 of the mark should make sure that they behave correctly and consistently
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 irrespective of the setting of @code{zmacs-regions}; some primitives are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 provided to ensure this behavior.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 In addition to the mark, each buffer has a @dfn{mark ring} which is a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 list of markers containing previous values of the mark. When editing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 commands change the mark, they should normally save the old value of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 mark on the mark ring. The variable @code{mark-ring-max} specifies the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 maximum number of entries in the mark ring; once the list becomes this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 long, adding a new element deletes the last element.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 @defun mark &optional force buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 @cindex current buffer mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 This function returns @var{buffer}'s mark position as an integer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 @var{buffer} defaults to the current buffer if omitted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 If the mark is inactive, @code{mark} normally returns @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 However, if @var{force} is non-@code{nil}, then @code{mark} returns the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 mark position anyway---or @code{nil}, if the mark is not yet set for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (Remember that if @var{zmacs-regions} is @code{nil}, the mark is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 always active as long as it exists, and the @var{force} argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 will have no effect.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 If you are using this in an editing command, you are most likely making
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 a mistake; see the documentation of @code{set-mark} below.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 @defun mark-marker inactive-p buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 This function returns @var{buffer}'s mark. @var{buffer} defaults to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 current buffer if omitted. This is the very marker that records the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 mark location inside XEmacs, not a copy. Therefore, changing this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 marker's position will directly affect the position of the mark. Don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 do it unless that is the effect you want.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 If the mark is inactive, @code{mark-marker} normally returns @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 However, if @var{force} is non-@code{nil}, then @code{mark-marker}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 returns the mark anyway.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (setq m (mark-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 @result{} #<marker at 3420 in markers.texi>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (set-marker m 100)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 @result{} #<marker at 100 in markers.texi>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (mark-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 @result{} #<marker at 100 in markers.texi>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 Like any marker, this marker can be set to point at any buffer you like.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 We don't recommend that you make it point at any buffer other than the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 one of which it is the mark. If you do, it will yield perfectly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 consistent, but rather odd, results.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 @ignore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 @deffn Command set-mark-command jump
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 If @var{jump} is @code{nil}, this command sets the mark to the value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 of point and pushes the previous value of the mark on the mark ring. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 message @samp{Mark set} is also displayed in the echo area.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 If @var{jump} is not @code{nil}, this command sets point to the value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 of the mark, and sets the mark to the previous saved mark value, which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 is popped off the mark ring.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 This function is @emph{only} intended for interactive use.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 @end ignore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 @defun set-mark position &optional buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 This function sets @code{buffer}'s mark to @var{position}, and activates
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 the mark. @var{buffer} defaults to the current buffer if omitted. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 old value of the mark is @emph{not} pushed onto the mark ring.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 @strong{Please note:} Use this function only if you want the user to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 see that the mark has moved, and you want the previous mark position to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 be lost. Normally, when a new mark is set, the old one should go on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 @code{mark-ring}. For this reason, most applications should use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 @code{push-mark} and @code{pop-mark}, not @code{set-mark}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 Novice XEmacs Lisp programmers often try to use the mark for the wrong
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 purposes. The mark saves a location for the user's convenience. An
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 editing command should not alter the mark unless altering the mark is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 part of the user-level functionality of the command. (And, in that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 case, this effect should be documented.) To remember a location for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 internal use in the Lisp program, store it in a Lisp variable. For
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 @group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (let ((beg (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (delete-region beg (point))).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 @end group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 @deffn Command exchange-point-and-mark &optional dont-activate-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 This function exchanges the positions of point and the mark.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 It is intended for interactive use. The mark is also activated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 unless @var{dont-activate-region} is non-@code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 @defun push-mark &optional position nomsg activate buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 This function sets @var{buffer}'s mark to @var{position}, and pushes a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 copy of the previous mark onto @code{mark-ring}. @var{buffer} defaults
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 to the current buffer if omitted. If @var{position} is @code{nil}, then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 the value of point is used. @code{push-mark} returns @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 If the last global mark pushed was not in @var{buffer}, also push
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 @var{position} on the global mark ring (see below).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 The function @code{push-mark} normally @emph{does not} activate the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 mark. To do that, specify @code{t} for the argument @var{activate}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 A @samp{Mark set} message is displayed unless @var{nomsg} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 non-@code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 @defun pop-mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 This function pops off the top element of @code{mark-ring} and makes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 that mark become the buffer's actual mark. This does not move point in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 the buffer, and it does nothing if @code{mark-ring} is empty. It
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 deactivates the mark.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 The return value is not meaningful.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 @defvar mark-ring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 The value of this buffer-local variable is the list of saved former
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 marks of the current buffer, most recent first.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 @example
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 mark-ring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 @result{} (#<marker at 11050 in markers.texi>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 #<marker at 10832 in markers.texi>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 @dots{})
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 example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 @defopt mark-ring-max
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 The value of this variable is the maximum size of @code{mark-ring}. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 more marks than this are pushed onto the @code{mark-ring},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 @code{push-mark} discards an old mark when it adds a new one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 @end defopt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 In additional to a per-buffer mark ring, there is a @dfn{global mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 ring}. Marks are pushed onto the global mark ring the first time you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 set a mark after switching buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 @defvar global-mark-ring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 The value of this variable is the list of saved former global marks,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 most recent first.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 @defopt mark-ring-max
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 The value of this variable is the maximum size of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 @code{global-mark-ring}. If more marks than this are pushed onto the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 @code{global-mark-ring}, @code{push-mark} discards an old mark when it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 adds a new one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 @end defopt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 @deffn Command pop-global-mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 This function pops a mark off the global mark ring and jumps to that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 location.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 @end deffn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 @node The Region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 @section The Region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 @cindex region, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 The text between point and the mark is known as @dfn{the region}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 Various functions operate on text delimited by point and the mark, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 only those functions specifically related to the region itself are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 described here.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 When @code{zmacs-regions} is non-@code{nil} (this is the default), the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 concept of an @dfn{active region} exists. The region is active when the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 corresponding mark is active. Note that only one active region at a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 time can exist -- i.e. only one buffer's region is active at a time.
394
7d59cb494b73 Import from CVS: tag r21-2-12
cvs
parents: 371
diff changeset
671 @xref{The Mark}, for more information about active regions.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 @defopt zmacs-regions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 If non-@code{nil} (the default), active regions are used. @xref{The Mark},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 for a detailed explanation of what this means.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 @end defopt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 A number of functions are provided for explicitly determining the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 bounds of the region and whether it is active. Few programs need to use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 these functions, however. A command designed to operate on a region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 should normally use @code{interactive} with the @samp{r} specification
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 to find the beginning and end of the region. This lets other Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 programs specify the bounds explicitly as arguments and automatically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 respects the user's setting for @var{zmacs-regions}. (@xref{Interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 Codes}.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 @defun region-beginning &optional buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 This function returns the position of the beginning of @var{buffer}'s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 region (as an integer). This is the position of either point or the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 mark, whichever is smaller. @var{buffer} defaults to the current buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 if omitted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 If the mark does not point anywhere, an error is signaled. Note that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 this function ignores whether the region is active.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 @defun region-end &optional buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 This function returns the position of the end of @var{buffer}'s region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 (as an integer). This is the position of either point or the mark,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 whichever is larger. @var{buffer} defaults to the current buffer if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 omitted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 If the mark does not point anywhere, an error is signaled. Note that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 this function ignores whether the region is active.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 @defun region-exists-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 This function is non-@code{nil} if the region exists. If active regions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 are in use (i.e. @code{zmacs-regions} is true), this means that the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 region is active. Otherwise, this means that the user has pushed a mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 in this buffer at some point in the past. If this function returns @code{nil},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 a function that uses the @samp{r} interactive specification will cause
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 an error when called interactively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 @defun region-active-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 If @code{zmacs-regions} is true, this is equivalent to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 @code{region-exists-p}. Otherwise, this function always returns false.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 This function is used by commands such as @code{fill-paragraph-or-region}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 and @code{capitalize-region-or-word}, which operate either on the active
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 region or on something else (e.g. the word or paragraph at point).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 @defvar zmacs-region-stays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 If a command sets this variable to true, the currently active region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 will remain activated when the command finishes. (Normally the region is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 deactivated when each command terminates.) If @var{zmacs-regions} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 false, however, this has no effect. Under normal circumstances, you do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 not need to set this; use the interactive specification @samp{_}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 instead, if you want the region to remain active.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 @defun zmacs-activate-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 This function activates the region in the current buffer (this is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 equivalent to activating the current buffer's mark). This will normally
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 also highlight the text in the active region and set
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 @var{zmacs-region-stays} to @code{t}. (If @var{zmacs-regions} is false,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 however, this function has no effect.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 @defun zmacs-deactivate-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 This function deactivates the region in the current buffer (this is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 equivalent to deactivating the current buffer's mark). This will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 normally also unhighlight the text in the active region and set
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 @var{zmacs-region-stays} to @code{nil}. (If @var{zmacs-regions} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 false, however, this function has no effect.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 @defun zmacs-update-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 This function updates the active region, if it's currently active. (If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 there is no active region, this function does nothing.) This has the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 effect of updating the highlighting on the text in the region; but you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 should never need to call this except under rather strange
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 circumstances. The command loop automatically calls it when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 appropriate. Calling this function will call the hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 @code{zmacs-update-region-hook}, if the region is active.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 @defvar zmacs-activate-region-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 This normal hook is called when a region becomes active. (Usually this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 happens as a result of a command that activates the region, such as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 @code{set-mark-command}, @code{activate-region}, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 @code{exchange-point-and-mark}.) Note that calling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 @file{zmacs-activate-region} will call this hook, even if the region is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 already active. If @var{zmacs-regions} is false, however, this hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 will never get called under any circumstances.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 @defvar zmacs-deactivate-region-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 This normal hook is called when an active region becomes inactive.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 (Calling @file{zmacs-deactivate-region} when the region is inactive will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 @emph{not} cause this hook to be called.) If @var{zmacs-regions} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 false, this hook will never get called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 @defvar zmacs-update-region-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 This normal hook is called when an active region is "updated" by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 @code{zmacs-update-region}. This normally gets called at the end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 of each command that sets @var{zmacs-region-stays} to @code{t},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 indicating that the region should remain activated. The motion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 commands do this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 @end defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784