<<< Date Index >>>     <<< Thread Index >>>

Re: question marks in default index_format



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Monday, February  2 at 12:21 PM, quoth Paul E Condon:
>I'm puzzled by the default index_format which is, I think:
>
>set index_format="%4C %Z %{%b %d} %-15.15L (%?l?%4l&%4c?) %s"
>
>I don't understand the string inside parentheses. Where can
>I find an explanation? Question marks often invoke some sort
>of conditional action, but I don't see them in printf docs.

Mutt doesn't rely strictly on printf; the semantics are printf-LIKE. 
:)

I don't know where it's documented, but yes, those are conditional. 
Basically, it works like an if-else statement, like so: 
%?condition?ifTrue&ifFalse? Additionally, conditional statements 
cannot be nested inside each other.

The "condition" is not very complicated - it's only allowed to be one 
of the valid %-letter letters. For example, in %?l?____&****?, you're 
testing the %l value (i.e. the number of lines in the message). If 
that value is zero or undefined, it's considered false. For example, 
unless mutt has scanned the message and formatted it, it does not know 
how many lines are in the message. Thus, in the default index_format, 
if the number of lines in the message is unknown, it will print %4c 
(i.e. the size of the message), but if the number of lines IS known, 
it will print that instead.

As another example, a pattern that I use in my index_format setting is 
this:

     %?M?[%M]> &?%s

It depends on the %M value (i.e. the number of hidden messages, if a 
thread is collapsed). What will happen is that, if a thread is 
collapsed, its subject will be printed like so:

     [4]> Discussion of threading

Whereas if it is uncollapsed, it will be printed like so:

     Discussion of threading

Not all %-letter values can be tested in a conditional statement like 
that. For example, it doesn't make any sense to test %i or %n or %d. 
But most of them; especially the ones that are essentially numbers, 
CAN be used as the condition for a conditional format.

Does that help explain it?

~Kyle
- -- 
Eskimo: If I did not know about God and sin, would I go to hell?
Priest: No, not if you did not know.
Eskimo: Then why did you tell me?
                                                       -- Annie Dillard
-----BEGIN PGP SIGNATURE-----
Comment: Thank you for using encryption!

iEYEARECAAYFAkmHYpAACgkQBkIOoMqOI176hgCgyeWCasbXmVIMm17Obtx6/wTl
iusAnAvOceWP0ikg9IM1vZgFqYs7Pe6F
=+PuF
-----END PGP SIGNATURE-----