diff -u clean/mutt-1.5.16/curs_main.c mutt-1.5.16/curs_main.c --- clean/mutt-1.5.16/curs_main.c 2007-05-20 09:30:00.000000000 +0200 +++ mutt-1.5.16/curs_main.c 2007-09-21 20:34:05.000000000 +0200 @@ -112,6 +112,8 @@ extern size_t UngetCount; +int was_delete=0; //ugly hack - dont automatically move to new message(another ugly hack) after any delete + void index_make_entry (char *s, size_t l, MUTTMENU *menu, int num) { format_flag flag = M_FORMAT_MAKEPRINT | M_FORMAT_ARROWCURSOR | M_FORMAT_INDEX; @@ -318,10 +320,71 @@ for (j = oldcount; j < ctx->msgcount; j++) save_new[j-oldcount] = ctx->hdrs[j]; } - - /* if the mailbox was reopened, need to rethread from scratch */ - mutt_sort_headers (ctx, (check == M_REOPENED)); + /* ulozime to znova; save_new list nepouzivam, protoze je vyvaren i rusen za v tenhle moment ne uplne jasnych podminek */ + HEADER **save_new2 = NULL; + if ( ((Sort & SORT_MASK) == SORT_THREADS) ) + { + save_new2 = (HEADER **) safe_malloc (sizeof (HEADER *) * (ctx->msgcount - oldcount)); + for (j = oldcount; j < ctx->msgcount; j++) + save_new2[j-oldcount] = ctx->hdrs[j]; + } + + + /* if the mailbox was reopened, need to rethread from scratch */ + mutt_sort_headers (ctx, (check == M_REOPENED)); + + + /* Otaguj smazanim ty zpravy, ktere patri k mazanym threadum. */ + for (j = oldcount; j msgcount; j++) + { + HEADER *h = save_new2[j-oldcount]; + THREAD *start, *cur = h->thread; + int pd=0; + + + while (cur->parent) cur = cur->parent; //prohledani celeho threadu prevzato z flags.c:298 + start = cur; + + if (cur->message) pd|=cur->message->persistent_delete; + + if ((cur = cur->child) != NULL) + FOREVER + { + if (cur->message) pd|=cur->message->persistent_delete; + + if (cur->child) + cur = cur->child; + else if (cur->next) + cur = cur->next; + else + { + while (!cur->next) + { + cur = cur->parent; + if (cur == start) + goto AFTER_FOREVER; + } + cur = cur->next; + } + } //FOREVER + + AFTER_FOREVER : ; + /* puvodni nedokonala verze hledani persistent flagu + // if (cur->prev && cur->prev->message) pd|=cur->prev->message->persistent_delete; tohle by mazalo nove zpravy na urovni threadu, pokud predtim thread smazan... + + while (cur->parent && cur->parent->message) //tohle by v patologickych pripadech promazaneho threadu nemuselo zafungovat + { + cur = cur->parent; + pd|=cur->message->persistent_delete; + }*/ + + + if (pd) + mutt_thread_set_flag (h, M_DELETE, 1, 0); + } + FREE (&save_new2); + /* uncollapse threads with new mail */ if ((Sort & SORT_MASK) == SORT_THREADS) { @@ -357,20 +420,27 @@ } } + int best_new=-1; menu->current = -1; if (oldcount) { /* restore the current message to the message it was pointing to */ for (j = 0; j < ctx->vcount; j++) { + //if ((UNREAD (ctx->hdrs[ctx->v2r[j]])) && !(ctx->hdrs[ctx->v2r[j]])->deleted) { //najdi prvni nesmazany neprecteny od zacatkua + if (!was_delete && (!(ctx->hdrs[ctx->v2r[j]])->read) && !(ctx->hdrs[ctx->v2r[j]])->deleted) { //najdi prvni nesmazany neprecteny od zacatkua + best_new=j; + break; + } + if (ctx->hdrs[ctx->v2r[j]]->index == menu->oldcurrent) { menu->current = j; - break; +// break; } } } - + if (best_new!=-1) menu->current=best_new; // a skoc na nej if (menu->current < 0) menu->current = ci_first_message (); @@ -449,6 +519,7 @@ FOREVER { + was_delete>0 && was_delete--; //delete nas sem hodi pomoci continue, dalsi iterace uz s tim nemaji nic spolecneho tag = 0; /* clear the tag-prefix */ menu->max = Context ? Context->vcount : 0; @@ -1800,6 +1871,7 @@ break; case OP_DELETE: + was_delete=2; CHECK_MSGCOUNT; CHECK_VISIBLE; @@ -1841,6 +1913,7 @@ case OP_DELETE_THREAD: case OP_DELETE_SUBTHREAD: + was_delete=2; CHECK_MSGCOUNT; CHECK_VISIBLE; diff -u clean/mutt-1.5.16/flags.c mutt-1.5.16/flags.c --- clean/mutt-1.5.16/flags.c 2007-04-13 03:02:02.000000000 +0200 +++ mutt-1.5.16/flags.c 2007-09-19 19:48:15.000000000 +0200 @@ -292,8 +292,21 @@ cur = cur->parent; start = cur; +/* + if (!subthread) //bude platit jen u celych threadu, o subthready se nestarame + if (flag==M_DELETE) //vyvolano jako CTR+D + { + THREAD *c = hdr->thread; + while (c->parent && c->parent->message) c=c->parent; + + if (c->message) c->message->persistent_delete=bf; //flag ulozime u vrchni zpravy threadu // tohle bohuzel nefunguje, pokud je thread promazany, tak se k prvni nedostanes + if (c->message) c->message->replied=1; //ladeni + } +*/ + + if (cur->message) - mutt_set_flag (Context, cur->message, flag, bf); + mutt_set_flag (Context, cur->message, flag, bf), !subthread&&flag==M_DELETE&&(cur->message->persistent_delete=bf); if ((cur = cur->child) == NULL) return (0); @@ -301,7 +314,7 @@ FOREVER { if (cur->message) - mutt_set_flag (Context, cur->message, flag, bf); + mutt_set_flag (Context, cur->message, flag, bf), !subthread&&flag==M_DELETE&&(cur->message->persistent_delete=bf); if (cur->child) cur = cur->child; diff -u clean/mutt-1.5.16/mutt.h mutt-1.5.16/mutt.h --- clean/mutt-1.5.16/mutt.h 2007-04-11 05:14:01.000000000 +0200 +++ mutt-1.5.16/mutt.h 2007-09-19 19:48:15.000000000 +0200 @@ -728,6 +728,7 @@ * This flag is used by the maildir_trash * option. */ + unsigned int persistent_delete : 1; /* persistently delete thread, with this mail on the top*/ /* timezone of the sender of this message */ unsigned int zhours : 5; diff -u clean/mutt-1.5.16/pager.c mutt-1.5.16/pager.c --- clean/mutt-1.5.16/pager.c 2007-04-16 01:56:26.000000000 +0200 +++ mutt-1.5.16/pager.c 2007-09-22 01:36:42.000000000 +0200 @@ -62,6 +62,8 @@ static int TopLine = 0; static HEADER *OldHdr = NULL; +extern int was_delete; + #define CHECK_MODE(x) if (!(x)) \ { \ mutt_flushinp (); \ @@ -1582,6 +1584,7 @@ while (ch != -1) { + was_delete=2; //dont use this when in pager mutt_curs_set (0); #ifdef USE_IMAP @@ -2299,6 +2302,35 @@ } break; + case OP_MAIN_READ_THREAD: + case OP_MAIN_READ_SUBTHREAD: + //CHECK_MSGCOUNT //these are in OP_MAIN_READ_THREAD in curs_main.c + //CHECK_VISIBLE //should it be here ? + CHECK_MODE(IsHeader (extra)); + CHECK_READONLY; + +#ifdef USE_IMAP +//CHECK_IMAP_ACL(IMAP_ACL_DELETE); //should be here ACL_SEEN ? +#endif + + r = mutt_thread_set_flag (extra->hdr, M_READ, 1, + ch == OP_MAIN_READ_THREAD ? 0 : 1); + + if (r != -1) + { + if (option (OPTRESOLVE)) + { + rc = ( ch == OP_MAIN_READ_THREAD ? OP_MAIN_NEXT_THREAD : OP_MAIN_NEXT_SUBTHREAD ); + ch = -1; + } + + if (!option (OPTRESOLVE) && PagerIndexLines) + redraw = REDRAW_FULL; + else + redraw = REDRAW_STATUS | REDRAW_INDEX; + } + break; + case OP_DISPLAY_ADDRESS: CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra)); if (IsMsgAttach (extra))