Mercurial > emacs
diff lispref/text.texi @ 7735:7db892210924
*** empty log message ***
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 28 May 1994 15:27:52 +0000 |
parents | 5b07647ec8f7 |
children | bc548090f760 |
line wrap: on
line diff
--- a/lispref/text.texi Sat May 28 14:52:37 1994 +0000 +++ b/lispref/text.texi Sat May 28 15:27:52 1994 +0000 @@ -48,6 +48,7 @@ * Case Changes:: Case conversion of parts of the buffer. * Text Properties:: Assigning Lisp property lists to text characters. * Substitution:: Replacing a given character wherever it appears. +* Transposition:: Swapping two portions of a buffer. * Registers:: How registers are implemented. Accessing the text or position stored in a register. * Change Hooks:: Supplying functions to be run when text is changed. @@ -520,17 +521,21 @@ in the preceding line. @smallexample +@group ---------- Buffer: foo ---------- When in the course of human @point{} events, it becomes necessary ---------- Buffer: foo ---------- +@end group (delete-indentation) @result{} nil +@group ---------- Buffer: foo ---------- When in the course of human@point{} events, it becomes necessary ---------- Buffer: foo ---------- +@end group @end smallexample After the lines are joined, the function @code{fixup-whitespace} is @@ -2615,6 +2620,25 @@ @end deffn @end ignore +@node Transposition +@section Transposition of Text + + This subroutine is used by the transposition commands. + +@defun transpose-regions start1 end1 start2 end2 &optional leave-markers +This function exchanges two nonoverlapping portions of the buffer. +Arguments @var{start1} and @var{end1} specify the bounds of one portion +and arguments @var{start2} and @var{end2} specify the bounds of the +other portion. + +Normally, @code{transpose-regions} relocates markers with the transposed +text; a marker previously positioned within one of the two transposed +portions moves along with that portion, thus remaining between the same +two characters in their new position. However, if @var{leave-markers} +is non-@code{nil}, @code{transpose-regions} does not do this---it leaves +all markers unrelocated. +@end defun + @node Change Hooks @section Change Hooks @cindex change hooks @@ -2665,6 +2689,25 @@ these functions, make it bind these variables back to their usual values. +One inconvenient result of this protective feature is that you cannot +have a function in @code{after-change-functions} or +@code{before-change-functions} which changes the value of that variable. +But that's not a real limitation. If you want those functions to change +the list of functions to run, simply add one fixed function to the hook, +and code that function to look in another variable for other functions +to call. Here is an example: + +@example +(setq my-own-after-change-functions nil) +(defun indirect-after-change-function (beg end len) + (let ((list my-own-after-change-functions)) + (while list + (funcall (car list) beg end len) + (setq list (cdr list))))) +(add-hooks 'after-change-functions + 'indirect-after-change-function) +@end example + @defvar first-change-hook This variable is a normal hook that is run whenever a buffer is changed that was previously in the unmodified state.