moving complete threads (was Re: patches (colored questions, conditional tag-prefix))

2002-03-15 Thread Nicolas Rachinsky

* Prahlad Vaidyanathan [EMAIL PROTECTED] [2001-11-28 09:44:54 +0530]:
 On Sat, 17 Nov 2001 christophe [EMAIL PROTECTED] spewed
 into the ether: 
 [-- snip --]
   I should add, this works also for push commands (and it seems to
   work for exec). I use the following in my .muttrc: folder-hook
   regex for all mailing list folders push
   
\tag-pattern~d2w\nuntag-pattern~F|~D\ntag-prefix-condsave-message\n\n\
   
   It moves all messages older than 2 weeks except flagged ones to an
   archive folder (I have other folder-hooks to set appropriate
   save-hooks).
  
  This is nearly what I would like to do except that I would like to
  keep thread together.  ie I would like to move thread with all mails
  older than X days, read and not flagged.
 
 I want to setup a macro that does this :
 
 1. Tag all messages older than, say, 2 weeks
 2. Tag entire threads of those messages, even if some messages in that
thread are newer than 2 weeks.
 3. Delete/Save tagged messages.
 
 1, and 3 seem possible, but 2 does not. So far I've been doing it
 manually, but as I subscribe to more and more lists it becomes
 increasingly tedious.
 
 Any solutions ?

I hope yes. I've written a patch to achieve this. It is not well
tested, but it seems to work, and I had no crash after applying it.

It adds an new pattern ~a. I see only two possible uses of it, T~a\n
and ^T! ~a\n. The first one tags all messages which are in threads
containing any tagged message, the second one untags all messages
which are in threads containing any untagged messages. I should add
that ~a and !~a are not the same module not. The not applies to the
tag status of the other messages in the thread.

As always, use at YOUR OWN RISK. But I would be glad to hear if
anybody considers this patch usefull, or can give me any feedback.

The above push command will soon be, but I have to test a bit before
using it :)
push 
\tag-pattern~d2w\nuntag-pattern~N|~O|~F|~D\nuntag-pattern!~a\ntag-prefix-condsave-message\n\n\

 PS: Sorry for raking up _old_ threads, but I just desperately need this
 one to work !

I hope no one gets angry with me, because of replying to e-mails after
such a long time.

Nicolas


written by Nicolas Rachinsky [EMAIL PROTECTED]
http://www.rachinsky.de

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation;  version 2 of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.
--- mutt-1.3.27.orig/PATCHESMon Nov 26 20:16:52 2001
+++ PATCHES Thu Dec  6 16:27:55 2001
@@ -1,0 +1 @@
+1.3.28.nr.threadcomplete
--- mutt-1.3.28.ori/mutt.h  Thu Mar 14 19:22:25 2002
+++ mutt.h  Fri Mar 15 00:22:41 2002
@@ -198,6 +198,7 @@
   M_LIMIT,
   M_EXPIRED,
   M_SUPERSEDED,
+  M_THREADCOMPLETE,
 
   /* actions for mutt_pattern_comp/mutt_pattern_exec */
   M_AND,
--- mutt-1.3.28.ori/pattern.c   Thu Mar 14 19:22:26 2002
+++ pattern.c   Fri Mar 15 00:23:52 2002
@@ -50,6 +50,7 @@
 }
 Flags[] =
 {
+  { 'a', M_THREADCOMPLETE, 0,  NULL },
   { 'A', M_ALL,0,  NULL },
   { 'b', M_BODY,   M_FULL_MSG, eat_regexp },
   { 'B', M_WHOLE_MSG,  M_FULL_MSG, eat_regexp },
@@ -957,6 +958,27 @@
   return alladdr;
 }
 
+static int match_threadcomplete(int flag,THREAD *t,int left,int up,int right,int down)
+{
+   int a=0;
+   HEADER *h=NULL;
+
+   if(! t)return 0;
+   h=t-message;
+   if(! flag  h  h-tagged)return 1;
+   if(flag  h  ! h-tagged) return 1;
+
+   if(up)a=match_threadcomplete(flag,t-parent,1,1,1,0);
+   if(a)return a;
+   if(right  t-parent)a=match_threadcomplete(flag,t-next,0,0,1,1);
+   if(a)return a;
+   if(left  t-parent)a=match_threadcomplete(flag,t-prev,1,0,0,1);
+   if(a)return a;
+   if(down)a=match_threadcomplete(flag,t-child,1,0,1,1);
+   if(a)return a;
+   return 0;
+}
+
 /* flags
M_MATCH_FULL_ADDRESSmatch both personal and machine address */
 int
@@ -1053,6 +1075,8 @@
   return (pat-not ^ (h-env-x_label  regexec (pat-rx, h-env-x_label, 0, 
NULL, 0) == 0));
 case M_DUPLICATED:
   return (pat-not ^ (h-thread  h-thread-duplicate_thread));
+case M_THREADCOMPLETE:
+  return ((h-thread  match_threadcomplete(pat-not,h-thread,1,1,1,1)));
   }
   mutt_error (_(error: unknown op %d (report this error).), pat-op);
   return (-1);



Re: patches (colored questions, conditional tag-prefix)

2001-12-03 Thread christophe barbé

On Sat, Nov 17, 2001 at 01:06:14PM +0100, Nicolas Rachinsky wrote:
 On Fri, Nov 16, 2001 at 05:07:59PM +0100, Nicolas Rachinsky [EMAIL PROTECTED] 
wrote:
  The second one adds a new command tag-prefix-cond. It should behave
  exactly the same as tag-prefix, with one difference. If there are no
  tagged messages, it will empty the ungetch-buffer, this seems to
  reliably stop/abort every macro. It's a hack, but it seems to work.
 
 I should add, this works also for push commands (and it seems to work
 for exec). I use the following in my .muttrc:
 folder-hook regex for all mailing list folders push 
\tag-pattern~d2w\nuntag-pattern~F|~D\ntag-prefix-condsave-message\n\n\

I've missed it the first time I read this mail but where comes from
'tag-prefix-cond' ?

It looks like this command doesn't exist in my version and neither in
cvs. Without it (using tag-prefix) when no mail are tagged (no old mail), 
the current one is saved.

# mutt -v
Mutt 1.3.24i (2001-11-29)
...
patch-1.3.23.2.rr.compressed.1
patch-1.3.15.sw.pgp-outlook.1
patch-1.3.23.Md.gnutls.1
Md.use-editor
Md.paths-mutt.man
Md.use-etc-mailname
Md.Muttrc
Md.muttbug-warning
patch-1.2.xtitles.1
patch-1.3.23.1.ametzler.pgp_good_sign

Christophe

 
 It moves all messages older than 2 weeks except flagged ones to an
 archive folder (I have other folder-hooks to set appropriate
 save-hooks).
 
 Nicolas
-- 
Christophe Barbé [EMAIL PROTECTED]
GnuPG FingerPrint: E0F6 FADF 2A5C F072 6AF8  F67A 8F45 2F1E D72C B41E



msg20978/pgp0.pgp
Description: PGP signature


Re: patches (colored questions, conditional tag-prefix)

2001-12-03 Thread Nicolas Rachinsky

On Mon, Dec 03, 2001 at 05:52:41PM +0100, christophe barbé 
[EMAIL PROTECTED] wrote:
 I've missed it the first time I read this mail but where comes from
 'tag-prefix-cond' ?

It comes from a patch I've written, you find it under
www.rachinsky.de.

Nicolas



Re: patches (colored questions, conditional tag-prefix)

2001-12-02 Thread christophe barbé


On Fri, Nov 30, 2001 at 12:12:33AM +0530, Prahlad Vaidyanathan wrote:
 Hi,
 
 On Wed, 28 Nov 2001 christophe [EMAIL PROTECTED] spewed into the ether:
 [-- snip --]
   Any solutions ?
  
  Implement a tag-thread-pattern.
  That's what I intent to do as soon I find time for it.
 
 Do post your results.
 
  Please Prahlad, upload your gpg key.
 
 http://www.symonds.net/~prahladv/files/pgpkey.asc
 
 Key fingerprint = 6537 4A5F E875 71AD 10B3  9D87 20A8 6339 2125 BB86

I was thinking about uploading your gpg sig on one of the gpg server.
They are sharing their content so if you upload your sig on
wwwkeys.nl.pgp.net after a few hours I will be able to download it on
pgp.mit.edu automatically.

I have the followwing line in my .gnupg/options file :
keyserver pgp.mit.edu 

Christophe

 
 pv.
 
 -- 
 Prahlad Vaidyanathan [EMAIL PROTECTED]What, me worry ?
 http://www.symonds.net/~prahladv/Don't Panic !
 --


-- 
Christophe Barbé [EMAIL PROTECTED]
GnuPG FingerPrint: E0F6 FADF 2A5C F072 6AF8  F67A 8F45 2F1E D72C B41E



msg20933/pgp0.pgp
Description: PGP signature


Re: patches (colored questions, conditional tag-prefix)

2001-11-29 Thread Prahlad Vaidyanathan

Hi,

On Wed, 28 Nov 2001 christophe [EMAIL PROTECTED] spewed into the ether:
[-- snip --]
  Any solutions ?
 
 Implement a tag-thread-pattern.
 That's what I intent to do as soon I find time for it.

Do post your results.

 Please Prahlad, upload your gpg key.

http://www.symonds.net/~prahladv/files/pgpkey.asc

Key fingerprint = 6537 4A5F E875 71AD 10B3  9D87 20A8 6339 2125 BB86

pv.

-- 
Prahlad Vaidyanathan [EMAIL PROTECTED]What, me worry ?
http://www.symonds.net/~prahladv/Don't Panic !
--



msg20813/pgp0.pgp
Description: PGP signature


Re: patches (colored questions, conditional tag-prefix)

2001-11-27 Thread Prahlad Vaidyanathan

Hi,

I saw this thread just today - must've overlooked it the first time it
came around. The reason I'm bringing it up again is that the problem at
hand has not been solved.

On Sat, 17 Nov 2001 christophe [EMAIL PROTECTED] spewed
into the ether: 
[-- snip --]
  I should add, this works also for push commands (and it seems to
  work for exec). I use the following in my .muttrc: folder-hook
  regex for all mailing list folders push
  \tag-pattern~d2w\nuntag-pattern~F|~D\ntag-prefix-condsave-message\n\n\
  
  It moves all messages older than 2 weeks except flagged ones to an
  archive folder (I have other folder-hooks to set appropriate
  save-hooks).
 
 This is nearly what I would like to do except that I would like to
 keep thread together.  ie I would like to move thread with all mails
 older than X days, read and not flagged.

I want to setup a macro that does this :

1. Tag all messages older than, say, 2 weeks
2. Tag entire threads of those messages, even if some messages in that
   thread are newer than 2 weeks.
3. Delete/Save tagged messages.

1, and 3 seem possible, but 2 does not. So far I've been doing it
manually, but as I subscribe to more and more lists it becomes
increasingly tedious.

Any solutions ?

pv.

PS: Sorry for raking up _old_ threads, but I just desperately need this
one to work !

-- 
Prahlad Vaidyanathan [EMAIL PROTECTED]What, me worry ?
http://www.symonds.net/~prahladv/Don't Panic !
--



msg20737/pgp0.pgp
Description: PGP signature


Re: patches (colored questions, conditional tag-prefix)

2001-11-17 Thread Nicolas Rachinsky

On Fri, Nov 16, 2001 at 05:07:59PM +0100, Nicolas Rachinsky [EMAIL PROTECTED] wrote:
 The second one adds a new command tag-prefix-cond. It should behave
 exactly the same as tag-prefix, with one difference. If there are no
 tagged messages, it will empty the ungetch-buffer, this seems to
 reliably stop/abort every macro. It's a hack, but it seems to work.

I should add, this works also for push commands (and it seems to work
for exec). I use the following in my .muttrc:
folder-hook regex for all mailing list folders push 
\tag-pattern~d2w\nuntag-pattern~F|~D\ntag-prefix-condsave-message\n\n\

It moves all messages older than 2 weeks except flagged ones to an
archive folder (I have other folder-hooks to set appropriate
save-hooks).

Nicolas



Re: patches (colored questions, conditional tag-prefix)

2001-11-17 Thread christophe barbé


On Sat, Nov 17, 2001 at 01:06:14PM +0100, Nicolas Rachinsky wrote:
 On Fri, Nov 16, 2001 at 05:07:59PM +0100, Nicolas Rachinsky [EMAIL PROTECTED] 
wrote:
  The second one adds a new command tag-prefix-cond. It should behave
  exactly the same as tag-prefix, with one difference. If there are no
  tagged messages, it will empty the ungetch-buffer, this seems to
  reliably stop/abort every macro. It's a hack, but it seems to work.
 
 I should add, this works also for push commands (and it seems to work
 for exec). I use the following in my .muttrc:
 folder-hook regex for all mailing list folders push 
\tag-pattern~d2w\nuntag-pattern~F|~D\ntag-prefix-condsave-message\n\n\
 
 It moves all messages older than 2 weeks except flagged ones to an
 archive folder (I have other folder-hooks to set appropriate
 save-hooks).

This is nearly what I would like to do except that I would like to keep
thread together. 
ie I would like to move thread with all mails older than X days, read and not flagged.

Do you see a way to do that ?

Christophe 

 
 Nicolas
-- 
Christophe Barbé [EMAIL PROTECTED]
GnuPG FingerPrint: E0F6 FADF 2A5C F072 6AF8  F67A 8F45 2F1E D72C B41E



msg20538/pgp0.pgp
Description: PGP signature


patches (colored questions, conditional tag-prefix)

2001-11-16 Thread Nicolas Rachinsky

Hallo,

Does anybody know if there are any patches to color mutt's questions
and to make tag-prefix conditional, i.e. doing nothing if there are
no tagged messages?

I should have asked first, but after not finding such patches, I tried
to write them.

They seem to work, but I don't know if they are really usable.

The first one let's you color questions, for example: 
color question brightwhite default
It contains no docu, and looks strange when you don't use the same
background as with normal. It also looks strange, for example when
you change mailboxes, the mailboxname changes its color when changing
this name. But if there is anybody interessted, I would try to solve
these and add some docu (and an entry to the patches list).

The second one adds a new command tag-prefix-cond. It should behave
exactly the same as tag-prefix, with one difference. If there are no
tagged messages, it will empty the ungetch-buffer, this seems to
reliably stop/abort every macro. It's a hack, but it seems to work.

Any comments appreciated.

The patches were created from the freebsd mutt-devel port 1.3.23.2

If you call me clueless after looking at the patches, you are right :-)

WARNING: 
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Nicolas


--- color.c.ori Tue Nov 13 22:19:54 2001
+++ color.c Tue Nov 13 22:20:31 2001
@@ -78,6 +78,7 @@
   { status,  MT_COLOR_STATUS },
   { tree,MT_COLOR_TREE },
   { error,   MT_COLOR_ERROR },
+  { question,MT_COLOR_QUESTION },
   { normal,  MT_COLOR_NORMAL },
   { tilde,   MT_COLOR_TILDE },
   { markers, MT_COLOR_MARKERS },
--- mutt_curses.h.ori   Tue Nov 13 22:19:12 2001
+++ mutt_curses.h   Tue Nov 13 22:19:44 2001
@@ -119,6 +119,7 @@
   MT_COLOR_BOLD,
   MT_COLOR_UNDERLINE,
   MT_COLOR_INDEX,
+  MT_COLOR_QUESTION,
   MT_COLOR_MAX
 };
 
--- curs_lib.c.ori  Thu Nov 15 21:58:00 2001
+++ curs_lib.c  Thu Nov 15 22:18:18 2001
@@ -105,7 +105,9 @@
   do
   {
 CLEARLINE (LINES-1);
+SETCOLOR(MT_COLOR_QUESTION);
 addstr (field);
+SETCOLOR(MT_COLOR_NORMAL);
 mutt_refresh ();
 getyx (stdscr, y, x);
 ret = _mutt_enter_string (buf, buflen, y, x, complete, multiple, files, numfiles, 
es);
@@ -170,7 +172,9 @@
 #endif
 
   CLEARLINE(LINES-1);
+  SETCOLOR(MT_COLOR_QUESTION);
   printw (%s ([%s]/%s): , msg, def ? yes : no, def ? no : yes);
+  SETCOLOR(MT_COLOR_NORMAL);
   FOREVER
   {
 mutt_refresh ();
@@ -396,10 +400,12 @@
 {
   event_t ch;
 
+  SETCOLOR(MT_COLOR_QUESTION);
   mvaddstr (LINES-1, 0, (char *) prompt);
   addstr (_( ('?' for list): ));
   if (buf[0])
 addstr (buf);
+  SETCOLOR(MT_COLOR_NORMAL);
   clrtoeol ();
   mutt_refresh ();
 
@@ -481,7 +487,9 @@
   char *p, *nletters;
 
   nletters = _(letters);
+  SETCOLOR (MT_COLOR_QUESTION);
   mvaddstr (LINES - 1, 0, prompt);
+  SETCOLOR (MT_COLOR_NORMAL);
   clrtoeol ();
   FOREVER
   {


--- OPS.origFri Nov 16 00:02:23 2001
+++ OPS Fri Nov 16 00:00:47 2001
@@ -153,6 +153,7 @@
 OP_SORT_REVERSE sort messages in reverse order
 OP_TAG tag the current entry
 OP_TAG_PREFIX apply next function to tagged messages
+OP_TAG_PREFIX_COND apply next function ONLY to tagged messages
 OP_TAG_SUBTHREAD tag the current subthread
 OP_TAG_THREAD tag the current thread
 OP_TOGGLE_NEW toggle a message's 'new' flag
--- curs_lib.c.orig Thu Nov 15 23:56:51 2001
+++ curs_lib.c  Thu Nov 15 23:57:02 2001
@@ -39,7 +39,7 @@
  * is impossible to unget function keys in SLang, so roll our own input
  * buffering routines.
  */
-static size_t UngetCount = 0;
+size_t UngetCount = 0;
 static size_t UngetBufLen = 0;
 static event_t *KeyEvent;
 
--- curs_main.c.origThu Nov 15 23:53:57 2001
+++ curs_main.c Thu Nov 15 23:58:31 2001
@@ -43,7 +43,7 @@
 
 
 
-
+extern size_t UngetCount;
 
 
 
@@ -620,6 +620,36 @@
   }
   else if (option (OPTAUTOTAG)  Context  Context-tagged)
tag = 1;
+
+  if (op == OP_TAG_PREFIX_COND)
+  {
+   if (!Context)
+   {
+ mutt_error _(No mailbox is open.);
+ continue;
+   }
+
+   if (!Context-tagged)
+   {
+ while(UngetCount0)
+   mutt_getch();
+ mutt_error _(No tagged messages.);
+ continue;
+   }
+   tag = 1;
+
+   /* give visual indication that the next command is a tag- command 

Re: patches (colored questions, conditional tag-prefix)

2001-11-16 Thread David T-G

Nicolas --

...and then Nicolas Rachinsky said...
% Hallo,

Hello!


% 
% Does anybody know if there are any patches to color mutt's questions
% and to make tag-prefix conditional, i.e. doing nothing if there are
% no tagged messages?

Nope; I haven't seen either one, and I know that a distinct need for the
latter exists (a way to acheive such a thing has been much discussed and
it was figured that we'd need to wait for an internal scripting language;
such a simple idea never came up!).

I don't use color, so I don't have much use for the first one, but I'll
try to compile both with my patch cocktail and then try write some macros
which would need the second so that I can test :-)


Thanks a bunch!

:-D
-- 
David T-G  * It's easier to fight for one's principles
(play) [EMAIL PROTECTED] * than to live up to them. -- fortune cookie
(work) [EMAIL PROTECTED]
http://www.justpickone.org/davidtg/Shpx gur Pbzzhavpngvbaf Qrprapl Npg!




msg20506/pgp0.pgp
Description: PGP signature