[imapfilter-devel] Improving Filter Writing Effeciency
Lefteris Chatzimparmpas
lefcha at hellug.gr
Sat Jan 8 22:41:17 EET 2011
Hm, if I understood this right:
results = account1.Sent:contain_subject('[OPEN]') * account1.Sent:contain_to('domain2.ca')
results:move_messages(account2['Open'])
results = account1.Sent:contain_subject('[OPEN]') * account1.Sent:contain_to('domain3.ca')
results:move_messages(account3['Open'])
You can apply an action like move_messages() to some results not the way
you did it. Have a look also in the sample files included with
imapfilter and the imapfilter_config(5) manual page.
On 01/08/2011 08:16 PM, Philippe LeCavalier wrote:
> Got it. Works like a charm!
>
> What about if I reply from my own account by mistake(common occurrence)
> and want to filter mail from my own INBOX.Sent folder to their respected
> folders, can I...
>
> for _, account1 do
> account1.Sent:contain_subject('[OPEN]') *
> account1.Sent:contain_to('domain2.ca'):move_messages(account2['Open'])
> account1.Sent:contain_subject('[OPEN]') *
> account1.Sent:contain_to('domain3.ca'):move_messages(account3['Open'])
> end
>
> That's prob. all wrong but I think you can see the idea?
>
> Phil
> On Sat, 2011-01-08 at 19:46 +0100, Lefteris Chatzimparmpas wrote:
>
>> Hello,
>>
>> You don't need the '+', just like this:
>>
>> for _, account in ipairs({ account1, account2 }) do
>> account.INBOX:contain_subject('[OPEN]'):move_messages(account['help/Open'])
>> account.INBOX:contain_subject('[CLOSED]'):move_messages(account['help/Closed'])
>> end
>>
>> The '+' (OR operator) is needed when you want to combine different
>> search results, in order then to apply a single action to all them at
>> once.
>>
>>
>> On 01/08/2011 07:17 PM, Philippe LeCavalier wrote:
>>> Hi again.
>>>
>>> Sorry to bug you. I'm asking this on the list just in case other lua
>>> illiterates may benefit from this...
>>>
>>> If I want to encompass more subjects and move them to more mailboxes,
>>> can I do
>>>
>>> for _, account in ipairs({ account1, account2 }) do
>>> account.INBOX:contain_subject('[OPEN]'):move_messages(account['help/Open']) +
>>> account.INBOX:contain_subject('[CLOSED]'):move_messages(account['help/Closed'])
>>> end
>>>
>>> Is '+' the still the correct syntax to indicate to offlineimap the
>>> operand 'OR'?
>>>
>>> Thanks,
>>> Phil
>>>
>>> On Sat, 2011-01-08 at 10:34 -0600, Philippe LeCavalier wrote:
>>>
>>>> Quoting Lefteris Chatzimparmpas <lefcha at hellug.gr>:
>>>>
>>>>> Yes, that's correct, you got that right. For each account it will move
>>>>> messages from its INBOX to its "help/Open" folder.
>>>>
>>>> Perfect!
>>>>
>>>> Thanks,
>>>> Phil
>>>>>
>>>>>
>>>>> On 01/08/2011 04:45 PM, Philippe LeCavalier wrote:
>>>>>> Thanks. That's much cleaner. I have one question though...
>>>>>> Quoting Lefteris Chatzimparmpas <lefcha at hellug.gr>:
>>>>>>
>>>>>>> Hello,
>>>>>>>
>>>>>>> You can make use of Lua to accomplish this. For example one way could
>>>>>>> be:
>>>>>>>
>>>>>>> for _, account in ipairs({ account1, account2 }) do
>>>>>>>
>>>>>>> account.INBOX:contain_subject('[OPEN]'):move_messages(account['help/Open'])
>>>>>>>
>>>>>>> end
>>>>>> Can I assume that I'm reading this correctly in that mail for/from
>>>>>> account1 will stay in account1 ie it won't move a msg with subject OPEN
>>>>>> from account1.INBOX to account2.INBOX.help.Open right?
>>>>>>
>>>>>> Pardon my ignorance, I really don't know any form of programming language.
>>>>>>
>>>>>> Thanks,
>>>>>> Phil
>>>>>>>
>>>>>>> You can add more accounts or even write a nice Lua function, and so on.
>>>>>>>
>>>>>>>
>>>>>>> On 01/07/2011 07:49 PM, Philippe LeCavalier wrote:
>>>>>>>> I have 3 IMAP accounts. I'm wondering if I can merge identical filters?
>>>>>>>> ie.
>>>>>>>>
>>>>>>>> --Move Open
>>>>>>>> results = account1.INBOX:contain_subject('[OPEN]')
>>>>>>>> results:move_messages(account1['help/Open'])
>>>>>>>> results = account2.INBOX:contain_subject('[OPEN]')
>>>>>>>> results:move_messages(account2['help/Open'])
>>>>>>>>
>>>>>>>> with something like:
>>>>>>>>
>>>>>>>> --Move Open
>>>>>>>> results = account{1|2}.INBOX:contain_subject('[OPEN]')
>>>>>>>> results:move_messages(account{1|2}1['help/Open'])
>>>>>>>>
>>>>>>>> I know the above syntax is incorrect; it's just for illustration
>>>>>>>> purposes.
>>>>>>>>
>>>>>>>> Any thoughts?
>>>>>>>>
>>>>>>>> Phil
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> Imapfilter-devel mailing list
>>>>>>>> Imapfilter-devel at lists.hellug.gr
>>>>>>>> http://lists.hellug.gr/mailman/listinfo/imapfilter-devel
>>>>>>>
>>>>>>
>>>>> _______________________________________________
>>>>> Imapfilter-devel mailing list
>>>>> Imapfilter-devel at lists.hellug.gr
>>>>> http://lists.hellug.gr/mailman/listinfo/imapfilter-devel
>>>>
>>>>
>>>> _______________________________________________
>>>> Imapfilter-devel mailing list
>>>> Imapfilter-devel at lists.hellug.gr
>>>> http://lists.hellug.gr/mailman/listinfo/imapfilter-devel
>>>
>>>
>>>
>>> _______________________________________________
>>> Imapfilter-devel mailing list
>>> Imapfilter-devel at lists.hellug.gr
>>> http://lists.hellug.gr/mailman/listinfo/imapfilter-devel
>> _______________________________________________
>> Imapfilter-devel mailing list
>> Imapfilter-devel at lists.hellug.gr
>> http://lists.hellug.gr/mailman/listinfo/imapfilter-devel
>
>
>
> _______________________________________________
> Imapfilter-devel mailing list
> Imapfilter-devel at lists.hellug.gr
> http://lists.hellug.gr/mailman/listinfo/imapfilter-devel
More information about the Imapfilter-devel
mailing list