There’s a lot of stuff in the default emacs modeline,
particularly once you start adding a bunch of useful minor modes like
show-paren-mode
, smartparens-mode
, aggressive-indent-mode
, which-key
, helm
, company-mode
etc etc…
I honestly don’t find it useful to have access to all that information in the modeline,
(if I need to know what’s active, I can just run C-h m
).
There’s a couple of packages specifically designed to shrink or remove minor mode indicators
from your mode line (diminish
, delight
…) but I don’t really want to have to
explicitly set an option for each minor mode.
I don’t want any of them to show up!
Or almost any of them, at least.
So I settled on using
smart-mode-line
which uses
rich-minority
to modify what minor modes get put on the mode line.
There’s two ways to go:
provide a blacklist of modes to remove,
or provide a whitelist of modes to keep in.
I’ve gone for the latter approach.
The only minor mode I want to display in the modeline is
wc-mode
.
This is basically a word count of your current buffer
displayed in the modeline.
rich-minority
basically works by just pattern matching what’s in the list of
minor mode indicators in minor-mode-alist
.
This is easy for all the modes that display some static text (e.g. WK
for which-key
).
But the whole point of wc-mode
is that it displays something that changes.
So we need a regular expression that matches the format wc-mode
outputs.
Here’s something that appears to work.
(setq rm-whitelist '"WC\\[.+?\\]")
That’s a literal “WC
”, and then a literal “[
”
(double escape backslashes because that’s what I saw in rich-minority.el
and it
seems to work).
.+?
then matches zero or one of: one or more of: anything.
Which is regex for “don’t be greedy”.
And then there’s a literal “]
”
Basically, without the ?
, the regex would match WC[1234]foo foo[]
,
which is not what we want.
We want to capture the first match only.
This wouldn’t work in general to capture everything up to the corresponding close bracket,
if nested brackets were allowed, but that’s not going to trip us up
for matching output from wc-mode
.
I haven’t played around with other settings in smart-mode-line
yet,
but I’m already really happy with the cleaner look.