Re: numerical field in .muttrc for positioning menus
- To: mutt-users@xxxxxxxx
- Subject: Re: numerical field in .muttrc for positioning menus
- From: Kyle Wheeler <kyle-mutt@xxxxxxxxxxxxxx>
- Date: Mon, 19 Nov 2007 18:55:40 -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; q=dns/txt; s=default; bh=9RazYCPT3deoP/yopCb4+ECtmbI=; b=Etu8sUaQfe9GnR1SfQ28X5De1AXBndf1RnFTj1ScV+2xOMx8C1uHNmklNMuqrnTbG89PgdsVy8Rzm/UU8rqSmY+VfylyJh0LhO8XX3UQtzk+YBaWUUN4LSS2lW+7m7WiGH3S5sLVFjbWNI1cY17OZsXTHd+YsYJAVy+rHIAY1m0=
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=memoryhole.net; b=b6rtgTAHNyHv61dzoiRDmQTjCtkA7cD5OF/b4Is1exw6DES/KUxasBUrLUQIAjyaiyzeyWUYc3f3vm/sNyGQOoFXfJJWPMJV7ZCemSyVSUsoNOKMAqQ1qtPpbXFVK3swQuioaQ6ZmcN9IOc9ZDIzKZcB2FPO2T/8n8fIaTYt0So=; h=Received:Received:Date:From:To:Subject:Message-ID:Mail-Followup-To:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To:User-Agent;
- In-reply-to: <20071119232900.GD13583@xxxxxxxx>
- 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
- References: <20071119232900.GD13583@xxxxxxxx>
- Sender: owner-mutt-users@xxxxxxxx
- User-agent: Mutt/1.5.17 (2007-11-15)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Tuesday, November 20 at 12:29 AM, quoth Mauro Sacchetto:
>In my -muttrc I've , for instance:
>set index_format = "(%3C) %Z %-7.7{%b %d} %-20.20F (lin:%4l msg:%2M) %-28.28t
>%s"
>What is the exact logic of the numerical field, as -7.7
>to obtain the right positioning of the fileds FROM, TOO etc?
It's the same logic as in printf. To quote the applicable parts from
the man page:
Each format specification is introduced by the percent character
(``%''). The remainder of the format specification includes, in
the following order:
Zero or more of the following flags:
- A minus sign `-' which specifies left adjustment of the
output in the indicated field;
` ' A space specifying that a blank should be left before a
positive number for a signed format. A `+' overrides a
space if both are used;
0 A zero `0' character indicating that zero-padding should
be used rather than blank-padding. A `-' overrides a `0'
if both are used;
Field Width:
An optional digit string specifying a field width; if the
output string has fewer characters than the field width it
will be blank-padded on the left (or right, if the
left-adjustment indicator has been given) to make up the field
width (note that a leading zero is a flag, but an embedded
zero is part of a field width);
Precision:
An optional period, `.', followed by an optional digit string
giving a precision which specifies the number of digits to
appear after the decimal point, for e and f formats, or the
maximum number of characters to be printed from a string; if
the digit string is missing, the precision is treated as zero;
Translating that, in the case of something like %-7.8s, we're telling
mutt that:
1. We want to print the subject (because it ends in s)
2. Exactly 7 spaces are to be reserved for the subject (because of
the 7), but more may be printed if the subject is longer.
3. The subject must be right-aligned (because of the -).
4. Only 8 characters may be printed.
To demonstrate the difference, let's take two subjects, "foobarbaz"
and "morky" to play with. I'll surround them with wockas (><) so that
you can see where other text would be printed if they were part of a
longer line. If we print both of them with >%s< we get:
>foobarbaz<
>morky<
If we use >%7s< we get:
>foobarbaz<
> morky<
Note that in both cases, 7 spots were reserved, but the longer subject
printed in its entirety anyway. If we negated it (>%-7s<), we'd get:
>foobarbaz<
>morky <
If we just use the bit after the decimal (>%.7s<), we're limiting how
many characters can print:
>foobarb<
>morky<
Note that without reserving spaces, adding a negative (>%-.7s<) does
nothing:
>foobarb<
>morky<
BUT these two can be combined to simulate a tabulated list. We use the
first number (to the left of the decimal) to reserve character spaces,
and the second number (to the right of the decimal) to limit how many
print. For example, if we use >%7.7s< then it looks like:
>foobarb<
> morky<
Adding a negative (>%-7.7s<) aligns things to the left:
>foobarb<
>morky <
To put that back in context, let's take a look at your $index_format:
set index_format = "(%3C) %Z %-7.7{%b %d} %-20.20F (lin:%4l msg:%2M) %-28.28t
%s"
Let's pretend that you have an unread message from foo sent on
November 20th, that's 10 lines long and 1k big, with a subject of "get
a load of this weird stuff!". That would be displayed like this:
1 N Nov 20 foo (lin:10 msg:1k) you
get a load of this weird stuff
Let me replace the spaces that were added as padding with underscores
so you can see them:
__1 N Nov 20_ foo_________________ (lin:10__ msg:1k)
you________________________ get a load of this weird stuff
Let's ignore everything after the msg: part, just to keep things
simple:
__1 N Nov 20_ foo_________________ (lin:10__ msg:1k)
Here's what it would look like if you used %20.20F instead of %-20.20F:
__1 N Nov 20_ _________________foo (lin:10__ msg:1k)
It would look exactly the same for this mail if you used %20F instead
of %-20.20F, but if the sender was foobarbazquxquuxgarply instead of
foo, here's how it would compare:
__1 N Nov 20_ foobarbazquxquuxgarp (lin:10__ msg:1k) << %-20.20F
__1 N Nov 20_ foobarbazquxquuxgarply (lin:10__ msg:1k) << %20F
Does that make sense?
~Kyle
- --
If Tyranny and Oppression come to this land, it will be in the guise
of fighting a foreign enemy.
-- James Madison
-----BEGIN PGP SIGNATURE-----
Comment: Thank you for using encryption!
iD8DBQFHQjCMBkIOoMqOI14RAmWUAJ9znJi4u3nywWcY2GXgDgK01lcXCQCgvhof
nmfAqbBENwrrPqJqp60DjIM=
=xXIz
-----END PGP SIGNATURE-----