[comp.mail.elm] "pointnew" option ignored with non-standard sorting order

solomon@speedy.cs.wisc.edu (Marvin Solomon) (05/08/88)

I set discovered the "pointnew" option in my .elmrc with the following
comment:
	# start up by pointing to the first new message received, if possible
	pointnew = OFF
I figured that's just what I wanted, but was dismayed to find that changing
it to "ON" made no difference!  Upon searching the code, I discovered that
this option is silently ignored if your sorting order is anything other
than RECEIVED_DATE.  I see no good reason for this restriction other than
that the algorithm for implementing the option only works for RECEIVED_DATE
order:  While reading in the mailbox, the code sets "current" to the first
message with a "new" status.  The following patch, while not exactly
elegant, makes "pointnew" work for any sorting order.  After the mailbox
is sorted, I make an extra pass, looking for the first new message.

Insert this code near the end of newmbox.c, between the call
	sort_mailbox(count, 1);
and the statement
	return(count);
at the end of read_headers().

	/* solomon@cs.wisc.edu 8 May 1988:  For funky sorting modes, if
	 * option "pointnew" is selected, we have to find the new message
	 * that is first in SORTED order
	 */
	if (point_to_new && !rereading &&
	    sortby != RECEIVED_DATE) {
	  int i;

	  for (i=0; i<count; i++) {
	    if (header_table[i].status & NEW) {
	      current = i+1;
	      get_page(current);	/* make sure we're ON that page! */
	      break;
	    }
	  }
	}
	Marvin Solomon
	Computer Sciences Department
	University of Wisconsin, Madison WI
	solomon@cs.wisc.edu or seismo!uwvax!solomon