all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Alexander Shukaev <haroogan@gmail.com>
Cc: 20592@debbugs.gnu.org
Subject: bug#20592: the `display' property messes the `face' properties after	`concat'
Date: Sun, 17 May 2015 17:39:12 +0300	[thread overview]
Message-ID: <83iobrfeun.fsf@gnu.org> (raw)
In-Reply-To: <CAKu-7WxyDdwzkewqwVArbQy4WCs2T3apx8W-tC7tGjwziv4=gg@mail.gmail.com>

> Date: Sun, 17 May 2015 01:58:29 +0200
> From: Alexander Shukaev <haroogan@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))))





  reply	other threads:[~2015-05-17 14:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-16 23:58 bug#20592: the `display' property messes the `face' properties after `concat' Alexander Shukaev
2015-05-17 14:39 ` Eli Zaretskii [this message]
2015-05-19  1:20   ` Stefan Monnier
2015-05-19 15:31     ` Eli Zaretskii
2015-06-25 19:16       ` Alexander Shukaev
2015-06-25 19:42         ` Eli Zaretskii
2021-12-02 10:00           ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83iobrfeun.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=20592@debbugs.gnu.org \
    --cc=haroogan@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.