annotate lispref/markers.texi @ 7304:cccf1cbf8944

Update copyright.
author Karl Heuer <kwzh@gnu.org>
date Wed, 04 May 1994 01:37:37 +0000
parents 9cbdecc5a37d
children a1c07008521d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6444
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 @c -*-texinfo-*-
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2 @c This is part of the GNU Emacs Lisp Reference Manual.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3 @c Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4 @c See the file elisp.texi for copying conditions.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 @setfilename ../info/markers
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 @node Markers, Text, Positions, Top
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 @chapter Markers
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 @cindex markers
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 A @dfn{marker} is a Lisp object used to specify a position in a buffer
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 relative to the surrounding text. A marker changes its offset from the
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 beginning of the buffer automatically whenever text is inserted or
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 deleted, so that it stays with the two characters on either side of it.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 @menu
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 * Overview of Markers:: The components of a marker, and how it relocates.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 * Predicates on Markers:: Testing whether an object is a marker.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 * Creating Markers:: Making empty markers or markers at certain places.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 * Information from Markers:: Finding the marker's buffer or character position.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 * Changing Markers:: Moving the marker to a new buffer or position.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 * The Mark:: How ``the mark'' is implemented with a marker.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 * The Region:: How to access ``the region''.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 @end menu
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 @node Overview of Markers
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 @section Overview of Markers
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 A marker specifies a buffer and a position in that buffer. The marker
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 can be used to represent a position in the functions that require one,
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 just as an integer could be used. @xref{Positions}, for a complete
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 description of positions.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 A marker has two attributes: the marker position, and the marker
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 buffer. The marker position is an integer which is equivalent (at a
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 given time) to the marker as a position in that buffer. But the
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 marker's position value can change often during the life of the marker.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 Insertion and deletion of text in the buffer relocate the marker. The
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 idea is that a marker positioned between two characters remains between
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 those two characters despite insertion and deletion elsewhere in the
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 buffer. Relocation changes the integer equivalent of the marker.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 @cindex marker relocation
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 Deleting text around a marker's position leaves the marker between the
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 characters immediately before and after the deleted text. Inserting
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 text at the position of a marker normally leaves the marker in front of
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 the new text---unless it is inserted with @code{insert-before-markers}
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 (@pxref{Insertion}).
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 @cindex marker garbage collection
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 Insertion and deletion in a buffer must check all the markers and
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 relocate them if necessary. This slows processing in a buffer with a
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 large number of markers. For this reason, it is a good idea to make a
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 marker point nowhere if you are sure you don't need it any more.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 Unreferenced markers are garbage collected eventually, but until then
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 will continue to use time if they do point somewhere.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 @cindex markers as numbers
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 Because it is common to perform arithmetic operations on a marker
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 position, most of the arithmetic operations (including @code{+} and
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 @code{-}) accept markers as arguments. In such cases, the marker
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 stands for its current position.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 Here are examples of creating markers, setting markers, and moving point
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 to markers:
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 @example
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 @group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 ;; @r{Make a new marker that initially does not point anywhere:}
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 (setq m1 (make-marker))
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 @result{} #<marker in no buffer>
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 @end group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 @group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 ;; @r{Set @code{m1} to point between the 99th and 100th characters}
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 ;; @r{in the current buffer:}
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 (set-marker m1 100)
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 @result{} #<marker at 100 in markers.texi>
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 @end group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 @group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 ;; @r{Now insert one character at the beginning of the buffer:}
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 (goto-char (point-min))
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 @result{} 1
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 (insert "Q")
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 @result{} nil
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 @end group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 @group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 ;; @r{@code{m1} is updated appropriately.}
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 m1
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 @result{} #<marker at 101 in markers.texi>
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 @end group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 @group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 ;; @r{Two markers that point to the same position}
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 ;; @r{are not @code{eq}, but they are @code{equal}.}
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 (setq m2 (copy-marker m1))
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 @result{} #<marker at 101 in markers.texi>
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 (eq m1 m2)
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 @result{} nil
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 (equal m1 m2)
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 @result{} t
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 @end group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 @group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 ;; @r{When you are finished using a marker, make it point nowhere.}
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 (set-marker m1 nil)
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 @result{} #<marker in no buffer>
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 @end group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 @end example
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 @node Predicates on Markers
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 @section Predicates on Markers
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 You can test an object to see whether it is a marker, or whether it is
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 either an integer or a marker. The latter test is useful in connection
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 with the arithmetic functions that work with both markers and integers.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 @defun markerp object
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 This function returns @code{t} if @var{object} is a marker, @code{nil}
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 otherwise. Note that integers are not markers, even though many
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 functions will accept either a marker or an integer.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 @end defun
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 @defun integer-or-marker-p object
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 This function returns @code{t} if @var{object} is an integer or a marker,
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 @code{nil} otherwise.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 @end defun
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 @defun number-or-marker-p object
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 This function returns @code{t} if @var{object} is a number (either kind)
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 or a marker, @code{nil} otherwise.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 @end defun
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 @node Creating Markers
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 @section Functions That Create Markers
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 When you create a new marker, you can make it point nowhere, or point
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 to the present position of point, or to the beginning or end of the
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 accessible portion of the buffer, or to the same place as another given
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 marker.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 @defun make-marker
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 This functions returns a newly allocated marker that does not point
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 anywhere.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 @example
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 @group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 (make-marker)
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 @result{} #<marker in no buffer>
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 @end group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 @end example
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 @end defun
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 @defun point-marker
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 This function returns a new marker that points to the present position
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 of point in the current buffer. @xref{Point}. For an example, see
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 @code{copy-marker}, below.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 @end defun
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 @defun point-min-marker
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 This function returns a new marker that points to the beginning of the
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 accessible portion of the buffer. This will be the beginning of the
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 buffer unless narrowing is in effect. @xref{Narrowing}.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 @end defun
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 @defun point-max-marker
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 @cindex end of buffer marker
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 This function returns a new marker that points to the end of the
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 accessible portion of the buffer. This will be the end of the buffer
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 unless narrowing is in effect. @xref{Narrowing}.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 Here are examples of this function and @code{point-min-marker}, shown in
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 a buffer containing a version of the source file for the text of this
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 chapter.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 @example
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 @group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 (point-min-marker)
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 @result{} #<marker at 1 in markers.texi>
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 (point-max-marker)
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 @result{} #<marker at 15573 in markers.texi>
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 @end group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 @group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 (narrow-to-region 100 200)
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 @result{} nil
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 @end group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 @group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 (point-min-marker)
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 @result{} #<marker at 100 in markers.texi>
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 @end group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 @group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 (point-max-marker)
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 @result{} #<marker at 200 in markers.texi>
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 @end group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 @end example
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 @end defun
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 @defun copy-marker marker-or-integer
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 If passed a marker as its argument, @code{copy-marker} returns a
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 new marker that points to the same place and the same buffer as does
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 @var{marker-or-integer}. If passed an integer as its argument,
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 @code{copy-marker} returns a new marker that points to position
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 @var{marker-or-integer} in the current buffer.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 If passed an integer argument less than 1, @code{copy-marker} returns a
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 new marker that points to the beginning of the current buffer. If
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 passed an integer argument greater than the length of the buffer,
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 @code{copy-marker} returns a new marker that points to the end of the
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 buffer.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 An error is signaled if @var{marker} is neither a marker nor an
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 integer.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 @example
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 @group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 (setq p (point-marker))
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 @result{} #<marker at 2139 in markers.texi>
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 @end group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 @group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 (setq q (copy-marker p))
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 @result{} #<marker at 2139 in markers.texi>
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 @end group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 @group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 (eq p q)
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 @result{} nil
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 @end group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 @group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 (equal p q)
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 @result{} t
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235 @end group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 @group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 (copy-marker 0)
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 @result{} #<marker at 1 in markers.texi>
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 @end group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 @group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 (copy-marker 20000)
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 @result{} #<marker at 7572 in markers.texi>
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 @end group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246 @end example
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247 @end defun
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 @node Information from Markers
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 @section Information from Markers
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 This section describes the functions for accessing the components of a
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 marker object.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 @defun marker-position marker
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 This function returns the position that @var{marker} points to, or
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 @code{nil} if it points nowhere.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 @end defun
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 @defun marker-buffer marker
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 This function returns the buffer that @var{marker} points into, or
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 @code{nil} if it points nowhere.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 @example
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 @group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 (setq m (make-marker))
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 @result{} #<marker in no buffer>
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268 @end group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 @group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 (marker-position m)
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 @result{} nil
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 @end group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 @group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 (marker-buffer m)
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 @result{} nil
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 @end group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 @group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 (set-marker m 3770 (current-buffer))
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 @result{} #<marker at 3770 in markers.texi>
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281 @end group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 @group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 (marker-buffer m)
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 @result{} #<buffer markers.texi>
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 @end group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 @group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 (marker-position m)
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288 @result{} 3770
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 @end group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290 @end example
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 @end defun
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 Two distinct markers are considered @code{equal} (even though not
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 @code{eq}) to each other if they have the same position and buffer, or
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 if they both point nowhere.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 @node Changing Markers
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 @section Changing Marker Positions
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 This section describes how to change the position of an existing
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 marker. When you do this, be sure you know whether the marker is used
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 outside of your program, and, if so, what effects will result from
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 moving it---otherwise, confusing things may happen in other parts of
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304 Emacs.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306 @defun set-marker marker position &optional buffer
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307 This function moves @var{marker} to @var{position}
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308 in @var{buffer}. If @var{buffer} is not provided, it defaults to
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 the current buffer.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311 If @var{position} is less than 1, @code{set-marker} moves @var{marker}
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312 to the beginning of the buffer. If the value of @var{position} is
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313 greater than the size of the buffer, @code{set-marker} moves marker to
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314 the end of the buffer. If @var{position} is @code{nil} or a marker that
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315 points nowhere, then @var{marker} is set to point nowhere.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 The value returned is @var{marker}.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 @example
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320 @group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321 (setq m (point-marker))
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322 @result{} #<marker at 4714 in markers.texi>
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323 @end group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 @group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 (set-marker m 55)
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326 @result{} #<marker at 55 in markers.texi>
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 @end group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 @group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 (setq b (get-buffer "foo"))
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 @result{} #<buffer foo>
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 @end group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 @group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 (set-marker m 0 b)
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 @result{} #<marker at 1 in foo>
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 @end group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 @end example
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 @end defun
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 @defun move-marker marker position &optional buffer
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 This is another name for @code{set-marker}.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341 @end defun
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343 @node The Mark
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344 @section The Mark
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
345 @cindex mark, the
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
346 @cindex mark ring
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
347
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
348 One special marker in each buffer is designated @dfn{the mark}. It
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349 records a position for the user for the sake of commands such as
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350 @kbd{C-w} and @kbd{C-x @key{TAB}}. Lisp programs should set the mark
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351 only to values that have a potential use to the user, and never for
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352 their own internal purposes. For example, the @code{replace-regexp}
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353 command sets the mark to the value of point before doing any
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354 replacements, because this enables the user to move back there
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
355 conveniently after the replace is finished.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
356
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
357 Many commands are designed so that when called interactively they
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358 operate on the text between point and the mark. If you are writing such
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
359 a command, don't examine the mark directly; instead, use
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
360 @code{interactive} with the @samp{r} specification. This provides the
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
361 values of point and the mark as arguments to the command in an
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
362 interactive call, but permits other Lisp programs to specify arguments
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
363 explicitly. @xref{Interactive Codes}.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
364
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365 Each buffer has its own value of the mark that is independent of the
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
366 value of the mark in other buffers. When a buffer is created, the mark
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
367 exists but does not point anywhere. We consider this state as ``the
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368 absence of a mark in that buffer''.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
369
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
370 Once the mark ``exists'' in a buffer, it normally never ceases to
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
371 exist. However, it may become @dfn{inactive}, if Transient Mark mode is
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
372 enabled. The variable @code{mark-active}, which is always local in all
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373 buffers, indicates whether the mark is active: non-@code{nil} means
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374 yes. A command can request deactivation of the mark upon return to the
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 editor command loop by setting @code{deactivate-mark} to a
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 non-@code{nil} value (but this deactivation only follows if Transient
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 Mark mode is enabled).
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379 The main motivation for using Transient Mark mode is that this mode
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380 also enables highlighting of the region when the mark is active.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381 @xref{Display}.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 In addition to the mark, each buffer has a @dfn{mark ring} which is a
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 list of markers containing previous values of the mark. When editing
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385 commands change the mark, they should normally save the old value of the
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386 mark on the mark ring. The variable @code{mark-ring-max} specifies the
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 maximum number of entries in the mark ring; once the list becomes this
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388 long, adding a new element deletes the last element.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390 @defun mark &optional force
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391 @cindex current buffer mark
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
392 This function returns the current buffer's mark position as an integer.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394 If the mark is inactive, @code{mark} normally signals an error.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395 However, if @var{force} is non-@code{nil}, then @code{mark} returns the
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396 mark position anyway---or @code{nil}, if the mark is not yet set for
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
397 this buffer.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398 @end defun
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
399
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400 @defun mark-marker
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
401 This function returns the current buffer's mark. This is the very marker
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402 which records the mark location inside Emacs, not a copy. Therefore,
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 changing this marker's position will directly affect the position of the mark.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404 Don't do it unless that is the effect you want.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406 @example
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
407 @group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
408 (setq m (mark-marker))
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
409 @result{} #<marker at 3420 in markers.texi>
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410 @end group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411 @group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412 (set-marker m 100)
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413 @result{} #<marker at 100 in markers.texi>
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414 @end group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 @group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416 (mark-marker)
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417 @result{} #<marker at 100 in markers.texi>
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 @end group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 @end example
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 Like any marker, this marker can be set to point at any buffer you like.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 We don't recommend that you make it point at any buffer other than the
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 one of which it is the mark. If you do, it will yield perfectly
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 consistent, but rather odd, results.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425 @end defun
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 @ignore
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428 @deffn Command set-mark-command jump
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429 If @var{jump} is @code{nil}, this command sets the mark to the value
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430 of point and pushes the previous value of the mark on the mark ring. The
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
431 message @samp{Mark set} is also displayed in the echo area.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
432
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433 If @var{jump} is not @code{nil}, this command sets point to the value
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434 of the mark, and sets the mark to the previous saved mark value, which
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435 is popped off the mark ring.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437 This function is @emph{only} intended for interactive use.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 @end deffn
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
439 @end ignore
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
440
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441 @defun set-mark position
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
442 This function sets the mark to @var{position}, and activates the mark.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 The old value of the mark is @emph{not} pushed onto the mark ring.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
445 @strong{Please note:} use this function only if you want the user to
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
446 see that the mark has moved, and you want the previous mark position to
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
447 be lost. Normally, when a new mark is set, the old one should go on the
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
448 @code{mark-ring}. For this reason, most applications should use
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
449 @code{push-mark} and @code{pop-mark}, not @code{set-mark}.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
450
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
451 Novice Emacs Lisp programmers often try to use the mark for the wrong
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
452 purposes. The mark saves a location for the user's convenience. An
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
453 editing command should not alter the mark unless altering the mark is
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
454 part of the user-level functionality of the command. (And, in that
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
455 case, this effect should be documented.) To remember a location for
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
456 internal use in the Lisp program, store it in a Lisp variable. For
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
457 example:
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
458
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
459 @example
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
460 @group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
461 (let ((beg (point)))
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
462 (forward-line 1)
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
463 (delete-region beg (point))).
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
464 @end group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
465 @end example
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
466 @end defun
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
467
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
468 @c for interactive use only
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
469 @ignore
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
470 @deffn Command exchange-point-and-mark
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
471 This function exchanges the positions of point and the mark.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
472 It is intended for interactive use.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
473 @end deffn
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
474 @end ignore
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
475
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
476 @defun push-mark &optional position nomsg activate
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
477 This function sets the current buffer's mark to @var{position}, and
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478 pushes a copy of the previous mark onto @code{mark-ring}. If
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479 @var{position} is @code{nil}, then the value of point is used.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480 @code{push-mark} returns @code{nil}.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
482 The function @code{push-mark} normally @emph{does not} activate the
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
483 mark. To do that, specify @code{t} for the argument @var{activate}.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
484
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
485 A @samp{Mark set} message is displayed unless @var{nomsg} is
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
486 non-@code{nil}.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
487 @end defun
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
488
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
489 @defun pop-mark
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
490 This function pops off the top element of @code{mark-ring} and makes
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
491 that mark become the buffer's actual mark. This does not move point in
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
492 the buffer, and it does nothing if @code{mark-ring} is empty. It
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
493 deactivates the mark.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
494
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
495 The return value is not meaningful.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
496 @end defun
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
497
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
498 @defopt transient-mark-mode
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
499 @cindex Transient Mark mode
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
500 This variable enables Transient Mark mode, in which every
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
501 buffer-modifying primitive sets @code{deactivate-mark}. The consequence
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
502 of this is that commands that modify the buffer normally make the mark
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
503 inactive.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
504 @end defopt
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
505
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
506 @defvar deactivate-mark
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
507 If an editor command sets this variable non-@code{nil}, then the editor
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
508 command loop deactivates the mark after the command returns.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
509 @end defvar
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
510
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511 @defvar mark-active
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512 The mark is active when this variable is non-@code{nil}. This variable
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513 is always local in each buffer.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
514 @end defvar
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
516 @defvar activate-mark-hook
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
517 @defvarx deactivate-mark-hook
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
518 These normal hooks are run, respectively, when the mark becomes active
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
519 and when it becomes inactive. The hook @code{activate-mark-hook} is also
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
520 run at the end of a command if the mark is active and the region may
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
521 have changed.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
522 @end defvar
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
523
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
524 @defvar mark-ring
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
525 The value of this buffer-local variable is the list of saved former
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
526 marks of the current buffer, most recent first.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
527
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
528 @example
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
529 @group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
530 mark-ring
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
531 @result{} (#<marker at 11050 in markers.texi>
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
532 #<marker at 10832 in markers.texi>
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
533 @dots{})
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
534 @end group
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535 @end example
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
536 @end defvar
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
537
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
538 @defopt mark-ring-max
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
539 The value of this variable is the maximum size of @code{mark-ring}. If
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
540 more marks than this are pushed onto the @code{mark-ring},
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
541 @code{push-mark} discards an old mark when it adds a new one.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
542 @end defopt
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
543
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
544 @node The Region
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
545 @section The Region
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
546 @cindex region, the
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
547
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
548 The text between point and the mark is known as @dfn{the region}.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
549 Various functions operate on text delimited by point and the mark, but
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
550 only those functions specifically related to the region itself are
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
551 described here.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
552
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
553 @defun region-beginning
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
554 This function returns the position of the beginning of the region (as
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
555 an integer). This is the position of either point or the mark,
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
556 whichever is smaller.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
557
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
558 If the mark does not point anywhere, an error is signaled.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
559 @end defun
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
560
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
561 @defun region-end
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
562 This function returns the position of the end of the region (as an
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
563 integer). This is the position of either point or the mark, whichever is
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
564 larger.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
565
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
566 If the mark does not point anywhere, an error is signaled.
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
567 @end defun
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
568
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
569 Few programs need to use the @code{region-beginning} and
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
570 @code{region-end} functions. A command designed to operate on a region
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
571 should normally use @code{interactive} with the @samp{r} specification
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
572 to find the beginning and end of the region. This lets other Lisp
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
573 programs specify the bounds explicitly as arguments. (@xref{Interactive
9cbdecc5a37d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
574 Codes}.)