[MlMt] Partial copy of incoming subject

Benny Kjær Nielsen mailinglist at freron.com
Fri Nov 22 04:39:15 EST 2013


On 22 Nov 2013, at 9:44, mailmate wrote:

> I need to copy a part of a subject kind of:
>
> 	ex Subject:	Serial: XHGFSTW - File: 509393 - Reference: 43467
>
> I need to copy ex the serial of the file number to lookup this info in 
> another application.
>
> Any idea how this can be done easily.

The GUI currently only supports right-click and then Copy followed by 
editing the text when it's pasted. Obviously not easy.

This is one of those small things which would be nice to automate. Using 
the experimental commands system then you could do it with the following 
command:

	{
		name    = 'Copy Serial';
		input   = 'formatted';
		formatString = "${subject/Serial: (\\S*) .*/$1/}";
		script  = '#!/usr/bin/pbcopy\n';
		keyEquivalent = "F";
		uuid = 'C2561103-D9BA-43C5-AB4D-5AC7FDA5A77B';
	}

This would allow you to just hit ⇧F and then the serial value 
(XHGFSTW) would be on the pasteboard.

The problem is that there is currently no way you could have created the 
above yourself (undocumented and no GUI), but you have been a major 
contributor to the crowd funding campaign and you deserve your own 
bundle of commands. I've attached a simple start. Unzip it and then 
place it here:

	~/Library/Application Support/MailMate/Bundles/

(Also enable experimental 2.0 features in the General preferences pane.)

For you and the rest of the mailing list, here is a quick dissection of 
the command:

		name    = 'Copy Serial';

The name of the menu item placed in the Command menu.

		input   = 'formatted';

The input format. This tells MailMate that the input to the script 
(stdin) should be the result of a format string based on the currently 
selected message(s).

		formatString = "${subject/Serial: (\\S*) .*/$1/}";

The formatString uses the subject of the message, but it's altered using 
a regular expression substitution. This locates the serial number in the 
subject and uses it as the result. (It is incomprehensible if you have 
no experience with regular expressions.)

		script  = '#!/usr/bin/pbcopy\n';

The script to be executed is extremely simple. It's just a system 
command used to put the input on the pasteboard.

		keyEquivalent = "S";

The command can be executed using ⇧S (as an alternative to using the 
menu item).

		uuid = 'C2561103-D9BA-43C5-AB4D-5AC7FDA5A77B';

Each command must have a unique identifier.

Final note: I introduced the `formatted` input format mainly to easily 
select a large number of messages and then retrieve a simple value from 
each of them. For example, one could easily retrieve all sender 
addresses and then send them through `sort | uniq -c | sort -r | head` 
to get a list of the 10 most frequent senders.

-- 
Benny
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freron.com/pipermail/mailmate/attachments/20131122/f72f0dc1/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ARC.mmBundle.zip
Type: application/zip
Size: 2176 bytes
Desc: not available
URL: <http://lists.freron.com/pipermail/mailmate/attachments/20131122/f72f0dc1/attachment.zip>


More information about the mailmate mailing list