GNU bug report logs - #20592
the `display' property messes the `face' properties after `concat'

Previous Next

Package: emacs;

Reported by: Alexander Shukaev <haroogan <at> gmail.com>

Date: Sat, 16 May 2015 23:59:02 UTC

Severity: minor

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Eli Zaretskii <eliz <at> gnu.org>
To: Alexander Shukaev <haroogan <at> gmail.com>
Cc: 20592 <at> debbugs.gnu.org
Subject: bug#20592: the `display' property messes the `face' properties after	`concat'
Date: Sun, 17 May 2015 17:39:12 +0300
> Date: Sun, 17 May 2015 01:58:29 +0200
> From: Alexander Shukaev <haroogan <at> gmail.com>
> 
> Consider another piece of code:
> 
> (setq-default minibuffer-line-format
> 	      `((:eval
> 		 (let ((string (concat
> 				(propertize (format-time-string "%Y.%m.%d")
> 					    'face
> 					    'minibuffer-line-date)
> 				" "
> 				(propertize (format-time-string "%A")
> 					    'face
> 					    'minibuffer-line-weekday)
> 				" "
> 				(propertize (format-time-string "%R")
> 					    'face
> 					    'minibuffer-line-time))))
> 		   (concat (propertize " "
> 				       'display
> 				       `((space :align-to
> 						(- right
> 						   right-fringe
> 						   ,(length string)))))
> 			   string)))))

> Alignment works as expected, but faces are messed up.  In fact, the default face is used everywhere (which comes from the `display' property), like if subsequent propertizings of date, weekday, and time have never been there.

(To complete the bug report, the 3 minibuffer-line-* faces need to be
defined, and the minibuffer-line package from ELPA loaded and then
minibuffer-line-mode turned on.)

The behavior you observe is because the ':eval' construct expects to
produce a single string with either the same common face spec on all
of its characters, or no faces at all.  You cannot use ':eval' to
produce a string that has more than one face spec on its different
characters; if you do, only the face spec of the first character of
the string will be honored.

'minibuffer-line-mode' is implemented via the function
'format-mode-line'.  While I can understand this design decision, the
downside is that you get to face some of the idiosyncrasies of
formatting the mode line.  (E.g., did you ask yourself why you get an
extra column of white space after the string?)

The upshot of this is that you need to generate each substring that
has a unique face with its own ':eval'.  For example, the following
abomination works as you expect:

  (setq-default minibuffer-line-format
		'((:eval
		   (propertize " "
			       'display
			       `((space :align-to
					(- right
					   right-fringe
					   ,(length
					     (concat
					      (format-time-string "%Y.%m.%d")
					      " "
					      (format-time-string "%A")
					      " "
					      (format-time-string "%R"))))))))
		  (:eval (propertize (format-time-string "%Y.%m.%d")
				     'face
				     'minibuffer-line-date))
		  " "
		  (:eval (propertize (format-time-string "%A")
				     'face
				     'minibuffer-line-weekday))
		  " "
		  (:eval (propertize (format-time-string "%R")
				     'face
				     'minibuffer-line-time))))




This bug report was last modified 3 years and 173 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.