Re: question marks in default index_format
- To: mutt-users@xxxxxxxx
- Subject: Re: question marks in default index_format
- From: Kyle Wheeler <kyle-mutt@xxxxxxxxxxxxxx>
- Date: Mon, 2 Feb 2009 15:16:00 -0600
- Comment: DomainKeys? See http://domainkeys.sourceforge.net/
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed; d=memoryhole.net; h=date :from:to:subject:message-id:references:mime-version:content-type :in-reply-to; s=default; bh=Vh2PLyOATqfLK6bdj+PajOZ/PnE=; b=QmA6 HnRVKhxTJrddFfqCpsn6tb2XzGY4MxQqTVD1Zm21dCW+BY0Hq1pslJNv/kmXC5m+ upV0Q5LkrKq0L939DqbHUxgny/B1taw8loDx90srCT9GhWEdBRQmZunnuG/fet9W 9zA24PfsveksZT4ONJA2+OoXuKQYCTzwcX0LfIg=
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=memoryhole.net; b=Pexjd1SaBhxN15VuQ4ZUvlWgdyiz4XU2KV/0Z0Fscoeg6BEIoioIJQmv9rqDNpVePdQbgNReEzaUf5L4ccE3MWkdrds7buyhmBAOMlZzSeXxQGrnWTwl6Vs1fjCnF2Rj85kDi2UdcfIJ1tlUCMSqIpAwmpIRyLLvYhyMCvbpSSI=; h=Received:Received:Date:From:To:Subject:Message-ID:Mail-Followup-To:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To:OpenPGP:User-Agent;
- In-reply-to: <20090202192101.GA4454@xxxxxxxxxxx>
- List-post: <mailto:mutt-users@mutt.org>
- List-unsubscribe: send mail to majordomo@mutt.org, body only "unsubscribe mutt-users"
- Mail-followup-to: mutt-users@xxxxxxxx
- Openpgp: id=CA8E235E; url=http://www.memoryhole.net/~kyle/kyle-pgp.asc; preference=signencrypt
- References: <20090202192101.GA4454@xxxxxxxxxxx>
- Sender: owner-mutt-users@xxxxxxxx
- User-agent: Mutt/1.5.19 (2009-01-27)
-----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-----