1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892
|
@c -*-texinfo-*-
@c This is part of the GNU Emacs Lisp Reference Manual.
@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998 Free Software Foundation, Inc.
@c See the file elisp.texi for copying conditions.
@setfilename ../info/markers
@node Markers, Text, Positions, Top
@c @chapter Markers
@chapter $B%^!<%+(B
@c @cindex markers
@cindex $B%^!<%+(B
@c A @dfn{marker} is a Lisp object used to specify a position in a buffer
@c relative to the surrounding text. A marker changes its offset from the
@c beginning of the buffer automatically whenever text is inserted or
@c deleted, so that it stays with the two characters on either side of it.
@dfn{$B%^!<%+(B}$B!J(Bmarker$B!K$H$O!"%P%C%U%!Fb0LCV$r$=$l$r<h$j4,$/%F%-%9%H$r(B
$B4p=`$K;XDj$9$k$?$a$K;H$o$l$k(BLisp$B%*%V%8%'%/%H$G$9!#(B
$B%F%-%9%H$,A^F~$5$l$?$j:o=|$5$l$k$H!"(B
$B%P%C%U%!$N@hF,$+$i%^!<%+$^$G$N5wN%$O<+F0E*$KJQ99$5$l!"(B
$B%^!<%+$OF1$8A08e$NJ8;z$N$"$$$@$KN1$^$j$^$9!#(B
@menu
* Overview of Markers:: The components of a marker, and how it relocates.
* Predicates on Markers:: Testing whether an object is a marker.
* Creating Markers:: Making empty markers or markers at certain places.
* Information from Markers:: Finding the marker's buffer or character position.
* Marker Insertion Types:: Two ways a marker can relocate when you
insert where it points.
* Moving Markers:: Moving the marker to a new buffer or position.
* The Mark:: How ``the mark'' is implemented with a marker.
* The Region:: How to access ``the region''.
@end menu
@node Overview of Markers
@c @section Overview of Markers
@section $B%^!<%+$N35MW(B
@c A marker specifies a buffer and a position in that buffer. The marker
@c can be used to represent a position in the functions that require one,
@c just as an integer could be used. @xref{Positions}, for a complete
@c description of positions.
$B%^!<%+$O!"%P%C%U%!$H$=$N%P%C%U%!Fb$G$N0LCV$r;XDj$7$^$9!#(B
$B%^!<%+$O!"0LCV$rI,MW$H$9$k4X?t$KBP$7$F0LCV$rI=$9$b$N$H$7$F;H$($^$9!#(B
$B%P%C%U%!Fb$N0LCV$K$D$$$F>\$7$/$O(B@xref{Positions}$B!#(B
@c A marker has two attributes: the marker position, and the marker
@c buffer. The marker position is an integer that is equivalent (at a
@c given time) to the marker as a position in that buffer. But the
@c marker's position value can change often during the life of the marker.
@c Insertion and deletion of text in the buffer relocate the marker. The
@c idea is that a marker positioned between two characters remains between
@c those two characters despite insertion and deletion elsewhere in the
@c buffer. Relocation changes the integer equivalent of the marker.
$B%^!<%+$K$O(B2$B$D$NB0@-!"$D$^$j!"%^!<%+0LCV$H%^!<%+%P%C%U%!$,$"$j$^$9!#(B
$B%^!<%+0LCV$O!"Ev3:%P%C%U%!Fb$N0LCV$H$7$F$N%^!<%+$K(B
$B!J$=$N;~E@$G!KEy2A$J@0?t$G$9!#(B
$B$7$+$7!"%^!<%+$N@8B84|4VCf!"%^!<%+0LCV$NCM$O$7$P$7$PJQ2=$7$^$9!#(B
$B%P%C%U%!$K%F%-%9%H$rA^F~$7$?$j:o=|$9$k$H!"%^!<%+$O:FG[CV$5$l$^$9!#(B
$B$3$l$O!"%P%C%U%!$NG$0U$N2U=j$GA^F~$7$?$j:o=|$7$?$H$7$F$b!"(B
2$B$D$NJ8;z$N$"$$$@$KCV$+$l$?%^!<%+$,(B
$BF1$8J8;z$N$"$$$@$KN1$^$k$h$&$K$9$k$?$a$G$9!#(B
$B:FG[CV$K$h$C$F!"%^!<%+$KEy2A$J@0?t$OJQ$o$j$^$9!#(B
@c @cindex marker relocation
@cindex $B%^!<%+$N:FG[CV(B
@c Deleting text around a marker's position leaves the marker between the
@c characters immediately before and after the deleted text. Inserting
@c text at the position of a marker normally leaves the marker either in
@c front of or after the new text, depending on the marker's @dfn{insertion
@c type} (@pxref{Marker Insertion Types})---unless the insertion is done
@c with @code{insert-before-markers} (@pxref{Insertion}).
$B%^!<%+0LCV$N<~$j$N%F%-%9%H$r:o=|$9$k$H!"(B
$B:o=|$5$l$?%F%-%9%H$NA08e$NJ8;z$N$"$$$@$K%^!<%+$ON1$^$j$^$9!#(B
$B%^!<%+$N0LCV$K%F%-%9%H$rA^F~$9$k$H!"(B
@code{insert-before-markers}$B!J(B@pxref{Insertion}$B!K$GA^F~$7$J$$8B$j!"(B
$B%^!<%+$N(B@dfn{$BA^F~7?(B}$B!J(Binsertion type$B!K!J(B@pxref{Marker Insertion Types}$B!K$K(B
$B0MB8$7$F!"%^!<%+$OA^F~$5$l$?%F%-%9%H$N$^$($+$&$7$m$KN1$^$j$^$9!#(B
@c @cindex marker garbage collection
@cindex $B%^!<%+$N%,%Y%C%8%3%l%/%7%g%s(B
@c Insertion and deletion in a buffer must check all the markers and
@c relocate them if necessary. This slows processing in a buffer with a
@c large number of markers. For this reason, it is a good idea to make a
@c marker point nowhere if you are sure you don't need it any more.
@c Unreferenced markers are garbage collected eventually, but until then
@c will continue to use time if they do point somewhere.
$B%P%C%U%!$KBP$9$kA^F~$d:o=|$G$O!"(B
$B$9$Y$F$N%^!<%+$r8!::$7!"I,MW$J$i$P%^!<%+$r:FG[CV$9$kI,MW$,$"$j$^$9!#(B
$B%^!<%+$rB??tJz$($k%P%C%U%!$G$O!"$3$N$?$a$K=hM}$,CY$/$J$j$^$9!#(B
$B$=$N$?$a!"%^!<%+$,ITMW$G$"$k$H3N?.$7$?$H$-$K$O!"(B
$B%^!<%+$,$I$3$b;X$5$J$$$h$&$K$7$F$*$/$N$,$h$$$G$9!#(B
$B;2>H$5$l$F$$$J$$%^!<%+$O:G=*E*$K$O!J%,%Y%C%8%3%l%/%7%g%s$G!K2s<}$5$l$^$9$,!"(B
$B$=$l$^$G$O!"%^!<%+$,$I$3$+$r;X$7$F$$$k$H=hM};~4V$rO2Hq$7$^$9!#(B
@c @cindex markers as numbers
@cindex $B?t$H$7$F$N%^!<%+(B
@cindex $B%^!<%+!"?t(B
@c Because it is common to perform arithmetic operations on a marker
@c position, most of the arithmetic operations (including @code{+} and
@c @code{-}) accept markers as arguments. In such cases, the marker
@c stands for its current position.
$B%^!<%+0LCV$K$O$h$/;;=Q1i;;$r;\$9$N$G!"(B
$B!J(B@code{+}$B$d(B@code{-}$B$r4^$`!K$[$H$s$I$N;;=Q1i;;$O(B
$B0z?t$H$7$F%^!<%+$r<u$1IU$1$^$9!#(B
$B$=$N$h$&$J>l9g!"%^!<%+$O$=$N8=:_0LCV$rI=$7$^$9!#(B
@c Here are examples of creating markers, setting markers, and moving point
@c to markers:
$B%^!<%+$r:n$C$F0LCV$r@_Dj$7!"%]%$%s%H$r%^!<%+$X0\F0$9$kNc$r<($7$^$9!#(B
@example
@group
@c ;; @r{Make a new marker that initially does not point anywhere:}
;; @r{$B$I$3$b;X$7$F$$$J$$?7$7$$%^!<%+$r:n$k(B}
(setq m1 (make-marker))
@result{} #<marker in no buffer>
@end group
@group
@c ;; @r{Set @code{m1} to point between the 99th and 100th characters}
@c ;; @r{in the current buffer:}
;; @r{$B%^!<%+(Bm1$B$N0LCV$r%+%l%s%H%P%C%U%!$N(B}
;; @r{99$BHVL\$H(B100$BHVL\$NJ8;z$N$"$$$@$K$9$k(B}
(set-marker m1 100)
@result{} #<marker at 100 in markers.texi>
@end group
@group
@c ;; @r{Now insert one character at the beginning of the buffer:}
;; @r{$B%P%C%U%!$N@hF,$K(B1$BJ8;zA^F~$9$k(B}
(goto-char (point-min))
@result{} 1
(insert "Q")
@result{} nil
@end group
@group
@c ;; @r{@code{m1} is updated appropriately.}
;; @r{$B$=$l$K$7$?$,$C$F(B@code{m1}$B$,99?7$5$l$k(B}
m1
@result{} #<marker at 101 in markers.texi>
@end group
@group
@c ;; @r{Two markers that point to the same position}
@c ;; @r{are not @code{eq}, but they are @code{equal}.}
;; @r{$BF1$80LCV$r;X$9(B2$B$D$N%^!<%+$O(B@code{eq}$B$G$O$J$$$,(B}
;; @r{@code{equal}$B$G$"$k(B}
(setq m2 (copy-marker m1))
@result{} #<marker at 101 in markers.texi>
(eq m1 m2)
@result{} nil
(equal m1 m2)
@result{} t
@end group
@group
@c ;; @r{When you are finished using a marker, make it point nowhere.}
;; @r{$B%^!<%+$r;H$$=*$C$?$i!"$I$3$b;X$7$F$$$J$$$h$&$K$9$k(B}
(set-marker m1 nil)
@result{} #<marker in no buffer>
@end group
@end example
@node Predicates on Markers
@c @section Predicates on Markers
@section $B%^!<%+8~$1$N=R8l(B
@c You can test an object to see whether it is a marker, or whether it is
@c either an integer or a marker. The latter test is useful in connection
@c with the arithmetic functions that work with both markers and integers.
$B%*%V%8%'%/%H$,%^!<%+$G$"$k$+$I$&$+$d!"(B
$B%*%V%8%'%/%H$,@0?t$+%^!<%+$G$"$k$+$I$&$+$r8!::$G$-$^$9!#(B
$B%^!<%+$H@0?t$NN><T$r07$&;;=Q4X?t$K4XO"$7$F!"(B
$B8e<T$N8!::$OM-MQ$G$9!#(B
@defun markerp object
@c This function returns @code{t} if @var{object} is a marker, @code{nil}
@c otherwise. Note that integers are not markers, even though many
@c functions will accept either a marker or an integer.
$B$3$N4X?t$O!"(B@var{object}$B$,%^!<%+$G$"$l$P(B@code{t}$B$rJV$7!"(B
$B$5$b$J$1$l$P(B@code{nil}$B$rJV$9!#(B
$BB?$/$N4X?t$,%^!<%+$d@0?t$r<u$1IU$1$k$,!"(B
$B@0?t$O%^!<%+$G$O$J$$$3$H$KCm0U$9$k$3$H!#(B
@end defun
@defun integer-or-marker-p object
@c This function returns @code{t} if @var{object} is an integer or a marker,
@c @code{nil} otherwise.
$B$3$N4X?t$O!"(B@var{object}$B$,@0?t$+%^!<%+$G$"$k$H(B@code{t}$B$rJV$7!"(B
$B$5$b$J$1$l$P(B@code{nil}$B$rJV$9!#(B
@end defun
@defun number-or-marker-p object
@c This function returns @code{t} if @var{object} is a number (either
@c integer or floating point) or a marker, @code{nil} otherwise.
$B$3$N4X?t$O!"(B@var{object}$B$,?t!J@0?t$+IbF0>.?tE@?t!K$+%^!<%+$G$"$k$H(B
@code{t}$B$rJV$7!"$5$b$J$1$l$P(B@code{nil}$B$rJV$9!#(B
@end defun
@node Creating Markers
@c @section Functions That Create Markers
@section $B%^!<%+:n@.4X?t(B
@c When you create a new marker, you can make it point nowhere, or point
@c to the present position of point, or to the beginning or end of the
@c accessible portion of the buffer, or to the same place as another given
@c marker.
$B?7$?$K%^!<%+$r:n@.$9$k$H$-$K$O!"$=$N%^!<%+$,!"(B
$B$I$3$b;X$7$F$$$J$$!"8=:_$N%]%$%s%H0LCV$r;X$7$F$$$k!"(B
$B%P%C%U%!$N;2>H2DG=ItJ,$N@hF,$dKvHx$r;X$7$F$$$k!"(B
$BJL$N%^!<%+$HF1$82U=j$r;X$7$F$$$k$N$$$:$l$+$K$G$-$^$9!#(B
@defun make-marker
@c This function returns a newly created marker that does not point
@c anywhere.
$B$3$N4X?t$O!"$I$3$b;X$7$F$$$J$$?7$?$K:n@.$7$?%^!<%+$rJV$9!#(B
@example
@group
(make-marker)
@result{} #<marker in no buffer>
@end group
@end example
@end defun
@defun point-marker
@c This function returns a new marker that points to the present position
@c of point in the current buffer. @xref{Point}. For an example, see
@c @code{copy-marker}, below.
$B$3$N4X?t$O!"%+%l%s%H%P%C%U%!$N8=:_$N%]%$%s%H0LCV$r(B
$B;X$9?7$?$K:n@.$7$?%^!<%+$rJV$9!#(B
@pxref{Point}$B!#(B
$BNc$K$D$$$F$O!"2<5-$N(B@code{copy-marker}$B$r;2>H!#(B
@end defun
@defun point-min-marker
@c This function returns a new marker that points to the beginning of the
@c accessible portion of the buffer. This will be the beginning of the
@c buffer unless narrowing is in effect. @xref{Narrowing}.
$B$3$N4X?t$O!"%P%C%U%!$N;2>H2DG=ItJ,$N@hF,$r;X$9?7$?$K:n@.$7$?%^!<%+$rJV$9!#(B
$B%J%m%$%s%0$7$F$$$J$1$l$P!"$3$l$O%P%C%U%!$N@hF,$G$"$k!#(B
@pxref{Narrowing}$B!#(B
@end defun
@defun point-max-marker
@c @cindex end of buffer marker
@cindex $B%P%C%U%!$NKvHx$N%^!<%+(B
@c This function returns a new marker that points to the end of the
@c accessible portion of the buffer. This will be the end of the buffer
@c unless narrowing is in effect. @xref{Narrowing}.
$B$3$N4X?t$O!"%P%C%U%!$N;2>H2DG=ItJ,$NKvHx$r;X$9?7$?$K:n@.$7$?%^!<%+$rJV$9!#(B
$B%J%m%$%s%0$7$F$$$J$1$l$P!"$3$l$O%P%C%U%!$NKvHx$G$"$k!#(B
@pxref{Narrowing}$B!#(B
@c Here are examples of this function and @code{point-min-marker}, shown in
@c a buffer containing a version of the source file for the text of this
@c chapter.
$BK\>O$N%=!<%9%U%!%$%k!J$N86J8!K$rF~$l$?%P%C%U%!$G$N(B
$B$3$N4X?t$H(B@code{point-min-marker}$B$NNc$r<($9!#(B
@example
@group
(point-min-marker)
@result{} #<marker at 1 in markers.texi>
(point-max-marker)
@result{} #<marker at 15573 in markers.texi>
@end group
@group
(narrow-to-region 100 200)
@result{} nil
@end group
@group
(point-min-marker)
@result{} #<marker at 100 in markers.texi>
@end group
@group
(point-max-marker)
@result{} #<marker at 200 in markers.texi>
@end group
@end example
@end defun
@c @defun copy-marker marker-or-integer insertion-type
@c = $B8m?"(B ^ &optional
@defun copy-marker marker-or-integer &optional insertion-type
@c If passed a marker as its argument, @code{copy-marker} returns a
@c new marker that points to the same place and the same buffer as does
@c @var{marker-or-integer}. If passed an integer as its argument,
@c @code{copy-marker} returns a new marker that points to position
@c @var{marker-or-integer} in the current buffer.
$B0z?t$H$7$F%^!<%+$rEO$5$l$k$H!"(B@code{copy-marker}$B$O!"(B
@var{marker-or-integer}$B$,;X$9$N$HF1$8(B
$B%P%C%U%!$H%P%C%U%!Fb0LCV$r;X$9?7$?$J%^!<%+$rJV$9!#(B
$B0z?t$H$7$F@0?t$rEO$5$l$k$H!"(B@code{copy-marker}$B$O!"(B
$B%+%l%s%H%P%C%U%!$G0LCV(B@var{marker-or-integer}$B$r;X$9?7$?$J%^!<%+$rJV$9!#(B
@c The new marker's insertion type is specified by the argument
@c @var{insertion-type}. @xref{Marker Insertion Types}.
$B?7$?$J%^!<%+$NA^F~7?$O0z?t(B@var{insertion-type}$B$G;XDj$9$k!#(B
@pxref{Marker Insertion Types}$B!#(B
@c If passed an integer argument less than 1, @code{copy-marker} returns a
@c new marker that points to the beginning of the current buffer. If
@c passed an integer argument greater than the length of the buffer,
@c @code{copy-marker} returns a new marker that points to the end of the
@c buffer.
$BEO$5$l$?@0?t0z?t$,(B1$BL$K~$G$"$k$H!"(B@code{copy-marker}$B$O!"(B
$B%+%l%s%H%P%C%U%!$G%P%C%U%!$N@hF,$r;X$9?7$?$J%^!<%+$rJV$9!#(B
$BEO$5$l$?@0?t0z?t$,%P%C%U%!$ND9$5$h$jBg$-$$$H!"(B@code{copy-marker}$B$O!"(B
$B%P%C%U%!$NKvHx$r;X$9?7$?$J%^!<%+$rJV$9!#(B
@example
@group
(copy-marker 0)
@result{} #<marker at 1 in markers.texi>
@end group
@group
(copy-marker 20000)
@result{} #<marker at 7572 in markers.texi>
@end group
@end example
@c An error is signaled if @var{marker} is neither a marker nor an
@c = $B8m?"(B @var{marker-or-integer}
@c integer.
@var{marker-or-integer}$B$,%^!<%+$G$b@0?t$G$b$J$$$H!"%(%i!<$rDLCN$9$k!#(B
@end defun
@c Two distinct markers are considered @code{equal} (even though not
@c @code{eq}) to each other if they have the same position and buffer, or
@c if they both point nowhere.
2$B$D$N0[$J$k%^!<%+$,!"F1$8%P%C%U%!$NF1$8%P%C%U%!Fb0LCV$G$"$k$+!"(B
$B$I$A$i$b$I$3$b;X$7$F$$$J$$$H$-$K$O!"(B
$BN><T$r!J(B@code{eq}$B$G$O$J$$$,!K(B@code{equal}$B$H$_$J$7$^$9!#(B
@example
@group
(setq p (point-marker))
@result{} #<marker at 2139 in markers.texi>
@end group
@group
(setq q (copy-marker p))
@result{} #<marker at 2139 in markers.texi>
@end group
@group
(eq p q)
@result{} nil
@end group
@group
(equal p q)
@result{} t
@end group
@end example
@node Information from Markers
@c @section Information from Markers
@section $B%^!<%+$N>pJs(B
@c This section describes the functions for accessing the components of a
@c marker object.
$BK\@a$G$O!"%^!<%+%*%V%8%'%/%H$N9=@.MWAG$r;2>H$9$k4X?t$K$D$$$F=R$Y$^$9!#(B
@defun marker-position marker
@c This function returns the position that @var{marker} points to, or
@c @code{nil} if it points nowhere.
$B$3$N4X?t$O!"(B@var{marker}$B$,;X$90LCV$rJV$9!#(B
$B$"$k$$$O!"(B@var{marker}$B$,$I$3$b;X$7$F$$$J$1$l$P(B@code{nil}$B$rJV$9!#(B
@end defun
@defun marker-buffer marker
@c This function returns the buffer that @var{marker} points into, or
@c @code{nil} if it points nowhere.
$B$3$N4X?t$O!"(B@var{marker}$B$,;X$9%P%C%U%!$rJV$9!#(B
$B$"$k$$$O!"(B@var{marker}$B$,$I$3$b;X$7$F$$$J$1$l$P(B@code{nil}$B$rJV$9!#(B
@example
@group
(setq m (make-marker))
@result{} #<marker in no buffer>
@end group
@group
(marker-position m)
@result{} nil
@end group
@group
(marker-buffer m)
@result{} nil
@end group
@group
(set-marker m 3770 (current-buffer))
@result{} #<marker at 3770 in markers.texi>
@end group
@group
(marker-buffer m)
@result{} #<buffer markers.texi>
@end group
@group
(marker-position m)
@result{} 3770
@end group
@end example
@end defun
@node Marker Insertion Types
@c @section Marker Insertion Types
@section $B%^!<%+$NA^F~7?(B
@c @cindex insertion type of a marker
@cindex $B%^!<%+$NA^F~7?(B
@c When you insert text directly at the place where a marker points,
@c there are two possible ways to relocate that marker: it can point before
@c the inserted text, or point after it. You can specify which one a given
@c marker should do by setting its @dfn{insertion type}. Note that use of
@c @code{insert-before-markers} ignores markers' insertion types, always
@c relocating a marker to point after the inserted text.
$B%^!<%+$,;X$92U=j$KD>@\%F%-%9%H$rA^F~$9$k$H!"(B
$B%^!<%+$N:FG[CVJ}K!$K$O(B2$B$D$N2DG=@-!"$D$^$j!"(B
$BA^F~$7$?%F%-%9%H$N$^$($KN1$^$k$+!"$"$H$K$/$k$+$N$I$A$i$+$G$9!#(B
$B%^!<%+$N(B@dfn{$BA^F~7?(B}$B!J(Binsertion type$B!K$r@_Dj$9$k$3$H$G!"(B
$B$"$k%^!<%+$G$O$I$A$i$rA*$V$+;XDj$G$-$^$9!#(B
@code{insert-before-markers}$B$r;H$&$H%^!<%+$NA^F~7?$OL5;k$5$l!"(B
$B%^!<%+$OA^F~$7$?%F%-%9%H$N$&$7$m$K$D$M$K:FG[CV$5$l$k$3$H$KCm0U$7$F$/$@$5$$!#(B
@defun set-marker-insertion-type marker type
@tindex set-marker-insertion-type
@c This function sets the insertion type of marker @var{marker} to
@c @var{type}. If @var{type} is @code{t}, @var{marker} will advance when
@c text is inserted at its position. If @var{type} is @code{nil},
@c @var{marker} does not advance when text is inserted there.
$B$3$N4X?t$O!"%^!<%+(B@var{marker}$B$NA^F~7?$r(B@var{type}$B$H$9$k!#(B
@var{type}$B$,(B@code{t}$B$G$"$k$H!"(B
$B%F%-%9%H$,A^F~$5$l$k$H(B@var{marker}$B$O$=$N0LCV$X?J$`!#(B
@var{type}$B$,(B@code{nil}$B$G$"$k$H!"(B
$B%F%-%9%H$,A^F~$5$l$F$b(B@var{marker}$B$O$=$N0LCV$X?J$^$J$$!#(B
@end defun
@defun marker-insertion-type marker
@tindex marker-insertion-type
@c This function reports the current insertion type of @var{marker}.
$B$3$N4X?t$O!"(B@var{marker}$B$N8=:_$NA^F~7?$rJs9p$9$k!#(B
@end defun
@node Moving Markers
@c @section Moving Marker Positions
@section $B%^!<%+0LCV$N0\F0(B
@c This section describes how to change the position of an existing
@c marker. When you do this, be sure you know whether the marker is used
@c outside of your program, and, if so, what effects will result from
@c moving it---otherwise, confusing things may happen in other parts of
@c Emacs.
$BK\@a$G$O!"4{B8$N%^!<%+$N0LCV$rJQ99$9$kJ}K!$K$D$$$F=R$Y$^$9!#(B
$B$3$l$r9T$&$H$-$K$O!"FI<T$N%W%m%0%i%`$N30B&$G(B
$BEv3:%^!<%+$,;H$o$l$F$$$k$+$I$&$+!"(B
$B;H$o$l$F$$$k$H$-$K$O0\F0$K$h$k8z2L$O$J$K$+$r3N<B$KM}2r$7$F$/$@$5$$!#(B
$B$5$b$J$$$H!"(BEmacs$B$NJL$NItJ,$G:.Mp$r@8$8$k$+$b$7$l$^$;$s!#(B
@defun set-marker marker position &optional buffer
@c This function moves @var{marker} to @var{position}
@c in @var{buffer}. If @var{buffer} is not provided, it defaults to
@c the current buffer.
$B$3$N4X?t$O!"(B@var{buffer}$B$K$*$$$F(B@var{marker}$B$r(B@var{position}$B$X0\F0$9$k!#(B
@var{buffer}$B$rM?$($J$$$H!"%G%U%)%k%H$O%+%l%s%H%P%C%U%!$G$"$k!#(B
@c If @var{position} is less than 1, @code{set-marker} moves @var{marker}
@c to the beginning of the buffer. If @var{position} is greater than the
@c size of the buffer, @code{set-marker} moves marker to the end of the
@c buffer. If @var{position} is @code{nil} or a marker that points
@c nowhere, then @var{marker} is set to point nowhere.
@var{position}$B$,(B1$BL$K~$G$"$k$H!"(B
@code{set-marker}$B$O(B@var{marker}$B$r%P%C%U%!$N@hF,$X0\F0$9$k!#(B
@var{position}$B$,%P%C%U%!$N%5%$%:$h$j$bBg$-$$$H!"(B
@code{set-marker}$B$O(B@var{marker}$B$r%P%C%U%!$NKvHx$X0\F0$9$k!#(B
@var{position}$B$,(B@code{nil}$B$G$"$C$?$j$I$3$b;X$7$F$$$J$$%^!<%+$G$"$k$H!"(B
@var{marker}$B$O$I$3$b;X$5$J$$$h$&$K$9$k!#(B
@c The value returned is @var{marker}.
$BLa$jCM$O(B@var{marker}$B$G$"$k!#(B
@example
@group
(setq m (point-marker))
@result{} #<marker at 4714 in markers.texi>
@end group
@group
(set-marker m 55)
@result{} #<marker at 55 in markers.texi>
@end group
@group
(setq b (get-buffer "foo"))
@result{} #<buffer foo>
@end group
@group
(set-marker m 0 b)
@result{} #<marker at 1 in foo>
@end group
@end example
@end defun
@defun move-marker marker position &optional buffer
@c This is another name for @code{set-marker}.
$B$3$l$O(B@code{set-marker}$B$NJLL>$G$"$k!#(B
@end defun
@node The Mark
@c @section The Mark
@section $B%^!<%/(B
@c @cindex mark, the
@c @cindex mark ring
@cindex $B%^!<%/(B
@cindex $B%^!<%/%j%s%0(B
@c One special marker in each buffer is designated @dfn{the mark}. It
@c records a position for the user for the sake of commands such as
@c @code{kill-region} and @code{indent-rigidly}. Lisp programs should set
@c the mark only to values that have a potential use to the user, and never
@c for their own internal purposes. For example, the @code{replace-regexp}
@c command sets the mark to the value of point before doing any
@c replacements, because this enables the user to move back there
@c conveniently after the replace is finished.
$B3F%P%C%U%!$N(B1$B$D$NFCJL$J%^!<%+$r(B@dfn{$B%^!<%/(B}$B!J(Bmark$B!K$H$7$F6hJL$7$^$9!#(B
$B$3$l$O!"(B@code{kill-region}$B$d(B@code{indent-rigidly}$B$J$I$N%3%^%s%I8~$1$K(B
$B%f!<%6!<$N$?$a$K0LCV$r5-O?$9$k$b$N$G$9!#(B
Lisp$B%W%m%0%i%`$G$O!"%f!<%6!<$,;H$&2DG=@-$N$"$kCM$@$1$r%^!<%/$K@_Dj$7!"(B
$B%W%m%0%i%`$NFbIt8~$1$K$O$1$C$7$F%^!<%/$r;H$$$^$;$s!#(B
$B$?$H$($P!"%3%^%s%I(B@code{replace-regexp}$B$O!"(B
$BCV49$r9T$&$^$($N%]%$%s%HCM$r%^!<%/$K@_Dj$7$^$9!#(B
$BCV49$r40N;$7$?$"$H$K!"%f!<%6!<$,<j7Z$K$^$($N0LCV$KLa$l$k$h$&$K$9$k$?$a$G$9!#(B
@c Many commands are designed so that when called interactively they
@c operate on the text between point and the mark. If you are writing such
@c a command, don't examine the mark directly; instead, use
@c @code{interactive} with the @samp{r} specification. This provides the
@c values of point and the mark as arguments to the command in an
@c interactive call, but permits other Lisp programs to specify arguments
@c explicitly. @xref{Interactive Codes}.
$BB?$/$N%3%^%s%I$O!"BPOCE*$K8F$P$l$k$H%]%$%s%H$H%^!<%/$N$"$$$@$N(B
$B%F%-%9%H$K:nMQ$9$k$h$&$K@_7W$5$l$F$$$^$9!#(B
$BFI<T$,$=$N$h$&$J%3%^%s%I$r=q$/$H$-$K$O!"(B
$B%^!<%/$rD>@\8!::$7$J$$$G$/$@$5$$!#(B
$B$=$N$+$o$j$K!"(B@samp{r}$B$r;XDj$7$?(B@code{interactive}$B$r;H$$$^$9!#(B
$B$3$&$9$k$H!"(B
$BBPOCE*$K8F$P$l$k$H%]%$%s%H$H%^!<%/$NCM$,%3%^%s%I$N0z?t$KM?$($i$l$^$9$,!"(B
$BJL$N(BLisp$B%W%m%0%i%`$+$i$O0z?t$rL@<($G$-$^$9!#(B
@xref{Interactive Codes}$B!#(B
@c Each buffer has its own value of the mark that is independent of the
@c value of the mark in other buffers. When a buffer is created, the mark
@c exists but does not point anywhere. We consider this state as ``the
@c absence of a mark in that buffer.''
$B3F%P%C%U%!$K$O!"B>$N%P%C%U%!$N%^!<%/$NCM$H$OFHN)$J(B
$BFH<+$N%^!<%/$NCM$,$"$j$^$9!#(B
$B%P%C%U%!$,:n@.$5$l$k$H!"%^!<%/$OB8:_$7$^$9$,$I$3$b;X$5$J$$>uBV$G$9!#(B
$B$3$l$r!X%P%C%U%!$N%^!<%/$O7gG!$7$F$$$k!Y>uBV$H$_$J$7$^$9!#(B
@c Once the mark ``exists'' in a buffer, it normally never ceases to
@c exist. However, it may become @dfn{inactive}, if Transient Mark mode is
@c enabled. The variable @code{mark-active}, which is always buffer-local
@c in all buffers, indicates whether the mark is active: non-@code{nil}
@c means yes. A command can request deactivation of the mark upon return
@c to the editor command loop by setting @code{deactivate-mark} to a
@c non-@code{nil} value (but this causes deactivation only if Transient
@c Mark mode is enabled).
$B%P%C%U%!$G$$$C$?$s%^!<%/$,!XB8:_!Y$9$k$h$&$K$J$l$P!"(B
$B%^!<%/$,B8:_$7$J$/$J$k$3$H$OIaDL$O$"$j$^$;$s!#(B
$B$7$+$7!";CDj%^!<%/!J(Btransient-mark$B!K%b!<%I$r%*%s$K$9$k$H!"(B
$B%^!<%/$,(B@dfn{$BIT3h@-(B}$B$K$J$k$3$H$O$"$j$^$9!#(B
$B$9$Y$F$N%P%C%U%!$G$D$M$K%P%C%U%!%m!<%+%k$JJQ?t(B@code{mark-active}$B$,(B
$B%^!<%/$,3h@-$+$I$&$+$rI=$7$^$9!#(B
$B$=$NCM$,(B@code{nil}$B0J30$G$"$k$H%^!<%/$O3h@-$G$9!#(B
$B%3%^%s%I$G(B@code{deactivate-mark}$B$K(B@code{nil}$B0J30$NCM$r@_Dj$9$k$H!"(B
$B%(%G%#%?%3%^%s%I%k!<%W$KLa$C$?$H$-$K%^!<%/$rIT3h@-$K$9$k$h$&$K$G$-$^$9(B
$B!J$?$@$7!";CDj%^!<%/!J(Btransient-mark$B!K%b!<%I$,%*%s$N>l9g$K8B$k!K!#(B
@c The main motivation for using Transient Mark mode is that this mode
@c also enables highlighting of the region when the mark is active.
@c @xref{Display}.
$B;CDj%^!<%/!J(Btransient-mark$B!K%b!<%I$r;H$&<g$JL\E*$O!"(B
$B%^!<%/$,3h@-$G$"$k$H$3$N%b!<%I$O%j!<%8%g%s$r6/D4I=<($9$k$+$i$G$9!#(B
@xref{Display}$B!#(B
@c In addition to the mark, each buffer has a @dfn{mark ring} which is a
@c list of markers containing previous values of the mark. When editing
@c commands change the mark, they should normally save the old value of the
@c mark on the mark ring. The variable @code{mark-ring-max} specifies the
@c maximum number of entries in the mark ring; once the list becomes this
@c long, adding a new element deletes the last element.
$B%^!<%/$K2C$($F!"3F%P%C%U%!$K$O(B@dfn{$B%^!<%/%j%s%0(B}$B!J(Bmark ring$B!K!"(B
$B$D$^$j!"%^!<%/$N0JA0$NCM$rJ];}$7$?%j%9%H$,$"$j$^$9!#(B
$BJT=8%3%^%s%I$,%^!<%/$rJQ99$9$k$H!"(B
$BDL>o!"JT=8%3%^%s%I$O%^!<%/$N8E$$CM$r%^!<%/%j%s%0$KJ]B8$7$^$9!#(B
$BJQ?t(B@code{mark-ring-max}$B$G!"%^!<%/%j%s%0$K<}$a$kMWAG$N:GBg8D?t$r;XDj$7$^$9!#(B
$B%j%9%H$,$3$ND9$5$KC#$9$k$H!"?7$?$JMWAG$r2C$($k$?$S$K8E$$MWAG$r:o=|$7$^$9!#(B
@defun mark &optional force
@c @cindex current buffer mark
@cindex $B%+%l%s%H%P%C%U%!$N%^!<%/(B
@c This function returns the current buffer's mark position as an integer.
$B$3$N4X?t$O!"%+%l%s%H%P%C%U%!$N%^!<%/0LCV$r@0?t$GJV$9!#(B
@c If the mark is inactive, @code{mark} normally signals an error.
@c However, if @var{force} is non-@code{nil}, then @code{mark} returns the
@c mark position anyway---or @code{nil}, if the mark is not yet set for
@c this buffer.
$B%^!<%/$,IT3h@-$G$"$k$H!"DL>o!"(B@code{mark}$B$O%(%i!<$rDLCN$9$k!#(B
$B$7$+$7!"(B@var{force}$B$,(B@code{nil}$B0J30$G$"$k$H(B@code{mark}$B$O%^!<%/0LCV$rJV$9$,!"(B
$BEv3:%P%C%U%!$G%^!<%/$,@_Dj$5$l$?$3$H$,$J$1$l$P(B@code{nil}$B$rJV$9!#(B
@end defun
@defun mark-marker
@c This function returns the current buffer's mark. This is the very marker
@c that records the mark location inside Emacs, not a copy. Therefore,
@c changing this marker's position will directly affect the position of the mark.
@c Don't do it unless that is the effect you want.
$B$3$N4X?t$O!"%+%l%s%H%P%C%U%!$N%^!<%/$rJV$9!#(B
$B$3$l$O!"(BEmacs$BFbIt$N%^!<%/0LCV$r5-O?$7$?%^!<%+$=$N$b$N$G$"$j!"%3%T!<$G$O$J$$!#(B
$B$7$?$,$C$F!"$3$N%^!<%+$N0LCV$rJQ99$9$k$H!"%^!<%/$N0LCV$KD>@\1F6A$9$k!#(B
$B$3$N8z2L$rK>$^$J$$8B$j!"$=$N$h$&$K$7$J$$$3$H!#(B
@example
@group
(setq m (mark-marker))
@result{} #<marker at 3420 in markers.texi>
@end group
@group
(set-marker m 100)
@result{} #<marker at 100 in markers.texi>
@end group
@group
(mark-marker)
@result{} #<marker at 100 in markers.texi>
@end group
@end example
@c Like any marker, this marker can be set to point at any buffer you like.
@c We don't recommend that you make it point at any buffer other than the
@c one of which it is the mark. If you do, it will yield perfectly
@c consistent, but rather odd, results.
$BB>$N%^!<%+$HF1MM$K!"$3$N%^!<%+$OG$0U$N%P%C%U%!$G%]%$%s%H$r;X$9$h$&$K$G$-$k!#(B
$B%^!<%/$,;X$7$F$$$k%P%C%U%!0J30$N%P%C%U%!Fb0LCV$r;X$9$3$H$O4+$a$J$$!#(B
$B$=$N$h$&$K$9$k$H!"0l4S@-$O$"$k$,L/$J7k2L$r@8$8$k!#(B
@end defun
@ignore
@c @deffn Command set-mark-command jump
@deffn $B%3%^%s%I(B set-mark-command jump
If @var{jump} is @code{nil}, this command sets the mark to the value
of point and pushes the previous value of the mark on the mark ring. The
message @samp{Mark set} is also displayed in the echo area.
If @var{jump} is not @code{nil}, this command sets point to the value
of the mark, and sets the mark to the previous saved mark value, which
is popped off the mark ring.
This function is @emph{only} intended for interactive use.
@end deffn
@end ignore
@defun set-mark position
@c This function sets the mark to @var{position}, and activates the mark.
@c The old value of the mark is @emph{not} pushed onto the mark ring.
$B$3$N4X?t$O!"0LCV(B@var{position}$B$K%^!<%/$r@_Dj$7!"%^!<%/$r3h@-$K$9$k!#(B
$B%^!<%/$N8E$$CM$O%^!<%/%j%s%0$KJ]B8$7(B@emph{$B$J$$(B}$B!#(B
@c @strong{Please note:} Use this function only if you want the user to
@c see that the mark has moved, and you want the previous mark position to
@c be lost. Normally, when a new mark is set, the old one should go on the
@c @code{mark-ring}. For this reason, most applications should use
@c @code{push-mark} and @code{pop-mark}, not @code{set-mark}.
@strong{$BCm0U!'(B}@code{ }$B%f!<%6!<$K%^!<%/$,0\F0$7$?$3$H$r<($7!"$+$D!"(B
$B$^$($N%^!<%/0LCV$rGK4~$7$?$$>l9g$K$N$_$3$N4X?t$r;H$&$3$H!#(B
$BDL>o!"?7$?$K%^!<%/$r@_Dj$7$?$H$-$K$O!"(B
$B8E$$%^!<%/$r(B@code{mark-ring}$B$KF~$l$k$Y$-$G$"$k!#(B
$B$3$NM}M3$+$i!"$[$H$s$I$N%"%W%j%1!<%7%g%s$G$O!"(B
@code{set-mark}$B$G$O$J$/(B@code{push-mark}$B$H(B@code{pop-mark}$B$r;H$&$Y$-$G$"$k!#(B
@c Novice Emacs Lisp programmers often try to use the mark for the wrong
@c purposes. The mark saves a location for the user's convenience. An
@c editing command should not alter the mark unless altering the mark is
@c part of the user-level functionality of the command. (And, in that
@c case, this effect should be documented.) To remember a location for
@c internal use in the Lisp program, store it in a Lisp variable. For
@c example:
Emacs Lisp$B$N=i?4<T%W%m%0%i%^$O!"8m$C$?L\E*$K%^!<%/$r;H$$$,$A$G$"$k!#(B
$B%^!<%/$O%f!<%6!<$NJX59$N$?$a$N0LCV$rJ]B8$9$k!#(B
$BJT=8%3%^%s%I$O!"(B
$B%3%^%s%I$N%f!<%6!<%l%Y%k$N5!G=$N0lIt$H$7$F%^!<%/$rJQ99$9$k0J30$K$O!"(B
$B%^!<%/$rJQ99$7$F$O$J$i$J$$!#(B
$B!JJQ99$9$k>l9g$K$O!"$=$N8z2L$rL@J82=$7$F$*$/$Y$-$G$"$k!#!K(B
Lisp$B%W%m%0%i%`$NFbIt$G;H$&0LCV$r5-O?$9$k$K$O!"(BLisp$BJQ?t$KJ]B8$9$k!#(B
$B$?$H$($P$D$.$N$h$&$K$9$k!#(B
@example
@group
(let ((beg (point)))
(forward-line 1)
(delete-region beg (point))).
@end group
@end example
@end defun
@c for interactive use only
@ignore
@deffn Command exchange-point-and-mark
This function exchanges the positions of point and the mark.
It is intended for interactive use.
@end deffn
@end ignore
@defun push-mark &optional position nomsg activate
@c This function sets the current buffer's mark to @var{position}, and
@c pushes a copy of the previous mark onto @code{mark-ring}. If
@c @var{position} is @code{nil}, then the value of point is used.
@c @code{push-mark} returns @code{nil}.
$B$3$N4X?t$O!"%+%l%s%H%P%C%U%!$N%^!<%/$r(B@var{position}$B$H$7!"(B
$B0JA0$N%^!<%/$N%3%T!<$r(B@code{mark-ring}$B$XF~$l$k!#(B
@var{position}$B$,(B@code{nil}$B$G$"$k$H!"%]%$%s%H$NCM$r;H$&!#(B
@code{push-mark}$B$O(B@code{nil}$B$rJV$9!#(B
@c The function @code{push-mark} normally @emph{does not} activate the
@c mark. To do that, specify @code{t} for the argument @var{activate}.
$B4X?t(B@code{push-mark}$B$O!"DL>o!"%^!<%/$r3h@-$K(B@emph{$B$7$J$$(B}$B!#(B
$B3h@-$K$9$k$K$O0z?t(B@var{activate}$B$K(B@code{t}$B$r;XDj$9$k!#(B
@c A @samp{Mark set} message is displayed unless @var{nomsg} is
@c non-@code{nil}.
@var{nomsg}$B$,(B@code{nil}$B$G$"$k$H!"%a%C%;!<%8(B@samp{Mark set}$B$rI=<($9$k!#(B
@end defun
@defun pop-mark
@c This function pops off the top element of @code{mark-ring} and makes
@c that mark become the buffer's actual mark. This does not move point in
@c the buffer, and it does nothing if @code{mark-ring} is empty. It
@c deactivates the mark.
$B$3$N4X?t$O!"(B@code{mark-ring}$B$+$i@hF,MWAG$r<h$j=P$7!"(B
$B$=$N%^!<%/$r%+%l%s%H%P%C%U%!$N<B:]$N%^!<%/$H$9$k!#(B
$B%P%C%U%!$N%]%$%s%H$O0\F0$7$J$$!#(B
$B$^$?!"(B@code{mark-ring}$B$,6u$G$"$k$H$J$K$b$7$J$$!#(B
$B%^!<%/$rIT3h@-$K$9$k!#(B
@c The return value is not meaningful.
$BLa$jCM$K0UL#$O$J$$!#(B
@end defun
@defopt transient-mark-mode
@c @cindex Transient Mark mode
@cindex $B;CDj%^!<%/!J(Btransient-mark$B!K%b!<%I(B
@c This variable if non-@code{nil} enables Transient Mark mode, in which
@c every buffer-modifying primitive sets @code{deactivate-mark}. The
@c consequence of this is that commands that modify the buffer normally
@c make the mark inactive.
$B$3$NJQ?t$,(B@code{nil}$B0J30$G$"$k$H(B
$B;CDj%^!<%/!J(Btransient-mark$B!K%b!<%I$,%*%s$G$"$k$,!"(B
$B%P%C%U%!$rJQ99$9$k3F4pK\4X?t$O(B@code{deactivate-mark}$B$K@_Dj$9$k!#(B
$B$D$^$j!"%P%C%U%!$rJQ99$9$k%3%^%s%I$O!"DL>o!"%^!<%/$rIT3h@-$K$9$k!#(B
@end defopt
@defopt mark-even-if-inactive
@c If this is non-@code{nil}, Lisp programs and the Emacs user can use the
@c mark even when it is inactive. This option affects the behavior of
@c Transient Mark mode. When the option is non-@code{nil}, deactivation of
@c the mark turns off region highlighting, but commands that use the mark
@c behave as if the mark were still active.
$B$3$l$,(B@code{nil}$B0J30$G$"$k$H!"(B
Lisp$B%W%m%0%i%`$d(BEmacs$B%f!<%6!<$O!"%^!<%/$,IT3h@-$G$"$C$F$b%^!<%/$r;H$($k!#(B
$B$3$N%*%W%7%g%s$O!";CDj%^!<%/!J(Btransient-mark$B!K%b!<%I$N$U$k$^$$$K1F6A$9$k!#(B
$B$3$N%*%W%7%g%s$,(B@code{nil}$B0J30$G$"$k$H!"(B
$B%^!<%/$,IT3h@-$K$J$k$H%j!<%8%g%s$N6/D4I=<($r;_$a$k$,!"(B
$B%^!<%/$r;H$&%3%^%s%I$O%^!<%/$,3h@-$G$"$k$b$N$H$7$FF0:n$9$k!#(B
@end defopt
@defvar deactivate-mark
@c If an editor command sets this variable non-@code{nil}, then the editor
@c command loop deactivates the mark after the command returns (if
@c Transient Mark mode is enabled). All the primitives that change the
@c buffer set @code{deactivate-mark}, to deactivate the mark when the
@c command is finished.
$BJT=8%3%^%s%I$,$3$NJQ?t$K(B@code{nil}$B0J30$r@_Dj$9$k$H!"(B
$B%(%G%#%?%3%^%s%I%k!<%W$O!J;CDj%^!<%/!J(Btransient-mark$B!K%b!<%I$,%*%s$G$"$k$H!K(B
$B%3%^%s%I$+$iLa$k$H%^!<%/$rIT3h@-$K$9$k!#(B
$B%3%^%s%I$,=*N;$7$?$i%^!<%/$rIT3h@-$K$9$k$?$a$K!"(B
$B%P%C%U%!$rJQ99$9$k$9$Y$F$N4pK\4X?t$O(B@code{deactivate-mark}$B$K@_Dj$9$k!#(B
@end defvar
@defun deactivate-mark
@c This function deactivates the mark, if Transient Mark mode is enabled.
@c Otherwise it does nothing.
$B$3$N4X?t$O!";CDj%^!<%/!J(Btransient-mark$B!K%b!<%I$,(B
$B%*%s$G$"$k$H%^!<%/$rIT3h@-$K$9$k!#(B
$B$5$b$J$1$l$P$J$K$b$7$J$$!#(B
@end defun
@defvar mark-active
@c The mark is active when this variable is non-@code{nil}. This variable
@c is always buffer-local in each buffer.
$B$3$NJQ?t$,(B@code{nil}$B0J30$G$"$k$H!"%^!<%/$O3h@-$G$"$k!#(B
$B$3$NJQ?t$O3F%P%C%U%!$K$*$$$F$D$M$K%P%C%U%!%m!<%+%k$G$"$k!#(B
@end defvar
@defvar activate-mark-hook
@defvarx deactivate-mark-hook
@c These normal hooks are run, respectively, when the mark becomes active
@c and when it becomes inactive. The hook @code{activate-mark-hook} is
@c also run at the end of a command if the mark is active and it is
@c possible that the region may have changed.
$B$3$l$i$N%N!<%^%k%U%C%/$O!"$=$l$>$l!"(B
$B%^!<%/$,3h@-$K$J$C$?$H$-!"IT3h@-$K$J$C$?$H$-$K<B9T$5$l$k!#(B
$B%^!<%/$,3h@-$G$"$j%j!<%8%g%s$,JQ99$5$l$?$H$-$K$O!"(B
$B%U%C%/(B@code{activate-mark-hook}$B$O%3%^%s%I$N=*$j$G$b<B9T$5$l$k!#(B
@end defvar
@defvar mark-ring
@c The value of this buffer-local variable is the list of saved former
@c marks of the current buffer, most recent first.
$B$3$N%P%C%U%!%m!<%+%k$JJQ?t$NCM$O!"(B
$B%+%l%s%H%P%C%U%!$GJ]B8$7$?%^!<%/$r:G?7$N$b$N$+$i=g$KJB$Y$?%j%9%H$G$"$k!#(B
@example
@group
mark-ring
@result{} (#<marker at 11050 in markers.texi>
#<marker at 10832 in markers.texi>
@dots{})
@end group
@end example
@end defvar
@defopt mark-ring-max
@c The value of this variable is the maximum size of @code{mark-ring}. If
@c more marks than this are pushed onto the @code{mark-ring},
@c @code{push-mark} discards an old mark when it adds a new one.
$B$3$NJQ?t$NCM$O!"(B@code{mark-ring}$B$N:GBg$NBg$-$5$G$"$k!#(B
$B$3$l$h$jB?$/$N%^!<%/$r(B@code{mark-ring}$B$K@Q$`$H!"(B
@code{push-mark}$B$O?7$7$$$b$N$rDI2C$9$k$H$-$K8E$$$b$N$r:o=|$9$k!#(B
@end defopt
@node The Region
@c @section The Region
@section $B%j!<%8%g%s(B
@c @cindex region, the
@cindex $B%j!<%8%g%s(B
@c The text between point and the mark is known as @dfn{the region}.
@c Various functions operate on text delimited by point and the mark, but
@c only those functions specifically related to the region itself are
@c described here.
$B%]%$%s%H$H%^!<%/$N$"$$$@$N%F%-%9%H$r(B@dfn{$B%j!<%8%g%s(B}$B!J(Bregion$B!K$H$$$$$^$9!#(B
$B$5$^$6$^$J4X?t$,%]%$%s%H$H%^!<%/$G6h@Z$i$l$?%F%-%9%H$K:nMQ$7$^$9$,!"(B
$B%j!<%8%g%s$=$N$b$N$KFC$K4XO"$7$?4X?t$@$1$K$D$$$F$3$3$G=R$Y$^$9!#(B
@defun region-beginning
@c This function returns the position of the beginning of the region (as
@c an integer). This is the position of either point or the mark,
@c whichever is smaller.
$B$3$N4X?t$O!"%j!<%8%g%s$N@hF,$N0LCV$r!J@0?t$G!KJV$9!#(B
$B$3$l$O!"%]%$%s%H$+%^!<%/$N>.$5$$$[$&$N0LCV$G$"$k!#(B
@c If the mark does not point anywhere, an error is signaled.
$B%^!<%/$,$I$3$b;X$7$F$$$J$1$l$P!"%(%i!<$rDLCN$9$k!#(B
@end defun
@defun region-end
@c This function returns the position of the end of the region (as an
@c integer). This is the position of either point or the mark, whichever is
@c larger.
$B$3$N4X?t$O!"%j!<%8%g%s$NKvHx$N0LCV$r!J@0?t$G!KJV$9!#(B
$B$3$l$O!"%]%$%s%H$+%^!<%/$NBg$-$$$[$&$N0LCV$G$"$k!#(B
@c If the mark does not point anywhere, an error is signaled.
$B%^!<%/$,$I$3$b;X$7$F$$$J$1$l$P!"%(%i!<$rDLCN$9$k!#(B
@end defun
@c Few programs need to use the @code{region-beginning} and
@c @code{region-end} functions. A command designed to operate on a region
@c should normally use @code{interactive} with the @samp{r} specification
@c to find the beginning and end of the region. This lets other Lisp
@c programs specify the bounds explicitly as arguments. (@xref{Interactive
@c Codes}.)
$B4X?t(B@code{region-beginning}$B$d(B@code{region-end}$B$r;H$&I,MW$,$"$k(B
$B%W%m%0%i%`$O$[$H$s$I$J$$$O$:$G$9!#(B
$B%j!<%8%g%s$K:nMQ$9$k$h$&$K@_7W$5$l$?%3%^%s%I$O!"(B
$BIaDL!"(B@samp{r}$B$r;XDj$7$?(B@code{interactive}$B$r;H$C$F(B
$B%j!<%8%g%s$N@hF,$HKvHx$r$_$D$1$^$9!#(B
$B$3$l$K$h$j!"(BLisp$B%W%m%0%i%`$+$i$O0z?t$H$7$F6-3&$rL@<(E*$K;XDj$G$-$^$9!#(B
$B!J(B@xref{Interactive Codes}$B!#!K(B
|