* Face text property for `minor-mode-alist` item.
@ 2020-12-27 15:13 Narendra Joshi
2020-12-27 22:09 ` Lars Ingebrigtsen
0 siblings, 1 reply; 5+ messages in thread
From: Narendra Joshi @ 2020-12-27 15:13 UTC (permalink / raw
To: Emacs Devel
Hi everyone,
I am trying to understand the following behaviour regarding
`mode-line-format' rendering the `:lighter` for `flycheck-mode'. I
wanted to have the flycheck lighter display different colors for the
error count and the warning count as `flymake` does.
The following doesn't work. The face property of the first character of
the string returned by `flycheck-mode-line-status-text' is used for the
whole string in this case.
--8<---------------cut here---------------start------------->8---
(setq flycheck-mode-line '(:eval (flycheck-mode-line-status-text))
(defun flycheck-mode-line-status-text ()
... returns a single string with substrings propertized,
e.g. #("some string" 1 2 ('face 'error) 2 3 ('face 'warning)))
--8<---------------cut here---------------end--------------->8---
If I change it to something like this:
--8<---------------cut here---------------start------------->8---
(setq flycheck-mode-line '(:eval (flycheck-mode-line-status-text))
(defun flycheck-mode-line-status-text ()
... returns a (list ... part_1_with_face_1 part_2_with_face_2 ...))
--8<---------------cut here---------------end--------------->8---
This seems to work as expected and the parts have their respective faces
applied to them in the mode-line.
Is this a bug in Emacs or is this expected behaviour?
Best regards,
--
Narendra Joshi
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Face text property for `minor-mode-alist` item.
2020-12-27 15:13 Face text property for `minor-mode-alist` item Narendra Joshi
@ 2020-12-27 22:09 ` Lars Ingebrigtsen
2020-12-27 23:46 ` Narendra Joshi
0 siblings, 1 reply; 5+ messages in thread
From: Lars Ingebrigtsen @ 2020-12-27 22:09 UTC (permalink / raw
To: Narendra Joshi; +Cc: Emacs Devel
Narendra Joshi <narendraj9@gmail.com> writes:
> Is this a bug in Emacs or is this expected behaviour?
It's expected (but possibly under-documented?) behaviour -- the mode
line code tries to be super-efficient, and doesn't allow text to have
different text properties. As you've discovered, it only uses the text
property from the first character, and uses that over the entire text
fragment.
You have to use the special (:propertize ...) mode line constructs (and
chop up the text) to get more fine-grained text properties in the mode
line.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Face text property for `minor-mode-alist` item.
2020-12-27 22:09 ` Lars Ingebrigtsen
@ 2020-12-27 23:46 ` Narendra Joshi
2020-12-28 1:19 ` Lars Ingebrigtsen
0 siblings, 1 reply; 5+ messages in thread
From: Narendra Joshi @ 2020-12-27 23:46 UTC (permalink / raw
To: Lars Ingebrigtsen; +Cc: Emacs Devel
Lars Ingebrigtsen <larsi@gnus.org> writes:
> Narendra Joshi <narendraj9@gmail.com> writes:
>
>> Is this a bug in Emacs or is this expected behaviour?
>
> It's expected (but possibly under-documented?) behaviour -- the mode
> line code tries to be super-efficient, and doesn't allow text to have
> different text properties. As you've discovered, it only uses the text
> property from the first character, and uses that over the entire text
> fragment.
Thanks for clarifying this. I did check the Emacs Lisp manual entries
for mode line constructs and couldn't find any documentation about this.
> You have to use the special (:propertize ...) mode line constructs (and
> chop up the text) to get more fine-grained text properties in the mode
> line.
Best regards,
--
Narendra Joshi
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Face text property for `minor-mode-alist` item.
2020-12-27 23:46 ` Narendra Joshi
@ 2020-12-28 1:19 ` Lars Ingebrigtsen
2020-12-28 1:46 ` Narendra Joshi
0 siblings, 1 reply; 5+ messages in thread
From: Lars Ingebrigtsen @ 2020-12-28 1:19 UTC (permalink / raw
To: Narendra Joshi; +Cc: Emacs Devel
Narendra Joshi <narendraj9@gmail.com> writes:
> Thanks for clarifying this. I did check the Emacs Lisp manual entries
> for mode line constructs and couldn't find any documentation about this.
Thanks for checking; I've now documented this quirk in the Emacs Lisp
manual in Emacs 28 (in the "Mode Line Data" node).
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Face text property for `minor-mode-alist` item.
2020-12-28 1:19 ` Lars Ingebrigtsen
@ 2020-12-28 1:46 ` Narendra Joshi
0 siblings, 0 replies; 5+ messages in thread
From: Narendra Joshi @ 2020-12-28 1:46 UTC (permalink / raw
To: Lars Ingebrigtsen; +Cc: Emacs Devel
[-- Attachment #1: Type: text/plain, Size: 530 bytes --]
Great, thanks! :)
On Mon, 28 Dec 2020, 02:19 Lars Ingebrigtsen, <larsi@gnus.org> wrote:
> Narendra Joshi <narendraj9@gmail.com> writes:
>
> > Thanks for clarifying this. I did check the Emacs Lisp manual entries
> > for mode line constructs and couldn't find any documentation about this.
>
> Thanks for checking; I've now documented this quirk in the Emacs Lisp
> manual in Emacs 28 (in the "Mode Line Data" node).
>
> --
> (domestic pets only, the antidote for overdose, milk.)
> bloggy blog: http://lars.ingebrigtsen.no
>
[-- Attachment #2: Type: text/html, Size: 1014 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-12-28 1:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-27 15:13 Face text property for `minor-mode-alist` item Narendra Joshi
2020-12-27 22:09 ` Lars Ingebrigtsen
2020-12-27 23:46 ` Narendra Joshi
2020-12-28 1:19 ` Lars Ingebrigtsen
2020-12-28 1:46 ` Narendra Joshi
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.