* bug#20592: the `display' property messes the `face' properties after `concat'
@ 2015-05-16 23:58 Alexander Shukaev
2015-05-17 14:39 ` Eli Zaretskii
0 siblings, 1 reply; 7+ messages in thread
From: Alexander Shukaev @ 2015-05-16 23:58 UTC (permalink / raw)
To: 20592
[-- Attachment #1: Type: text/plain, Size: 2203 bytes --]
Following the "Minibuffer tray to display current time and date"
discussion, it seems that a bug with the `display' property. Consider the
following code:
(setq-default minibuffer-line-format
'((: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))))
It works as expected.
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.
[-- Attachment #2: Type: text/html, Size: 4480 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#20592: the `display' property messes the `face' properties after `concat'
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
2015-05-19 1:20 ` Stefan Monnier
0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2015-05-17 14:39 UTC (permalink / raw)
To: Alexander Shukaev; +Cc: 20592
> 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))))
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#20592: the `display' property messes the `face' properties after `concat'
2015-05-17 14:39 ` Eli Zaretskii
@ 2015-05-19 1:20 ` Stefan Monnier
2015-05-19 15:31 ` Eli Zaretskii
0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2015-05-19 1:20 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 20592, Alexander Shukaev
> 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.
IIUC, this is the bug that needs to be fixed.
Or is there a reason to consider this as a feature?
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#20592: the `display' property messes the `face' properties after `concat'
2015-05-19 1:20 ` Stefan Monnier
@ 2015-05-19 15:31 ` Eli Zaretskii
2015-06-25 19:16 ` Alexander Shukaev
0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2015-05-19 15:31 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 20592, haroogan
> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: Alexander Shukaev <haroogan@gmail.com>, 20592@debbugs.gnu.org
> Date: Mon, 18 May 2015 21:20:05 -0400
>
> > 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.
>
> IIUC, this is the bug that needs to be fixed.
> Or is there a reason to consider this as a feature?
I think the reason for this implementation was to keep the code simple
and efficient. After all, ':eval' is part of the standard mode line,
in several places, so this code runs each time we update the mode
line, which we do a lot.
I agree that the limitation is counter-intuitive, and barely
documented, but given that using a separate ':eval' is such an easy
solution, perhaps we should simply document this. Fixing this doesn't
sound as high priority to me.
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#20592: the `display' property messes the `face' properties after `concat'
2015-05-19 15:31 ` Eli Zaretskii
@ 2015-06-25 19:16 ` Alexander Shukaev
2015-06-25 19:42 ` Eli Zaretskii
0 siblings, 1 reply; 7+ messages in thread
From: Alexander Shukaev @ 2015-06-25 19:16 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 20592
[-- Attachment #1: Type: text/plain, Size: 2038 bytes --]
Not sure how this complies with what Eli said:
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.
but I've still managed to work it out in the following way:
(setq-default minibuffer-line-format
'((:eval
(let* ((date-string
(propertize (format-time-string "%Y.%m.%d")
'face
'minibuffer-line-date))
(weekday-string
(propertize (format-time-string "%A")
'face
'minibuffer-line-weekday))
(time-string
(propertize (format-time-string "%R")
'face
'minibuffer-line-time))
(right-string-list
(list date-string
" "
weekday-string
" "
time-string))
(right-string
(apply #'concat right-string-list))
(pad-string
(propertize " "
'display
`((space :align-to
(- right
right-fringe
,(length
right-string)))))))
(list pad-string
right-string-list)))))
[-- Attachment #2: Type: text/html, Size: 4174 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#20592: the `display' property messes the `face' properties after `concat'
2015-06-25 19:16 ` Alexander Shukaev
@ 2015-06-25 19:42 ` Eli Zaretskii
2021-12-02 10:00 ` Lars Ingebrigtsen
0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2015-06-25 19:42 UTC (permalink / raw)
To: Alexander Shukaev; +Cc: 20592
> Date: Thu, 25 Jun 2015 21:16:41 +0200
> From: Alexander Shukaev <haroogan@gmail.com>
> Cc: Stefan Monnier <monnier@iro.umontreal.ca>, 20592@debbugs.gnu.org
>
> Not sure how this complies with what Eli said:
>
> 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.
>
> but I've still managed to work it out in the following way:
It does comply, AFAIU: you produced a list, not a string. Each string
in the list still needs to have a single face on all of its
characters.
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#20592: the `display' property messes the `face' properties after `concat'
2015-06-25 19:42 ` Eli Zaretskii
@ 2021-12-02 10:00 ` Lars Ingebrigtsen
0 siblings, 0 replies; 7+ messages in thread
From: Lars Ingebrigtsen @ 2021-12-02 10:00 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 20592, Alexander Shukaev, monnier
Eli Zaretskii <eliz@gnu.org> writes:
> It does comply, AFAIU: you produced a list, not a string. Each string
> in the list still needs to have a single face on all of its
> characters.
So I don't think there's anything to fix here -- the text property
limitation on mode line strings wasn't documented before, but it's
documented in Emacs 28.
So I'm closing this bug report.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-12-02 10:00 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
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.