]> code.delx.au - gnu-emacs/blob - doc/lispref/markers.texi
Update copyright year to 2016
[gnu-emacs] / doc / lispref / markers.texi
1 @c -*-texinfo-*-
2 @c This is part of the GNU Emacs Lisp Reference Manual.
3 @c Copyright (C) 1990-1995, 1998-1999, 2001-2016 Free Software
4 @c Foundation, Inc.
5 @c See the file elisp.texi for copying conditions.
6 @node Markers
7 @chapter Markers
8 @cindex markers
9
10 A @dfn{marker} is a Lisp object used to specify a position in a buffer
11 relative to the surrounding text. A marker changes its offset from the
12 beginning of the buffer automatically whenever text is inserted or
13 deleted, so that it stays with the two characters on either side of it.
14
15 @menu
16 * Overview of Markers:: The components of a marker, and how it relocates.
17 * Predicates on Markers:: Testing whether an object is a marker.
18 * Creating Markers:: Making empty markers or markers at certain places.
19 * Information from Markers:: Finding the marker's buffer or character position.
20 * Marker Insertion Types:: Two ways a marker can relocate when you
21 insert where it points.
22 * Moving Markers:: Moving the marker to a new buffer or position.
23 * The Mark:: How the mark is implemented with a marker.
24 * The Region:: How to access the region.
25 @end menu
26
27 @node Overview of Markers
28 @section Overview of Markers
29
30 A marker specifies a buffer and a position in that buffer. A
31 marker can be used to represent a position in functions that
32 require one, just as an integer could be used. In that case, the
33 marker's buffer is normally ignored. Of course, a marker used in this
34 way usually points to a position in the buffer that the function
35 operates on, but that is entirely the programmer's responsibility.
36 @xref{Positions}, for a complete description of positions.
37
38 A marker has three attributes: the marker position, the marker
39 buffer, and the insertion type. The marker position is an integer
40 that is equivalent (at a given time) to the marker as a position in
41 that buffer. But the marker's position value can change during
42 the life of the marker, and often does. Insertion and deletion of
43 text in the buffer relocate the marker. The idea is that a marker
44 positioned between two characters remains between those two characters
45 despite insertion and deletion elsewhere in the buffer. Relocation
46 changes the integer equivalent of the marker.
47
48 @cindex marker relocation
49 Deleting text around a marker's position leaves the marker between the
50 characters immediately before and after the deleted text. Inserting
51 text at the position of a marker normally leaves the marker either in
52 front of or after the new text, depending on the marker's @dfn{insertion
53 type} (@pxref{Marker Insertion Types})---unless the insertion is done
54 with @code{insert-before-markers} (@pxref{Insertion}).
55
56 @cindex marker garbage collection
57 Insertion and deletion in a buffer must check all the markers and
58 relocate them if necessary. This slows processing in a buffer with a
59 large number of markers. For this reason, it is a good idea to make a
60 marker point nowhere if you are sure you don't need it any more.
61 Markers that can no longer be accessed are eventually removed
62 (@pxref{Garbage Collection}).
63
64 @cindex markers as numbers
65 Because it is common to perform arithmetic operations on a marker
66 position, most of these operations (including @code{+} and
67 @code{-}) accept markers as arguments. In such cases, the marker
68 stands for its current position.
69
70 Here are examples of creating markers, setting markers, and moving point
71 to markers:
72
73 @example
74 @group
75 ;; @r{Make a new marker that initially does not point anywhere:}
76 (setq m1 (make-marker))
77 @result{} #<marker in no buffer>
78 @end group
79
80 @group
81 ;; @r{Set @code{m1} to point between the 99th and 100th characters}
82 ;; @r{in the current buffer:}
83 (set-marker m1 100)
84 @result{} #<marker at 100 in markers.texi>
85 @end group
86
87 @group
88 ;; @r{Now insert one character at the beginning of the buffer:}
89 (goto-char (point-min))
90 @result{} 1
91 (insert "Q")
92 @result{} nil
93 @end group
94
95 @group
96 ;; @r{@code{m1} is updated appropriately.}
97 m1
98 @result{} #<marker at 101 in markers.texi>
99 @end group
100
101 @group
102 ;; @r{Two markers that point to the same position}
103 ;; @r{are not @code{eq}, but they are @code{equal}.}
104 (setq m2 (copy-marker m1))
105 @result{} #<marker at 101 in markers.texi>
106 (eq m1 m2)
107 @result{} nil
108 (equal m1 m2)
109 @result{} t
110 @end group
111
112 @group
113 ;; @r{When you are finished using a marker, make it point nowhere.}
114 (set-marker m1 nil)
115 @result{} #<marker in no buffer>
116 @end group
117 @end example
118
119 @node Predicates on Markers
120 @section Predicates on Markers
121 @cindex predicates for markers
122 @cindex markers, predicates for
123
124 You can test an object to see whether it is a marker, or whether it is
125 either an integer or a marker. The latter test is useful in connection
126 with the arithmetic functions that work with both markers and integers.
127
128 @defun markerp object
129 This function returns @code{t} if @var{object} is a marker, @code{nil}
130 otherwise. Note that integers are not markers, even though many
131 functions will accept either a marker or an integer.
132 @end defun
133
134 @defun integer-or-marker-p object
135 This function returns @code{t} if @var{object} is an integer or a marker,
136 @code{nil} otherwise.
137 @end defun
138
139 @defun number-or-marker-p object
140 This function returns @code{t} if @var{object} is a number (either
141 integer or floating point) or a marker, @code{nil} otherwise.
142 @end defun
143
144 @node Creating Markers
145 @section Functions that Create Markers
146 @cindex creating markers
147 @cindex marker creation
148
149 When you create a new marker, you can make it point nowhere, or point
150 to the present position of point, or to the beginning or end of the
151 accessible portion of the buffer, or to the same place as another given
152 marker.
153
154 The next four functions all return markers with insertion type
155 @code{nil}. @xref{Marker Insertion Types}.
156
157 @defun make-marker
158 This function returns a newly created marker that does not point
159 anywhere.
160
161 @example
162 @group
163 (make-marker)
164 @result{} #<marker in no buffer>
165 @end group
166 @end example
167 @end defun
168
169 @defun point-marker
170 This function returns a new marker that points to the present position
171 of point in the current buffer. @xref{Point}. For an example, see
172 @code{copy-marker}, below.
173 @end defun
174
175 @defun point-min-marker
176 This function returns a new marker that points to the beginning of the
177 accessible portion of the buffer. This will be the beginning of the
178 buffer unless narrowing is in effect. @xref{Narrowing}.
179 @end defun
180
181 @defun point-max-marker
182 This function returns a new marker that points to the end of the
183 accessible portion of the buffer. This will be the end of the buffer
184 unless narrowing is in effect. @xref{Narrowing}.
185
186 Here are examples of this function and @code{point-min-marker}, shown in
187 a buffer containing a version of the source file for the text of this
188 chapter.
189
190 @example
191 @group
192 (point-min-marker)
193 @result{} #<marker at 1 in markers.texi>
194 (point-max-marker)
195 @result{} #<marker at 24080 in markers.texi>
196 @end group
197
198 @group
199 (narrow-to-region 100 200)
200 @result{} nil
201 @end group
202 @group
203 (point-min-marker)
204 @result{} #<marker at 100 in markers.texi>
205 @end group
206 @group
207 (point-max-marker)
208 @result{} #<marker at 200 in markers.texi>
209 @end group
210 @end example
211 @end defun
212
213 @defun copy-marker &optional marker-or-integer insertion-type
214 If passed a marker as its argument, @code{copy-marker} returns a
215 new marker that points to the same place and the same buffer as does
216 @var{marker-or-integer}. If passed an integer as its argument,
217 @code{copy-marker} returns a new marker that points to position
218 @var{marker-or-integer} in the current buffer.
219
220 The new marker's insertion type is specified by the argument
221 @var{insertion-type}. @xref{Marker Insertion Types}.
222
223 @c This behavior used to be documented until 2013/08.
224 @ignore
225 If passed an integer argument less than 1, @code{copy-marker} returns a
226 new marker that points to the beginning of the current buffer. If
227 passed an integer argument greater than the length of the buffer,
228 @code{copy-marker} returns a new marker that points to the end of the
229 buffer.
230 @end ignore
231
232 @example
233 @group
234 (copy-marker 0)
235 @result{} #<marker at 1 in markers.texi>
236 @end group
237
238 @group
239 (copy-marker 90000)
240 @result{} #<marker at 24080 in markers.texi>
241 @end group
242 @end example
243
244 An error is signaled if @var{marker} is neither a marker nor an
245 integer.
246 @end defun
247
248 Two distinct markers are considered @code{equal} (even though not
249 @code{eq}) to each other if they have the same position and buffer, or
250 if they both point nowhere.
251
252 @example
253 @group
254 (setq p (point-marker))
255 @result{} #<marker at 2139 in markers.texi>
256 @end group
257
258 @group
259 (setq q (copy-marker p))
260 @result{} #<marker at 2139 in markers.texi>
261 @end group
262
263 @group
264 (eq p q)
265 @result{} nil
266 @end group
267
268 @group
269 (equal p q)
270 @result{} t
271 @end group
272 @end example
273
274 @node Information from Markers
275 @section Information from Markers
276 @cindex marker information
277
278 This section describes the functions for accessing the components of a
279 marker object.
280
281 @defun marker-position marker
282 This function returns the position that @var{marker} points to, or
283 @code{nil} if it points nowhere.
284 @end defun
285
286 @defun marker-buffer marker
287 This function returns the buffer that @var{marker} points into, or
288 @code{nil} if it points nowhere.
289
290 @c FIXME: The 'buffer' argument of 'set-marker' already defaults to
291 @c the current buffer, why use '(current-buffer)' explicitly here?
292 @example
293 @group
294 (setq m (make-marker))
295 @result{} #<marker in no buffer>
296 @end group
297 @group
298 (marker-position m)
299 @result{} nil
300 @end group
301 @group
302 (marker-buffer m)
303 @result{} nil
304 @end group
305
306 @group
307 (set-marker m 3770 (current-buffer))
308 @result{} #<marker at 3770 in markers.texi>
309 @end group
310 @group
311 (marker-buffer m)
312 @result{} #<buffer markers.texi>
313 @end group
314 @group
315 (marker-position m)
316 @result{} 3770
317 @end group
318 @end example
319 @end defun
320
321 @node Marker Insertion Types
322 @section Marker Insertion Types
323
324 @cindex insertion type of a marker
325 When you insert text directly at the place where a marker points,
326 there are two possible ways to relocate that marker: it can point before
327 the inserted text, or point after it. You can specify which one a given
328 marker should do by setting its @dfn{insertion type}. Note that use of
329 @code{insert-before-markers} ignores markers' insertion types, always
330 relocating a marker to point after the inserted text.
331
332 @defun set-marker-insertion-type marker type
333 This function sets the insertion type of marker @var{marker} to
334 @var{type}. If @var{type} is @code{t}, @var{marker} will advance when
335 text is inserted at its position. If @var{type} is @code{nil},
336 @var{marker} does not advance when text is inserted there.
337 @end defun
338
339 @defun marker-insertion-type marker
340 This function reports the current insertion type of @var{marker}.
341 @end defun
342
343 Most functions that create markers, without an argument allowing to
344 specify the insertion type, create them with insertion type
345 @code{nil}. Also, the mark has, by default, insertion type
346 @code{nil}.
347
348 @node Moving Markers
349 @section Moving Marker Positions
350 @cindex moving markers
351 @cindex marker, how to move position
352
353 This section describes how to change the position of an existing
354 marker. When you do this, be sure you know whether the marker is used
355 outside of your program, and, if so, what effects will result from
356 moving it---otherwise, confusing things may happen in other parts of
357 Emacs.
358
359 @defun set-marker marker position &optional buffer
360 This function moves @var{marker} to @var{position}
361 in @var{buffer}. If @var{buffer} is not provided, it defaults to
362 the current buffer.
363
364 @c This behavior used to be documented until 2013/08.
365 @ignore
366 If @var{position} is less than 1, @code{set-marker} moves @var{marker}
367 to the beginning of the buffer. If @var{position} is greater than the
368 size of the buffer (@pxref{Point}), @code{set-marker} moves marker to
369 the end of the buffer.
370 @end ignore
371 If @var{position} is @code{nil} or a marker that points nowhere, then
372 @var{marker} is set to point nowhere.
373
374 The value returned is @var{marker}.
375
376 @example
377 @group
378 (setq m (point-marker))
379 @result{} #<marker at 4714 in markers.texi>
380 @end group
381 @group
382 (set-marker m 55)
383 @result{} #<marker at 55 in markers.texi>
384 @end group
385 @group
386 (setq b (get-buffer "foo"))
387 @result{} #<buffer foo>
388 @end group
389 @group
390 (set-marker m 0 b)
391 @result{} #<marker at 1 in foo>
392 @end group
393 @end example
394 @end defun
395
396 @defun move-marker marker position &optional buffer
397 This is another name for @code{set-marker}.
398 @end defun
399
400 @node The Mark
401 @section The Mark
402 @cindex mark, the
403 @c @cindex the mark?
404
405 Each buffer has a special marker, which is designated @dfn{the
406 mark}. When a buffer is newly created, this marker exists but does
407 not point anywhere; this means that the mark doesn't exist in that
408 buffer yet. Subsequent commands can set the mark.
409
410 The mark specifies a position to bound a range of text for many
411 commands, such as @code{kill-region} and @code{indent-rigidly}. These
412 commands typically act on the text between point and the mark, which
413 is called the @dfn{region}. If you are writing a command that
414 operates on the region, don't examine the mark directly; instead, use
415 @code{interactive} with the @samp{r} specification. This provides the
416 values of point and the mark as arguments to the command in an
417 interactive call, but permits other Lisp programs to specify arguments
418 explicitly. @xref{Interactive Codes}.
419
420 Some commands set the mark as a side-effect. Commands should do
421 this only if it has a potential use to the user, and never for their
422 own internal purposes. For example, the @code{replace-regexp} command
423 sets the mark to the value of point before doing any replacements,
424 because this enables the user to move back there conveniently after
425 the replace is finished.
426
427 Once the mark exists in a buffer, it normally never ceases to
428 exist. However, it may become @dfn{inactive}, if Transient Mark mode
429 is enabled. The buffer-local variable @code{mark-active}, if
430 non-@code{nil}, means that the mark is active. A command can call the
431 function @code{deactivate-mark} to deactivate the mark directly, or it
432 can request deactivation of the mark upon return to the editor command
433 loop by setting the variable @code{deactivate-mark} to a
434 non-@code{nil} value.
435
436 If Transient Mark mode is enabled, certain editing commands that
437 normally apply to text near point, apply instead to the region when
438 the mark is active. This is the main motivation for using Transient
439 Mark mode. (Another is that this enables highlighting of the region
440 when the mark is active. @xref{Display}.)
441
442 @cindex mark ring
443 In addition to the mark, each buffer has a @dfn{mark ring} which is a
444 list of markers containing previous values of the mark. When editing
445 commands change the mark, they should normally save the old value of the
446 mark on the mark ring. The variable @code{mark-ring-max} specifies the
447 maximum number of entries in the mark ring; once the list becomes this
448 long, adding a new element deletes the last element.
449
450 There is also a separate global mark ring, but that is used only in a
451 few particular user-level commands, and is not relevant to Lisp
452 programming. So we do not describe it here.
453
454 @defun mark &optional force
455 @cindex current buffer mark
456 This function returns the current buffer's mark position as an integer,
457 or @code{nil} if no mark has ever been set in this buffer.
458
459 If Transient Mark mode is enabled, and @code{mark-even-if-inactive} is
460 @code{nil}, @code{mark} signals an error if the mark is inactive.
461 However, if @var{force} is non-@code{nil}, then @code{mark} disregards
462 inactivity of the mark, and returns the mark position (or @code{nil})
463 anyway.
464 @end defun
465
466 @defun mark-marker
467 This function returns the marker that represents the current buffer's
468 mark. It is not a copy, it is the marker used internally. Therefore,
469 changing this marker's position will directly affect the buffer's
470 mark. Don't do that unless that is the effect you want.
471
472 @example
473 @group
474 (setq m (mark-marker))
475 @result{} #<marker at 3420 in markers.texi>
476 @end group
477 @group
478 (set-marker m 100)
479 @result{} #<marker at 100 in markers.texi>
480 @end group
481 @group
482 (mark-marker)
483 @result{} #<marker at 100 in markers.texi>
484 @end group
485 @end example
486
487 Like any marker, this marker can be set to point at any buffer you
488 like. If you make it point at any buffer other than the one of which
489 it is the mark, it will yield perfectly consistent, but rather odd,
490 results. We recommend that you not do it!
491 @end defun
492
493 @defun set-mark position
494 This function sets the mark to @var{position}, and activates the mark.
495 The old value of the mark is @emph{not} pushed onto the mark ring.
496
497 @strong{Please note:} Use this function only if you want the user to
498 see that the mark has moved, and you want the previous mark position to
499 be lost. Normally, when a new mark is set, the old one should go on the
500 @code{mark-ring}. For this reason, most applications should use
501 @code{push-mark} and @code{pop-mark}, not @code{set-mark}.
502
503 Novice Emacs Lisp programmers often try to use the mark for the wrong
504 purposes. The mark saves a location for the user's convenience. An
505 editing command should not alter the mark unless altering the mark is
506 part of the user-level functionality of the command. (And, in that
507 case, this effect should be documented.) To remember a location for
508 internal use in the Lisp program, store it in a Lisp variable. For
509 example:
510
511 @example
512 @group
513 (let ((beg (point)))
514 (forward-line 1)
515 (delete-region beg (point))).
516 @end group
517 @end example
518 @end defun
519
520 @defun push-mark &optional position nomsg activate
521 This function sets the current buffer's mark to @var{position}, and
522 pushes a copy of the previous mark onto @code{mark-ring}. If
523 @var{position} is @code{nil}, then the value of point is used.
524 @c Doesn't seem relevant.
525 @c @code{push-mark} returns @code{nil}.
526
527 The function @code{push-mark} normally @emph{does not} activate the
528 mark. To do that, specify @code{t} for the argument @var{activate}.
529
530 A @samp{Mark set} message is displayed unless @var{nomsg} is
531 non-@code{nil}.
532 @end defun
533
534 @defun pop-mark
535 This function pops off the top element of @code{mark-ring} and makes
536 that mark become the buffer's actual mark. This does not move point in
537 the buffer, and it does nothing if @code{mark-ring} is empty. It
538 deactivates the mark.
539 @c
540 @c Seems even less relevant.
541 @c The return value is not meaningful.
542 @end defun
543
544 @defopt transient-mark-mode
545 This variable, if non-@code{nil}, enables Transient Mark mode. In
546 Transient Mark mode, every buffer-modifying primitive sets
547 @code{deactivate-mark}. As a consequence, most commands that modify
548 the buffer also deactivate the mark.
549
550 When Transient Mark mode is enabled and the mark is active, many
551 commands that normally apply to the text near point instead apply to
552 the region. Such commands should use the function @code{use-region-p}
553 to test whether they should operate on the region. @xref{The Region}.
554
555 Lisp programs can set @code{transient-mark-mode} to non-@code{nil},
556 non-@code{t} values to enable Transient Mark mode temporarily. If the
557 value is @code{lambda}, Transient Mark mode is automatically turned
558 off after any action, such as buffer modification, that would normally
559 deactivate the mark. If the value is @w{@code{(only . @var{oldval})}},
560 then @code{transient-mark-mode} is set to the value @var{oldval} after
561 any subsequent command that moves point and is not shift-translated
562 (@pxref{Key Sequence Input, shift-translation}), or after any other
563 action that would normally deactivate the mark.
564 @end defopt
565
566 @defopt mark-even-if-inactive
567 If this is non-@code{nil}, Lisp programs and the Emacs user can use the
568 mark even when it is inactive. This option affects the behavior of
569 Transient Mark mode. When the option is non-@code{nil}, deactivation of
570 the mark turns off region highlighting, but commands that use the mark
571 behave as if the mark were still active.
572 @end defopt
573
574 @defvar deactivate-mark
575 If an editor command sets this variable non-@code{nil}, then the editor
576 command loop deactivates the mark after the command returns (if
577 Transient Mark mode is enabled). All the primitives that change the
578 buffer set @code{deactivate-mark}, to deactivate the mark when the
579 command is finished.
580
581 To write Lisp code that modifies the buffer without causing
582 deactivation of the mark at the end of the command, bind
583 @code{deactivate-mark} to @code{nil} around the code that does the
584 modification. For example:
585
586 @example
587 (let (deactivate-mark)
588 (insert " "))
589 @end example
590 @end defvar
591
592 @defun deactivate-mark &optional force
593 If Transient Mark mode is enabled or @var{force} is non-@code{nil},
594 this function deactivates the mark and runs the normal hook
595 @code{deactivate-mark-hook}. Otherwise, it does nothing.
596 @end defun
597
598 @defvar mark-active
599 The mark is active when this variable is non-@code{nil}. This
600 variable is always buffer-local in each buffer. Do @emph{not} use the
601 value of this variable to decide whether a command that normally
602 operates on text near point should operate on the region instead. Use
603 the function @code{use-region-p} for that (@pxref{The Region}).
604 @end defvar
605
606 @defvar activate-mark-hook
607 @defvarx deactivate-mark-hook
608 These normal hooks are run, respectively, when the mark becomes active
609 and when it becomes inactive. The hook @code{activate-mark-hook} is
610 also run at the end of the command loop if the mark is active and it
611 is possible that the region may have changed.
612 @ignore
613 This piece of command_loop_1, run unless deactivating the mark:
614 if (current_buffer != prev_buffer || MODIFF != prev_modiff)
615 {
616 Lisp_Object hook = intern ("activate-mark-hook");
617 Frun_hooks (1, &hook);
618 }
619 @end ignore
620 @end defvar
621
622 @defun handle-shift-selection
623 This function implements the shift-selection behavior of
624 point-motion commands. @xref{Shift Selection,,, emacs, The GNU Emacs
625 Manual}. It is called automatically by the Emacs command loop
626 whenever a command with a @samp{^} character in its @code{interactive}
627 spec is invoked, before the command itself is executed
628 (@pxref{Interactive Codes, ^}).
629
630 If @code{shift-select-mode} is non-@code{nil} and the current command
631 was invoked via shift translation (@pxref{Key Sequence Input,
632 shift-translation}), this function sets the mark and temporarily
633 activates the region, unless the region was already temporarily
634 activated in this way. Otherwise, if the region has been activated
635 temporarily, it deactivates the mark and restores the variable
636 @code{transient-mark-mode} to its earlier value.
637 @end defun
638
639 @defvar mark-ring
640 The value of this buffer-local variable is the list of saved former
641 marks of the current buffer, most recent first.
642
643 @example
644 @group
645 mark-ring
646 @result{} (#<marker at 11050 in markers.texi>
647 #<marker at 10832 in markers.texi>
648 @dots{})
649 @end group
650 @end example
651 @end defvar
652
653 @defopt mark-ring-max
654 The value of this variable is the maximum size of @code{mark-ring}. If
655 more marks than this are pushed onto the @code{mark-ring},
656 @code{push-mark} discards an old mark when it adds a new one.
657 @end defopt
658
659 @c There is also global-mark-ring-max, but this chapter explicitly
660 @c does not talk about the global mark.
661
662 @node The Region
663 @section The Region
664 @c The index entry must be just "region" to make it the first hit
665 @c when the user types "i region RET", because otherwise the Info
666 @c reader will present substring matches in alphabetical order,
667 @c putting this one near the end, with something utterly unrelated as
668 @c the first hit.
669 @cindex region
670
671 The text between point and the mark is known as @dfn{the region}.
672 Various functions operate on text delimited by point and the mark, but
673 only those functions specifically related to the region itself are
674 described here.
675
676 The next two functions signal an error if the mark does not point
677 anywhere. If Transient Mark mode is enabled and
678 @code{mark-even-if-inactive} is @code{nil}, they also signal an error
679 if the mark is inactive.
680
681 @defun region-beginning
682 This function returns the position of the beginning of the region (as
683 an integer). This is the position of either point or the mark,
684 whichever is smaller.
685 @end defun
686
687 @defun region-end
688 This function returns the position of the end of the region (as an
689 integer). This is the position of either point or the mark, whichever is
690 larger.
691 @end defun
692
693 @c FIXME: Mention it in tips.texi?
694 Instead of using @code{region-beginning} and @code{region-end}, a
695 command designed to operate on a region should normally use
696 @code{interactive} with the @samp{r} specification to find the
697 beginning and end of the region. This lets other Lisp programs
698 specify the bounds explicitly as arguments. @xref{Interactive Codes}.
699
700 @defun use-region-p
701 This function returns @code{t} if Transient Mark mode is enabled, the
702 mark is active, and there is a valid region in the buffer. This
703 function is intended to be used by commands that operate on the
704 region, instead of on text near point, when the mark is active.
705
706 @cindex empty region
707 @vindex use-empty-active-region
708 A region is valid if it has a non-zero size, or if the user option
709 @code{use-empty-active-region} is non-@code{nil} (by default, it is
710 @code{nil}). The function @code{region-active-p} is similar to
711 @code{use-region-p}, but considers all regions as valid. In most
712 cases, you should not use @code{region-active-p}, since if the region
713 is empty it is often more appropriate to operate on point.
714 @end defun