Add command to limit view on the thread from any of its message.
Predefined on command <ESC>L, though the lowercase 'l' would be better
(less keystrokes), but it's already occupied by a not-so-useful command
"show limit".
Tested on large folders, no performance problems observed.
Search in current thread is not implemented.
Signed-off-by: David Sterba <dsterba@suse.cz>
OP_VIEW_ATTACH "view attachment using mailcap entry if necessary"
OP_VIEW_ATTACHMENTS "show MIME attachments"
OP_WHAT_KEY "display the keycode for a key press"
+OP_LIMIT_CURRENT_THREAD "limit view to current thread"
OP_MAIN_SHOW_LIMIT "show currently active limit pattern"
OP_MAIN_COLLAPSE_THREAD "collapse/uncollapse current thread"
OP_MAIN_COLLAPSE_ALL "collapse/uncollapse all threads"
}
break;
+ case OP_LIMIT_CURRENT_THREAD:
case OP_MAIN_LIMIT:
CHECK_IN_MAILBOX;
menu->oldcurrent = (Context->vcount && menu->current >= 0 && menu->current < Context->vcount) ?
CURHDR->index : -1;
- if (mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
+ if ((op == OP_LIMIT_CURRENT_THREAD && mutt_limit_current_thread(CURHDR))
+ || (op == OP_MAIN_LIMIT && mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0))
{
if (menu->oldcurrent >= 0)
{
{ "next-undeleted", OP_MAIN_NEXT_UNDELETED, "j" },
{ "previous-undeleted", OP_MAIN_PREV_UNDELETED, "k" },
{ "limit", OP_MAIN_LIMIT, "l" },
+ { "limit-current-thread", OP_LIMIT_CURRENT_THREAD, "\033L" },
{ "link-threads", OP_MAIN_LINK_THREADS, "&" },
{ "list-reply", OP_LIST_REPLY, "L" },
{ "mail", OP_MAIL, "m" },
void index_make_entry (char *, size_t, struct menu_t *, int);
int index_color (int);
+int mutt_limit_current_thread (HEADER *h);
+
#endif /* _MUTT_MENU_H_ */
}
}
+static THREAD* top_of_thread(HEADER *h)
+{
+ THREAD *t = h->thread;
+
+ while (t && t->parent) t = t->parent;
+ return t;
+}
+
+int mutt_limit_current_thread (HEADER *h)
+{
+ int i;
+ THREAD *me;
+
+ me = top_of_thread(h);
+
+ if (!me) {
+ /* NOP */
+ return 0;
+ }
+
+ Context->vcount = 0;
+ Context->vsize = 0;
+ Context->collapsed = 0;
+
+ for (i = 0; i < Context->msgcount; i++)
+ {
+ Context->hdrs[i]->virtual = -1;
+ Context->hdrs[i]->limited = 0;
+ Context->hdrs[i]->collapsed = 0;
+ Context->hdrs[i]->num_hidden = 0;
+ if (top_of_thread(Context->hdrs[i]) == me)
+ {
+ BODY *body = Context->hdrs[i]->content;
+
+ Context->hdrs[i]->virtual = Context->vcount;
+ Context->hdrs[i]->limited = 1;
+ Context->v2r[Context->vcount] = i;
+ Context->vcount++;
+ Context->vsize += body->length + body->offset -
+ body->hdr_offset;
+ }
+ }
+ return 1;
+}
+
int mutt_pattern_func (int op, char *prompt)
{
pattern_t *pat;