(Window System Selections): Remove doubled `it'.
[bpt/emacs.git] / lispref / display.texi
index 005ac90..4cfef83 100644 (file)
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
-@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999
+@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2000, 2001
 @c   Free Software Foundation, Inc. 
 @c See the file elisp.texi for copying conditions.
 @setfilename ../info/display
@@ -212,6 +212,9 @@ Minibuffer depth is 0.
 ---------- Echo Area ----------
 @end group
 @end example
+
+To automatically display a message in the echo area or in a pop-buffer,
+depending on its size, use @code{display-message-or-buffer}.
 @end defun
 
 @tindex with-temp-message
@@ -244,6 +247,27 @@ support them, then @code{message-box} uses the echo area, like
 @code{message}.
 @end defun
 
+@defun display-message-or-buffer message &optional buffer-name not-this-window frame
+@tindex display-message-or-buffer
+This function displays the message @var{message}, which may be either a
+string or a buffer.  If it is shorter than the maximum height of the
+echo area, as defined by @code{max-mini-window-height}, it is displayed
+in the echo area, using @code{message}.  Otherwise,
+@code{display-buffer} is used to show it in a pop-up buffer.
+
+Returns either the string shown in the echo area, or when a pop-up
+buffer is used, the window used to display it.
+
+If @var{message} is a string, then the optional argument
+@var{buffer-name} is the name of the buffer used to display it when a
+pop-up buffer is used, defaulting to @samp{*Message*}.  In the case
+where @var{message} is a string and displayed in the echo area, it is
+not specified whether the contents are inserted into the buffer anyway.
+
+The optional arguments @var{not-this-window} and @var{frame} are as for
+@code{display-buffer}, and only used if a buffer is displayed.
+@end defun
+
 @defun current-message
 This function returns the message currently being displayed in the
 echo area, or @code{nil} if there is none.
@@ -281,7 +305,8 @@ how to display a message and prevent it from being logged:
 
 @defvar echo-keystrokes
 This variable determines how much time should elapse before command
-characters echo.  Its value must be an integer, which specifies the
+characters echo.  Its value must be an integer or floating point number,
+which specifies the
 number of seconds to wait before echoing.  If the user types a prefix
 key (such as @kbd{C-x}) and then delays this many seconds before
 continuing, the prefix key is echoed in the echo area.  (Once echoing
@@ -532,11 +557,14 @@ about to be executed.
 @defvar overlay-arrow-string
 This variable holds the string to display to call attention to a
 particular line, or @code{nil} if the arrow feature is not in use.
+On a graphical display the contents of the string are ignored; instead a
+glyph is displayed in the fringe area to the left of the display area.
 @end defvar
 
 @defvar overlay-arrow-position
 This variable holds a marker that indicates where to display the overlay
-arrow.  It should point at the beginning of a line.  The arrow text
+arrow.  It should point at the beginning of a line.  On a non-graphical
+display the arrow text
 appears at the beginning of that line, overlaying any text that would
 otherwise appear.  Since the arrow is usually short, and the line
 usually begins with indentation, normally nothing significant is
@@ -818,10 +846,10 @@ or shorter, higher or lower, wider or narror, or replaced with an image.
 
 @item help-echo
 @kindex help-echo @r{(text property)}
-If an overlay has a string as its @code{help-echo} property, then when
-you move the mouse onto the text in the overlay, Emacs displays that
-string in the echo area, or in the tooltip window.  This feature is
-available starting in Emacs 21.
+If an overlay has a @code{help-echo} property, then when you move the
+mouse onto the text in the overlay, Emacs displays a help string in the
+echo area, or in the tooltip window.  For details see @ref{Text
+help-echo}.  This feature is available starting in Emacs 21.
 
 @item modification-hooks
 @kindex modification-hooks @r{(overlay property)}
@@ -900,6 +928,12 @@ if it ever becomes empty (i.e., if it spans no characters).
 If this property is non-@code{nil}, it specifies a keymap for a portion
 of the text.  The property's value replaces the buffer's local map, when
 the character after point is within the overlay.  @xref{Active Keymaps}.
+
+@item keymap
+@kindex keymap @r{(overlay property)}
+The @code{keymap} property is similar to @code{local-map} but overrides the
+buffer's local map (and the map specified by the @code{local-map}
+property) rather than replacing it.
 @end table
 
 @node Managing Overlays
@@ -1309,9 +1343,10 @@ apply to.  Here are the possible values of @var{characteristic}:
 
 @table @code
 @item type
-The kind of window system the frame uses---either @code{x}, @code{pc}
-(for the MS-DOS console), @code{w32} (for MS Windows 9X/NT), or
-@code{tty}.
+The kind of window system the frame uses---either @code{graphic} (any
+graphics-capable display), @code{x}, @code{pc} (for the MS-DOS console),
+@code{w32} (for MS Windows 9X/NT), or @code{tty} (a non-graphics-capable
+display).
 
 @item class
 What kinds of colors the frame supports---either @code{color},
@@ -1401,7 +1436,10 @@ set width.  This should be one of the symbols @code{ultra-condensed},
 @code{extra-expanded}, or @code{ultra-expanded}.
    
 @item :height
-Font height, an integer in units of 1/10 point.
+Either the font height, an integer in units of 1/10 point, a floating
+point number specifying the amount by which to scale the height of any
+underlying face, or a function, which is called with the old height
+(from the underlying face), and should return the new height.
    
 @item :weight
 Font weight---a symbol from this series (from most dense to most faint):
@@ -1463,6 +1501,11 @@ The value is used like that of @code{:underline}.
 Whether or not characters should be strike-through, and in what
 color.  The value is used like that of @code{:underline}.
 
+@item :inherit
+The name of a face from which to inherit attributes, or a list of face
+names.  Attributes from inherited faces are merged into the face like an
+underlying face would be, with higher priority than underlying faces.
+
 @item :box
 Whether or not a box should be drawn around characters, its color, the
 width of the box lines, and 3D appearance.
@@ -1785,8 +1828,10 @@ family, a font pattern is constructed.
 and character's registry and encoding.  If there is a font that matches
 exactly, it is used, of course.  The hard case is when no available font
 exactly fits the specification.  Then Emacs looks for one that is
-``close''---one attribute at a time.  You can specify the order
-to consider the attributes.
+``close''---one attribute at a time.  You can specify the order to
+consider the attributes.  In the case where a specified font family is
+not available, you can specify a set of mappings for alternatives to
+try.
 
 @defvar face-font-selection-order
 @tindex face-font-selection-order
@@ -1818,8 +1863,8 @@ default one.  But if you put @code{:slant} before @code{:height}, the
 quite right.
 @end defvar
 
-@defvar face-alternative-font-family-alist
-@tindex face-alternative-font-family-alist
+@defvar face-font-family-alternatives
+@tindex face-font-family-alternatives
 This variable lets you specify alternative font families to try, if a
 given family is specified and doesn't exist.  Each element should have
 this form:
@@ -1831,6 +1876,21 @@ this form:
 If @var{family} is specified but not available, Emacs will try the other
 families given in @var{alternate-families}, one by one, until it finds a
 family that does exist.
+@end defvar
+
+@defvar face-font-registry-alternatives
+@tindex face-font-registry-alternatives
+This variable lets you specify alternative font registries to try, if a
+given registry is specified and doesn't exist.  Each element should have
+this form:
+
+@example
+(@var{registry} @var{alternate-registries}@dots{})
+@end example
+
+If @var{registry} is specified but not available, Emacs will try the
+other registries given in @var{alternate-registries}, one by one,
+until it finds a registry that does exist.
 @end defvar
 
   Emacs can make use of scalable fonts, but by default it does not use
@@ -2211,6 +2271,13 @@ This is in fact an image descriptor (@pxref{Images}).  When used as a
 display specification, it means to display the image instead of the text
 that has the display specification.
 
+@item ((margin nil) @var{string})
+@itemx @var{string}
+A display specification of this form means to display @var{string}
+instead of the text that has the display specification, at the same
+position as that text.  This is a special case of marginal display
+(@pxref{Display Margins}).
+
 @item (space-width @var{factor})
 This display specification affects all the space characters within the
 text that has the specification.  It displays all of these spaces
@@ -2319,7 +2386,7 @@ If @var{window} is @code{nil}, the selected window is used.
 @cindex conditional display specifications
 
   You can make any display specification conditional.  To do that,
-package it in another list of the form @code{(when @var{condition}
+package it in another list of the form @code{(when @var{condition} .
 @var{spec})}.  Then the specification @var{spec} applies only when
 @var{condition} evaluates to a non-@code{nil} value.  During the
 evaluation, point is temporarily set at the end position of the text
@@ -2384,15 +2451,28 @@ types:
 
 @table @code
 @item :ascent @var{ascent}
-The @code{:ascent} property specifies the percentage of the image's
-height to use for its ascent---that is, the part above the baseline.  The
-value, @var{ascent}, must be a number in the range 0 to 100.  If this
-property is omitted, it defaults to 50.
+The @code{:ascent} property specifies the amount of the image's
+height to use for its ascent---that is, the part above the baseline.
+The value, @var{ascent}, must be a number in the range 0 to 100, or
+the symbol @code{center}.
+
+If @var{ascent} is a number, that percentage of the image's height is
+used for its ascent.
+
+If @var{ascent} is @code{center}, the image is vertically centered
+around a centerline which would be the vertical centerline of text drawn
+at the position of the image, in the manner specified by the text
+properties and overlays that apply to the image.
+
+If this property is omitted, it defaults to 50.
 
 @item :margin @var{margin}
-The @code{:margin} property specifies how many pixels to add as an extra
-margin around the image.  The value, @var{margin}, must be a
-non-negative number; if it is not specified, the default is zero.
+The @code{:margin} property specifies how many pixels to add as an
+extra margin around the image.  The value, @var{margin}, must be a a
+non-negative number, or a pair @code{(@var{x} . @var{y})} of such
+numbers.  If it is a pair, @var{x} specifies how many pixels to add
+horizontally, and @var{y} specifies how many pixels to add vertically.
+If @code{:margin} is not specified, the default is zero.
 
 @item :relief @var{relief}
 The @code{:relief} property, if non-@code{nil}, adds a shadow rectangle
@@ -2401,30 +2481,97 @@ shadow lines, in pixels.  If @var{relief} is negative, shadows are drawn
 so that the image appears as a pressed button; otherwise, it appears as
 an unpressed button.
 
-@item :algorithm @var{algorithm}
-The @code{:algorithm} property, if non-@code{nil}, specifies a
+@item :conversion @var{algorithm}
+The @code{:conversion} property, if non-@code{nil}, specifies a
 conversion algorithm that should be applied to the image before it is
 displayed; the value, @var{algorithm}, specifies which algorithm.
 
-Currently, the only meaningful value for @var{algorithm} (aside from
-@code{nil}) is @code{laplace}; this applies the Laplace edge detection
-algorithm, which blurs out small differences in color while highlighting
-larger differences.  People sometimes consider this useful for
-displaying the image for a ``disabled'' button.
+@table @code
+@item laplace
+@itemx emboss
+Specifies the Laplace edge detection algorithm, which blurs out small
+differences in color while highlighting larger differences.  People
+sometimes consider this useful for displaying the image for a
+``disabled'' button.
+
+@item (edge-detection :matrix @var{matrix} :color-adjust @var{adjust})
+Specifies a general edge-detection algorithm.  @var{matrix} must be
+either a nine-element list or a nine-element vector of numbers.  A pixel
+at position @math{x/y} in the transformed image is computed from
+original pixels around that position.  @var{matrix} specifies, for each
+pixel in the neighborhood of @math{x/y}, a factor with which that pixel
+will influence the transformed pixel; element @math{0} specifies the
+factor for the pixel at @math{x-1/y-1}, element @math{1} the factor for
+the pixel at @math{x/y-1} etc., as shown below:
+@iftex
+@tex
+$$\pmatrix{x-1/y-1 & x/y-1  & x+1/y-1 \cr
+   x-1/y  &   x/y &    x+1/y \cr
+   x-1/y+1&   x/y+1 &  x+1/y+1 \cr}$$
+@end tex
+@end iftex
+@ifnottex
+@display
+  (x-1/y-1  x/y-1  x+1/y-1
+   x-1/y    x/y    x+1/y
+   x-1/y+1  x/y+1  x+1/y+1)
+@end display
+@end ifnottex
+
+The resulting pixel is computed from the color intensity of the color
+resulting from summing up the RGB values of surrounding pixels,
+multiplied by the specified factors, and dividing that sum by the sum
+of the factors' absolute values.
+
+Laplace edge-detection currently uses a matrix of
+@iftex
+@tex
+$$\pmatrix{1 & 0 & 0 \cr
+   0&  0 &  0 \cr
+   9 & 9 & -1 \cr}$$
+@end tex
+@end iftex
+@ifnottex
+@display
+  (1  0  0
+   0  0  0
+   9  9 -1)
+@end display
+@end ifnottex
+
+Emboss edge-detection uses a matrix of
+@iftex
+@tex
+$$\pmatrix{ 2 & -1 &  0 \cr
+   -1 &  0 &  1 \cr
+    0  & 1 & -2 \cr}$$
+@end tex
+@end iftex
+@ifnottex
+@display
+  ( 2 -1  0
+   -1  0  1
+    0  1 -2)
+@end display
+@end ifnottex
 
-@item :heuristic-mask @var{transparent-color}
-The @code{:heuristic-mask} property, if non-@code{nil}, specifies that a
-certain color in the image should be transparent.  Each pixel where this
-color appears will actually allow the frame's background to show
-through.
+@item disabled
+Specifies transforming the image so that it looks ``disabled''.
+@end table
 
-If @var{transparent-color} is @code{t}, then determine the transparent
-color by looking at the four corners of the image.  This uses the color
-that occurs most frequently near the corners as the transparent color.
+@item :mask @var{mask}
+If @var{mask} is @code{heuristic} or @code{(heuristic @var{bg})}, build
+a clipping mask for the image, so that the background of a frame is
+visible behind the image.  If @var{bg} is not specified, or if @var{bg}
+is @code{t}, determine the background color of the image by looking at
+the four corners of the image, assuming the most frequently occurring
+color from the corners is the background color of the image.  Otherwise,
+@var{bg} must be a list @code{(@var{red} @var{green} @var{blue})}
+specifying the color to assume for the background of the image.
 
-Otherwise, @var{heuristic-mask} should specify the transparent color
-directly, as a list of three integers in the form @code{(@var{red}
-@var{green} @var{blue})}.
+If @var{mask} is nil, remove a mask from the image, if it has one.  Images
+in some formats include a mask which can be removed by specifying
+@code{:mask nil}.
 
 @item :file @var{file}
 The @code{:file} property specifies to load the image from file
@@ -2444,6 +2591,13 @@ for some, @code{:data} alone is not enough, so you need to use other
 image properties along with @code{:data}.
 @end table
 
+@defun image-mask-p spec &optional frame
+@tindex image-mask-p
+This function returns @code{t} if image @var{spec} has a mask bitmap.
+@var{frame} is the frame on which the image will be displayed.
+@var{frame} @code{nil} or omitted means to use the selected frame.
+@end defun
+
 @node XBM Images
 @subsection XBM Images
 @cindex XBM
@@ -2467,22 +2621,38 @@ background color.  This color is used for each pixel in the XBM that is
 @end table
 
   If you specify an XBM image using data within Emacs instead of an
-external file, use the following three properties (all of them):
+external file, use the following three properties:
 
 @table @code
-@item :width @var{width}
-The value, @var{width}, specifies the width the image in pixels.
+@item :data @var{data}
+The value, @var{data}, specifies the contents of the image.
+There are three formats you can use for @var{data}:
 
-@item :height @var{height}
-The value, @var{height}, specifies the height of the image in pixels.
+@itemize @bullet
+@item
+A vector of strings or bool-vectors, each specifying one line of the
+image.  Do specify @code{:height} and @code{:width}.
 
-@item :data @var{data}
-The value, @var{data}, should normally be a string or a bool-vector.
-Either way, it must contain enough bits for the area of the image: at
-least @var{width} * @code{height} bits.
+@item
+A string containing the same byte sequence as an XBM file would contain.
+You must not specify @code{:height} and @code{:width} in this case,
+because omitting them is what indicates the data has the format of an
+XBM file.  The file contents specify the height and width of the image.
 
-Alternatively, @var{data} can be a vector of strings or bool-vectors,
-each specifying one line of the image.
+@item
+A string or a bool-vector containing the bits of the image (plus perhaps
+some extra bits at the end that will not be used).  It should contain at
+least @var{width} * @code{height} bits.  In this case, you must specify
+@code{:height} and @code{:width}, both to indicate that the string
+contains just the bits rather than a whole XBM file, and to specify the
+size of the image.
+@end itemize
+
+@item :width @var{width}
+The value, @var{width}, specifies the width of the image, in pixels.
+
+@item :height @var{height}
+The value, @var{height}, specifies the height of the image, in pixels.
 @end table
 
 @node XPM Images
@@ -2578,7 +2748,20 @@ See the @file{etc/NEWS} file to make sure.
 @cindex PBM
 
   For PBM images, specify image type @code{pbm}.  Color, gray-scale and
-monochromatic images are supported.
+monochromatic images are supported.   For mono PBM images, two additional
+image properties are supported.
+
+@table @code
+@item :foreground @var{foreground}
+The value, @var{foreground}, should be a string specifying the image
+foreground color.  This color is used for each pixel in the XBM that is
+1.  The default is the frame's foreground color.
+
+@item :background @var{background}
+The value, @var{background}, should be a string specifying the image
+background color.  This color is used for each pixel in the XBM that is
+0.  The default is the frame's background color.
+@end table
 
   For JPEG images, specify image type @code{jpeg}.
 
@@ -2589,8 +2772,8 @@ monochromatic images are supported.
 @node Defining Images
 @subsection Defining Images
 
-  The functions @code{create-image} and @code{defimage} provide
-convenient ways to create image descriptors.
+  The functions @code{create-image}, @code{defimage} and
+@code{find-image} provide convenient ways to create image descriptors.
 
 @defun create-image file &optional type &rest props
 @tindex create-image
@@ -2638,6 +2821,25 @@ If none of the alternatives will work, then @var{variable} is defined
 as @code{nil}.
 @end defmac
 
+@defun find-image specs
+@tindex find-image
+This function provides a convenient way to find an image satisfying one
+of a list of image specifications @var{specs}.
+
+Each specification in @var{specs} is a property list with contents
+depending on image type.  All specifications must at least contain the
+properties @code{:type @var{type}} and either @w{@code{:file @var{file}}}
+or @w{@code{:data @var{DATA}}}, where @var{type} is a symbol specifying
+the image type, e.g.@: @code{xbm}, @var{file} is the file to load the
+image from, and @var{data} is a string containing the actual image data.
+The first specification in the list whose @var{type} is supported, and
+@var{file} exists, is used to construct the image specification to be
+returned.  If no specification is satisfied, @code{nil} is returned.
+
+The image is looked for first on @code{load-path} and then in
+@code{data-directory}.
+@end defun
+
 @node Showing Images
 @subsection Showing Images
 
@@ -2645,7 +2847,7 @@ as @code{nil}.
 property yourself, but it is easier to use the functions in this
 section.
 
-@defun insert-image image string &optional area
+@defun insert-image image &optional string area
 This function inserts @var{image} in the current buffer at point.  The
 value @var{image} should be an image descriptor; it could be a value
 returned by @code{create-image}, or the value of a symbol defined with
@@ -2663,11 +2865,12 @@ it a @code{display} property which specifies @var{image}.  @xref{Display
 Property}.
 @end defun
 
-@defun put-image image pos string &optional area
+@defun put-image image pos &optional string area
 This function puts image @var{image} in front of @var{pos} in the
 current buffer.  The argument @var{pos} should be an integer or a
 marker.  It specifies the buffer position where the image should appear.
-The argument @var{string} specifies the text that should hold the image.
+The argument @var{string} specifies the text that should hold the image
+as an alternative to the default.
 
 The argument @var{image} must be an image descriptor, perhaps returned
 by @code{create-image} or stored by @code{defimage}.
@@ -2693,6 +2896,17 @@ This removes only images that were put into @var{buffer} the way
 @code{insert-image} or in other ways.
 @end defun
 
+@defun image-size spec &optional pixels frame
+@tindex image-size
+This function returns the size of an image as a pair
+@w{@code{(@var{width} . @var{height})}}.  @var{spec} is an image
+specification.  @var{pixels} non-nil means return sizes measured in
+pixels, otherwise return sizes measured in canonical character units
+(fractions of the width/height of the frame's default font).
+@var{frame} is the frame on which the image will be displayed.
+@var{frame} null or omitted means use the selected frame.
+@end defun
+
 @node Image Cache
 @subsection Image Cache
 
@@ -2700,6 +2914,10 @@ This removes only images that were put into @var{buffer} the way
 display them again more efficiently.  It removes an image from the cache
 when it hasn't been displayed for a specified period of time.
 
+When an image is looked up in the cache, its specification is compared
+with cached image specifications using @code{equal}.  This means that
+all images with equal specifications share the same image in the cache.
+
 @defvar image-cache-eviction-delay
 @tindex image-cache-eviction-delay
 This variable specifies the number of seconds an image can remain in the