annotate man/lispref/markers.texi @ 5692:be87f507f510

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