emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master bf0b6fa: Allow minibuffer prompts to use faces


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] master bf0b6fa: Allow minibuffer prompts to use faces
Date: Sun, 01 May 2016 14:55:00 +0000

branch: master
commit bf0b6fab032bd35fae36f7371b7cd1fe3bfaaac7
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    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).
---
 doc/lispref/minibuf.texi |   17 +++++++++++++++++
 etc/NEWS                 |    6 ++++++
 src/minibuf.c            |   27 +++++++++++++++++++++++++--
 3 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi
index 6f41090..88662ab 100644
--- a/doc/lispref/minibuf.texi
+++ b/doc/lispref/minibuf.texi
@@ -170,6 +170,23 @@ address@hidden, 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.
 
address@hidden 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:
+
address@hidden
+(read-from-minibuffer
+ (concat
+  (propertize "Bold" 'face '(bold default))
+  (propertize " and normal: " 'face '(default))))
address@hidden lisp
+
 If the argument @var{inherit-input-method} is address@hidden, then the
 minibuffer inherits the current input method (@pxref{Input Methods}) and
 the setting of @code{enable-multibyte-characters} (@pxref{Text
diff --git a/etc/NEWS b/etc/NEWS
index ed4810b..cf360a3 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -57,6 +57,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.
 
diff --git a/src/minibuf.c b/src/minibuf.c
index 0b8b00c..d2a4c9b 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -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);
   }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]