]> code.delx.au - gnu-emacs/blobdiff - doc/lispref/text.texi
xdisp fix
[gnu-emacs] / doc / lispref / text.texi
index bc65e314da0db9e6cd1a496b1b4dc35c1e9193de..6d5a39d887aff8706824573c5c7f7f705c5a6ae4 100644 (file)
@@ -1,9 +1,8 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
-@c Copyright (C) 1990-1995, 1998-201 Free Software Foundation, Inc.
+@c Copyright (C) 1990-1995, 1998-2013 Free Software Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
-@setfilename ../../info/text
-@node Text, Non-ASCII Characters, Markers, Top
+@node Text
 @chapter Text
 @cindex text
 
@@ -52,9 +51,9 @@ the character after point.
 * 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.
+* Transposition::    Swapping two portions of a buffer.
 * Base 64::          Conversion to or from base 64 encoding.
 * Checksum/Hash::    Computing cryptographic hashes.
 * Parsing HTML/XML:: Parsing HTML and XML.
@@ -216,8 +215,7 @@ properties, just the characters themselves.  @xref{Text Properties}.
 
 @defun buffer-string
 This function returns the contents of the entire accessible portion of
-the current buffer as a string.  It is equivalent to
-@w{@code{(buffer-substring (point-min) (point-max))}}.
+the current buffer, as a string.
 @end defun
 
 @defun filter-buffer-substring start end &optional delete
@@ -226,7 +224,7 @@ through the filter functions specified by the wrapper hook
 @code{filter-buffer-substring-functions}, and returns the result.  The
 obsolete variable @code{buffer-substring-filters} is also consulted.
 If both of these variables are @code{nil}, the value is the unaltered
-text from the buffer, i.e.@: what @code{buffer-substring} would
+text from the buffer, i.e., what @code{buffer-substring} would
 return.
 
 If @var{delete} is non-@code{nil}, this function deletes the text
@@ -252,7 +250,7 @@ and returns a string.  In both cases, the @var{start}, @var{end}, and
 @code{filter-buffer-substring}.
 
 The first hook function is passed a @var{fun} that is equivalent to
-the default operation of @code{filter-buffer-substring}, i.e. it
+the default operation of @code{filter-buffer-substring}, i.e., it
 returns the buffer-substring between @var{start} and @var{end}
 (processed by any @code{buffer-substring-filters}) and optionally
 deletes the original text from the buffer.  In most cases, the hook
@@ -403,19 +401,23 @@ ends at the insertion point, the inserted text falls inside that
 overlay.
 @end defun
 
-@defun insert-char character count &optional inherit
-This function inserts @var{count} instances of @var{character} into the
-current buffer before point.  The argument @var{count} should be an
-integer, and @var{character} must be a character.  The value is @code{nil}.
+@deffn Command insert-char character &optional count inherit
+This command inserts @var{count} instances of @var{character} into the
+current buffer before point.  The argument @var{count} must be an
+integer, and @var{character} must be a character.
+
+If called interactively, this command prompts for @var{character}
+using its Unicode name or its code point.  @xref{Inserting Text,,,
+emacs, The GNU Emacs Manual}.
 
 This function does not convert unibyte character codes 128 through 255
 to multibyte characters, not even if the current buffer is a multibyte
 buffer.  @xref{Converting Representations}.
 
-If @var{inherit} is non-@code{nil}, then the inserted characters inherit
+If @var{inherit} is non-@code{nil}, the inserted characters inherit
 sticky text properties from the two characters before and after the
 insertion point.  @xref{Sticky Properties}.
-@end defun
+@end deffn
 
 @defun insert-buffer-substring from-buffer-or-name &optional start end
 This function inserts a portion of buffer @var{from-buffer-or-name}
@@ -824,7 +826,6 @@ would be difficult to change the terminology now.
 @end menu
 
 @node Kill Ring Concepts
-@comment  node-name,  next,  previous,  up
 @subsection Kill Ring Concepts
 
   The kill ring records killed text as strings in a list, most recent
@@ -851,7 +852,6 @@ change the list itself---the most recent entry always comes first in the
 list.
 
 @node Kill Functions
-@comment  node-name,  next,  previous,  up
 @subsection Functions for Killing
 
   @code{kill-region} is the usual subroutine for killing text.  Any
@@ -899,31 +899,34 @@ In Lisp programs, it is better to use @code{kill-new} or
 @node Yanking
 @subsection Yanking
 
-  Yanking means inserting text from the kill ring, but it does
-not insert the text blindly.  Yank commands and some other commands
-use @code{insert-for-yank} to perform special processing on the
-text that they copy into the buffer.
+  Yanking means inserting text from the kill ring, but it does not
+insert the text blindly.  The @code{yank} command, and related
+commands, use @code{insert-for-yank} to perform special processing on
+the text before it is inserted.
 
 @defun insert-for-yank string
-This function normally works like @code{insert} except that it doesn't
-insert the text properties (@pxref{Text Properties}) in the list
-variable @code{yank-excluded-properties}.  However, if any part of
-@var{string} has a non-@code{nil} @code{yank-handler} text property,
-that property can do various special processing on that part of the
-text being inserted.
+This function works like @code{insert}, except that it processes the
+text in @var{string} according to the @code{yank-handler} text
+property, as well as the variables @code{yank-handled-properties} and
+@code{yank-excluded-properties} (see below), before inserting the
+result into the current buffer.
 @end defun
 
 @defun insert-buffer-substring-as-yank buf &optional start end
-This function resembles @code{insert-buffer-substring} except that it
-doesn't insert the text properties in the
-@code{yank-excluded-properties} list.
+This function resembles @code{insert-buffer-substring}, except that it
+processes the text according to @code{yank-handled-properties} and
+@code{yank-excluded-properties}.  (It does not handle the
+@code{yank-handler} property, which does not normally occur in buffer
+text anyway.)
 @end defun
 
-  You can put a @code{yank-handler} text property on all or part of
-the text to control how it will be inserted if it is yanked.  The
-@code{insert-for-yank} function looks for that property.  The property
-value must be a list of one to four elements, with the following
-format (where elements after the first may be omitted):
+  If you put a @code{yank-handler} text property on all or part of a
+string, that alters how @code{insert-for-yank} inserts the string.  If
+different parts of the string have different @code{yank-handler}
+values (comparison being done with @code{eq}), each substring is
+handled separately.  The property value must be a list of one to four
+elements, with the following format (where elements after the first
+may be omitted):
 
 @example
 (@var{function} @var{param} @var{noexclude} @var{undo})
@@ -933,22 +936,21 @@ format (where elements after the first may be omitted):
 
 @table @var
 @item function
-When @var{function} is present and non-@code{nil}, it is called instead of
-@code{insert} to insert the string.  @var{function} takes one
-argument---the string to insert.
+When @var{function} is non-@code{nil}, it is called instead of
+@code{insert} to insert the string, with one argument---the string to
+insert.
 
 @item param
 If @var{param} is present and non-@code{nil}, it replaces @var{string}
-(or the part of @var{string} being processed) as the object passed to
-@var{function} (or @code{insert}); for example, if @var{function} is
-@code{yank-rectangle}, @var{param} should be a list of strings to
-insert as a rectangle.
+(or the substring of @var{string} being processed) as the object
+passed to @var{function} (or @code{insert}).  For example, if
+@var{function} is @code{yank-rectangle}, @var{param} should be a list
+of strings to insert as a rectangle.
 
 @item noexclude
-If @var{noexclude} is present and non-@code{nil}, the normal removal of the
-yank-excluded-properties is not performed; instead @var{function} is
-responsible for removing those properties.  This may be necessary
-if @var{function} adjusts point before or after inserting the object.
+If @var{noexclude} is present and non-@code{nil}, that disables the
+normal action of @code{yank-handled-properties} and
+@code{yank-excluded-properties} on the inserted string.
 
 @item undo
 If @var{undo} is present and non-@code{nil}, it is a function that will be
@@ -959,16 +961,30 @@ the @var{undo} value.
 @end table
 
 @cindex yanking and text properties
+@defopt yank-handled-properties
+This variable specifies special text property handling conditions for
+yanked text.  It takes effect after the text has been inserted (either
+normally, or via the @code{yank-handler} property), and prior to
+@code{yank-excluded-properties} taking effect.
+
+The value should be an alist of elements @code{(@var{prop}
+. @var{fun})}.  Each alist element is handled in order.  The inserted
+text is scanned for stretches of text having text properties @code{eq}
+to @var{prop}; for each such stretch, @var{fun} is called with three
+arguments: the value of the property, and the start and end positions
+of the text.
+@end defopt
+
 @defopt yank-excluded-properties
-Yanking discards certain text properties from the yanked text, as
-described above.  The value of this variable is the list of properties
-to discard.  Its default value contains properties that might lead to
-annoying results, such as causing the text to respond to the mouse or
-specifying key bindings.
+The value of this variable is the list of properties to remove from
+inserted text.  Its default value contains properties that might lead
+to annoying results, such as causing the text to respond to the mouse
+or specifying key bindings.  It takes effect after
+@code{yank-handled-properties}.
 @end defopt
 
+
 @node Yank Commands
-@comment  node-name,  next,  previous,  up
 @subsection Functions for Yanking
 
   This section describes higher-level commands for yanking, which are
@@ -1124,7 +1140,6 @@ window system's clipboard.  @xref{Window System Selections}.
 @end defvar
 
 @node Internals of Kill Ring
-@comment  node-name,  next,  previous,  up
 @subsection Internals of the Kill Ring
 
   The variable @code{kill-ring} holds the kill ring contents, in the
@@ -1197,7 +1212,6 @@ value for @code{kill-ring-max} is 60.
 @end defopt
 
 @node Undo
-@comment  node-name,  next,  previous,  up
 @section Undo
 @cindex redo
 
@@ -1236,11 +1250,12 @@ reinsert it is @code{(abs @var{position})}.  If @var{position} is
 positive, point was at the beginning of the deleted text, otherwise it
 was at the end.
 
-@item (t @var{high} . @var{low})
+@item (t @var{sec-high} @var{sec-low} @var{microsec} @var{picosec})
 This kind of element indicates that an unmodified buffer became
-modified.  The elements @var{high} and @var{low} are two integers, each
-recording 16 bits of the visited file's modification time as of when it
-was previously visited or saved.  @code{primitive-undo} uses those
+modified.  The list @code{(@var{sec-high} @var{sec-low} @var{microsec}
+@var{picosec})} represents the visited file's modification time as of
+when it was previously visited or saved, using the same format as
+@code{current-time}; see @ref{Time of Day}.  @code{primitive-undo} uses those
 values to determine whether to mark the buffer as unmodified once again;
 it does so only if the file's modification time matches those numbers.
 
@@ -1400,7 +1415,6 @@ leak memory if the user waits too long before answering the question.
 @end defopt
 
 @node Filling
-@comment  node-name,  next,  previous,  up
 @section Filling
 @cindex filling text
 
@@ -1778,7 +1792,6 @@ prefix or @code{nil}, meaning it has failed to determine a prefix.
 @end defopt
 
 @node Auto Filling
-@comment  node-name,  next,  previous,  up
 @section Auto Filling
 @cindex filling, automatic
 @cindex Auto Fill mode
@@ -1800,12 +1813,6 @@ special is done in that case.
 The value of @code{auto-fill-function} is @code{do-auto-fill} when
 Auto-Fill mode is enabled.  That is a function whose sole purpose is to
 implement the usual strategy for breaking a line.
-
-@quotation
-In older Emacs versions, this variable was named @code{auto-fill-hook},
-but since it is not called with the standard convention for hooks, it
-was renamed to @code{auto-fill-function} in version 19.
-@end quotation
 @end defvar
 
 @defvar normal-auto-fill-function
@@ -2079,7 +2086,6 @@ utility program.
 @end deffn
 
 @node Columns
-@comment  node-name,  next,  previous,  up
 @section Counting Columns
 @cindex columns
 @cindex counting columns
@@ -2422,7 +2428,6 @@ column, this command does nothing.
 @end deffn
 
 @node Indent Tabs
-@comment  node-name,  next,  previous,  up
 @subsection Adjustable ``Tab Stops''
 @cindex tabs stops for indentation
 
@@ -2481,7 +2486,6 @@ If @var{arg} is omitted or @code{nil}, it defaults to 1.
 @end deffn
 
 @node Case Changes
-@comment  node-name,  next,  previous,  up
 @section Case Changes
 @cindex case conversion in buffers
 
@@ -3004,24 +3008,31 @@ character.
 @item face
 @cindex face codes of text
 @kindex face @r{(text property)}
-The @code{face} property controls the appearance of the character,
-such as its font and color.  @xref{Faces}.  The value of the property
-can be the following:
+The @code{face} property controls the appearance of the character
+(@pxref{Faces}).  The value of the property can be the following:
 
 @itemize @bullet
 @item
 A face name (a symbol or string).
 
 @item
-A property list of face attributes.  This has the
-form (@var{keyword} @var{value} @dots{}), where each @var{keyword} is a
-face attribute name and @var{value} is a meaningful value for that
-attribute.  With this feature, you do not need to create a face each
-time you want to specify a particular attribute for certain text.
-@xref{Face Attributes}.
+An anonymous face: a property list of the form @code{(@var{keyword}
+@var{value} @dots{})}, where each @var{keyword} is a face attribute
+name and @var{value} is a value for that attribute.
+
+@item
+A list of faces.  Each list element should be either a face name or an
+anonymous face.  This specifies a face which is an aggregate of the
+attributes of each of the listed faces.  Faces occurring earlier in
+the list have higher priority.
 
 @item
-A list, where each element uses one of the two forms listed above.
+A cons cell of the form @code{(foreground-color . @var{color-name})}
+or @code{(background-color . @var{color-name})}.  This specifies the
+foreground or background color, similar to @code{(:foreground
+@var{color-name})} or @code{(:background @var{color-name})}.  This
+form is supported for backward compatibility only, and should be
+avoided.
 @end itemize
 
 Font Lock mode (@pxref{Font Lock Mode}) works in most buffers by
@@ -3045,7 +3056,7 @@ between the character and where the mouse is have the same
 @code{mouse-face} property value.
 
 Emacs ignores all face attributes from the @code{mouse-face} property
-that alter the text size (e.g. @code{:height}, @code{:weight}, and
+that alter the text size (e.g., @code{:height}, @code{:weight}, and
 @code{:slant}).  Those attributes are always the same as for the
 unhighlighted text.
 
@@ -3392,7 +3403,7 @@ of the text.
 @node Sticky Properties
 @subsection Stickiness of Text Properties
 @cindex sticky text properties
-@cindex inheritance of text properties
+@cindex inheritance, text property
 
   Self-inserting characters normally take on the same properties as the
 preceding character.  This is called @dfn{inheritance} of properties.
@@ -3537,7 +3548,7 @@ properties.  For simplicity, we will refer to the clickable text as a
 @dfn{link}.
 
   Implementing a link involves three separate steps: (1) indicating
-clickability when the mouse moves over the link; (2) making @kbd{RET}
+clickability when the mouse moves over the link; (2) making @key{RET}
 or @kbd{Mouse-2} on that link do something; and (3) setting up a
 @code{follow-link} condition so that the link obeys
 @code{mouse-1-click-follows-link}.
@@ -4064,7 +4075,7 @@ converting to and from this code.
 @deffn Command base64-encode-region beg end &optional no-line-break
 This function converts the region from @var{beg} to @var{end} into base
 64 code.  It returns the length of the encoded text.  An error is
-signaled if a character in the region is multibyte, i.e.@: in a
+signaled if a character in the region is multibyte, i.e., in a
 multibyte buffer the region must contain only characters from the
 charsets @code{ascii}, @code{eight-bit-control} and
 @code{eight-bit-graphic}.
@@ -4075,7 +4086,7 @@ text, to avoid overlong lines.  However, if the optional argument
 the output is just one long line.
 @end deffn
 
-@deffn Command base64-encode-string string &optional no-line-break
+@defun base64-encode-string string &optional no-line-break
 This function converts the string @var{string} into base 64 code.  It
 returns a string containing the encoded text.  As for
 @code{base64-encode-region}, an error is signaled if a character in the
@@ -4085,15 +4096,15 @@ Normally, this function inserts newline characters into the encoded
 text, to avoid overlong lines.  However, if the optional argument
 @var{no-line-break} is non-@code{nil}, these newlines are not added, so
 the result string is just one long line.
-@end deffn
+@end defun
 
-@defun base64-decode-region beg end
+@deffn Command base64-decode-region beg end
 This function converts the region from @var{beg} to @var{end} from base
 64 code into the corresponding decoded text.  It returns the length of
 the decoded text.
 
 The decoding functions ignore newline characters in the encoded text.
-@end defun
+@end deffn
 
 @defun base64-decode-string string
 This function converts the string @var{string} from base 64 code into
@@ -4112,7 +4123,7 @@ The decoding functions ignore newline characters in the encoded text.
 
   Emacs has built-in support for computing @dfn{cryptographic hashes}.
 A cryptographic hash, or @dfn{checksum}, is a digital ``fingerprint''
-of a piece of data (e.g.@: a block of text) which can be used to check
+of a piece of data (e.g., a block of text) which can be used to check
 that you have an unaltered copy of that data.
 
 @cindex message digest
@@ -4120,7 +4131,7 @@ that you have an unaltered copy of that data.
 SHA-1, SHA-2, SHA-224, SHA-256, SHA-384 and SHA-512.  MD5 is the
 oldest of these algorithms, and is commonly used in @dfn{message
 digests} to check the integrity of messages transmitted over a
-network.  MD5 is not ``collision resistant'' (i.e.@: it is possible to
+network.  MD5 is not ``collision resistant'' (i.e., it is possible to
 deliberately design different pieces of data which have the same MD5
 hash), so you should not used it for anything security-related.  A
 similar theoretical weakness also exists in SHA-1.  Therefore, for
@@ -4337,7 +4348,7 @@ This variable holds a list of functions to call after any buffer
 modification.  Each function receives three arguments: the beginning
 and end of the region just changed, and the length of the text that
 existed before the change.  All three arguments are integers.  The
-buffer has been changed is always the current buffer.
+buffer that has been changed is always the current buffer.
 
 The length of the old text is the difference between the buffer
 positions before and after that text as it was before the change.  As