In minor-mode-alist documentation it is described that lighter can be a lisp expression that is evaluated to get text used in the display of minor mode in mode line. It has the form of (:eval ...)

Given a function that makes such a string upon evaluation, for example, called compose-mode-line (no parameters), how minor-mode's lighter can be set to results of evaluation of that function?


You can do:

(define-minor-mode ...
  :lighter (:eval (compose-mode-line))

Note that this will re-compute (compose-mode-line) very frequently (after every key press, typically), so make sure it does not perform longish or blocking computations.

  • i have a branching on a symbol equality there, which is, i believe, cheap enough.
    – Srv19
    Jul 12 '16 at 13:23
  • Oh, yes, that's very cheap.
    – Stefan
    Jul 12 '16 at 13:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.