diff options
| author | Lars Ingebrigtsen | 2016-05-01 16:53:38 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2016-05-01 16:53:38 +0200 |
| commit | bf0b6fab032bd35fae36f7371b7cd1fe3bfaaac7 (patch) | |
| tree | 4bbed3f5de389fea0f5f66a78a100d623accee2d | |
| parent | 8cfd9ba1a97a02157c6b730cca9d61b0fb7de53b (diff) | |
| download | emacs-bf0b6fab032bd35fae36f7371b7cd1fe3bfaaac7.tar.gz emacs-bf0b6fab032bd35fae36f7371b7cd1fe3bfaaac7.zip | |
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).
| -rw-r--r-- | doc/lispref/minibuf.texi | 17 | ||||
| -rw-r--r-- | etc/NEWS | 6 | ||||
| -rw-r--r-- | src/minibuf.c | 27 |
3 files changed, 48 insertions, 2 deletions
diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi index 6f41090ebea..88662aba08a 100644 --- a/doc/lispref/minibuf.texi +++ b/doc/lispref/minibuf.texi | |||
| @@ -170,6 +170,23 @@ non-@code{nil}, then the string that is returned includes whatever text | |||
| 170 | properties were present in the minibuffer. Otherwise all the text | 170 | properties were present in the minibuffer. Otherwise all the text |
| 171 | properties are stripped when the value is returned. | 171 | properties are stripped when the value is returned. |
| 172 | 172 | ||
| 173 | @cvindex minibuffer-prompt-properties | ||
| 174 | The text properties in @code{minibuffer-prompt-properties} are applied | ||
| 175 | to the prompt. By default, this property list defines a face to use | ||
| 176 | for the prompt. This face, if present, is applied to the end of the | ||
| 177 | face list and merged before display. | ||
| 178 | |||
| 179 | If the user wants to completely control the look of the prompt, the | ||
| 180 | most convenient way to do that is to specify the @code{default} face | ||
| 181 | at the end of all face lists. For instance: | ||
| 182 | |||
| 183 | @lisp | ||
| 184 | (read-from-minibuffer | ||
| 185 | (concat | ||
| 186 | (propertize "Bold" 'face '(bold default)) | ||
| 187 | (propertize " and normal: " 'face '(default)))) | ||
| 188 | @end lisp | ||
| 189 | |||
| 173 | If the argument @var{inherit-input-method} is non-@code{nil}, then the | 190 | If the argument @var{inherit-input-method} is non-@code{nil}, then the |
| 174 | minibuffer inherits the current input method (@pxref{Input Methods}) and | 191 | minibuffer inherits the current input method (@pxref{Input Methods}) and |
| 175 | the setting of @code{enable-multibyte-characters} (@pxref{Text | 192 | the setting of @code{enable-multibyte-characters} (@pxref{Text |
| @@ -57,6 +57,12 @@ affected by this, as SGI stopped supporting IRIX in December 2013. | |||
| 57 | * Changes in Emacs 25.2 | 57 | * Changes in Emacs 25.2 |
| 58 | 58 | ||
| 59 | +++ | 59 | +++ |
| 60 | ** Faces in `minibuffer-prompt-properties' no longer overwrite properties | ||
| 61 | in the text in functions like `read-from-minibuffer', but instead are | ||
| 62 | added to the end of the face list. This allows users to say things | ||
| 63 | like `(read-from-minibuffer (propertize "Enter something: " 'face 'bold))'. | ||
| 64 | |||
| 65 | +++ | ||
| 60 | ** The new variable `extended-command-suggest-shorter' has been added | 66 | ** The new variable `extended-command-suggest-shorter' has been added |
| 61 | to control whether to suggest shorter `M-x' commands or not. | 67 | to control whether to suggest shorter `M-x' commands or not. |
| 62 | 68 | ||
diff --git a/src/minibuf.c b/src/minibuf.c index 0b8b00ce2c9..d2a4c9b9538 100644 --- a/src/minibuf.c +++ b/src/minibuf.c | |||
| @@ -630,8 +630,31 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, | |||
| 630 | Qrear_nonsticky, Qt, Qnil); | 630 | Qrear_nonsticky, Qt, Qnil); |
| 631 | Fput_text_property (make_number (BEG), make_number (PT), | 631 | Fput_text_property (make_number (BEG), make_number (PT), |
| 632 | Qfield, Qt, Qnil); | 632 | Qfield, Qt, Qnil); |
| 633 | Fadd_text_properties (make_number (BEG), make_number (PT), | 633 | if (Fconsp (Vminibuffer_prompt_properties)) |
| 634 | Vminibuffer_prompt_properties, Qnil); | 634 | { |
| 635 | /* We want to apply all properties from | ||
| 636 | `minibuffer-prompt-properties' to the region normally, | ||
| 637 | but if the `face' property is present, add that | ||
| 638 | property to the end of the face properties to avoid | ||
| 639 | overwriting faces. */ | ||
| 640 | Lisp_Object list = Vminibuffer_prompt_properties; | ||
| 641 | while (CONSP (list)) | ||
| 642 | { | ||
| 643 | Lisp_Object key = XCAR (list); | ||
| 644 | list = XCDR (list); | ||
| 645 | if (CONSP (list)) | ||
| 646 | { | ||
| 647 | Lisp_Object val = XCAR (list); | ||
| 648 | list = XCDR (list); | ||
| 649 | if (EQ (key, Qface)) | ||
| 650 | Fadd_face_text_property (make_number (BEG), | ||
| 651 | make_number (PT), val, Qt, Qnil); | ||
| 652 | else | ||
| 653 | Fput_text_property (make_number (BEG), make_number (PT), | ||
| 654 | key, val, Qnil); | ||
| 655 | } | ||
| 656 | } | ||
| 657 | } | ||
| 635 | } | 658 | } |
| 636 | unbind_to (count1, Qnil); | 659 | unbind_to (count1, Qnil); |
| 637 | } | 660 | } |