unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Narendra Joshi <narendraj9@gmail.com>
To: Emacs Devel <emacs-devel@gnu.org>
Subject: Face text property for `minor-mode-alist` item.
Date: Sun, 27 Dec 2020 16:13:02 +0100	[thread overview]
Message-ID: <87im8nz3i9.fsf@gmail.com> (raw)


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



             reply	other threads:[~2020-12-27 15:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-27 15:13 Narendra Joshi [this message]
2020-12-27 22:09 ` Face text property for `minor-mode-alist` item Lars Ingebrigtsen
2020-12-27 23:46   ` Narendra Joshi
2020-12-28  1:19     ` Lars Ingebrigtsen
2020-12-28  1:46       ` Narendra Joshi

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87im8nz3i9.fsf@gmail.com \
    --to=narendraj9@gmail.com \
    --cc=emacs-devel@gnu.org \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).