diff options
| -rw-r--r-- | lispref/text.texi | 200 |
1 files changed, 120 insertions, 80 deletions
diff --git a/lispref/text.texi b/lispref/text.texi index b6e477e6651..413c10e29c1 100644 --- a/lispref/text.texi +++ b/lispref/text.texi | |||
| @@ -58,7 +58,7 @@ the character after point. | |||
| 58 | position stored in a register. | 58 | position stored in a register. |
| 59 | * Base 64:: Conversion to or from base 64 encoding. | 59 | * Base 64:: Conversion to or from base 64 encoding. |
| 60 | * MD5 Checksum:: Compute the MD5 ``message digest''/``checksum''. | 60 | * MD5 Checksum:: Compute the MD5 ``message digest''/``checksum''. |
| 61 | * Atomic Changes:: Installing several buffer changs ``atomically''. | 61 | * Atomic Changes:: Installing several buffer changes ``atomically''. |
| 62 | * Change Hooks:: Supplying functions to be run when text is changed. | 62 | * Change Hooks:: Supplying functions to be run when text is changed. |
| 63 | @end menu | 63 | @end menu |
| 64 | 64 | ||
| @@ -69,6 +69,9 @@ the character after point. | |||
| 69 | Several simple functions are described here. See also @code{looking-at} | 69 | Several simple functions are described here. See also @code{looking-at} |
| 70 | in @ref{Regexp Search}. | 70 | in @ref{Regexp Search}. |
| 71 | 71 | ||
| 72 | In the following four functions, ``beginning'' or ``end'' of buffer | ||
| 73 | refers to the beginning or end of the accessible portion. | ||
| 74 | |||
| 72 | @defun char-after &optional position | 75 | @defun char-after &optional position |
| 73 | This function returns the character in the current buffer at (i.e., | 76 | This function returns the character in the current buffer at (i.e., |
| 74 | immediately after) position @var{position}. If @var{position} is out of | 77 | immediately after) position @var{position}. If @var{position} is out of |
| @@ -230,9 +233,9 @@ This is the contents of buffer foo | |||
| 230 | This function returns the symbol (or word) at or near point, as a string. | 233 | This function returns the symbol (or word) at or near point, as a string. |
| 231 | The return value includes no text properties. | 234 | The return value includes no text properties. |
| 232 | 235 | ||
| 233 | The optional argument @var{really-word} is non-@code{nil}, it finds a | 236 | If the optional argument @var{really-word} is non-@code{nil}, it finds a |
| 234 | word; otherwise, it finds a symbol (which includes word characters and | 237 | word; otherwise, it finds a symbol (which includes both word |
| 235 | both symbol constituent characters). | 238 | characters and symbol constituent characters). |
| 236 | 239 | ||
| 237 | If the optional argument @var{strict} is non-@code{nil}, then point | 240 | If the optional argument @var{strict} is non-@code{nil}, then point |
| 238 | must be in or next to the symbol or word---if no symbol or word is | 241 | must be in or next to the symbol or word---if no symbol or word is |
| @@ -273,10 +276,10 @@ copying them into strings first. | |||
| 273 | @defun compare-buffer-substrings buffer1 start1 end1 buffer2 start2 end2 | 276 | @defun compare-buffer-substrings buffer1 start1 end1 buffer2 start2 end2 |
| 274 | This function lets you compare two substrings of the same buffer or two | 277 | This function lets you compare two substrings of the same buffer or two |
| 275 | different buffers. The first three arguments specify one substring, | 278 | different buffers. The first three arguments specify one substring, |
| 276 | giving a buffer and two positions within the buffer. The last three | 279 | giving a buffer (or a buffer name) and two positions within the |
| 277 | arguments specify the other substring in the same way. You can use | 280 | buffer. The last three arguments specify the other substring in the |
| 278 | @code{nil} for @var{buffer1}, @var{buffer2}, or both to stand for the | 281 | same way. You can use @code{nil} for @var{buffer1}, @var{buffer2}, or |
| 279 | current buffer. | 282 | both to stand for the current buffer. |
| 280 | 283 | ||
| 281 | The value is negative if the first substring is less, positive if the | 284 | The value is negative if the first substring is less, positive if the |
| 282 | first is greater, and zero if they are equal. The absolute value of | 285 | first is greater, and zero if they are equal. The absolute value of |
| @@ -360,8 +363,7 @@ overlay. | |||
| 360 | @defun insert-char character count &optional inherit | 363 | @defun insert-char character count &optional inherit |
| 361 | This function inserts @var{count} instances of @var{character} into the | 364 | This function inserts @var{count} instances of @var{character} into the |
| 362 | current buffer before point. The argument @var{count} should be a | 365 | current buffer before point. The argument @var{count} should be a |
| 363 | number (@code{nil} means 1), and @var{character} must be a character. | 366 | number, and @var{character} must be a character. The value is @code{nil}. |
| 364 | The value is @code{nil}. | ||
| 365 | 367 | ||
| 366 | This function does not convert unibyte character codes 128 through 255 | 368 | This function does not convert unibyte character codes 128 through 255 |
| 367 | to multibyte characters, not even if the current buffer is a multibyte | 369 | to multibyte characters, not even if the current buffer is a multibyte |
| @@ -375,7 +377,7 @@ insertion point. @xref{Sticky Properties}. | |||
| 375 | @defun insert-buffer-substring from-buffer-or-name &optional start end | 377 | @defun insert-buffer-substring from-buffer-or-name &optional start end |
| 376 | This function inserts a portion of buffer @var{from-buffer-or-name} | 378 | This function inserts a portion of buffer @var{from-buffer-or-name} |
| 377 | (which must already exist) into the current buffer before point. The | 379 | (which must already exist) into the current buffer before point. The |
| 378 | text inserted is the region from @var{start} and @var{end}. (These | 380 | text inserted is the region between @var{start} and @var{end}. (These |
| 379 | arguments default to the beginning and end of the accessible portion of | 381 | arguments default to the beginning and end of the accessible portion of |
| 380 | that buffer.) This function returns @code{nil}. | 382 | that buffer.) This function returns @code{nil}. |
| 381 | 383 | ||
| @@ -418,9 +420,10 @@ commands intended primarily for the user but useful also in Lisp | |||
| 418 | programs. | 420 | programs. |
| 419 | 421 | ||
| 420 | @deffn Command insert-buffer from-buffer-or-name | 422 | @deffn Command insert-buffer from-buffer-or-name |
| 421 | This command inserts the entire contents of @var{from-buffer-or-name} | 423 | This command inserts the entire accessible contents of |
| 422 | (which must exist) into the current buffer after point. It leaves | 424 | @var{from-buffer-or-name} (which must exist) into the current buffer |
| 423 | the mark after the inserted text. The value is @code{nil}. | 425 | after point. It leaves the mark after the inserted text. The value |
| 426 | is @code{nil}. | ||
| 424 | @end deffn | 427 | @end deffn |
| 425 | 428 | ||
| 426 | @deffn Command self-insert-command count | 429 | @deffn Command self-insert-command count |
| @@ -501,11 +504,11 @@ yanked, but can be reinserted using the undo mechanism (@pxref{Undo}). | |||
| 501 | Some deletion functions do save text in the kill ring in some special | 504 | Some deletion functions do save text in the kill ring in some special |
| 502 | cases. | 505 | cases. |
| 503 | 506 | ||
| 504 | All of the deletion functions operate on the current buffer, and all | 507 | All of the deletion functions operate on the current buffer. |
| 505 | return a value of @code{nil}. | ||
| 506 | 508 | ||
| 507 | @deffn Command erase-buffer | 509 | @deffn Command erase-buffer |
| 508 | This function deletes the entire text of the current buffer, leaving it | 510 | This function deletes the entire text of the current buffer |
| 511 | (@emph{not} just the accessible portion), leaving it | ||
| 509 | empty. If the buffer is read-only, it signals a @code{buffer-read-only} | 512 | empty. If the buffer is read-only, it signals a @code{buffer-read-only} |
| 510 | error; if some of the text in it is read-only, it signals a | 513 | error; if some of the text in it is read-only, it signals a |
| 511 | @code{text-read-only} error. Otherwise, it deletes the text without | 514 | @code{text-read-only} error. Otherwise, it deletes the text without |
| @@ -591,8 +594,9 @@ The value returned is always @code{nil}. | |||
| 591 | This option specifies how @code{backward-delete-char-untabify} should | 594 | This option specifies how @code{backward-delete-char-untabify} should |
| 592 | deal with whitespace. Possible values include @code{untabify}, the | 595 | deal with whitespace. Possible values include @code{untabify}, the |
| 593 | default, meaning convert a tab to many spaces and delete one; | 596 | default, meaning convert a tab to many spaces and delete one; |
| 594 | @code{hungry}, meaning delete all the whitespace characters before point | 597 | @code{hungry}, meaning delete all tabs and spaces before point with |
| 595 | with one command, and @code{nil}, meaning do nothing special for | 598 | one command; @code{all} meaning delete all tabs, spaces and newlines |
| 599 | before point, and @code{nil}, meaning do nothing special for | ||
| 596 | whitespace characters. | 600 | whitespace characters. |
| 597 | @end defopt | 601 | @end defopt |
| 598 | 602 | ||
| @@ -603,11 +607,14 @@ whitespace characters. | |||
| 603 | commands intended primarily for the user but useful also in Lisp | 607 | commands intended primarily for the user but useful also in Lisp |
| 604 | programs. | 608 | programs. |
| 605 | 609 | ||
| 606 | @deffn Command delete-horizontal-space | 610 | @deffn Command delete-horizontal-space &optional backward-only |
| 607 | @cindex deleting whitespace | 611 | @cindex deleting whitespace |
| 608 | This function deletes all spaces and tabs around point. It returns | 612 | This function deletes all spaces and tabs around point. It returns |
| 609 | @code{nil}. | 613 | @code{nil}. |
| 610 | 614 | ||
| 615 | If @var{backward-only} is non-@code{nil}, the function deletes | ||
| 616 | spaces and tabs before point, but not after point. | ||
| 617 | |||
| 611 | In the following examples, we call @code{delete-horizontal-space} four | 618 | In the following examples, we call @code{delete-horizontal-space} four |
| 612 | times, once on each line, with point between the second and third | 619 | times, once on each line, with point between the second and third |
| 613 | characters on the line each time. | 620 | characters on the line each time. |
| @@ -673,9 +680,10 @@ After the lines are joined, the function @code{fixup-whitespace} is | |||
| 673 | responsible for deciding whether to leave a space at the junction. | 680 | responsible for deciding whether to leave a space at the junction. |
| 674 | @end deffn | 681 | @end deffn |
| 675 | 682 | ||
| 676 | @defun fixup-whitespace | 683 | @deffn Command fixup-whitespace |
| 677 | This function replaces all the whitespace surrounding point with either | 684 | This function replaces all the horizontal whitespace surrounding point |
| 678 | one space or no space, according to the context. It returns @code{nil}. | 685 | with either one space or no space, according to the context. It |
| 686 | returns @code{nil}. | ||
| 679 | 687 | ||
| 680 | At the beginning or end of a line, the appropriate amount of space is | 688 | At the beginning or end of a line, the appropriate amount of space is |
| 681 | none. Before a character with close parenthesis syntax, or after a | 689 | none. Before a character with close parenthesis syntax, or after a |
| @@ -709,7 +717,7 @@ This has too many spaces at the start of (this list) | |||
| 709 | ---------- Buffer: foo ---------- | 717 | ---------- Buffer: foo ---------- |
| 710 | @end group | 718 | @end group |
| 711 | @end smallexample | 719 | @end smallexample |
| 712 | @end defun | 720 | @end deffn |
| 713 | 721 | ||
| 714 | @deffn Command just-one-space | 722 | @deffn Command just-one-space |
| 715 | @comment !!SourceFile simple.el | 723 | @comment !!SourceFile simple.el |
| @@ -722,7 +730,7 @@ This function deletes blank lines surrounding point. If point is on a | |||
| 722 | blank line with one or more blank lines before or after it, then all but | 730 | blank line with one or more blank lines before or after it, then all but |
| 723 | one of them are deleted. If point is on an isolated blank line, then it | 731 | one of them are deleted. If point is on an isolated blank line, then it |
| 724 | is deleted. If point is on a nonblank line, the command deletes all | 732 | is deleted. If point is on a nonblank line, the command deletes all |
| 725 | blank lines following it. | 733 | blank lines immediately following it. |
| 726 | 734 | ||
| 727 | A blank line is defined as a line containing only tabs and spaces. | 735 | A blank line is defined as a line containing only tabs and spaces. |
| 728 | 736 | ||
| @@ -771,7 +779,7 @@ would be difficult to change the terminology now. | |||
| 771 | * Yanking:: How yanking is done. | 779 | * Yanking:: How yanking is done. |
| 772 | * Yank Commands:: Commands that access the kill ring. | 780 | * Yank Commands:: Commands that access the kill ring. |
| 773 | * Low-Level Kill Ring:: Functions and variables for kill ring access. | 781 | * Low-Level Kill Ring:: Functions and variables for kill ring access. |
| 774 | * Internals of Kill Ring:: Variables that hold kill-ring data. | 782 | * Internals of Kill Ring:: Variables that hold kill ring data. |
| 775 | @end menu | 783 | @end menu |
| 776 | 784 | ||
| 777 | @node Kill Ring Concepts | 785 | @node Kill Ring Concepts |
| @@ -791,7 +799,7 @@ new entry automatically deletes the last entry. | |||
| 791 | 799 | ||
| 792 | When kill commands are interwoven with other commands, each kill | 800 | When kill commands are interwoven with other commands, each kill |
| 793 | command makes a new entry in the kill ring. Multiple kill commands in | 801 | command makes a new entry in the kill ring. Multiple kill commands in |
| 794 | succession build up a single kill-ring entry, which would be yanked as a | 802 | succession build up a single kill ring entry, which would be yanked as a |
| 795 | unit; the second and subsequent consecutive kill commands add text to | 803 | unit; the second and subsequent consecutive kill commands add text to |
| 796 | the entry made by the first one. | 804 | the entry made by the first one. |
| 797 | 805 | ||
| @@ -828,8 +836,10 @@ This is convenient because it lets the user use a series of kill | |||
| 828 | commands to copy text from a read-only buffer into the kill ring. | 836 | commands to copy text from a read-only buffer into the kill ring. |
| 829 | 837 | ||
| 830 | If @var{yank-handler} is non-@code{nil}, this puts that value onto | 838 | If @var{yank-handler} is non-@code{nil}, this puts that value onto |
| 831 | the string of killed text, as a @code{yank-handler} property. | 839 | the string of killed text, as a @code{yank-handler} text property. |
| 832 | @xref{Yanking}. | 840 | @xref{Yanking}. Note that if @var{yank-handler} is @code{nil}, any |
| 841 | @code{yank-handler} properties present on the killed text are copied | ||
| 842 | onto the kill ring, like other text properties. | ||
| 833 | @end deffn | 843 | @end deffn |
| 834 | 844 | ||
| 835 | @defopt kill-read-only-ok | 845 | @defopt kill-read-only-ok |
| @@ -841,9 +851,7 @@ updating the kill ring but not changing the buffer. | |||
| 841 | @deffn Command copy-region-as-kill start end | 851 | @deffn Command copy-region-as-kill start end |
| 842 | This command saves the region defined by @var{start} and @var{end} on | 852 | This command saves the region defined by @var{start} and @var{end} on |
| 843 | the kill ring (including text properties), but does not delete the text | 853 | the kill ring (including text properties), but does not delete the text |
| 844 | from the buffer. It returns @code{nil}. It also indicates the extent | 854 | from the buffer. It returns @code{nil}. |
| 845 | of the text copied by moving the cursor momentarily, or by displaying a | ||
| 846 | message in the echo area. | ||
| 847 | 855 | ||
| 848 | The command does not set @code{this-command} to @code{kill-region}, so a | 856 | The command does not set @code{this-command} to @code{kill-region}, so a |
| 849 | subsequent kill command does not append to the same kill ring entry. | 857 | subsequent kill command does not append to the same kill ring entry. |
| @@ -865,9 +873,9 @@ text that they copy into the buffer. | |||
| 865 | @defun insert-for-yank string | 873 | @defun insert-for-yank string |
| 866 | This function normally works like @code{insert} except that it doesn't | 874 | This function normally works like @code{insert} except that it doesn't |
| 867 | insert the text properties in the @code{yank-excluded-properties} | 875 | insert the text properties in the @code{yank-excluded-properties} |
| 868 | list. However, if the first character of @var{string} has a | 876 | list. However, if any part of @var{string} has a non-@code{nil} |
| 869 | non-@code{nil}@code{yank-handler} text property, that property | 877 | @code{yank-handler} text property, that property can do various |
| 870 | can do various special processing on the text being inserted. | 878 | special processing on that part of the text being inserted. |
| 871 | @end defun | 879 | @end defun |
| 872 | 880 | ||
| 873 | @defun insert-buffer-substring-as-yank buf &optional start end | 881 | @defun insert-buffer-substring-as-yank buf &optional start end |
| @@ -876,12 +884,11 @@ doesn't insert the text properties in the | |||
| 876 | @code{yank-excluded-properties} list. | 884 | @code{yank-excluded-properties} list. |
| 877 | @end defun | 885 | @end defun |
| 878 | 886 | ||
| 879 | You can put a @code{yank-handler} text property on the text to | 887 | You can put a @code{yank-handler} text property on all or part of |
| 880 | control how it will be inserted if it is yanked. The | 888 | the text to control how it will be inserted if it is yanked. The |
| 881 | @code{insert-for-yank} function looks for a @code{yank-handler} | 889 | @code{insert-for-yank} function looks for that property. The property |
| 882 | property on the first character in its @var{string} argument. The | 890 | value must be a list of one to four elements, with the following |
| 883 | property value must be a list of one to four elements, with the | 891 | format (where elements after the first may be omitted): |
| 884 | following format (where elements after the first may be omitted): | ||
| 885 | 892 | ||
| 886 | @example | 893 | @example |
| 887 | (@var{function} @var{param} @var{noexclude} @var{undo}) | 894 | (@var{function} @var{param} @var{noexclude} @var{undo}) |
| @@ -891,15 +898,16 @@ following format (where elements after the first may be omitted): | |||
| 891 | 898 | ||
| 892 | @table @var | 899 | @table @var |
| 893 | @item function | 900 | @item function |
| 894 | When @var{function} is present and non-nil, it is called instead of | 901 | When @var{function} is present and non-@code{nil}, it is called instead of |
| 895 | @code{insert} to insert the string. @var{function} takes one | 902 | @code{insert} to insert the string. @var{function} takes one |
| 896 | argument---the string to insert. | 903 | argument---the string to insert. |
| 897 | 904 | ||
| 898 | @item param | 905 | @item param |
| 899 | If @var{param} is present and non-@code{nil}, it replaces @var{string} | 906 | If @var{param} is present and non-@code{nil}, it replaces @var{string} |
| 900 | as the object passed to @var{function} (or @code{insert}); for | 907 | (or the part of @var{string} being processed) as the object passed to |
| 901 | example, if @var{function} is @code{yank-rectangle}, @var{param} | 908 | @var{function} (or @code{insert}); for example, if @var{function} is |
| 902 | should be a list of strings to insert as a rectangle. | 909 | @code{yank-rectangle}, @var{param} should be a list of strings to |
| 910 | insert as a rectangle. | ||
| 903 | 911 | ||
| 904 | @item noexclude | 912 | @item noexclude |
| 905 | If @var{noexclude} is present and non-@code{nil}, the normal removal of the | 913 | If @var{noexclude} is present and non-@code{nil}, the normal removal of the |
| @@ -908,7 +916,7 @@ responsible for removing those properties. This may be necessary | |||
| 908 | if @var{function} adjusts point before or after inserting the object. | 916 | if @var{function} adjusts point before or after inserting the object. |
| 909 | 917 | ||
| 910 | @item undo | 918 | @item undo |
| 911 | If @var{undo} is present and non-nil, it is a function that will be | 919 | If @var{undo} is present and non-@code{nil}, it is a function that will be |
| 912 | called by @code{yank-pop} to undo the insertion of the current object. | 920 | called by @code{yank-pop} to undo the insertion of the current object. |
| 913 | It is called with two arguments, the start and end of the current | 921 | It is called with two arguments, the start and end of the current |
| 914 | region. @var{function} can set @code{yank-undo-function} to override | 922 | region. @var{function} can set @code{yank-undo-function} to override |
| @@ -924,23 +932,29 @@ from the kill ring. The text properties are copied too. | |||
| 924 | 932 | ||
| 925 | @deffn Command yank &optional arg | 933 | @deffn Command yank &optional arg |
| 926 | @cindex inserting killed text | 934 | @cindex inserting killed text |
| 927 | This command inserts before point the text in the first entry in the | 935 | This command inserts before point the text at the front of the |
| 928 | kill ring. It positions the mark at the beginning of that text, and | 936 | kill ring. It positions the mark at the beginning of that text, and |
| 929 | point at the end. | 937 | point at the end. |
| 930 | 938 | ||
| 931 | If @var{arg} is a list (which occurs interactively when the user | 939 | If @var{arg} is a non-@code{nil} list (which occurs interactively when |
| 932 | types @kbd{C-u} with no digits), then @code{yank} inserts the text as | 940 | the user types @kbd{C-u} with no digits), then @code{yank} inserts the |
| 933 | described above, but puts point before the yanked text and puts the mark | 941 | text as described above, but puts point before the yanked text and |
| 934 | after it. | 942 | puts the mark after it. |
| 935 | 943 | ||
| 936 | If @var{arg} is a number, then @code{yank} inserts the @var{arg}th most | 944 | If @var{arg} is a number, then @code{yank} inserts the @var{arg}th |
| 937 | recently killed text---the @var{arg}th element of the kill ring list. | 945 | most recently killed text---the @var{arg}th element of the kill ring |
| 946 | list, counted cyclically from the front, which is considered the | ||
| 947 | first element for this purpose. | ||
| 938 | 948 | ||
| 939 | @code{yank} does not alter the contents of the kill ring or rotate it. | 949 | @code{yank} does not alter the contents of the kill ring, unless it |
| 940 | It returns @code{nil}. | 950 | used text provided by another program, in which case it pushes that text |
| 951 | onto the kill ring. However if @var{arg} is an integer different from | ||
| 952 | one, it rotates the kill ring to place the yanked string at the front. | ||
| 953 | |||
| 954 | @code{yank} returns @code{nil}. | ||
| 941 | @end deffn | 955 | @end deffn |
| 942 | 956 | ||
| 943 | @deffn Command yank-pop arg | 957 | @deffn Command yank-pop &optional arg |
| 944 | This command replaces the just-yanked entry from the kill ring with a | 958 | This command replaces the just-yanked entry from the kill ring with a |
| 945 | different entry from the kill ring. | 959 | different entry from the kill ring. |
| 946 | 960 | ||
| @@ -949,6 +963,8 @@ This is allowed only immediately after a @code{yank} or another | |||
| 949 | inserted by yanking. @code{yank-pop} deletes that text and inserts in | 963 | inserted by yanking. @code{yank-pop} deletes that text and inserts in |
| 950 | its place a different piece of killed text. It does not add the deleted | 964 | its place a different piece of killed text. It does not add the deleted |
| 951 | text to the kill ring, since it is already in the kill ring somewhere. | 965 | text to the kill ring, since it is already in the kill ring somewhere. |
| 966 | It does however rotate the kill ring to place the newly yanked string at | ||
| 967 | the front. | ||
| 952 | 968 | ||
| 953 | If @var{arg} is @code{nil}, then the replacement text is the previous | 969 | If @var{arg} is @code{nil}, then the replacement text is the previous |
| 954 | element of the kill ring. If @var{arg} is numeric, the replacement is | 970 | element of the kill ring. If @var{arg} is numeric, the replacement is |
| @@ -966,7 +982,8 @@ The return value is always @code{nil}. | |||
| 966 | If this variable is non-@code{nil}, the function @code{yank-pop} uses | 982 | If this variable is non-@code{nil}, the function @code{yank-pop} uses |
| 967 | its value instead of @code{delete-region} to delete the text | 983 | its value instead of @code{delete-region} to delete the text |
| 968 | inserted by the previous @code{yank} or | 984 | inserted by the previous @code{yank} or |
| 969 | @code{yank-pop} command. | 985 | @code{yank-pop} command. The value must be a function of two |
| 986 | arguments, the start and end of the current region. | ||
| 970 | 987 | ||
| 971 | The function @code{insert-for-yank} automatically sets this variable | 988 | The function @code{insert-for-yank} automatically sets this variable |
| 972 | according to the @var{undo} element of the @code{yank-handler} | 989 | according to the @var{undo} element of the @code{yank-handler} |
| @@ -992,27 +1009,44 @@ returns the @var{n}th kill, counting from the current yanking pointer. | |||
| 992 | 1009 | ||
| 993 | If @var{n} is zero, indicating a request for the latest kill, | 1010 | If @var{n} is zero, indicating a request for the latest kill, |
| 994 | @code{current-kill} calls the value of | 1011 | @code{current-kill} calls the value of |
| 995 | @code{interprogram-paste-function} (documented below) before consulting | 1012 | @code{interprogram-paste-function} (documented below) before |
| 996 | the kill ring. | 1013 | consulting the kill ring. If that value is a function and calling it |
| 997 | @end defun | 1014 | returns a string, @code{current-kill} pushes that string onto the kill |
| 998 | 1015 | ring and returns it. It also sets the yanking pointer to point to | |
| 999 | @defun kill-new string &optional yank-handler | 1016 | that new entry, regardless of the value of @var{do-not-move}. |
| 1000 | This function puts the text @var{string} into the kill ring as a new | 1017 | Otherwise, @code{current-kill} does not treat a zero value for @var{n} |
| 1001 | entry at the front of the ring. It discards the oldest entry if | 1018 | specially: it returns the entry pointed at by the yanking pointer and |
| 1002 | appropriate. It also invokes the value of | 1019 | does not move the yanking pointer. |
| 1020 | @end defun | ||
| 1021 | |||
| 1022 | @defun kill-new string &optional replace yank-handler | ||
| 1023 | This function pushes the text @var{string} onto the kill ring and | ||
| 1024 | makes the yanking pointer point to it. It discards the oldest entry | ||
| 1025 | if appropriate. It also invokes the value of | ||
| 1003 | @code{interprogram-cut-function} (see below). | 1026 | @code{interprogram-cut-function} (see below). |
| 1004 | 1027 | ||
| 1028 | If @var{replace} is non-@code{nil}, then @code{kill-new} replaces the | ||
| 1029 | first element of the kill ring with @var{string}, rather than pushing | ||
| 1030 | @var{string} onto the kill ring. | ||
| 1031 | |||
| 1005 | If @var{yank-handler} is non-@code{nil}, this puts that value onto | 1032 | If @var{yank-handler} is non-@code{nil}, this puts that value onto |
| 1006 | the string of killed text, as a @code{yank-handler} property. | 1033 | the string of killed text, as a @code{yank-handler} property. |
| 1007 | @xref{Yanking}. | 1034 | @xref{Yanking}. Note that if @var{yank-handler} is @code{nil}, then |
| 1035 | @code{kill-new} copies any @code{yank-handler} properties present on | ||
| 1036 | @var{string} onto the kill ring, as it does with other text properties. | ||
| 1008 | @end defun | 1037 | @end defun |
| 1009 | 1038 | ||
| 1010 | @defun kill-append string before-p &optional yank-handler | 1039 | @defun kill-append string before-p &optional yank-handler |
| 1011 | This function appends the text @var{string} to the first entry in the | 1040 | This function appends the text @var{string} to the first entry in the |
| 1012 | kill ring. Normally @var{string} goes at the end of the entry, but if | 1041 | kill ring and makes the yanking pointer point to the combined entry. |
| 1042 | Normally @var{string} goes at the end of the entry, but if | ||
| 1013 | @var{before-p} is non-@code{nil}, it goes at the beginning. This | 1043 | @var{before-p} is non-@code{nil}, it goes at the beginning. This |
| 1014 | function also invokes the value of @code{interprogram-cut-function} (see | 1044 | function also invokes the value of @code{interprogram-cut-function} |
| 1015 | below). This handles @var{yank-handler} just like @code{kill-new}. | 1045 | (see below). This handles @var{yank-handler} just like |
| 1046 | @code{kill-new}, except that if @var{yank-handler} is different from | ||
| 1047 | the @code{yank-handler} property of the first entry of the kill ring, | ||
| 1048 | @code{kill-append} pushes the concatenated string onto the kill ring, | ||
| 1049 | instead of replacing the original first entry with it. | ||
| 1016 | @end defun | 1050 | @end defun |
| 1017 | 1051 | ||
| 1018 | @defvar interprogram-paste-function | 1052 | @defvar interprogram-paste-function |
| @@ -1023,7 +1057,7 @@ programs, when you are using a window system. Its value should be | |||
| 1023 | If the value is a function, @code{current-kill} calls it to get the | 1057 | If the value is a function, @code{current-kill} calls it to get the |
| 1024 | ``most recent kill''. If the function returns a non-@code{nil} value, | 1058 | ``most recent kill''. If the function returns a non-@code{nil} value, |
| 1025 | then that value is used as the ``most recent kill''. If it returns | 1059 | then that value is used as the ``most recent kill''. If it returns |
| 1026 | @code{nil}, then the first element of @code{kill-ring} is used. | 1060 | @code{nil}, then the front of the kill ring is used. |
| 1027 | 1061 | ||
| 1028 | The normal use of this hook is to get the window system's primary | 1062 | The normal use of this hook is to get the window system's primary |
| 1029 | selection as the most recent kill, even if the selection belongs to | 1063 | selection as the most recent kill, even if the selection belongs to |
| @@ -1033,13 +1067,17 @@ another application. @xref{Window System Selections}. | |||
| 1033 | @defvar interprogram-cut-function | 1067 | @defvar interprogram-cut-function |
| 1034 | This variable provides a way of communicating killed text to other | 1068 | This variable provides a way of communicating killed text to other |
| 1035 | programs, when you are using a window system. Its value should be | 1069 | programs, when you are using a window system. Its value should be |
| 1036 | @code{nil} or a function of one argument. | 1070 | @code{nil} or a function of one required and one optional argument. |
| 1037 | 1071 | ||
| 1038 | If the value is a function, @code{kill-new} and @code{kill-append} call | 1072 | If the value is a function, @code{kill-new} and @code{kill-append} call |
| 1039 | it with the new first element of the kill ring as an argument. | 1073 | it with the new first element of the kill ring as the first argument. |
| 1074 | The second, optional, argument has the same meaning as the @var{push} | ||
| 1075 | argument to @code{x-set-cut-buffer} (@pxref{Definition of | ||
| 1076 | x-set-cut-buffer}) and only affects the second and later cut buffers. | ||
| 1040 | 1077 | ||
| 1041 | The normal use of this hook is to set the window system's primary | 1078 | The normal use of this hook is to set the window system's primary |
| 1042 | selection from the newly killed text. @xref{Window System Selections}. | 1079 | selection (and first cut buffer) from the newly killed text. |
| 1080 | @xref{Window System Selections}. | ||
| 1043 | @end defvar | 1081 | @end defvar |
| 1044 | 1082 | ||
| 1045 | @node Internals of Kill Ring | 1083 | @node Internals of Kill Ring |
| @@ -1112,7 +1150,7 @@ that @kbd{C-y} should yank. | |||
| 1112 | @defopt kill-ring-max | 1150 | @defopt kill-ring-max |
| 1113 | The value of this variable is the maximum length to which the kill | 1151 | The value of this variable is the maximum length to which the kill |
| 1114 | ring can grow, before elements are thrown away at the end. The default | 1152 | ring can grow, before elements are thrown away at the end. The default |
| 1115 | value for @code{kill-ring-max} is 30. | 1153 | value for @code{kill-ring-max} is 60. |
| 1116 | @end defopt | 1154 | @end defopt |
| 1117 | 1155 | ||
| 1118 | @node Undo | 1156 | @node Undo |
| @@ -1149,7 +1187,9 @@ buffer. | |||
| 1149 | @item (@var{text} . @var{position}) | 1187 | @item (@var{text} . @var{position}) |
| 1150 | This kind of element indicates how to reinsert text that was deleted. | 1188 | This kind of element indicates how to reinsert text that was deleted. |
| 1151 | The deleted text itself is the string @var{text}. The place to | 1189 | The deleted text itself is the string @var{text}. The place to |
| 1152 | reinsert it is @code{(abs @var{position})}. | 1190 | reinsert it is @code{(abs @var{position})}. If @var{position} is |
| 1191 | positive, point was at the beginning of the deleted text, otherwise it | ||
| 1192 | was at the end. | ||
| 1153 | 1193 | ||
| 1154 | @item (t @var{high} . @var{low}) | 1194 | @item (t @var{high} . @var{low}) |
| 1155 | This kind of element indicates that an unmodified buffer became | 1195 | This kind of element indicates that an unmodified buffer became |
| @@ -1241,13 +1281,13 @@ In an interactive call, @var{buffer-or-name} is the current buffer. | |||
| 1241 | You cannot specify any other buffer. | 1281 | You cannot specify any other buffer. |
| 1242 | @end deffn | 1282 | @end deffn |
| 1243 | 1283 | ||
| 1244 | @deffn Command buffer-disable-undo &optional buffer | 1284 | @deffn Command buffer-disable-undo &optional buffer-or-name |
| 1245 | @deffnx Command buffer-flush-undo &optional buffer | 1285 | @deffnx Command buffer-flush-undo &optional buffer-or-name |
| 1246 | @cindex disable undo | 1286 | @cindex disable undo |
| 1247 | This function discards the undo list of @var{buffer}, and disables | 1287 | This function discards the undo list of @var{buffer-or-name}, and disables |
| 1248 | further recording of undo information. As a result, it is no longer | 1288 | further recording of undo information. As a result, it is no longer |
| 1249 | possible to undo either previous changes or any subsequent changes. If | 1289 | possible to undo either previous changes or any subsequent changes. If |
| 1250 | the undo list of @var{buffer} is already disabled, this function | 1290 | the undo list of @var{buffer-or-name} is already disabled, this function |
| 1251 | has no effect. | 1291 | has no effect. |
| 1252 | 1292 | ||
| 1253 | This function returns @code{nil}. | 1293 | This function returns @code{nil}. |
| @@ -3935,7 +3975,7 @@ changed text, its length is simply the difference between the first two | |||
| 3935 | arguments. | 3975 | arguments. |
| 3936 | @end defvar | 3976 | @end defvar |
| 3937 | 3977 | ||
| 3938 | Output of messges into the @samp{*Messages*} buffer does not | 3978 | Output of messages into the @samp{*Messages*} buffer does not |
| 3939 | call these functions. | 3979 | call these functions. |
| 3940 | 3980 | ||
| 3941 | @defmac combine-after-change-calls body... | 3981 | @defmac combine-after-change-calls body... |