Telephone Line is a new implementation of Powerline with a few new features that set it apart from the existing Emacs implementations: easier customization and antialiased separators.
First off, this is how they look
Classic powerline, called “abs” (you’ll see why later).
Spacemacs’ default separator, called “cubed”.
A gradient separator.
You can use two right separators instead of a left and right, if you want.
Each of these separators is defined programmatically (the existing powerline.el does something more along the lines of templating), being created from two potentially user-defined functions – but more on that later. For now, just enjoy their pixels-wot-have-intermediate-colors
The screenshots above aren’t the default configuration; it’s all defined in my dotfiles.
Here’s the relevant section:
(setq telephone-line-lhs
'((evil . (telephone-line-evil-tag-segment))
(accent . (telephone-line-vc-segment
telephone-line-erc-modified-channels-segment
telephone-line-process-segment))
(nil . (telephone-line-minor-mode-segment
telephone-line-buffer-segment))))
(setq telephone-line-rhs
'((evil . (telephone-line-airline-position-segment))
(accent . (telephone-line-major-mode-segment))
(nil . (telephone-line-misc-info-segment))))
…That’s it. That’s essentially all there is to creating a theme.
Now, as a caveat, this makes things like the spacemacs theme harder to create (it could still be done, maybe with a closure that returns left/right alternating separators). However, it addresses most of my issues with the existing solutions.
I mentioned before that the separators are defined in terms of two functions. Here’s the way that works:
Imagine the cross-section of the mode-line as a number line, ranging from -height/2 to +height/2. The first function is applied across this number line to get the shape of the separator. Here’s the most famous separator, defined as 2*abs(x).
-4 | * -3 | * -2 | * -1 | * 0 + 1 | * 2 | * 3 | * 4 | *
There you go – a separator. However, we still need another piece. That second function I mentioned determines the fill – the difference between a solid separator and a hollow one.
This isn’t the sort of function I’d expect to get much customization out of, but there are 3 included ones. The first makes a hollow separator, which looks more-or-less like the ASCII art above. The second provides a fill:
-4 | * -3 | *-- -2 | *---- -1 | *------ 0 +-------- 1 | *------ 2 | *---- 3 | *-- 4 | *
The third one is a special thing that ignores the first function entirely and just produces the same output regardless of the input. It’s used to make the gradient separator.
Choice of separator can be customized as well, by changing the values
of telephone-line-{primary,secondary}-{left,right}-separator
. This
should be a function which accepts two faces or colors (if provided
faces, the built-in separators use the background field) and returns a
propertized image. The separators can be defined independently of one
another – feel free to use a nominally left separator for your rhs,
or mix two different types of separators.
You probably also noticed from the screenshots that there are in fact two types of separator on either side of the mode-line. The way this works involves the lhs/rhs alists.
Basically, lists of segment functions associated to a color symbol are rendered into a ‘supersegment’. Supersegments are separated by primary separators. Internally, non-nil segment-functions are rendered into ‘subsegments’. Subsegments are separated by secondary separators.
Primary separators are static – the customization I showed will always produce 4 primary separators. Secondaries depend upon the subsegments state, so there could be anywhere from 0-3 in my config.
- telephone-line.el: Stuff for setting up the mode-line
- telephone-line-separators.el: Separator definitions
- telephone-line-segments.el: Segment definitions
- telephone-line-utils.el: Functions strictly for defining new Separators and Segments
If you just want the separators, you can just require that. It does depend upon utils, however.