[MlMt] Customizing Headers Display

Benny Kjær Nielsen mailinglist at freron.com
Wed Mar 13 10:50:24 UTC 2013


On 12 Mar 2013, at 23:55, Zvi Biener wrote:

> Does anyone know how/if one may customize the long-view of headers 
> that is displayed above the body of any given message?

Yes, that is possible (both the long and short format).

> I'd love to stick a list of the attachments up there (along w/ 
> standard from, subject, date, and to), if that's possible.

No, that is not possible. You can get an attachments count or just an 
indication of whether or not attachments exist, but that's probably it. 
I can think of ways to make this more flexible, but the long term plan 
is to completely re-implement the headers view and therefore I'm not 
really motivated with regard to improving it.

This is the relevant file:

	MailMate.app/Contents/Resources/Layouts/headersFormatting.plist

And this is where you could place a customization/extension of the file:

	~/Library/Application 
Support/MailMate/Resources/Layouts/headersFormatting.plist

If you do this then you won't see any future changes I make to the 
default file when MailMate is updated. Note that the files are merged, 
that is, you should only include the top-level keys you actually change.

For the sake of completion, here is an example of how to show an 
attachment count. (This is MailMate-hacking and I make no guarantees 
that it'll work in the future. In fact, I guarantee the opposite.)

	{
		prefix = { string = "\tAttachments:\t"; fontStyle = bold; color = 
'#777777'; };
		formatString = "${#attachments-count/^0$//}";
	},

The above should be appended to the default `longFormatting` value. This 
is probably all a bit confusing. I've attached the full example.

Note that I use a regexp replacement in the format string to convert a 
count of 0 to an empty string. This has the effect of hiding the 
attachments line when the count is 0 .

-- 
Benny
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freron.com/pipermail/mailmate/attachments/20130313/e1d28f08/attachment-0001.html>
-------------- next part --------------
{
	// defaultFormatting = "longFormatting";
	longFormatting =
	{
		separator = { string = "\n"; };
		children =
		(
			{
				prefix = { string = "\tFrom:\t"; fontStyle = bold; color = '#777777'; };
				children =
				(
					{
						formatString = "${from.name}";
						singleClick =
						{
							titleFormatting = { prefixString = "From "; formatString = "?${from.name}?"; };
							queryFormatting = { formatString = "from.name = '${from.name}'"; separatorString = " or "; escapeSingleQuotes = 1; };
						};
					},
					{
						prefix = { formatString = "${from.name:+ <}";};
						formatString = "${from.address}";
						suffix = { formatString = "${from.name:+>}";};
						singleClick =
						{
							titleFormatting = { prefixString = "From "; formatString = "?${from.address}?"; };
							queryFormatting = { formatString = "from.address = '${from.address}'"; separatorString = " or "; escapeSingleQuotes = 1; };
						};
					},
				);
				copyValues =
				(
					{ title = ''; valueFormatting = { formatString = '${from.name:+${from.name} <${from.address}>}'; }; },
					{ title = 'Address Only'; valueFormatting = { formatString = '${from.address}'; }; },
					{ title = 'Name Only'; valueFormatting = { formatString = '${from.name}'; }; },
				);
				isAddress = :true;
			},
			{
				prefix = { string = "\tSubject:\t"; fontStyle = bold; color = '#777777'; };
				children =
				(
					{
						formatString = "${subject.prefix}";
						suffix = { string = " "; };
						// link stuff
					},
					{
						prefix = { string = "["; };
						formatString = "${subject.blob}";
						suffix = { string = "] "; };
						singleClick =
						{
							titleFormatting = { prefixString = "Related to "; formatString = "${list-id.identifier:??${list-id.identifier}?:[${subject.blob}]}"; };
							queryFormatting = { formatString = "${list-id.identifier:?list-id.identifier = '${list-id.identifier}':subject.blob = '${subject.blob}'}"; escapeSingleQuotes = 1; };
						};
					},
					{
						formatString = "${subject.body}";
						singleClick =
						{
							titleFormatting = { prefixString = "Related to "; formatString = "?${subject.body}?"; };
							queryFormatting = { formatString = "subject.body = '${subject.body}'"; escapeSingleQuotes = 1; };
						};
					},
				);
			},
			{
				prefix = { string = "\tDate:\t"; fontStyle = bold; color = '#777777'; };
				formatString = "${#date.formatted}";
				singleClick =
				{
					titleFormatting = { prefixString = "Date is "; formatString = "?${#date.day}?"; };
					queryFormatting = { formatString = "#date.day = '${#date.day}'"; escapeSingleQuotes = 1; };
				};
			},
			{
				prefix = { string = "\tTo:\t"; fontStyle = bold; color = '#777777'; };
				sharedPrefix = "to";
				separatorString = ", ";
				children =
				(
					{
						formatString = "${to.name}";
						singleClick =
						{
							titleFormatting = { prefixString = "To "; formatString = "?${to.name}?"; };
							queryFormatting = { formatString = "#recipient.name = '${to.name}'"; escapeSingleQuotes = 1; };
						};
						copyValues =
						(
							{ title = ''; valueFormatting = { formatString = '${to.name:+${to.name} <${to.address}>}'; }; },
							{ title = 'Address Only'; valueFormatting = { formatString = '${to.address}'; }; },
							{ title = 'Name Only'; valueFormatting = { formatString = '${to.name}'; }; },
						);
						isAddress = :true;
					},
					{
						prefix = { formatString = "${to.name:+ <}";};
						formatString = "${to.address}";
						suffix = { formatString = "${to.name:+>}";};
						singleClick =
						{
							titleFormatting = { prefixString = "To "; formatString = "?${to.address}?"; };
							queryFormatting = { formatString = "#recipient.address = '${to.address}'"; escapeSingleQuotes = 1; };
						};
						copyValues =
						(
							{ title = ''; valueFormatting = { formatString = '${to.name:+${to.name} <${to.address}>}'; }; },
							{ title = 'Address Only'; valueFormatting = { formatString = '${to.address}'; }; },
							{ title = 'Name Only'; valueFormatting = { formatString = '${to.name}'; }; },
						);
						isAddress = :true;
					},
				);
			},
			{
				prefix = { string = "\tCc:\t"; fontStyle = bold; color = '#777777'; };
				sharedPrefix = "cc";
				separatorString = ", ";
				children =
				(
					{
						formatString = "${cc.name}";
						singleClick =
						{
							titleFormatting = { prefixString = "To "; formatString = "?${cc.name}?"; };
							queryFormatting = { formatString = "#recipient.name = '${cc.name}'"; escapeSingleQuotes = 1; };
						};
						copyValues =
						(
							{ title = ''; valueFormatting = { formatString = '${cc.name:+${cc.name} <${cc.address}>}'; }; },
							{ title = 'Address Only'; valueFormatting = { formatString = '${cc.address}'; }; },
							{ title = 'Name Only'; valueFormatting = { formatString = '${cc.name}'; }; },
						);
						isAddress = :true;
					},
					{
						prefix = { formatString = "${cc.name:+ <}";};
						formatString = "${cc.address}";
						suffix = { formatString = "${cc.name:+>}";};
						singleClick =
						{
							titleFormatting = { prefixString = "To "; formatString = "?${cc.address}?"; };
							queryFormatting = { formatString = "#recipient.address = '${cc.address}'"; escapeSingleQuotes = 1; };
						};
						copyValues =
						(
							{ title = ''; valueFormatting = { formatString = '${cc.name:+${cc.name} <${cc.address}>}'; }; },
							{ title = 'Address Only'; valueFormatting = { formatString = '${cc.address}'; }; },
							{ title = 'Name Only'; valueFormatting = { formatString = '${cc.name}'; }; },
						);
						isAddress = :true;
					},
				);
			},
			{
				prefix = { string = "\tBcc:\t"; fontStyle = bold; color = '#777777'; };
				sharedPrefix = "bcc";
				separatorString = ", ";
				children =
				(
					{
						formatString = "${bcc.name}";
						singleClick =
						{
							titleFormatting = { prefixString = "To "; formatString = "?${bcc.name}?"; };
							queryFormatting = { formatString = "#recipient.name = '${bcc.name}'"; escapeSingleQuotes = 1; };
						};
						copyValues =
						(
							{ title = ''; valueFormatting = { formatString = '${bcc.name:+${bcc.name} <${bcc.address}>}'; }; },
							{ title = 'Address Only'; valueFormatting = { formatString = '${bcc.address}'; }; },
							{ title = 'Name Only'; valueFormatting = { formatString = '${bcc.name}'; }; },
						);
						isAddress = :true;
					},
					{
						prefix = { formatString = "${bcc.name:+ <}";};
						formatString = "${bcc.address}";
						suffix = { formatString = "${bcc.name:+>}";};
						singleClick =
						{
							titleFormatting = { prefixString = "To "; formatString = "?${bcc.address}?"; };
							queryFormatting = { formatString = "#recipient.address = '${bcc.address}'"; escapeSingleQuotes = 1; };
						};
						copyValues =
						(
							{ title = ''; valueFormatting = { formatString = '${bcc.name:+${bcc.name} <${bcc.address}>}'; }; },
							{ title = 'Address Only'; valueFormatting = { formatString = '${bcc.address}'; }; },
							{ title = 'Name Only'; valueFormatting = { formatString = '${bcc.name}'; }; },
						);
						isAddress = :true;
					},
				);
			},
			{
				prefix = { string = "\tSecurity:\t"; fontStyle = bold; color = '#777777'; };
				separatorString = " ";
				children =
				(
					{
						// formatString = "${#encrypted:+?Encrypted (${#security-protocol:+Unknown protocol})}";
						formatString = "${#encrypted:+?Encrypted}";
						singleClick = { selector = "showDetails:"; };
						toolTip = { formatString = "This message is encrypted."; };
					},
					{
						// formatString = "${#signed:+?Signed (${#security-protocol:+Unknown protocol})}";
						formatString = "${#signed:+?Signed}";
						singleClick = { selector = "showDetails:"; };
						toolTip = { formatString = "This message is signed."; };
					}
				);
			},
			{
				prefix = { string = "\tTags:\t"; fontStyle = bold; color = '#777777'; };
				separatorString = " ";
				sharedPrefix = "#flags.flag";
				children =
				(
					{
						formatString = "${#flags.flag.name}";
						singleClick =
						{
							titleFormatting = { prefixString = "Tagged "; formatString = "?${#flags.flag}?"; };
							queryFormatting = { formatString = "#flags.flag = '${#flags.flag}'"; escapeSingleQuotes = 1; };
						};
						copyValues =
						(
							{ title = ''; valueFormatting = { formatString = '${#flags.flag.name}'; }; },
							{ titleFormatting = 'Server Keyword (${#flags.flag})'; valueFormatting = { formatString = '${#flags.flag}'; }; },
						);
						// isTag = :true;
					},
				);
			},
			{
				prefix = { string = "\tAttachments:\t"; fontStyle = bold; color = '#777777'; };
				formatString = "${#attachments-count/^0$//}";
			},
		);
	};

}


More information about the mailmate mailing list