diff options
| author | Chong Yidong | 2012-03-21 15:02:13 +0800 |
|---|---|---|
| committer | Chong Yidong | 2012-03-21 15:02:13 +0800 |
| commit | fb5b8aca9928223c3fef042f1de4b50cd08fde43 (patch) | |
| tree | b1da6f261d64e95a4bbdf0566157c3919185adb2 | |
| parent | dc9924b8bd30e0f3f43b552070f6cac5c11942f7 (diff) | |
| download | emacs-fb5b8aca9928223c3fef042f1de4b50cd08fde43.tar.gz emacs-fb5b8aca9928223c3fef042f1de4b50cd08fde43.zip | |
Updates to Display chapter of Lisp manual.
* doc/lispref/display.texi (The Echo Area): Add xref to Output Streams.
(Displaying Messages): Improve doc of message.
(Echo Area Customization, Invisible Text): Copyedits.
(Invisible Text): Mention that spec comparison is done with eq.
(Width): Improve doc of char-width.
(Faces): Recommend using symbol instead of string for face name.
Minor clarifications.
(Defining Faces): Copyedits. Update face example.
(Attribute Functions): Mark set-face-foreground etc as commands.
(Face Remapping): Mention text-scale-adjust. Clarify
face-remapping-alist and related docs.
(Face Functions): Don't document make-face or copy-face.
* lisp/faces.el (make-face, make-empty-face, copy-face):
* lisp/face-remap.el (face-remap-add-relative, face-remap-set-base):
Doc fixes.
* src/xfaces.c (Vface_remapping_alist): Doc fix.
| -rw-r--r-- | doc/lispref/ChangeLog | 15 | ||||
| -rw-r--r-- | doc/lispref/display.texi | 407 | ||||
| -rw-r--r-- | etc/NEWS | 2 | ||||
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/face-remap.el | 42 | ||||
| -rw-r--r-- | lisp/faces.el | 47 | ||||
| -rw-r--r-- | src/ChangeLog | 4 | ||||
| -rw-r--r-- | src/xfaces.c | 36 |
8 files changed, 276 insertions, 283 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index 43ae349cb4c..77468f562c6 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | 2012-03-21 Chong Yidong <cyd@gnu.org> | ||
| 2 | |||
| 3 | * display.texi (The Echo Area): Add xref to Output Streams. | ||
| 4 | (Displaying Messages): Improve doc of message. | ||
| 5 | (Echo Area Customization, Invisible Text): Copyedits. | ||
| 6 | (Invisible Text): Mention that spec comparison is done with eq. | ||
| 7 | (Width): Improve doc of char-width. | ||
| 8 | (Faces): Recommend using symbol instead of string for face name. | ||
| 9 | Minor clarifications. | ||
| 10 | (Defining Faces): Copyedits. Update face example. | ||
| 11 | (Attribute Functions): Mark set-face-foreground etc as commands. | ||
| 12 | (Face Remapping): Mention text-scale-adjust. Clarify | ||
| 13 | face-remapping-alist and related docs. | ||
| 14 | (Face Functions): Don't document make-face or copy-face. | ||
| 15 | |||
| 1 | 2012-03-20 Chong Yidong <cyd@gnu.org> | 16 | 2012-03-20 Chong Yidong <cyd@gnu.org> |
| 2 | 17 | ||
| 3 | * display.texi (Forcing Redisplay): Various rewrites to reflect | 18 | * display.texi (Forcing Redisplay): Various rewrites to reflect |
diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index b68b0697936..dbcc1d1190b 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi | |||
| @@ -243,14 +243,12 @@ This variable is automatically buffer-local in every buffer. | |||
| 243 | (@pxref{Errors}), for messages made with the @code{message} primitive, | 243 | (@pxref{Errors}), for messages made with the @code{message} primitive, |
| 244 | and for echoing keystrokes. It is not the same as the minibuffer, | 244 | and for echoing keystrokes. It is not the same as the minibuffer, |
| 245 | despite the fact that the minibuffer appears (when active) in the same | 245 | despite the fact that the minibuffer appears (when active) in the same |
| 246 | place on the screen as the echo area. The @cite{GNU Emacs Manual} | 246 | place on the screen as the echo area. @xref{Minibuffer,, The |
| 247 | specifies the rules for resolving conflicts between the echo area and | 247 | Minibuffer, emacs, The GNU Emacs Manual}. |
| 248 | the minibuffer for use of that screen space (@pxref{Minibuffer,, The | ||
| 249 | Minibuffer, emacs, The GNU Emacs Manual}). | ||
| 250 | 248 | ||
| 251 | You can write output in the echo area by using the Lisp printing | 249 | Apart from the functions documented in this section, you can print |
| 252 | functions with @code{t} as the stream (@pxref{Output Functions}), or | 250 | Lisp objects to the echo area by specifying @code{t} as the output |
| 253 | explicitly. | 251 | stream. @xref{Output Streams}. |
| 254 | 252 | ||
| 255 | @menu | 253 | @menu |
| 256 | * Displaying Messages:: Explicitly displaying text in the echo area. | 254 | * Displaying Messages:: Explicitly displaying text in the echo area. |
| @@ -263,27 +261,26 @@ explicitly. | |||
| 263 | @subsection Displaying Messages in the Echo Area | 261 | @subsection Displaying Messages in the Echo Area |
| 264 | @cindex display message in echo area | 262 | @cindex display message in echo area |
| 265 | 263 | ||
| 266 | This section describes the functions for explicitly producing echo | 264 | This section describes the standard functions for displaying |
| 267 | area messages. Many other Emacs features display messages there, too. | 265 | messages in the echo area. |
| 268 | 266 | ||
| 269 | @defun message format-string &rest arguments | 267 | @defun message format-string &rest arguments |
| 270 | This function displays a message in the echo area. The argument | 268 | This function displays a message in the echo area. |
| 271 | @var{format-string} is similar to a C language @code{printf} format | 269 | @var{format-string} is a format string, and @var{arguments} are the |
| 272 | string. See @code{format} in @ref{Formatting Strings}, for the details | 270 | objects for its format specifications, like in the @code{format} |
| 273 | on the conversion specifications. @code{message} returns the | 271 | function (@pxref{Formatting Strings}). The resulting formatted string |
| 274 | constructed string. | 272 | is displayed in the echo area; if it contains @code{face} text |
| 273 | properties, it is displayed with the specified faces (@pxref{Faces}). | ||
| 274 | The string is also added to the @samp{*Messages*} buffer, but without | ||
| 275 | text properties (@pxref{Logging Messages}). | ||
| 276 | |||
| 277 | In batch mode, the message is printed to the standard error stream, | ||
| 278 | followed by a newline. | ||
| 275 | 279 | ||
| 276 | In batch mode, @code{message} prints the message text on the standard | ||
| 277 | error stream, followed by a newline. | ||
| 278 | |||
| 279 | If @var{format-string}, or strings among the @var{arguments}, have | ||
| 280 | @code{face} text properties, these affect the way the message is displayed. | ||
| 281 | |||
| 282 | @c Emacs 19 feature | ||
| 283 | If @var{format-string} is @code{nil} or the empty string, | 280 | If @var{format-string} is @code{nil} or the empty string, |
| 284 | @code{message} clears the echo area; if the echo area has been | 281 | @code{message} clears the echo area; if the echo area has been |
| 285 | expanded automatically, this brings it back to its normal size. | 282 | expanded automatically, this brings it back to its normal size. If |
| 286 | If the minibuffer is active, this brings the minibuffer contents back | 283 | the minibuffer is active, this brings the minibuffer contents back |
| 287 | onto the screen immediately. | 284 | onto the screen immediately. |
| 288 | 285 | ||
| 289 | @example | 286 | @example |
| @@ -559,13 +556,13 @@ If the value is zero, then command input is not echoed. | |||
| 559 | Normally, displaying a long message resizes the echo area to display | 556 | Normally, displaying a long message resizes the echo area to display |
| 560 | the entire message. But if the variable @code{message-truncate-lines} | 557 | the entire message. But if the variable @code{message-truncate-lines} |
| 561 | is non-@code{nil}, the echo area does not resize, and the message is | 558 | is non-@code{nil}, the echo area does not resize, and the message is |
| 562 | truncated to fit it, as in Emacs 20 and before. | 559 | truncated to fit it. |
| 563 | @end defvar | 560 | @end defvar |
| 564 | 561 | ||
| 565 | The variable @code{max-mini-window-height}, which specifies the | 562 | The variable @code{max-mini-window-height}, which specifies the |
| 566 | maximum height for resizing minibuffer windows, also applies to the | 563 | maximum height for resizing minibuffer windows, also applies to the |
| 567 | echo area (which is really a special use of the minibuffer window. | 564 | echo area (which is really a special use of the minibuffer window; |
| 568 | @xref{Minibuffer Misc}.). | 565 | @pxref{Minibuffer Misc}). |
| 569 | 566 | ||
| 570 | @node Warnings | 567 | @node Warnings |
| 571 | @section Reporting Warnings | 568 | @section Reporting Warnings |
| @@ -762,10 +759,11 @@ that warning is not logged. | |||
| 762 | @cindex invisible text | 759 | @cindex invisible text |
| 763 | You can make characters @dfn{invisible}, so that they do not appear on | 760 | You can make characters @dfn{invisible}, so that they do not appear on |
| 764 | the screen, with the @code{invisible} property. This can be either a | 761 | the screen, with the @code{invisible} property. This can be either a |
| 765 | text property (@pxref{Text Properties}) or a property of an overlay | 762 | text property (@pxref{Text Properties}) or an overlay property |
| 766 | (@pxref{Overlays}). Cursor motion also partly ignores these | 763 | (@pxref{Overlays}). Cursor motion also partly ignores these |
| 767 | characters; if the command loop finds point within them, it moves | 764 | characters; if the command loop finds that point is inside a range of |
| 768 | point to the other side of them. | 765 | invisible text after a command, it relocates point to the other side |
| 766 | of the text. | ||
| 769 | 767 | ||
| 770 | In the simplest case, any non-@code{nil} @code{invisible} property makes | 768 | In the simplest case, any non-@code{nil} @code{invisible} property makes |
| 771 | a character invisible. This is the default case---if you don't alter | 769 | a character invisible. This is the default case---if you don't alter |
| @@ -805,13 +803,15 @@ the character is invisible. The list can have two kinds of elements: | |||
| 805 | 803 | ||
| 806 | @table @code | 804 | @table @code |
| 807 | @item @var{atom} | 805 | @item @var{atom} |
| 808 | A character is invisible if its @code{invisible} property value | 806 | A character is invisible if its @code{invisible} property value is |
| 809 | is @var{atom} or if it is a list with @var{atom} as a member. | 807 | @var{atom} or if it is a list with @var{atom} as a member; comparison |
| 808 | is done with @code{eq}. | ||
| 810 | 809 | ||
| 811 | @item (@var{atom} . t) | 810 | @item (@var{atom} . t) |
| 812 | A character is invisible if its @code{invisible} property value is | 811 | A character is invisible if its @code{invisible} property value is |
| 813 | @var{atom} or if it is a list with @var{atom} as a member. Moreover, | 812 | @var{atom} or if it is a list with @var{atom} as a member; comparison |
| 814 | a sequence of such characters displays as an ellipsis. | 813 | is done with @code{eq}. Moreover, a sequence of such characters |
| 814 | displays as an ellipsis. | ||
| 815 | @end table | 815 | @end table |
| 816 | @end table | 816 | @end table |
| 817 | @end defvar | 817 | @end defvar |
| @@ -846,7 +846,7 @@ major mode should use the mode's own name as an element of | |||
| 846 | (overlay-put (make-overlay beginning end) | 846 | (overlay-put (make-overlay beginning end) |
| 847 | 'invisible 'my-symbol) | 847 | 'invisible 'my-symbol) |
| 848 | 848 | ||
| 849 | ;; @r{When done with the overlays:} | 849 | ;; @r{When done with the invisibility:} |
| 850 | (remove-from-invisibility-spec '(my-symbol . t)) | 850 | (remove-from-invisibility-spec '(my-symbol . t)) |
| 851 | ;; @r{Or respectively:} | 851 | ;; @r{Or respectively:} |
| 852 | (remove-from-invisibility-spec 'my-symbol) | 852 | (remove-from-invisibility-spec 'my-symbol) |
| @@ -872,15 +872,16 @@ ignore invisible newlines if @code{line-move-ignore-invisible} is | |||
| 872 | non-@code{nil} (the default), but only because they are explicitly | 872 | non-@code{nil} (the default), but only because they are explicitly |
| 873 | programmed to do so. | 873 | programmed to do so. |
| 874 | 874 | ||
| 875 | However, if a command ends with point inside or at the boundary of invisible | 875 | However, if a command ends with point inside or at the boundary of |
| 876 | text, the main editing loop moves point to one of the two ends of the invisible | 876 | invisible text, the main editing loop relocates point to one of the |
| 877 | text. Which end to move to is chosen based on the following factors: make sure | 877 | two ends of the invisible text. Emacs chooses the direction of |
| 878 | that the overall movement of the command is still in the same direction, and | 878 | relocation so that it is the same as the overall movement direction of |
| 879 | prefer a position where an inserted char would not inherit the @code{invisible} | 879 | the command; if in doubt, it prefers a position where an inserted char |
| 880 | property. Additionally, if the text is not replaced by an ellipsis and the | 880 | would not inherit the @code{invisible} property. Additionally, if the |
| 881 | command only moved within the invisible text, then point is moved one extra | 881 | text is not replaced by an ellipsis and the command only moved within |
| 882 | character so as to try and reflect the command's movement by a visible movement | 882 | the invisible text, then point is moved one extra character so as to |
| 883 | of the cursor. | 883 | try and reflect the command's movement by a visible movement of the |
| 884 | cursor. | ||
| 884 | 885 | ||
| 885 | Thus, if the command moved point back to an invisible range (with the usual | 886 | Thus, if the command moved point back to an invisible range (with the usual |
| 886 | stickiness), Emacs moves point back to the beginning of that range. If the | 887 | stickiness), Emacs moves point back to the beginning of that range. If the |
| @@ -1666,8 +1667,11 @@ check the width of a character. @xref{Primitive Indent}, and | |||
| 1666 | @ref{Screen Lines}, for related functions. | 1667 | @ref{Screen Lines}, for related functions. |
| 1667 | 1668 | ||
| 1668 | @defun char-width char | 1669 | @defun char-width char |
| 1669 | This function returns the width in columns of the character @var{char}, | 1670 | This function returns the width in columns of the character |
| 1670 | if it were displayed in the current buffer and the selected window. | 1671 | @var{char}, if it were displayed in the current buffer (i.e.@: taking |
| 1672 | into account the buffer's display table, if any; @pxref{Display | ||
| 1673 | Tables}). The width of a tab character is usually @code{tab-width} | ||
| 1674 | (@pxref{Usual Display}). | ||
| 1671 | @end defun | 1675 | @end defun |
| 1672 | 1676 | ||
| 1673 | @defun string-width string | 1677 | @defun string-width string |
| @@ -1813,26 +1817,27 @@ height. | |||
| 1813 | @section Faces | 1817 | @section Faces |
| 1814 | @cindex faces | 1818 | @cindex faces |
| 1815 | 1819 | ||
| 1816 | A @dfn{face} is a collection of graphical attributes for displaying | 1820 | A @dfn{face} is a collection of graphical @dfn{attributes} for |
| 1817 | text: font, foreground color, background color, optional underlining, | 1821 | displaying text: font, foreground color, background color, optional |
| 1818 | and so on. Faces control how buffer text is displayed, and how some | 1822 | underlining, and so on. Faces control how Emacs displays text in |
| 1819 | parts of the frame, such as the mode-line, are displayed. | 1823 | buffers, as well as other parts of the frame such as the mode line. |
| 1820 | @xref{Standard Faces,,, emacs, The GNU Emacs Manual}, for the list of | 1824 | @xref{Standard Faces,,, emacs, The GNU Emacs Manual}, for the list of |
| 1821 | faces Emacs normally comes with. | 1825 | faces Emacs normally comes with. |
| 1822 | 1826 | ||
| 1823 | @cindex face id | 1827 | @cindex face id |
| 1824 | For most purposes, you refer to a face in Lisp programs using its | 1828 | For most purposes, you refer to a face in Lisp programs using its |
| 1825 | @dfn{face name}. This is either a string or (equivalently) a Lisp | 1829 | @dfn{face name}, which is usually a Lisp symbol. For backward |
| 1826 | symbol whose name is equal to that string. | 1830 | compatibility, a face name can also be a string, which is equivalent |
| 1831 | to a Lisp symbol of the same name. | ||
| 1827 | 1832 | ||
| 1828 | @defun facep object | 1833 | @defun facep object |
| 1829 | This function returns a non-@code{nil} value if @var{object} is a Lisp | 1834 | This function returns a non-@code{nil} value if @var{object} is a Lisp |
| 1830 | symbol or string that names a face. Otherwise, it returns @code{nil}. | 1835 | symbol or string that names a face. Otherwise, it returns @code{nil}. |
| 1831 | @end defun | 1836 | @end defun |
| 1832 | 1837 | ||
| 1833 | Each face name is meaningful for all frames, and by default it has | 1838 | By default, each face name corresponds to the same set of attributes |
| 1834 | the same meaning in all frames. But you can arrange to give a | 1839 | in all frames. But you can also assign a face name a special set of |
| 1835 | particular face name a special meaning in one frame if you wish. | 1840 | attributes in one frame (@pxref{Attribute Functions}). |
| 1836 | 1841 | ||
| 1837 | @menu | 1842 | @menu |
| 1838 | * Defining Faces:: How to define a face with @code{defface}. | 1843 | * Defining Faces:: How to define a face with @code{defface}. |
| @@ -1855,9 +1860,8 @@ particular face name a special meaning in one frame if you wish. | |||
| 1855 | @subsection Defining Faces | 1860 | @subsection Defining Faces |
| 1856 | 1861 | ||
| 1857 | The way to define a new face is with @code{defface}. This creates a | 1862 | The way to define a new face is with @code{defface}. This creates a |
| 1858 | kind of customization item (@pxref{Customization}) which the user can | 1863 | kind of customization item which the user can customize using the |
| 1859 | customize using the Customization buffer (@pxref{Easy Customization,,, | 1864 | Customization buffer (@pxref{Customization}). |
| 1860 | emacs, The GNU Emacs Manual}). | ||
| 1861 | 1865 | ||
| 1862 | People are sometimes tempted to create variables whose values specify | 1866 | People are sometimes tempted to create variables whose values specify |
| 1863 | which faces to use (for example, Font-Lock does this). In the vast | 1867 | which faces to use (for example, Font-Lock does this). In the vast |
| @@ -1883,14 +1887,16 @@ exactly what the @code{defface} says. | |||
| 1883 | 1887 | ||
| 1884 | The purpose of @var{spec} is to specify how the face should appear on | 1888 | The purpose of @var{spec} is to specify how the face should appear on |
| 1885 | different kinds of terminals. It should be an alist whose elements | 1889 | different kinds of terminals. It should be an alist whose elements |
| 1886 | have the form @code{(@var{display} @var{atts})}. Each element's | 1890 | have the form @code{(@var{display} @var{atts})}. @var{display} |
| 1887 | @sc{car}, @var{display}, specifies a class of terminals. (The first | 1891 | specifies a class of terminals (see below), while @var{atts} is a |
| 1888 | element, if its @sc{car} is @code{default}, is special---it specifies | 1892 | property list of face attributes and their values, specifying the |
| 1889 | defaults for the remaining elements). The element's @sc{cadr}, | 1893 | appearance of the face on matching terminals |
| 1890 | @var{atts}, is a list of face attributes and their values; it | 1894 | @iftex |
| 1891 | specifies what the face should look like on that kind of terminal. | 1895 | (see the next section for details about face attributes). |
| 1892 | The possible attributes are defined in the value of | 1896 | @end iftex |
| 1893 | @code{custom-face-attributes}. | 1897 | @ifnottex |
| 1898 | (@pxref{Face Attributes}, for details about face attributes). | ||
| 1899 | @end ifnottex | ||
| 1894 | 1900 | ||
| 1895 | The @var{display} part of an element of @var{spec} determines which | 1901 | The @var{display} part of an element of @var{spec} determines which |
| 1896 | frames the element matches. If more than one element of @var{spec} | 1902 | frames the element matches. If more than one element of @var{spec} |
| @@ -1952,29 +1958,23 @@ frame must match one of the @var{value}s specified for it in | |||
| 1952 | @end table | 1958 | @end table |
| 1953 | @end defmac | 1959 | @end defmac |
| 1954 | 1960 | ||
| 1955 | Here's how the standard face @code{region} is defined: | 1961 | Here's how the standard face @code{highlight} is defined: |
| 1956 | 1962 | ||
| 1957 | @example | 1963 | @example |
| 1958 | @group | 1964 | (defface highlight |
| 1959 | (defface region | 1965 | '((((class color) (min-colors 88) (background light)) |
| 1960 | '((((class color) (min-colors 88) (background dark)) | 1966 | :background "darkseagreen2") |
| 1961 | :background "blue3") | 1967 | (((class color) (min-colors 88) (background dark)) |
| 1962 | @end group | 1968 | :background "darkolivegreen") |
| 1963 | (((class color) (min-colors 88) (background light)) | ||
| 1964 | :background "lightgoldenrod2") | ||
| 1965 | (((class color) (min-colors 16) (background dark)) | ||
| 1966 | :background "blue3") | ||
| 1967 | (((class color) (min-colors 16) (background light)) | 1969 | (((class color) (min-colors 16) (background light)) |
| 1968 | :background "lightgoldenrod2") | 1970 | :background "darkseagreen2") |
| 1971 | (((class color) (min-colors 16) (background dark)) | ||
| 1972 | :background "darkolivegreen") | ||
| 1969 | (((class color) (min-colors 8)) | 1973 | (((class color) (min-colors 8)) |
| 1970 | :background "blue" :foreground "white") | 1974 | :background "green" :foreground "black") |
| 1971 | (((type tty) (class mono)) | 1975 | (t :inverse-video t)) |
| 1972 | :inverse-video t) | 1976 | "Basic face for highlighting." |
| 1973 | (t :background "gray")) | ||
| 1974 | @group | ||
| 1975 | "Basic face for highlighting the region." | ||
| 1976 | :group 'basic-faces) | 1977 | :group 'basic-faces) |
| 1977 | @end group | ||
| 1978 | @end example | 1978 | @end example |
| 1979 | 1979 | ||
| 1980 | Internally, @code{defface} uses the symbol property | 1980 | Internally, @code{defface} uses the symbol property |
| @@ -2010,8 +2010,8 @@ doesn't specify that attribute. In face merging, when the first face | |||
| 2010 | fails to specify a particular attribute, the next face gets a chance. | 2010 | fails to specify a particular attribute, the next face gets a chance. |
| 2011 | However, the @code{default} face must specify all attributes. | 2011 | However, the @code{default} face must specify all attributes. |
| 2012 | 2012 | ||
| 2013 | Some of these font attributes are meaningful only on certain kinds | 2013 | Some of these attributes are meaningful only on certain kinds of |
| 2014 | of displays. If your display cannot handle a certain attribute, the | 2014 | displays. If your display cannot handle a certain attribute, the |
| 2015 | attribute is ignored. | 2015 | attribute is ignored. |
| 2016 | 2016 | ||
| 2017 | @table @code | 2017 | @table @code |
| @@ -2216,20 +2216,18 @@ This function sets one or more attributes of @var{face} for | |||
| 2216 | the @code{defface} says. | 2216 | the @code{defface} says. |
| 2217 | 2217 | ||
| 2218 | The extra arguments @var{arguments} specify the attributes to set, and | 2218 | The extra arguments @var{arguments} specify the attributes to set, and |
| 2219 | the values for them. They should consist of alternating attribute names | 2219 | the values for them. They should consist of alternating attribute |
| 2220 | (such as @code{:family} or @code{:underline}) and corresponding values. | 2220 | names (such as @code{:family} or @code{:underline}) and values. Thus, |
| 2221 | Thus, | ||
| 2222 | 2221 | ||
| 2223 | @example | 2222 | @example |
| 2224 | (set-face-attribute 'foo nil | 2223 | (set-face-attribute 'foo nil |
| 2225 | :width 'extended | 2224 | :width 'extended |
| 2226 | :weight 'bold | 2225 | :weight 'bold) |
| 2227 | :underline "red") | ||
| 2228 | @end example | 2226 | @end example |
| 2229 | 2227 | ||
| 2230 | @noindent | 2228 | @noindent |
| 2231 | sets the attributes @code{:width}, @code{:weight} and @code{:underline} | 2229 | sets the attribute @code{:width} to @code{extended} and the attribute |
| 2232 | to the corresponding values. | 2230 | @code{:weight} to @code{bold}. |
| 2233 | 2231 | ||
| 2234 | If @var{frame} is @code{t}, this function sets the default attributes | 2232 | If @var{frame} is @code{t}, this function sets the default attributes |
| 2235 | for new frames. Default attribute values specified this way override | 2233 | for new frames. Default attribute values specified this way override |
| @@ -2306,54 +2304,51 @@ If @var{value1} is a relative value for the face attribute | |||
| 2306 | face attribute @var{attribute}, returns @var{value1} unchanged. | 2304 | face attribute @var{attribute}, returns @var{value1} unchanged. |
| 2307 | @end defun | 2305 | @end defun |
| 2308 | 2306 | ||
| 2309 | The following functions provide compatibility with Emacs 20 and | 2307 | The following commands and functions mostly provide compatibility |
| 2310 | below. They work by calling @code{set-face-attribute}. Values of | 2308 | with old versions of Emacs. They work by calling |
| 2311 | @code{t} and @code{nil} for their @var{frame} argument are handled | 2309 | @code{set-face-attribute}. Values of @code{t} and @code{nil} for |
| 2312 | just like @code{set-face-attribute} and @code{face-attribute}. | 2310 | their @var{frame} argument are handled just like |
| 2311 | @code{set-face-attribute} and @code{face-attribute}. The commands | ||
| 2312 | read their arguments using the minibuffer, if called interactively. | ||
| 2313 | 2313 | ||
| 2314 | @defun set-face-foreground face color &optional frame | 2314 | @deffn Command set-face-foreground face color &optional frame |
| 2315 | @defunx set-face-background face color &optional frame | 2315 | @deffnx Command set-face-background face color &optional frame |
| 2316 | These functions set the @code{:foreground} attribute (or | 2316 | These set the @code{:foreground} attribute (or @code{:background} |
| 2317 | @code{:background} attribute, respectively) of @var{face} to | 2317 | attribute, respectively) of @var{face} to @var{color}. |
| 2318 | @var{color}. | 2318 | @end deffn |
| 2319 | @end defun | ||
| 2320 | 2319 | ||
| 2321 | @defun set-face-stipple face pattern &optional frame | 2320 | @deffn Command set-face-stipple face pattern &optional frame |
| 2322 | This function sets the @code{:stipple} attribute of @var{face} to | 2321 | This sets the @code{:stipple} attribute of @var{face} to |
| 2323 | @var{pattern}. | 2322 | @var{pattern}. |
| 2324 | @end defun | 2323 | @end deffn |
| 2325 | 2324 | ||
| 2326 | @defun set-face-font face font &optional frame | 2325 | @deffn Command set-face-font face font &optional frame |
| 2327 | This function sets the @code{:font} attribute of @var{face} to | 2326 | This sets the @code{:font} attribute of @var{face} to @var{font}. |
| 2328 | @var{font}. | 2327 | @end deffn |
| 2329 | @end defun | ||
| 2330 | 2328 | ||
| 2331 | @defun set-face-bold-p face bold-p &optional frame | 2329 | @defun set-face-bold-p face bold-p &optional frame |
| 2332 | This function sets the @code{:weight} attribute of @var{face} to | 2330 | This sets the @code{:weight} attribute of @var{face} to @var{normal} |
| 2333 | @var{normal} if @var{bold-p} is @code{nil}, and to @var{bold} | 2331 | if @var{bold-p} is @code{nil}, and to @var{bold} otherwise. |
| 2334 | otherwise. | ||
| 2335 | @end defun | 2332 | @end defun |
| 2336 | 2333 | ||
| 2337 | @defun set-face-italic-p face italic-p &optional frame | 2334 | @defun set-face-italic-p face italic-p &optional frame |
| 2338 | This function sets the @code{:slant} attribute of @var{face} to | 2335 | This sets the @code{:slant} attribute of @var{face} to @var{normal} if |
| 2339 | @var{normal} if @var{italic-p} is @code{nil}, and to @var{italic} | 2336 | @var{italic-p} is @code{nil}, and to @var{italic} otherwise. |
| 2340 | otherwise. | ||
| 2341 | @end defun | 2337 | @end defun |
| 2342 | 2338 | ||
| 2343 | @defun set-face-underline-p face underline &optional frame | 2339 | @defun set-face-underline-p face underline &optional frame |
| 2344 | This function sets the @code{:underline} attribute of @var{face} to | 2340 | This sets the @code{:underline} attribute of @var{face} to |
| 2345 | @var{underline}. | 2341 | @var{underline}. |
| 2346 | @end defun | 2342 | @end defun |
| 2347 | 2343 | ||
| 2348 | @defun set-face-inverse-video-p face inverse-video-p &optional frame | 2344 | @defun set-face-inverse-video-p face inverse-video-p &optional frame |
| 2349 | This function sets the @code{:inverse-video} attribute of @var{face} | 2345 | This sets the @code{:inverse-video} attribute of @var{face} to |
| 2350 | to @var{inverse-video-p}. | 2346 | @var{inverse-video-p}. |
| 2351 | @end defun | 2347 | @end defun |
| 2352 | 2348 | ||
| 2353 | @defun invert-face face &optional frame | 2349 | @deffn Command invert-face face &optional frame |
| 2354 | This function swaps the foreground and background colors of face | 2350 | This swaps the foreground and background colors of face @var{face}. |
| 2355 | @var{face}. | 2351 | @end deffn |
| 2356 | @end defun | ||
| 2357 | 2352 | ||
| 2358 | The following functions examine the attributes of a face. If you | 2353 | The following functions examine the attributes of a face. If you |
| 2359 | don't specify @var{frame}, they refer to the selected frame; @code{t} | 2354 | don't specify @var{frame}, they refer to the selected frame; @code{t} |
| @@ -2459,27 +2454,26 @@ steps, Emacs applies the attribute of the @code{default} face. | |||
| 2459 | If these various sources together specify more than one face for a | 2454 | If these various sources together specify more than one face for a |
| 2460 | particular character, Emacs merges the attributes of the various faces | 2455 | particular character, Emacs merges the attributes of the various faces |
| 2461 | specified. For each attribute, Emacs tries using the above order | 2456 | specified. For each attribute, Emacs tries using the above order |
| 2462 | (i.e., first the face of any special glyph; then the face for region | 2457 | (i.e.@: first the face of any special glyph; then the face for region |
| 2463 | highlighting, if appropriate; then faces specified by overlays, then | 2458 | highlighting, if appropriate; and so on). |
| 2464 | faces specified by text properties, then the @code{mode-line} or | ||
| 2465 | @code{mode-line-inactive} or @code{header-line} face, if appropriate, | ||
| 2466 | and finally the @code{default} face). | ||
| 2467 | 2459 | ||
| 2468 | @node Face Remapping | 2460 | @node Face Remapping |
| 2469 | @subsection Face Remapping | 2461 | @subsection Face Remapping |
| 2470 | 2462 | ||
| 2471 | The variable @code{face-remapping-alist} is used for buffer-local or | 2463 | The variable @code{face-remapping-alist} is used for buffer-local or |
| 2472 | global changes in the appearance of a face. For instance, it can be | 2464 | global changes in the appearance of a face. For instance, it is used |
| 2473 | used to make the @code{default} face a variable-pitch face within a | 2465 | to implement the @code{text-scale-adjust} command (@pxref{Text |
| 2474 | particular buffer. | 2466 | Scale,,, emacs, The GNU Emacs Manual}). |
| 2475 | 2467 | ||
| 2476 | @defvar face-remapping-alist | 2468 | @defvar face-remapping-alist |
| 2477 | An alist whose elements have the form @code{(@var{face} | 2469 | The value of this variable is an alist whose elements have the form |
| 2478 | @var{remapping...})}. This causes Emacs to display text using the | 2470 | @code{(@var{face} . @var{remapping})}. This causes Emacs to display |
| 2479 | face @var{face} using @var{remapping...} instead of @var{face}'s | 2471 | any text having the face @var{face} with @var{remapping}, rather than |
| 2480 | ordinary definition. @var{remapping...} may be any face specification | 2472 | the ordinary definition of @var{face}. @var{remapping} may be any |
| 2481 | suitable for a @code{face} text property: either a face name, or a | 2473 | face specification suitable for a @code{face} text property: either a |
| 2482 | property list of attribute/value pairs. @xref{Special Properties}. | 2474 | face name, or a property list of attribute/value pairs, or a list in |
| 2475 | which each element is either a face name or a property list | ||
| 2476 | (@pxref{Special Properties}). | ||
| 2483 | 2477 | ||
| 2484 | If @code{face-remapping-alist} is buffer-local, its local value takes | 2478 | If @code{face-remapping-alist} is buffer-local, its local value takes |
| 2485 | effect only within that buffer. | 2479 | effect only within that buffer. |
| @@ -2488,17 +2482,15 @@ Two points bear emphasizing: | |||
| 2488 | 2482 | ||
| 2489 | @enumerate | 2483 | @enumerate |
| 2490 | @item | 2484 | @item |
| 2491 | The new definition @var{remapping...} is the complete | 2485 | @var{remapping} serves as the complete specification for the remapped |
| 2492 | specification of how to display @var{face}---it entirely replaces, | 2486 | face---it replaces the normal definition of @var{face}, instead of |
| 2493 | rather than augmenting or modifying, the normal definition of that | 2487 | modifying it. |
| 2494 | face. | ||
| 2495 | 2488 | ||
| 2496 | @item | 2489 | @item |
| 2497 | If @var{remapping...} recursively references the same face name | 2490 | If @var{remapping} references the same face name @var{face}, either |
| 2498 | @var{face}, either directly remapping entry, or via the | 2491 | directly or via the @code{:inherit} attribute of some other face in |
| 2499 | @code{:inherit} attribute of some other face in @var{remapping...}, | 2492 | @var{remapping}, that reference uses the normal definition of |
| 2500 | then that reference uses the normal definition of @var{face} in the | 2493 | @var{face}. In other words, the remapping cannot be recursive. |
| 2501 | selected frame, instead of the ``remapped'' definition. | ||
| 2502 | 2494 | ||
| 2503 | For instance, if the @code{mode-line} face is remapped using this | 2495 | For instance, if the @code{mode-line} face is remapped using this |
| 2504 | entry in @code{face-remapping-alist}: | 2496 | entry in @code{face-remapping-alist}: |
| @@ -2512,82 +2504,72 @@ then the new definition of the @code{mode-line} face inherits from the | |||
| 2512 | @end enumerate | 2504 | @end enumerate |
| 2513 | @end defvar | 2505 | @end defvar |
| 2514 | 2506 | ||
| 2515 | A typical use of the @code{face-remapping-alist} is to change a | ||
| 2516 | buffer's @code{default} face; for example, the following changes a | ||
| 2517 | buffer's @code{default} face to use the @code{variable-pitch} face, | ||
| 2518 | with the height doubled: | ||
| 2519 | |||
| 2520 | @example | ||
| 2521 | (set (make-local-variable 'face-remapping-alist) | ||
| 2522 | '((default variable-pitch :height 2.0))) | ||
| 2523 | @end example | ||
| 2524 | |||
| 2525 | The following functions implement a higher-level interface to | 2507 | The following functions implement a higher-level interface to |
| 2526 | @code{face-remapping-alist}, making it easier to use | 2508 | @code{face-remapping-alist}. Most Lisp code should use these |
| 2527 | ``cooperatively''. They are mainly intended for buffer-local use, and | 2509 | functions instead of setting @code{face-remapping-alist} directly, to |
| 2528 | so all make @code{face-remapping-alist} variable buffer-local as a | 2510 | avoid trampling on remappings applied elsewhere. These functions are |
| 2529 | side-effect. They use entries in @code{face-remapping-alist} which | 2511 | intended for buffer-local remappings, so they all make |
| 2530 | have the general form: | 2512 | @code{face-remapping-alist} buffer-local as a side-effect. They manage |
| 2513 | @code{face-remapping-alist} entries of the form | ||
| 2531 | 2514 | ||
| 2532 | @example | 2515 | @example |
| 2533 | (@var{face} @var{relative_specs_1} @var{relative_specs_2} @var{...} @var{base_specs}) | 2516 | (@var{face} @var{relative-spec-1} @var{relative-spec-2} @var{...} @var{base-spec}) |
| 2534 | @end example | 2517 | @end example |
| 2535 | 2518 | ||
| 2536 | Everything except @var{face} is a ``face spec'': a list of face names | 2519 | @noindent |
| 2537 | or face attribute-value pairs. All face specs are merged together, | 2520 | where, as explained above, each of the @var{relative-spec-N} and |
| 2538 | with earlier values taking precedence. | 2521 | @var{base-spec} is either a face name, or a property list of |
| 2539 | 2522 | attribute/value pairs. Each of the @dfn{relative remapping} entries, | |
| 2540 | The @var{relative_specs_}n values are ``relative specs'', and are | 2523 | @var{relative-spec-N}, is managed by the |
| 2541 | added by @code{face-remap-add-relative} (and removed by | 2524 | @code{face-remap-add-relative} and @code{face-remap-remove-relative} |
| 2542 | @code{face-remap-remove-relative}. These are intended for face | 2525 | functions; these are intended for simple modifications like changing |
| 2543 | modifications (such as increasing the size). Typical users of these | 2526 | the text size. The @dfn{base remapping} entry, @var{base-spec}, has |
| 2544 | relative specs would be minor modes. | 2527 | the lowest priority and is managed by the @code{face-remap-set-base} |
| 2545 | 2528 | and @code{face-remap-reset-base} functions; it is intended for major | |
| 2546 | @var{base_specs} is the lowest-priority value, and by default is just the | 2529 | modes to remap faces in the buffers they control. |
| 2547 | face name, which causes the global definition of that face to be used. | ||
| 2548 | |||
| 2549 | A non-default value of @var{base_specs} may also be set using | ||
| 2550 | @code{face-remap-set-base}. Because this @emph{overwrites} the | ||
| 2551 | default base-spec value (which inherits the global face definition), | ||
| 2552 | it is up to the caller of @code{face-remap-set-base} to add such | ||
| 2553 | inheritance if it is desired. A typical use of | ||
| 2554 | @code{face-remap-set-base} would be a major mode adding a face | ||
| 2555 | remappings, e.g., of the default face. | ||
| 2556 | |||
| 2557 | 2530 | ||
| 2558 | @defun face-remap-add-relative face &rest specs | 2531 | @defun face-remap-add-relative face &rest specs |
| 2559 | This functions adds a face remapping entry of @var{face} to @var{specs} | 2532 | This functions adds the face specifications in @var{specs} as relative |
| 2560 | in the current buffer. | 2533 | remappings for face @var{face} in the current buffer. The remaining |
| 2534 | arguments, @var{specs}, should form either a list of face names, or a | ||
| 2535 | property list of attribute/value pairs. | ||
| 2536 | |||
| 2537 | The return value is a Lisp object that serves as a ``cookie''; you can | ||
| 2538 | pass this object as an argument to @code{face-remap-remove-relative} | ||
| 2539 | if you need to remove the remapping later. | ||
| 2561 | 2540 | ||
| 2562 | It returns a ``cookie'' which can be used to later delete the remapping with | 2541 | @example |
| 2563 | @code{face-remap-remove-relative}. | 2542 | ;; Remap the `escape-glyph' face into a combination |
| 2543 | ;; of the `highlight' and `italic' faces: | ||
| 2544 | (face-remap-add-relative 'escape-glyph 'highlight 'italic) | ||
| 2564 | 2545 | ||
| 2565 | @var{specs} can be any value suitable for the @code{face} text | 2546 | ;; Increase the size of the `default' face by 50%: |
| 2566 | property, including a face name, a list of face names, or a | 2547 | (face-remap-add-relative 'default :height 1.5) |
| 2567 | face-attribute property list. The attributes given by @var{specs} | 2548 | @end example |
| 2568 | will be merged with any other currently active face remappings of | ||
| 2569 | @var{face}, and with the global definition of @var{face} (by default; | ||
| 2570 | this may be changed using @code{face-remap-set-base}), with the most | ||
| 2571 | recently added relative remapping taking precedence. | ||
| 2572 | @end defun | 2549 | @end defun |
| 2573 | 2550 | ||
| 2574 | @defun face-remap-remove-relative cookie | 2551 | @defun face-remap-remove-relative cookie |
| 2575 | This function removes a face remapping previously added by | 2552 | This function removes a relative remapping previously added by |
| 2576 | @code{face-remap-add-relative}. @var{cookie} should be a return value | 2553 | @code{face-remap-add-relative}. @var{cookie} should be the Lisp |
| 2577 | from that function. | 2554 | object returned by @code{face-remap-add-relative} when the remapping |
| 2555 | was added. | ||
| 2578 | @end defun | 2556 | @end defun |
| 2579 | 2557 | ||
| 2580 | @defun face-remap-set-base face &rest specs | 2558 | @defun face-remap-set-base face &rest specs |
| 2581 | This function sets the ``base remapping'' of @var{face} in the current | 2559 | This function sets the base remapping of @var{face} in the current |
| 2582 | buffer to @var{specs}. If @var{specs} is empty, the default base | 2560 | buffer to @var{specs}. If @var{specs} is empty, the default base |
| 2583 | remapping is restored, which inherits from the global definition of | 2561 | remapping is restored, similar to calling @code{face-remap-reset-base} |
| 2584 | @var{face}; note that this is different from @var{specs} containing a | 2562 | (see below); note that this is different from @var{specs} containing a |
| 2585 | single value @code{nil}, which has the opposite result (the global | 2563 | single value @code{nil}, which has the opposite result (the global |
| 2586 | definition of @var{face} is ignored). | 2564 | definition of @var{face} is ignored). |
| 2565 | |||
| 2566 | This overwrites the default @var{base-spec}, which inherits the global | ||
| 2567 | face definition, so it is up to the caller to add such inheritance if | ||
| 2568 | so desired. | ||
| 2587 | @end defun | 2569 | @end defun |
| 2588 | 2570 | ||
| 2589 | @defun face-remap-reset-base face | 2571 | @defun face-remap-reset-base face |
| 2590 | This function sets the ``base remapping'' of @var{face} to its default | 2572 | This function sets the base remapping of @var{face} to its default |
| 2591 | value, which inherits from @var{face}'s global definition. | 2573 | value, which inherits from @var{face}'s global definition. |
| 2592 | @end defun | 2574 | @end defun |
| 2593 | 2575 | ||
| @@ -2596,29 +2578,8 @@ value, which inherits from @var{face}'s global definition. | |||
| 2596 | 2578 | ||
| 2597 | Here are additional functions for creating and working with faces. | 2579 | Here are additional functions for creating and working with faces. |
| 2598 | 2580 | ||
| 2599 | @defun make-face name | ||
| 2600 | This function defines a new face named @var{name}, initially with all | ||
| 2601 | attributes @code{nil}. It does nothing if there is already a face named | ||
| 2602 | @var{name}. | ||
| 2603 | @end defun | ||
| 2604 | |||
| 2605 | @defun face-list | 2581 | @defun face-list |
| 2606 | This function returns a list of all defined faces. | 2582 | This function returns a list of all defined face names. |
| 2607 | @end defun | ||
| 2608 | |||
| 2609 | @defun copy-face old-face new-name &optional frame new-frame | ||
| 2610 | This function defines a face named @var{new-name} as a copy of the existing | ||
| 2611 | face named @var{old-face}. It creates the face @var{new-name} if that | ||
| 2612 | doesn't already exist. | ||
| 2613 | |||
| 2614 | If the optional argument @var{frame} is given, this function applies | ||
| 2615 | only to that frame. Otherwise it applies to each frame individually, | ||
| 2616 | copying attributes from @var{old-face} in each frame to @var{new-face} | ||
| 2617 | in the same frame. | ||
| 2618 | |||
| 2619 | If the optional argument @var{new-frame} is given, then @code{copy-face} | ||
| 2620 | copies the attributes of @var{old-face} in @var{frame} to @var{new-name} | ||
| 2621 | in @var{new-frame}. | ||
| 2622 | @end defun | 2583 | @end defun |
| 2623 | 2584 | ||
| 2624 | @defun face-id face | 2585 | @defun face-id face |
| @@ -2752,7 +2713,7 @@ these are used for messages in @samp{*Compilation*} buffers. | |||
| 2752 | @node Font Selection | 2713 | @node Font Selection |
| 2753 | @subsection Font Selection | 2714 | @subsection Font Selection |
| 2754 | 2715 | ||
| 2755 | Before Emacs can draw a character on a particular display, it must | 2716 | Before Emacs can draw a character on a graphical display, it must |
| 2756 | select a @dfn{font} for that character@footnote{In this context, the | 2717 | select a @dfn{font} for that character@footnote{In this context, the |
| 2757 | term @dfn{font} has nothing to do with Font Lock (@pxref{Font Lock | 2718 | term @dfn{font} has nothing to do with Font Lock (@pxref{Font Lock |
| 2758 | Mode}).}. @xref{Fonts,,, emacs, The GNU Emacs Manual}. Normally, | 2719 | Mode}).}. @xref{Fonts,,, emacs, The GNU Emacs Manual}. Normally, |
| @@ -123,6 +123,8 @@ and pops down the *Completions* buffer accordingly. | |||
| 123 | *** Completion style can be set per-category `completion-category-overrides'. | 123 | *** Completion style can be set per-category `completion-category-overrides'. |
| 124 | +++ | 124 | +++ |
| 125 | *** Completion of buffers now uses substring completion by default. | 125 | *** Completion of buffers now uses substring completion by default. |
| 126 | --- | ||
| 127 | *** The `widget-complete-field' option has been removed. | ||
| 126 | 128 | ||
| 127 | ** Mail changes | 129 | ** Mail changes |
| 128 | 130 | ||
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 3699bb0f5bd..ea7d81bb969 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2012-03-21 Chong Yidong <cyd@gnu.org> | ||
| 2 | |||
| 3 | * faces.el (make-face, make-empty-face, copy-face): | ||
| 4 | * face-remap.el (face-remap-add-relative, face-remap-set-base): | ||
| 5 | Doc fixes. | ||
| 6 | |||
| 1 | 2012-03-21 Stefan Monnier <monnier@iro.umontreal.ca> | 7 | 2012-03-21 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 8 | ||
| 3 | * wid-edit.el (widget-complete-field): Remove (bug#11051). | 9 | * wid-edit.el (widget-complete-field): Remove (bug#11051). |
diff --git a/lisp/face-remap.el b/lisp/face-remap.el index 3af9e31a6f7..ca7a28328f9 100644 --- a/lisp/face-remap.el +++ b/lisp/face-remap.el | |||
| @@ -106,21 +106,20 @@ The list structure of ENTRY may be destructively modified." | |||
| 106 | ;;;###autoload | 106 | ;;;###autoload |
| 107 | (defun face-remap-add-relative (face &rest specs) | 107 | (defun face-remap-add-relative (face &rest specs) |
| 108 | "Add a face remapping entry of FACE to SPECS in the current buffer. | 108 | "Add a face remapping entry of FACE to SPECS in the current buffer. |
| 109 | 109 | Return a cookie which can be used to delete this remapping with | |
| 110 | Return a cookie which can be used to delete the remapping with | ||
| 111 | `face-remap-remove-relative'. | 110 | `face-remap-remove-relative'. |
| 112 | 111 | ||
| 113 | SPECS can be any value suitable for the `face' text property, | 112 | The remaining arguments, SPECS, should be either a list of face |
| 114 | including a face name, a list of face names, or a face-attribute | 113 | names, or a property list of face attribute/value pairs. The |
| 115 | property list. The attributes given by SPECS will be merged with | 114 | remapping specified by SPECS takes effect alongside the |
| 116 | any other currently active face remappings of FACE, and with the | 115 | remappings from other calls to `face-remap-add-relative', as well |
| 117 | global definition of FACE. An attempt is made to sort multiple | 116 | as the normal definition of FACE (at lowest priority). This |
| 118 | entries so that entries with relative face-attributes are applied | 117 | function tries to sort multiple remappings for the same face, so |
| 119 | after entries with absolute face-attributes. | 118 | that remappings specifying relative face attributes are applied |
| 120 | 119 | after remappings specifying absolute face attributes. | |
| 121 | The base (lowest priority) remapping may be set to a specific | 120 | |
| 122 | value, instead of the default of the global face definition, | 121 | The base (lowest priority) remapping may be set to something |
| 123 | using `face-remap-set-base'." | 122 | other than the normal definition of FACE via `face-remap-set-base'." |
| 124 | (while (and (consp specs) (null (cdr specs))) | 123 | (while (and (consp specs) (null (cdr specs))) |
| 125 | (setq specs (car specs))) | 124 | (setq specs (car specs))) |
| 126 | (make-local-variable 'face-remapping-alist) | 125 | (make-local-variable 'face-remapping-alist) |
| @@ -148,7 +147,9 @@ COOKIE should be the return value from that function." | |||
| 148 | 147 | ||
| 149 | ;;;###autoload | 148 | ;;;###autoload |
| 150 | (defun face-remap-reset-base (face) | 149 | (defun face-remap-reset-base (face) |
| 151 | "Set the base remapping of FACE to inherit from FACE's global definition." | 150 | "Set the base remapping of FACE to the normal definition of FACE. |
| 151 | This causes the remappings specified by `face-remap-add-relative' | ||
| 152 | to apply on top of the normal definition of FACE." | ||
| 152 | (let ((entry (assq face face-remapping-alist))) | 153 | (let ((entry (assq face face-remapping-alist))) |
| 153 | (when entry | 154 | (when entry |
| 154 | ;; If there's nothing except a base remapping, we simply remove | 155 | ;; If there's nothing except a base remapping, we simply remove |
| @@ -163,10 +164,15 @@ COOKIE should be the return value from that function." | |||
| 163 | ;;;###autoload | 164 | ;;;###autoload |
| 164 | (defun face-remap-set-base (face &rest specs) | 165 | (defun face-remap-set-base (face &rest specs) |
| 165 | "Set the base remapping of FACE in the current buffer to SPECS. | 166 | "Set the base remapping of FACE in the current buffer to SPECS. |
| 166 | If SPECS is empty, the default base remapping is restored, which | 167 | This causes the remappings specified by `face-remap-add-relative' |
| 167 | inherits from the global definition of FACE; note that this is | 168 | to apply on top of the face specification given by SPECS. SPECS |
| 168 | different from SPECS containing a single value `nil', which does | 169 | should be either a list of face names, or a property list of face |
| 169 | not inherit from the global definition of FACE." | 170 | attribute/value pairs. |
| 171 | |||
| 172 | If SPECS is empty, call `face-remap-reset-base' to use the normal | ||
| 173 | definition of FACE as the base remapping; note that this is | ||
| 174 | different from SPECS containing a single value `nil', which means | ||
| 175 | not to inherit from the global definition of FACE at all." | ||
| 170 | (while (and (consp specs) (not (null (car specs))) (null (cdr specs))) | 176 | (while (and (consp specs) (not (null (car specs))) (null (cdr specs))) |
| 171 | (setq specs (car specs))) | 177 | (setq specs (car specs))) |
| 172 | (if (or (null specs) | 178 | (if (or (null specs) |
diff --git a/lisp/faces.el b/lisp/faces.el index 34fad66ce27..0256f8d951a 100644 --- a/lisp/faces.el +++ b/lisp/faces.el | |||
| @@ -122,15 +122,13 @@ REGISTRY, ALTERNATIVE1, ALTERNATIVE2, and etc." | |||
| 122 | "Return a list of all defined faces." | 122 | "Return a list of all defined faces." |
| 123 | (mapcar #'car face-new-frame-defaults)) | 123 | (mapcar #'car face-new-frame-defaults)) |
| 124 | 124 | ||
| 125 | |||
| 126 | ;;; ### If not frame-local initialize by what X resources? | ||
| 127 | |||
| 128 | (defun make-face (face &optional no-init-from-resources) | 125 | (defun make-face (face &optional no-init-from-resources) |
| 129 | "Define a new face with name FACE, a symbol. | 126 | "Define a new face with name FACE, a symbol. |
| 130 | NO-INIT-FROM-RESOURCES non-nil means don't initialize frame-local | 127 | Do not call this directly from Lisp code; use `defface' instead. |
| 131 | variants of FACE from X resources. (X resources recognized are found | 128 | |
| 132 | in the global variable `face-x-resources'.) If FACE is already known | 129 | If NO-INIT-FROM-RESOURCES is non-nil, don't initialize face |
| 133 | as a face, leave it unmodified. Value is FACE." | 130 | attributes from X resources. If FACE is already known as a face, |
| 131 | leave it unmodified. Return FACE." | ||
| 134 | (interactive (list (read-from-minibuffer | 132 | (interactive (list (read-from-minibuffer |
| 135 | "Make face: " nil nil t 'face-name-history))) | 133 | "Make face: " nil nil t 'face-name-history))) |
| 136 | (unless (facep face) | 134 | (unless (facep face) |
| @@ -145,31 +143,30 @@ as a face, leave it unmodified. Value is FACE." | |||
| 145 | (make-face-x-resource-internal face))) | 143 | (make-face-x-resource-internal face))) |
| 146 | face) | 144 | face) |
| 147 | 145 | ||
| 148 | |||
| 149 | (defun make-empty-face (face) | 146 | (defun make-empty-face (face) |
| 150 | "Define a new, empty face with name FACE. | 147 | "Define a new, empty face with name FACE. |
| 151 | If the face already exists, it is left unmodified. Value is FACE." | 148 | Do not call this directly from Lisp code; use `defface' instead." |
| 152 | (interactive (list (read-from-minibuffer | 149 | (interactive (list (read-from-minibuffer |
| 153 | "Make empty face: " nil nil t 'face-name-history))) | 150 | "Make empty face: " nil nil t 'face-name-history))) |
| 154 | (make-face face 'no-init-from-resources)) | 151 | (make-face face 'no-init-from-resources)) |
| 155 | 152 | ||
| 156 | |||
| 157 | (defun copy-face (old-face new-face &optional frame new-frame) | 153 | (defun copy-face (old-face new-face &optional frame new-frame) |
| 158 | "Define a face just like OLD-FACE, with name NEW-FACE. | 154 | "Define a face named NEW-FACE, which is a copy of OLD-FACE. |
| 159 | 155 | This function does not copy face customization data, so NEW-FACE | |
| 160 | If NEW-FACE already exists as a face, it is modified to be like | 156 | will not be made customizable. Most Lisp code should not call |
| 161 | OLD-FACE. If it doesn't already exist, it is created. | 157 | this function; use `defface' with :inherit instead. |
| 162 | 158 | ||
| 163 | If the optional argument FRAME is given as a frame, NEW-FACE is | 159 | If NEW-FACE already exists as a face, modify it to be like |
| 164 | changed on FRAME only. | 160 | OLD-FACE. If NEW-FACE doesn't already exist, create it. |
| 165 | If FRAME is t, the frame-independent default specification for OLD-FACE | 161 | |
| 166 | is copied to NEW-FACE. | 162 | If the optional argument FRAME is a frame, change NEW-FACE on |
| 167 | If FRAME is nil, copying is done for the frame-independent defaults | 163 | FRAME only. If FRAME is t, copy the frame-independent default |
| 168 | and for each existing frame. | 164 | specification for OLD-FACE to NEW-FACE. If FRAME is nil, copy |
| 169 | 165 | the defaults as well as the faces on each existing frame. | |
| 170 | If the optional fourth argument NEW-FRAME is given, | 166 | |
| 171 | copy the information from face OLD-FACE on frame FRAME | 167 | If the optional fourth argument NEW-FRAME is given, copy the |
| 172 | to NEW-FACE on frame NEW-FRAME. In this case, FRAME may not be nil." | 168 | information from face OLD-FACE on frame FRAME to NEW-FACE on |
| 169 | frame NEW-FRAME. In this case, FRAME must not be nil." | ||
| 173 | (let ((inhibit-quit t)) | 170 | (let ((inhibit-quit t)) |
| 174 | (if (null frame) | 171 | (if (null frame) |
| 175 | (progn | 172 | (progn |
diff --git a/src/ChangeLog b/src/ChangeLog index 4f32309562b..7a97859ba63 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2012-03-21 Chong Yidong <cyd@gnu.org> | ||
| 2 | |||
| 3 | * xfaces.c (Vface_remapping_alist): Doc fix. | ||
| 4 | |||
| 1 | 2012-03-20 Eli Zaretskii <eliz@gnu.org> | 5 | 2012-03-20 Eli Zaretskii <eliz@gnu.org> |
| 2 | 6 | ||
| 3 | * w32proc.c (Fw32_set_console_codepage) | 7 | * w32proc.c (Fw32_set_console_codepage) |
diff --git a/src/xfaces.c b/src/xfaces.c index bcb04188aeb..476fb1e0366 100644 --- a/src/xfaces.c +++ b/src/xfaces.c | |||
| @@ -6599,20 +6599,22 @@ ignore. */); | |||
| 6599 | doc: /* Alist of face remappings. | 6599 | doc: /* Alist of face remappings. |
| 6600 | Each element is of the form: | 6600 | Each element is of the form: |
| 6601 | 6601 | ||
| 6602 | (FACE REPLACEMENT...), | 6602 | (FACE . REPLACEMENT), |
| 6603 | 6603 | ||
| 6604 | which causes display of the face FACE to use REPLACEMENT... instead. | 6604 | which causes display of the face FACE to use REPLACEMENT instead. |
| 6605 | REPLACEMENT... is interpreted the same way as the value of a `face' | 6605 | REPLACEMENT is a face specification, i.e. one of the following: |
| 6606 | text property: it may be (1) A face name, (2) A list of face names, | ||
| 6607 | (3) A property-list of face attribute/value pairs, or (4) A list of | ||
| 6608 | face names or lists containing face attribute/value pairs. | ||
| 6609 | 6606 | ||
| 6610 | Multiple entries in REPLACEMENT... are merged together to form the final | 6607 | (1) a face name |
| 6611 | result, with faces or attributes earlier in the list taking precedence | 6608 | (2) a property list of attribute/value pairs, or |
| 6612 | over those that are later. | 6609 | (3) a list in which each element has the form of (1) or (2). |
| 6613 | 6610 | ||
| 6614 | Face-name remapping cycles are suppressed; recursive references use the | 6611 | List values for REPLACEMENT are merged to form the final face |
| 6615 | underlying face instead of the remapped face. So a remapping of the form: | 6612 | specification, with earlier entries taking precedence, in the same as |
| 6613 | as in the `face' text property. | ||
| 6614 | |||
| 6615 | Face-name remapping cycles are suppressed; recursive references use | ||
| 6616 | the underlying face instead of the remapped face. So a remapping of | ||
| 6617 | the form: | ||
| 6616 | 6618 | ||
| 6617 | (FACE EXTRA-FACE... FACE) | 6619 | (FACE EXTRA-FACE... FACE) |
| 6618 | 6620 | ||
| @@ -6620,13 +6622,13 @@ or: | |||
| 6620 | 6622 | ||
| 6621 | (FACE (FACE-ATTR VAL ...) FACE) | 6623 | (FACE (FACE-ATTR VAL ...) FACE) |
| 6622 | 6624 | ||
| 6623 | will cause EXTRA-FACE... or (FACE-ATTR VAL ...) to be _merged_ with the | 6625 | causes EXTRA-FACE... or (FACE-ATTR VAL ...) to be _merged_ with the |
| 6624 | existing definition of FACE. Note that for the default face, this isn't | 6626 | existing definition of FACE. Note that this isn't necessary for the |
| 6625 | necessary, as every face inherits from the default face. | 6627 | default face, since every face inherits from the default face. |
| 6626 | 6628 | ||
| 6627 | Making this variable buffer-local is a good way to allow buffer-specific | 6629 | If this variable is made buffer-local, the face remapping takes effect |
| 6628 | face definitions. For instance, the mode my-mode could define a face | 6630 | only in that buffer. For instance, the mode my-mode could define a |
| 6629 | `my-mode-default', and then in the mode setup function, do: | 6631 | face `my-mode-default', and then in the mode setup function, do: |
| 6630 | 6632 | ||
| 6631 | (set (make-local-variable 'face-remapping-alist) | 6633 | (set (make-local-variable 'face-remapping-alist) |
| 6632 | '((default my-mode-default)))). | 6634 | '((default my-mode-default)))). |