Holmberg <markush@acc.umu.se>.
}
break;
+ case 'e':
+ snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
+ snprintf (dest, destlen, fmt, mutt_msgno_in_thread(hdr) + 1);
+ break;
+
+ case 'E':
+ snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
+ snprintf (dest, destlen, fmt, mutt_messages_in_thread(hdr));
+ break;
+
case 'f':
buf2[0] = 0;
rfc822_write_address (buf2, sizeof (buf2), hdr->env->from);
** %D date and time of the message in the format
** . specified by ``date_format'' converted to
** . the local time zone
+ ** %e current message number in thread
+ ** %E number of messages in current thread
** %f entire From: line (address + real name)
** %F author name, or recipient name if the
** . message is from you
int mutt_is_subscribed_list (ADDRESS *);
int mutt_is_text_type (int, char *);
int mutt_is_valid_mailbox (const char *);
+int mutt_messages_in_thread (HEADER *);
+int mutt_msgno_in_thread (HEADER *);
int mutt_multi_choice (char *prompt, char *letters);
int mutt_needs_mailcap (BODY *);
int mutt_num_postponed (int);
#undef CHECK_LIMIT
}
+int mutt_messages_in_thread (HEADER *cur)
+{
+ HEADER *top;
+ int n = 1;
+
+ if ((Sort & SORT_MASK) != SORT_THREADS)
+ {
+ mutt_error _("Threading is not enabled.");
+ return (-1);
+ }
+
+ /* find top parent */
+ while (cur->parent)
+ cur = cur->parent;
+ top = cur;
+
+ /* return if there are no children at all */
+ if ((cur = cur->child) == NULL)
+ return n;
+
+ FOREVER
+ {
+ n++;
+ if (cur->child)
+ cur = cur->child;
+ else if (cur->next)
+ cur = cur->next;
+ else
+ {
+ while (!cur->next)
+ {
+ cur = cur->parent;
+ if (cur == top)
+ return n;
+ }
+ cur = cur->next;
+ }
+ }
+ /* not reached */
+}
+
+int mutt_msgno_in_thread (HEADER *cur)
+{
+ HEADER *top;
+ HEADER *target;
+ int n = 0;
+
+ if ((Sort & SORT_MASK) != SORT_THREADS)
+ {
+ mutt_error _("Threading is not enabled.");
+ return (-1);
+ }
+
+ /* save target */
+ target = cur;
+
+ /* find top parent */
+ while (cur->parent)
+ cur = cur->parent;
+ top = cur;
+
+ /* return if single message */
+ if (top == target)
+ return n;
+
+ /* return if there are no children at all */
+ if ((cur = cur->child) == NULL)
+ return n;
+
+ FOREVER
+ {
+ n++;
+ if (cur == target)
+ return n;
+ if (cur->child)
+ cur = cur->child;
+ else if (cur->next)
+ cur = cur->next;
+ else
+ {
+ while (!cur->next)
+ {
+ cur = cur->parent;
+ if (cur == top)
+ {
+ mutt_error _("Target message not found while counting messages in thread.");
+ return (-1);
+ }
+ }
+ cur = cur->next;
+ }
+ }
+ /* not reached */
+}