Re: delete only undeleted messages?

2014-02-27 Thread Peter P.
* Ed Blackman e...@edgewood.to [2014-02-26 20:46]:
 On Wed, Feb 26, 2014 at 04:45:00PM +0100, Peter P. wrote:
folder-hook . 'macro pager d save-message=Trash \r
 [...]
 Is there a way to incoorporate the status/flag of a message as
 conditional for the above key binding to only allow saving to trash if
 the message is not marked as 'deleted'?
 
 You might want to investigate the 'trash' patch, which is commonly
 already applied to packaged versions of mutt.
 http://cedricduval.free.fr/mutt/patches/#trash

Thanks Ed! It seems my version of mutt (1.5.21) has the
features/trash-folder
compiled in, yet I didn't yet set the respective variable in the
config file. Will test that and get back to this list if there is
still questions open. Thank you also for hacking out the option below,
which seems very cool as well!

best, Peter

 If you don't have the patch and don't want to build mutt to apply
 it, there are not a lot of good options.  The main problem is
 there's no way I know of to do general conditional logic (if
 message isn't marked as deleted, save to trash, otherwise do
 nothing) directly in a macro.
 
 The only conditional logic I know of is tag-prefix-cond, but I can't
 think of a way to use that for your end.
 
 You can use backticks to move some of the conditional logic to a
 shell script.  You would need a macro that would pipe a message to
 save it in a known location, then use :push with backticks to call a
 program that read the email in that location, then either emitted
 the command to save the message or a noop depending on whether the
 email's Message-Id was in a cache.
 
 It would look something like this:
 
 macro index d 'pipe-messagecat  /tmp/message.txtenter\
 :push `/path/to/script.sh`enter' Save to trash folder
 
 /path/to/script.sh would:
 1) read /tmp/message.txt and extract the Message-Id
 2) check to see if the Message-Id was in the cache
 3) if not, print 'save-message=Trashenterenter' and add the Id
 to the cache
 
 If the message was in the cache, the script would do nothing,
 causing the macro to do nothing further.
 
 Pretty convoluted, and race-prone since you have to save the message
 in a fixed location.  There might be further tricks to remove that
 particular limitation, but I've procrastinated enough today.
 
 -- 
 Ed Blackman
Thanks Ed


Re: delete only undeleted messages?

2014-02-26 Thread Patrick Shanahan
* Peter P. p8...@aol.com [02-26-14 10:48]:
 Hi!
 
 I have noticed that I can delete (save to trash folder) the same
 message over and over again using, 
 
 folder-hook . 'macro index d save-message=Trash \r
 folder-hook . 'macro pager d save-message=Trash \r
 
 even after it has been marked as deleted. I end up with mutiple
 accidental copies in the trash this way. Is there a way to
 incoorporate the status/flag of a message as conditional for the above
 key binding to only allow saving to trash if the message is not marked
 as 'deleted'?

You need sync-mailbox after the save_to_tash.  As long as you remain in
the same mailbox, destructive actions aside from editing are not applied
until you close, move to another, or sync the mailbox.

-- 
(paka)Patrick Shanahan   Plainfield, Indiana, USA  @ptilopteri
http://en.opensuse.orgopenSUSE Community Memberfacebook/ptilopteri
http://wahoo.no-ip.orgPhoto Album: http://wahoo.no-ip.org/gallery2
Registered Linux User #207535@ http://linuxcounter.net


Re: delete only undeleted messages?

2014-02-26 Thread Peter P.
* Patrick Shanahan ptilopt...@gmail.com [2014-02-26 17:23]:
 * Peter P. p8...@aol.com [02-26-14 10:48]:
  Hi!
  
  I have noticed that I can delete (save to trash folder) the same
  message over and over again using, 
  
  folder-hook . 'macro index d save-message=Trash \r
  folder-hook . 'macro pager d save-message=Trash \r
  
  even after it has been marked as deleted. I end up with mutiple
  accidental copies in the trash this way. Is there a way to
  incoorporate the status/flag of a message as conditional for the above
  key binding to only allow saving to trash if the message is not marked
  as 'deleted'?
 
 You need sync-mailbox after the save_to_tash.  As long as you remain in
 the same mailbox, destructive actions aside from editing are not applied
 until you close, move to another, or sync the mailbox.

Thank you for the reply Patrick, I would prefer to not sync/expunge   
the mailbox after every copy to trash key shortcut.
Perhaps there is a way to make key commands aware of a message's flag 
instead.

Thank you again!
best, P


Re: delete only undeleted messages?

2014-02-26 Thread Christian Brabandt
On Mi, 26 Feb 2014, Peter P. wrote:

 * Patrick Shanahan ptilopt...@gmail.com [2014-02-26 17:23]:
  * Peter P. p8...@aol.com [02-26-14 10:48]:
   Hi!
   
   I have noticed that I can delete (save to trash folder) the same
   message over and over again using, 
   
   folder-hook . 'macro index d save-message=Trash \r
   folder-hook . 'macro pager d save-message=Trash \r
   
   even after it has been marked as deleted. I end up with mutiple
   accidental copies in the trash this way. Is there a way to
   incoorporate the status/flag of a message as conditional for the above
   key binding to only allow saving to trash if the message is not marked
   as 'deleted'?
  
  You need sync-mailbox after the save_to_tash.  As long as you remain in
  the same mailbox, destructive actions aside from editing are not applied
  until you close, move to another, or sync the mailbox.
 
 Thank you for the reply Patrick, I would prefer to not sync/expunge   
 the mailbox after every copy to trash key shortcut.
 Perhaps there is a way to make key commands aware of a message's flag 
 instead.

I see three possibilities.

- Instead of deleting the actual messages you tag them and on a key 
  press, you move all tagged, not-deleted messages to your Archive/Trash 
  folder. Something like this (untested):
  
   macro index,pager d 
tag-pattern!~D~Tentertag-prefix-condsave-messagekill-line=Trashenteruntag-pattern~Aenter
 'Delete messages'

- Add an folder hook, to delete duplicate messages (something like 
  this):
   folder-hook =Trash 'push 
untag-pattern~Aentertag-pattern~=entertag-prefix-conddelete-messageuntag-pattern~Aentersync-mailboxenter'

- Use the trash folder patch, that is floating around and even provided 
  in some distributions like Debians mutt-patched, IIRC
   

Best,
Christian
-- 
If it weren't for the last minute, nothing would ever get done.


Re: delete only undeleted messages?

2014-02-26 Thread Peter P.
* Christian Brabandt cbli...@256bit.org [2014-02-26 19:45]:
 On Mi, 26 Feb 2014, Peter P. wrote:
 
  * Patrick Shanahan ptilopt...@gmail.com [2014-02-26 17:23]:
   * Peter P. p8...@aol.com [02-26-14 10:48]:
Hi!

I have noticed that I can delete (save to trash folder) the same
message over and over again using, 

folder-hook . 'macro index d save-message=Trash \r
folder-hook . 'macro pager d save-message=Trash \r

even after it has been marked as deleted. I end up with mutiple
accidental copies in the trash this way. Is there a way to
incoorporate the status/flag of a message as conditional for the above
key binding to only allow saving to trash if the message is not marked
as 'deleted'?
   
   You need sync-mailbox after the save_to_tash.  As long as you remain in
   the same mailbox, destructive actions aside from editing are not applied
   until you close, move to another, or sync the mailbox.
  
  Thank you for the reply Patrick, I would prefer to not sync/expunge   
  the mailbox after every copy to trash key shortcut.
  Perhaps there is a way to make key commands aware of a message's flag 
  instead.
 
 I see three possibilities.
 
 - Instead of deleting the actual messages you tag them and on a key 
   press, you move all tagged, not-deleted messages to your Archive/Trash 
   folder. Something like this (untested):
   
macro index,pager d 
 tag-pattern!~D~Tentertag-prefix-condsave-messagekill-line=Trashenteruntag-pattern~Aenter
  'Delete messages'
 
 - Add an folder hook, to delete duplicate messages (something like 
   this):
folder-hook =Trash 'push 
 untag-pattern~Aentertag-pattern~=entertag-prefix-conddelete-messageuntag-pattern~Aentersync-mailboxenter'
 
 - Use the trash folder patch, that is floating around and even provided 
   in some distributions like Debians mutt-patched, IIRC

 
 Best,
 Christian
 -- 
 If it weren't for the last minute, nothing would ever get done.

Wow, thanks a lot Christian for this precise information! It is 
greatly appreciated and I am going to look deeper into the solutions 
you suggest.

best, Peter


Re: delete only undeleted messages?

2014-02-26 Thread Ed Blackman

On Wed, Feb 26, 2014 at 04:45:00PM +0100, Peter P. wrote:

   folder-hook . 'macro pager d save-message=Trash \r

[...]

Is there a way to incoorporate the status/flag of a message as
conditional for the above key binding to only allow saving to trash if
the message is not marked as 'deleted'?


You might want to investigate the 'trash' patch, which is commonly 
already applied to packaged versions of mutt.  
http://cedricduval.free.fr/mutt/patches/#trash


If you don't have the patch and don't want to build mutt to apply it, 
there are not a lot of good options.  The main problem is there's no way 
I know of to do general conditional logic (if message isn't marked as 
deleted, save to trash, otherwise do nothing) directly in a macro.


The only conditional logic I know of is tag-prefix-cond, but I can't 
think of a way to use that for your end.


You can use backticks to move some of the conditional logic to a shell 
script.  You would need a macro that would pipe a message to save it in 
a known location, then use :push with backticks to call a program that 
read the email in that location, then either emitted the command to save 
the message or a noop depending on whether the email's Message-Id was in 
a cache.


It would look something like this:

macro index d 'pipe-messagecat  /tmp/message.txtenter\
:push `/path/to/script.sh`enter' Save to trash folder

/path/to/script.sh would:
1) read /tmp/message.txt and extract the Message-Id
2) check to see if the Message-Id was in the cache
3) if not, print 'save-message=Trashenterenter' and add the Id to 
the cache


If the message was in the cache, the script would do nothing, causing 
the macro to do nothing further.


Pretty convoluted, and race-prone since you have to save the message in 
a fixed location.  There might be further tricks to remove that 
particular limitation, but I've procrastinated enough today.


--
Ed Blackman