Allow minibuffer prompts to use faces
* doc/lispref/minibuf.texi (Text from Minibuffer): Document `minibuffer-prompt-properties' and explain how faces work in the minibuffer prompt. * src/minibuf.c (read_minibuf): If `face' is in `minibuffer-prompt-properties', apply it to the end of the face list to allow users to have their own faces on the prompts (bug#16136).
This commit is contained in:
parent
8cfd9ba1a9
commit
bf0b6fab03
3 changed files with 48 additions and 2 deletions
|
@ -170,6 +170,23 @@ non-@code{nil}, then the string that is returned includes whatever text
|
|||
properties were present in the minibuffer. Otherwise all the text
|
||||
properties are stripped when the value is returned.
|
||||
|
||||
@cvindex minibuffer-prompt-properties
|
||||
The text properties in @code{minibuffer-prompt-properties} are applied
|
||||
to the prompt. By default, this property list defines a face to use
|
||||
for the prompt. This face, if present, is applied to the end of the
|
||||
face list and merged before display.
|
||||
|
||||
If the user wants to completely control the look of the prompt, the
|
||||
most convenient way to do that is to specify the @code{default} face
|
||||
at the end of all face lists. For instance:
|
||||
|
||||
@lisp
|
||||
(read-from-minibuffer
|
||||
(concat
|
||||
(propertize "Bold" 'face '(bold default))
|
||||
(propertize " and normal: " 'face '(default))))
|
||||
@end lisp
|
||||
|
||||
If the argument @var{inherit-input-method} is non-@code{nil}, then the
|
||||
minibuffer inherits the current input method (@pxref{Input Methods}) and
|
||||
the setting of @code{enable-multibyte-characters} (@pxref{Text
|
||||
|
|
6
etc/NEWS
6
etc/NEWS
|
@ -56,6 +56,12 @@ affected by this, as SGI stopped supporting IRIX in December 2013.
|
|||
|
||||
* Changes in Emacs 25.2
|
||||
|
||||
+++
|
||||
** Faces in `minibuffer-prompt-properties' no longer overwrite properties
|
||||
in the text in functions like `read-from-minibuffer', but instead are
|
||||
added to the end of the face list. This allows users to say things
|
||||
like `(read-from-minibuffer (propertize "Enter something: " 'face 'bold))'.
|
||||
|
||||
+++
|
||||
** The new variable `extended-command-suggest-shorter' has been added
|
||||
to control whether to suggest shorter `M-x' commands or not.
|
||||
|
|
|
@ -630,8 +630,31 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
|
|||
Qrear_nonsticky, Qt, Qnil);
|
||||
Fput_text_property (make_number (BEG), make_number (PT),
|
||||
Qfield, Qt, Qnil);
|
||||
Fadd_text_properties (make_number (BEG), make_number (PT),
|
||||
Vminibuffer_prompt_properties, Qnil);
|
||||
if (Fconsp (Vminibuffer_prompt_properties))
|
||||
{
|
||||
/* We want to apply all properties from
|
||||
`minibuffer-prompt-properties' to the region normally,
|
||||
but if the `face' property is present, add that
|
||||
property to the end of the face properties to avoid
|
||||
overwriting faces. */
|
||||
Lisp_Object list = Vminibuffer_prompt_properties;
|
||||
while (CONSP (list))
|
||||
{
|
||||
Lisp_Object key = XCAR (list);
|
||||
list = XCDR (list);
|
||||
if (CONSP (list))
|
||||
{
|
||||
Lisp_Object val = XCAR (list);
|
||||
list = XCDR (list);
|
||||
if (EQ (key, Qface))
|
||||
Fadd_face_text_property (make_number (BEG),
|
||||
make_number (PT), val, Qt, Qnil);
|
||||
else
|
||||
Fput_text_property (make_number (BEG), make_number (PT),
|
||||
key, val, Qnil);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
unbind_to (count1, Qnil);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue