Next: User-Defined Specs, Previous: Mode Line Formatting, Up: Formatting Variables [Contents][Index]
It is frequently useful to post-process the fields in some way. Padding, limiting, cutting off parts and suppressing certain values can be achieved by using tilde modifiers. A typical tilde spec might look like ‘%~(cut 3)~(ignore "0")y’.
These are the valid modifiers:
padpad-leftPad the field to the left with spaces until it reaches the required length.
pad-rightPad the field to the right with spaces until it reaches the required length.
maxmax-leftCut off characters from the left until it reaches the specified length.
max-rightCut off characters from the right until it reaches the specified length.
cutcut-leftCut off the specified number of characters from the left.
cut-rightCut off the specified number of characters from the right.
ignoreReturn an empty string if the field is equal to the specified value.
formUse the specified form as the field value when the ‘@’ spec is used.
Here’s an example:
"~(form (current-time-string))@"
Let’s take an example. The ‘%o’ spec in the summary mode lines will return a date in compact ISO8601 format—‘19960809T230410’. This is quite a mouthful, so we want to shave off the century number and the time, leaving us with a six-character date. That would be ‘%~(cut-left 2)~(max-right 6)~(pad 6)o’. (Cutting is done before maxing, and we need the padding to ensure that the date is never less than 6 characters to make it look nice in columns.)
Ignoring is done first; then cutting; then maxing; and then as the very last operation, padding.
Next: User-Defined Specs, Previous: Mode Line Formatting, Up: Formatting Variables [Contents][Index]