emacsflymakedefadvice

Emacs 26 flymake: customizing the mode line format


I'm considering switching back from flycheck to flymake after the Emacs 26 rewrite. One thing that bothers me about flymake is how much room on the mode line it takes up. It has a string Flymake plus the results. It seems like a silly thing but this is 10% of the mode line on an 80-char frame, just for a name! I have lots of important info I'd like to see on my mode line so I try to remove things that aren't helpful to me--I know what minor modes etc. are enabled in my buffers, since I configured them! Personally I'd prefer to not see a name at all, just the results, or at most F or FM.

I could use diminish to get rid of the mode line info completely but of course I don't want that: I want to be able to see the state of my buffer.

I took a look at flymake.el and the flymake--mode-line-format defun and it doesn't seem like this string is configurable, or easy to change at all.

Anyone have any thoughts about this?


Solution

  • You'd need to redefine flymake--mode-line-format function. It should probably be more customizable, but it's not. Possibly the least intrusive way to do it is to define :filter-return advice on that function to transform the output.

    (defun flymake--transform-mode-line-format (ret)
      "Change the output of `flymake--mode-line-format'."
      (setf (seq-elt (car ret) 1) " FM")
      ret)
    (advice-add #'flymake--mode-line-format
                :filter-return #'flymake--transform-mode-line-format)