[comp.mail.elm] Elm Patch 5 of 8

taylor@hpldat.UUCP (Dave Taylor) (05/03/87)

This is Elm Patch Kit #5 of 8 and contains patches for:

  src/mailmsg2.c    src/savecopy.c   src/mailmsg1.c   src/connect_to.c
  src/remail.c      src/signals.c    src/edit.c       src/sort.c
  src/showmsg_cmd.c src/options.c

Please feed this directly to 'patch'.

Index: src/mailmsg2.c

***************
*** 58,61
  
! 	dprint2(4,"\nMailing to '%s'(with%s editing)\n",
! 		  expanded_to, edit_message? "" : "out");
  	

--- 58,61 -----
  
! 	dprint(4, (debugfile, "\nMailing to '%s'(with%s editing)\n",
! 		  expanded_to, edit_message? "" : "out"));
  	
***************
*** 75,77
  	  if ((reply = fopen(filename,"w")) == NULL) {
! 	    dprint2(1,
                 "Attempt to write to temp file %s failed with error %s (mail)\n",

--- 75,77 -----
  	  if ((reply = fopen(filename,"w")) == NULL) {
! 	    dprint(1, (debugfile, 
                 "Attempt to write to temp file %s failed with error %s (mail)\n",
***************
*** 77,79
                 "Attempt to write to temp file %s failed with error %s (mail)\n",
! 		 filename, error_name(errno));
  	    error2("Could not create file %s (%s)",filename,

--- 77,79 -----
                 "Attempt to write to temp file %s failed with error %s (mail)\n",
! 		 filename, error_name(errno)));
  	    error2("Could not create file %s (%s)",filename,
***************
*** 109,112
  	  unlink(filename);
! 	  dprint2(4, "-- linking existing file %s to file %s --\n",
! 		  fname, filename);
  	  link(fname, filename);

--- 109,112 -----
  	  unlink(filename);
! 	  dprint(4, (debugfile, "-- linking existing file %s to file %s --\n",
! 		  fname, filename));
  	  link(fname, filename);
***************
*** 181,183
  	  if ((reply = fopen(filename,"r")) == NULL) {
! 	      dprint2(1,
  	    "Attempt to open file %s for reading failed with error %s (mail)\n",

--- 181,183 -----
  	  if ((reply = fopen(filename,"r")) == NULL) {
! 	      dprint(1, (debugfile,
  	    "Attempt to open file %s for reading failed with error %s (mail)\n",
***************
*** 183,185
  	    "Attempt to open file %s for reading failed with error %s (mail)\n",
!                 filename, error_name(errno));
  	      error1("Could not open reply file (%s)", error_name(errno));

--- 183,185 -----
  	    "Attempt to open file %s for reading failed with error %s (mail)\n",
!                 filename, error_name(errno)));
  	      error1("Could not open reply file (%s)", error_name(errno));
***************
*** 189,191
  	else if ((reply = fopen(filename,"r")) == NULL) {
! 	  dprint2(1,
  	    "Attempt to open file %s for reading failed with error %s (mail)\n",

--- 189,191 -----
  	else if ((reply = fopen(filename,"r")) == NULL) {
! 	  dprint(1, (debugfile, 
  	    "Attempt to open file %s for reading failed with error %s (mail)\n",
***************
*** 191,193
  	    "Attempt to open file %s for reading failed with error %s (mail)\n",
!              filename, error_name(errno));
  	  error1("Could not open reply file (%s)", error_name(errno));

--- 191,193 -----
  	    "Attempt to open file %s for reading failed with error %s (mail)\n",
!              filename, error_name(errno)));
  	  error1("Could not open reply file (%s)", error_name(errno));
***************
*** 217,220
  
! 	dprint2(6, "Composition file='%s' and mail buffer='%s'\n", 
! 		    filename, filename2);
  

--- 217,220 -----
  
! 	dprint(6, (debugfile, "Composition file='%s' and mail buffer='%s'\n", 
! 		    filename, filename2));
  
***************
*** 228,230
  
! 	  dprint1(3,"** write_header failed: %s\n", error_name(errno));
  

--- 228,231 -----
  
! 	  dprint(3, (debugfile, "** write_header failed: %s\n", 
! 		 error_name(errno)));
  
***************
*** 371,373
  	      if ((deadfd = fopen(fname,"a")) == NULL) {
! 		dprint2(1,
  		   "\nAttempt to append to deadletter file '%s' failed: %s\n\r",

--- 372,374 -----
  	      if ((deadfd = fopen(fname,"a")) == NULL) {
! 		dprint(1, (debugfile,
  		   "\nAttempt to append to deadletter file '%s' failed: %s\n\r",
***************
*** 373,375
  		   "\nAttempt to append to deadletter file '%s' failed: %s\n\r",
! 		    fname, error_name(errno));
  	        printf("Message not saved, Sorry.\n\r\n\r");

--- 374,376 -----
  		   "\nAttempt to append to deadletter file '%s' failed: %s\n\r",
! 		    fname, error_name(errno)));
  	        printf("Message not saved, Sorry.\n\r\n\r");
***************
*** 378,381
  	      else if ((messagefd = fopen(filename, "r")) == NULL) {
! 		dprint2(1,"\nAttempt to read reply file '%s' failed: %s\n\r",
! 			filename, error_name(errno));
  	        printf("Message not saved, Sorry.\n\r\n\r");

--- 379,383 -----
  	      else if ((messagefd = fopen(filename, "r")) == NULL) {
! 		dprint(1, (debugfile,
! 			"\nAttempt to read reply file '%s' failed: %s\n\r",
! 			filename, error_name(errno)));
  	        printf("Message not saved, Sorry.\n\r\n\r");
***************
*** 522,524
  	if ((filedesc = fopen(filename, "w")) == NULL) {
! 	  dprint1(1,
  	    "Attempt to open file %s for writing failed! (write_header_info)\n",

--- 524,526 -----
  	if ((filedesc = fopen(filename, "w")) == NULL) {
! 	  dprint(1, (debugfile,
  	    "Attempt to open file %s for writing failed! (write_header_info)\n",
***************
*** 524,528
  	    "Attempt to open file %s for writing failed! (write_header_info)\n",
! 	     filename);
! 	  dprint2(1,"** %s - %s **\n\n", error_name(errno),
! 		 error_description(errno));
  	  error2("Error %s encountered trying to write to %s", 

--- 526,530 -----
  	    "Attempt to open file %s for writing failed! (write_header_info)\n",
! 	     filename));
! 	  dprint(1, (debugfile, "** %s - %s **\n\n", error_name(errno),
! 		 error_description(errno)));
  	  error2("Error %s encountered trying to write to %s", 
***************
*** 539,541
  	  fprintf(filedesc, "%s", buffer);
! 	  dprint1(1,"\nadded: %s", buffer);
  	  /** so is this perverted or what? **/

--- 541,543 -----
  	  fprintf(filedesc, "%s", buffer);
! 	  dprint(1,(debugfile, "\nadded: %s", buffer));
  	  /** so is this perverted or what? **/

Index: src/savecopy.c

***************
*** 20,21
  
  char *format_long(), *get_arpa_date();

--- 20,23 -----
  
+ #define  metachar(c)	(c == '+' || c == '%' || c == '+')
+ 
  char *format_long(), *get_arpa_date();
***************
*** 53,55
  	  if (strlen(buffer) == 0) {
! 	    dprint1(3,"Warning: get_return_name couldn't break down %s\n", to);
  	    savename[0] = '\0';

--- 55,58 -----
  	  if (strlen(buffer) == 0) {
! 	    dprint(3, (debugfile,
! 		   "Warning: get_return_name couldn't break down %s\n", to));
  	    savename[0] = '\0';
***************
*** 66,70
  	if (strlen(savename) == 0) {
! 	  if (strlen(savefile) == 0)
! 	    return(error("variable 'SAVEFILE' not defined!"));
! 	  strcpy(savename, savefile);
  	}

--- 69,80 -----
  	if (strlen(savename) == 0) {
! 	  if (strlen(savefile) == 0) {
! 	    error("variable 'SAVEFILE' not defined!");
! 	    return;
! 	  }
! 	  if (metachar(savefile[0])) {
! 	    sprintf(savename, "%s%s%s", folders,
! 		lastch(folders) == '/' ? "" : "/", savefile+1);
! 	  }
! 	  else
! 	    strcpy(savename, savefile);
  	}
***************
*** 71,77
  
! 	if ((errno = can_access(savename, WRITE_ACCESS))) {
! 	  dprint0(2,"Error: attempt to autosave to a file that can't...\n");
! 	  dprint1(2,"\tbe appended to: %s (save_copy)\n", savename);
! 	  dprint2(2,"** %s - %s **\n", error_name(errno),
! 		  error_description(errno));
  	  error1("permission to append to %s denied!", savename);

--- 81,88 -----
  
! 	if ((errno = can_open(savename, WRITE_ACCESS))) {
! 	  dprint(2, (debugfile,
! "Error: attempt to autosave to a file that can't be appended to!\n"));
! 	  dprint(2, (debugfile, "\tfilename = \"%s\"\n", savename));
! 	  dprint(2, (debugfile, "** %s - %s **\n", error_name(errno),
! 		  error_description(errno)));
  	  error1("permission to append to %s denied!", savename);
***************
*** 82,87
  	if ((save = fopen(savename, "a")) == NULL) {
! 	  dprint2(1,"Error: Couldn't append message to file %s (%s)\n",
! 		  savename, "save_copy");
! 	  dprint2(1,"** %s - %s **\n", error_name(errno),
! 		  error_description(errno));
  	  error1("couldn't append to %s", savename);

--- 93,99 -----
  	if ((save = fopen(savename, "a")) == NULL) {
! 	  dprint(1, (debugfile,
! 		"Error: Couldn't append message to file %s (%s)\n",
! 		savename, "save_copy"));
! 	  dprint(1, (debugfile,"** %s - %s **\n", error_name(errno),
! 		  error_description(errno)));
  	  error1("couldn't append to %s", savename);
***************
*** 93,97
  	  fclose(save);
! 	  dprint1(1,"Error: Couldn't read file %s (save_copy)\n", filename);
! 	  dprint2(1,"** %s - %s **\n", error_name(errno),
! 		  error_description(errno));
  	  error1("couldn't read file %s!", filename);

--- 105,110 -----
  	  fclose(save);
! 	  dprint(1, (debugfile,
! 		 "Error: Couldn't read file %s (save_copy)\n", filename));
! 	  dprint(1, (debugfile, "** %s - %s **\n", error_name(errno),
! 		  error_description(errno)));
  	  error1("couldn't read file %s!", filename);
***************
*** 110,112
  
! 	fprintf(save,"\nFrom To:%s %s", buffer, ctime(&thetime));
  

--- 123,125 -----
  
! 	fprintf(save,"From To:%s %s", buffer, ctime(&thetime));
  
***************
*** 134,136
  	      crypted = 0;
! 	    else if (strncmp(buffer, DONT_SAVE, strlen(DONT_SAVE)) == 0) {
  	      fclose(message);

--- 147,154 -----
  	      crypted = 0;
! 	    else if (strncmp(buffer, DONT_SAVE, strlen(DONT_SAVE)) == 0 ||
! 	             strncmp(buffer, DONT_SAVE2, strlen(DONT_SAVE2)) == 0) {
! 
! 		/* second test added due to an imcompatability between the
! 		   documentation and the software!  (Thanks Bill!) */
! 
  	      fclose(message);
***************
*** 146,148
  	  }
! 	  fputs(buffer, save);
  	}

--- 164,169 -----
  	  }
! 	  if (strncmp(buffer, "From ", 5) == 0)
! 	    fprintf(save, ">%s", buffer);
! 	  else
! 	    fputs(buffer, save);
  	}
***************
*** 148,149
  	}
  

--- 169,172 -----
  	}
+ 
+ 	fprintf(save, "\n");	/* ensure a blank line at the end */
  

Index: src/mailmsg1.c

***************
*** 24,27
  int
! send(given_to, given_subject, edit_message, form_letter)
! char *given_to, *given_subject;
  int   edit_message, form_letter;

--- 24,27 -----
  int
! send(given_to, given_cc, given_subject, edit_message, form_letter)
! char *given_to, *given_cc, *given_subject;
  int   edit_message, form_letter;
***************
*** 46,47
  	strcpy(to, given_to);			/* copy given to:     */
  

--- 46,48 -----
  	strcpy(to, given_to);			/* copy given to:     */
+ 	strcpy(cc, given_cc);			/*  and so on..       */
  
***************
*** 71,73
  
! 	dprint1(3,"\nMailing to %s\n", expanded_to);
    

--- 72,74 -----
  
! 	dprint(3, (debugfile, "\nMailing to %s\n", expanded_to));
    
***************
*** 76,78
  
! 	dprint1(4,"Subject is %s\n", subject);
  

--- 77,79 -----
  
! 	dprint(4, (debugfile, "Subject is %s\n", subject));
  
***************
*** 82,84
  	if (strlen(cc) > 0)
! 	  dprint1(4,"Copies to %s\n", expanded_cc);
  

--- 83,85 -----
  	if (strlen(cc) > 0)
! 	  dprint(4, (debugfile, "Copies to %s\n", expanded_cc));
  
***************
*** 220,223
  	if (strlen(address) + strlen(addressII) > VERY_LONG_STRING) {
! 	  dprint0(2,
! 		"String length of \"To:\" + \"Cc\" too long! (get_copies)\n");
  	  error("Too many people.  Copies ignored");

--- 221,224 -----
  	if (strlen(address) + strlen(addressII) > VERY_LONG_STRING) {
! 	  dprint(2, (debugfile, 
! 		"String length of \"To:\" + \"Cc\" too long! (get_copies)\n"));
  	  error("Too many people.  Copies ignored");

Index: src/connect_to.c

***************
*** 32,34
  	if ((lsysfile = fopen(Lsys,"r")) == NULL) {
! 	  dprint1(1, "Warning: Can't open L.sys file %s (read_lsys)\n", Lsys);
  #endif

--- 32,35 -----
  	if ((lsysfile = fopen(Lsys,"r")) == NULL) {
! 	  dprint(1, (debugfile, 
! 		"Warning: Can't open L.sys file %s (read_lsys)\n", Lsys));
  #endif
***************
*** 49,51
  	  if (previous_record == NULL) {
! 	    dprint1(2, "L.sys\tdirect connection to %s, ", sysname);
  	    loc_on_line = 30 + strlen(sysname);  

--- 50,53 -----
  	  if (previous_record == NULL) {
! 	    dprint(2, (debugfile, 
! 		"L.sys\tdirect connection to %s, ", sysname));
  	    loc_on_line = 30 + strlen(sysname);  
***************
*** 59,61
  	    if (loc_on_line + strlen(sysname) > 80) {
! 	      dprint0(2, "\n\t");
  	      loc_on_line = 8;

--- 61,63 -----
  	    if (loc_on_line + strlen(sysname) > 80) {
! 	      dprint(2, (debugfile, "\n\t"));
  	      loc_on_line = 8;
***************
*** 62,64
  	    }
! 	    dprint1(2, "%s, ", sysname);
  	    loc_on_line += (strlen(sysname) + 2);

--- 64,66 -----
  	    }
! 	    dprint(2, (debugfile, "%s, ", sysname));
  	    loc_on_line += (strlen(sysname) + 2);
***************
*** 76,78
  	if (loc_on_line != 8)
! 	  dprint0(2, "\n");
  

--- 78,80 -----
  	if (loc_on_line != 8)
! 	  dprint(2, (debugfile, "\n"));
  
***************
*** 78,80
  
! 	dprint0(2, "\n");			/* for a nice format! Yeah! */
  #endif

--- 80,82 -----
  
! 	dprint(2, (debugfile, "\n"));	/* for an even nicer format... */
  #endif
***************
*** 99,101
  	if (system_call(buffer, SH) != 0) {
! 	  dprint0(1, "Can't get uuname info - system call failed!\n");
  	  unlink(filename);	/* insurance */

--- 101,103 -----
  	if (system_call(buffer, SH) != 0) {
! 	  dprint(1, (debugfile, "Can't get uuname info - system() failed!\n"));
  	  unlink(filename);	/* insurance */
***************
*** 105,108
  	if ((fd = fopen(filename, "r")) == NULL) {
! 	  dprint1(1, "Can't get uuname info - can't open file %s for reading\n",
! 		   filename);
  	  unlink(filename);	/* insurance */

--- 107,111 -----
  	if ((fd = fopen(filename, "r")) == NULL) {
! 	  dprint(1, (debugfile,
! 		"Can't get uuname info - can't open file %s for reading\n",
! 		 filename));
  	  unlink(filename);	/* insurance */
***************
*** 116,118
  	  if (previous_record == NULL) {
! 	    dprint1(2, "uuname\tdirect connection to %s, ", buffer);
  	    loc_on_line = 30 + strlen(buffer);

--- 119,121 -----
  	  if (previous_record == NULL) {
! 	    dprint(2, (debugfile, "uuname\tdirect connection to %s, ", buffer));
  	    loc_on_line = 30 + strlen(buffer);
***************
*** 126,128
  	    if (loc_on_line + strlen(buffer) > 80) {
! 	      dprint0(2, "\n\t");
  	      loc_on_line = 8;

--- 129,131 -----
  	    if (loc_on_line + strlen(buffer) > 80) {
! 	      dprint(2, (debugfile, "\n\t"));
  	      loc_on_line = 8;
***************
*** 129,131
  	    }
! 	    dprint1(2, "%s, ", buffer);
  	    loc_on_line += (strlen(buffer) + 2);

--- 132,134 -----
  	    }
! 	    dprint(2, (debugfile, "%s, ", buffer));
  	    loc_on_line += (strlen(buffer) + 2);
***************
*** 144,146
  
! 	dprint0(2, "\n");			/* for a nice format! Yeah! */
  

--- 147,149 -----
  
! 	dprint(2, (debugfile, "\n"));		/* for a nice format! Yeah! */
  

Index: src/remail.c

***************
*** 39,43
  	if ((mailfd = fopen(filename, "w")) == NULL) {
! 	  dprint1(1,"couldn't open temp file %s! (remail)\n", filename);
! 	  dprint2(1,"** %s - %s **\n", error_name(errno),
! 		  error_description(errno));
  	  sprintf(buffer, "Sorry - couldn't open file %s for writing (%s)",

--- 39,44 -----
  	if ((mailfd = fopen(filename, "w")) == NULL) {
! 	  dprint(1, (debugfile, "couldn't open temp file %s! (remail)\n", 
! 		  filename));
! 	  dprint(1, (debugfile, "** %s - %s **\n", error_name(errno),
! 		  error_description(errno)));
  	  sprintf(buffer, "Sorry - couldn't open file %s for writing (%s)",
***************
*** 72,74
  
! 	sprintf(buffer, "%s %s < %s", mailer, expanded, filename);
  

--- 73,75 -----
  
! 	sprintf(buffer, "%s %s < %s", mailer, strip_parens(expanded), filename);
  

Index: src/signals.c

***************
*** 16,18
  {
! 	dprint0(2,"\n\n** Received SIGQUIT **\n\n\n\n");
  	leave();

--- 16,18 -----
  {
! 	dprint(2, (debugfile, "\n\n** Received SIGQUIT **\n\n\n\n"));
  	leave();
***************
*** 22,24
  {
! 	dprint0(2,"\n\n** Received SIGTERM **\n\n\n\n");
  	leave();

--- 22,24 -----
  {
! 	dprint(2, (debugfile, "\n\n** Received SIGTERM **\n\n\n\n"));
  	leave();
***************
*** 28,30
  {
! 	dprint0(1,"\n\n** Received SIGILL **\n\n\n\n");
  	PutLine0(LINES, 0, "\n\nIllegal Instruction signal!\n\n");

--- 28,30 -----
  {
! 	dprint(1, (debugfile, "\n\n** Received SIGILL **\n\n\n\n"));
  	PutLine0(LINES, 0, "\n\nIllegal Instruction signal!\n\n");
***************
*** 35,37
  {
! 	dprint0(1,"\n\n** Received SIGFPE **\n\n\n\n");
  	PutLine0(LINES, 0,"\n\nFloating Point Exception signal!\n\n");

--- 35,37 -----
  {
! 	dprint(1, (debugfile, "\n\n** Received SIGFPE **\n\n\n\n"));
  	PutLine0(LINES, 0,"\n\nFloating Point Exception signal!\n\n");
***************
*** 42,44
  {
! 	dprint0(1,"\n\n** Received SIGBUS **\n\n\n\n");
  	PutLine0(LINES, 0,"\n\nBus Error signal!\n\n");

--- 42,44 -----
  {
! 	dprint(1, (debugfile, "\n\n** Received SIGBUS **\n\n\n\n"));
  	PutLine0(LINES, 0,"\n\nBus Error signal!\n\n");
***************
*** 49,51
  {
! 	dprint0(1,"\n\n** Received SIGSEGV **\n\n\n\n");
  	PutLine0(LINES, 0,"\n\nSegment Violation signal!\n\n");

--- 49,51 -----
  {
! 	dprint(1, (debugfile,"\n\n** Received SIGSEGV **\n\n\n\n"));
  	PutLine0(LINES, 0,"\n\nSegment Violation signal!\n\n");
***************
*** 69,71
  
! 	dprint0(2,"*** received SIGPIPE ***\n\n");
  	

--- 69,71 -----
  
! 	dprint(2, (debugfile, "*** received SIGPIPE ***\n\n"));
  	
***************
*** 75,75
  }

--- 75,112 -----
  }
+ 
+ #ifdef BSD
+ int was_in_raw_state;
+ 
+ sig_user_stop()
+ {
+ 	/* This is called when the user presses a ^Z to stop the
+ 	   process within BSD 
+ 	*/
+ 	int sig_user_stop;
+ 
+ 	was_in_raw_state = RawState();
+ 
+ 	Raw(OFF);	/* turn it off regardless */
+ 
+ 	printf("\n\nStopped.  Use \"fg\" to return to Elm\n\n");
+ 
+ 	signal(SIGTSTP, sig_user_stop);
+ 
+ 	kill(getpid(), SIGSTOP);
+ }
+ 
+ sig_return_from_user_stop()
+ {
+ 	/** this is called when returning from a ^Z stop **/
+ 
+ 	int sig_return_from_user_stop();
+ 
+ 	printf(
+ 	 "\nBack in Elm.  (you might need to explicitly request a redraw)\n\n");
+ 
+ 	if (was_in_raw_state)
+ 	  Raw(ON);
+ 
+ 	signal(SIGCONT, sig_return_from_user_stop);
+ }
+ #endif

Index: src/edit.c

***************
*** 85,88
  	     if ((temp_mailbox = fopen(filename, "a")) == NULL) {
! 		dprint2(1, "Attempt to open %s to append failed! (%s)\n", 
! 			filename, "edit_mailbox");
  	       set_error("Couldn't reopen tempfile.  Edit LOST!");

--- 85,89 -----
  	     if ((temp_mailbox = fopen(filename, "a")) == NULL) {
! 	       dprint(1, (debugfile, 
! 			"Attempt to open \"%s\" to append failed in %s\n", 
! 			filename, "edit_mailbox"));
  	       set_error("Couldn't reopen tempfile.  Edit LOST!");
***************
*** 95,99
  	     if ((real_mailbox = fopen(infile, "r")) == NULL) {
! 	       dprint2(1, 
! 		       "Attempt to open %s for reading new mail failed! (%s)\n",
!  		 	infile, "edit_mailbox");
  	       sprintf(buffer, "Couldn't open %s for reading!  Edit LOST!", 

--- 96,100 -----
  	     if ((real_mailbox = fopen(infile, "r")) == NULL) {
! 	       dprint(1, (debugfile, 
! 	           "Attempt to open \"%s\" for reading new mail failed in %s\n",
!  		   infile, "edit_mailbox"));
  	       sprintf(buffer, "Couldn't open %s for reading!  Edit LOST!", 
***************
*** 105,108
  	     if (fseek(real_mailbox, mailfile_size, 0) != 0) {
! 	       dprint2(1, "Couldn't seek to end of infile (offset %ld) (%s)\n",
! 			mailfile_size, "edit_mailbox");
  	       set_error("Couldn't seek to end of mailbox.  Edit LOST!");

--- 106,110 -----
  	     if (fseek(real_mailbox, mailfile_size, 0) != 0) {
! 	       dprint(1, (debugfile,
! 			"Couldn't seek to end of infile (offset %ld) (%s)\n",
! 			mailfile_size, "edit_mailbox"));
  	       set_error("Couldn't seek to end of mailbox.  Edit LOST!");

Index: src/sort.c

***************
*** 24,26
  
! 	dprint1(2,"\n** sorting mailbox by %s **\n\n", sort_name(FULL));
  

--- 24,27 -----
  
! 	dprint(2, (debugfile, "\n** sorting mailbox by %s **\n\n", 
! 		sort_name(FULL)));
  
***************
*** 73,74
  
  	  case SUBJECT   : /* need some extra work 'cause of STATIC buffers */

--- 74,78 -----
  
+ 	  case MAILBOX_ORDER  : return( sign*
+ 				  (first->index_number - second->index_number));
+ 
  	  case SUBJECT   : /* need some extra work 'cause of STATIC buffers */
***************
*** 103,105
  			      abr?     "Reverse-Received":
! 			               "Reverse Date Mail Rec'vd");
  	    case SENDER       : return(

--- 107,115 -----
  			      abr?     "Reverse-Received":
! 			      "Reverse Date Mail Rec'vd" );
! 
! 	    case MAILBOX_ORDER: return(
! 			      pad?     "Reverse Mailbox Order   " :
! 			      abr?     "Reverse-Mailbox":
! 			               "Reverse Mailbox Order");
! 
  	    case SENDER       : return(
***************
*** 130,132
  	                        abr?   "Received" :
! 	                               "Date Mail Rec'vd");
  	    case SENDER       : return(

--- 140,146 -----
  	                        abr?   "Received" :
! 				       "Date Mail Sent");
! 	    case MAILBOX_ORDER: return(
! 	                        pad?   "Mailbox Order           " :
! 	                        abr?   "Mailbox" :
! 	                               "Mailbox Order");
  	    case SENDER       : return(
***************
*** 162,164
  
! 	dprint1(2,"find-old-current(%d)\n", index);
  

--- 176,178 -----
  
! 	dprint(4, (debugfile, "find-old-current(%d)\n", index));
  
***************
*** 167,169
  	    current = i+1;
! 	    dprint1(2,"\tset current to %d!\n", current);
  	    return;

--- 181,183 -----
  	    current = i+1;
! 	    dprint(4, (debugfile, "\tset current to %d!\n", current));
  	    return;
***************
*** 171,174
  
! 	dprint1(2,"\tcouldn't find current index.  Current left as %d\n",
! 		current);
  	return;		/* can't be found.  Leave it alone, then */

--- 185,189 -----
  
! 	dprint(4, (debugfile, 
! 		"\tcouldn't find current index.  Current left as %d\n",
! 		current));
  	return;		/* can't be found.  Leave it alone, then */

Index: src/showmsg_cmd.c

***************
*** 12,14
  	   d    = mark message for deletion
- 	   e    = edit entire mailbox
  	   f    = forward message

--- 12,13 -----
  	   d    = mark message for deletion
  	   f    = forward message
***************
*** 15,16
  	   g    = group reply
  	   j,n  = move to body of next message

--- 14,17 -----
  	   g    = group reply
+ 	   h    = redisplay this message from line #1, showing headers
+ 	   i    = move back to the index page (simply returns from function)
  	   j,n  = move to body of next message
***************
*** 17,18
  	   k    = move to body of previous message
  	   p    = print this (all tagged) message

--- 18,20 -----
  	   k    = move to body of previous message
+ 	   m    = mail a message out to someone
  	   p    = print this (all tagged) message
***************
*** 21,23
  	   t    = tag this message
! 	   x    = Exit Elm NOW
  

--- 23,26 -----
  	   t    = tag this message
! 	   u    = undelete message
! 	   x    = Exit Elm NOW 
  
***************
*** 23,26
  
!     all commands not explicitly listed here are returned as unprocessed
!     to be dealt with at the main command level.
  

--- 26,29 -----
  
!     all commands not explicitly listed here are beeped at.  Use I)ndex
!     to get back to the main index page, please.
  
***************
*** 26,29
  
!     This function returns 0 if it dealt with the command, or the command
!     otherwise.
  **/

--- 29,32 -----
  
!     This function returns when it is ready to go back to the index
!     page.
  **/
***************
*** 32,35
  
! process_showmsg_command(command)
! char command;
  {

--- 35,41 -----
  
! int screen_mangled = 0;
! 
! int
! process_showmsg_cmd(command)
! int command;
  {
***************
*** 35,43
  {
! 	switch (command) {
! 	  case '|' : clear_bottom_of_screen();
! 		     PutLine0(LINES-3,0,"Command: pipe");
! 		     softkeys_off();
! 		     (void) pipe();	/* do pipe regardless */
! 		     softkeys_on();
! 		     return(0);		/* must have new screen */
  

--- 41,44 -----
  {
! 	int     intbuf;			/* for dummy parameters...etc */
! 	char    error_line[SLEN];	/* for stat line messsages    */
  
***************
*** 43,50
  
! 	  case '!' : clear_bottom_of_screen();
! 		     PutLine0(LINES-3,0,"Command: system call");
! 		     softkeys_off();
! 		     (void) subshell();	/* do shell regardless */
! 		     softkeys_on();
! 		     return(0);		/* must have new screen */
  

--- 44,46 -----
  
! 	Raw(ON);
  
***************
*** 50,52
  
! 	  case '<' : 
  #ifdef ENABLE_CALENDAR

--- 46,61 -----
  
! 	while (TRUE) {
! 	  error_line[0] = '\0';
! 	  switch (command) {
! 	    case '|' : clear_bottom_of_screen();
! 		       PutLine0(LINES-3,0,"Command: pipe");
! 		       (void) do_pipe();     /* do pipe - ignore return val */
! 		       break; 
! 
! 	    case '!' : clear_bottom_of_screen();
! 		       PutLine0(LINES-3,0,"Command: system call");
! 		       (void) subshell();	     /* do shell regardless */
! 		       break;
! 
! 	    case '<' : 
  #ifdef ENABLE_CALENDAR
***************
*** 52,54
  #ifdef ENABLE_CALENDAR
! 		     scan_calendar();
  #else

--- 61,63 -----
  #ifdef ENABLE_CALENDAR
! 		       scan_calendar();
  #else
***************
*** 54,56
  #else
! 		     error("can't scan for calendar entries!");
  #endif

--- 63,65 -----
  #else
! 		       strcpy(,error_line, "can't scan for calendar entries!");
  #endif
***************
*** 56,58
  #endif
! 		    break;
  

--- 65,67 -----
  #endif
! 		      break;
  
***************
*** 58,63
  
! 	  case 'b' : clear_bottom_of_screen();
! 		     PutLine0(LINES-3,0,"Command: bounce message");
! 		     remail();
! 		     return(0);		/* must have new screen */
  

--- 67,85 -----
  
! 	    case 'b' : clear_bottom_of_screen();
! 		       PutLine0(LINES-3,0,"Command: bounce message");
! 		       remail();
! 		       break;
!   
! 	    case 'd' : delete_msg(TRUE, FALSE); /* really delete it, silent */
! 		       if (! resolve_mode) {
! 		         if (screen_mangled) 
! 		           strcpy(error_line,"message marked for deletion");
! 		         else {
! 			   ClearLine(LINES-1);
! 		           PutLine0(LINES-1, 0, 
! 			      "Message marked for deletion.  Command ? ");
! 		           CleartoEOLN();
! 		         }
! 		       } else goto move_to_next_message;
! 		       break;
  
***************
*** 63,66
  
! 	  case 'd' : delete(TRUE);
! 		     break;
  

--- 85,90 -----
  
! 	    case 'f' : clear_bottom_of_screen();
! 		       PutLine0(LINES-3,0,"Command: forward message");
! 		       (void) forward();
! 		       break;
  
***************
*** 66,69
  
! 	  case 'e' : edit_mailbox();
! 		     return(0);		/* must have new screen */
  

--- 90,95 -----
  
! 	    case 'g' : clear_bottom_of_screen();
! 		       PutLine0(LINES-3,0,"Command: group reply");
! 		       (void) reply_to_everyone();
! 		       break;
  
***************
*** 69,74
  
! 	  case 'f' : clear_bottom_of_screen();
! 		     PutLine0(LINES-3,0,"Command: forward message");
! 		     (void) forward();
! 		     return(0);		/* must have new screen */
  

--- 95,107 -----
  
! 	    case 'h' : screen_mangled = 0;
! 		       if (filter) { 
! 		         filter = 0; 
! 		         intbuf = show_msg(current); 
! 		         filter = 1;
! 			 return(intbuf);
! 		       }
! 		       else
! 		         return(show_msg(current)); 
!  
! move_to_next_message :	/* a target for resolve mode actions */
  
***************
*** 74,79
  
! 	  case 'g' : clear_bottom_of_screen();
! 		     PutLine0(LINES-3,0,"Command: group reply");
! 		     (void) reply_to_everyone();
! 		     return(0);		/* must have new screen */
  

--- 107,115 -----
  
! 	    case 'j' :
! 	    case 'n' : if (current < message_count) {
! 	                 screen_mangled = 0;
! 		         return(show_msg(++current));
! 		       }
! 		       else putchar(007);
! 		       fflush(stdout);				break;
  
***************
*** 79,84
  
! 	  case 'j' :
! 	  case 'n' : if (current < message_count)
! 		       show_msg(++current);
! 		     return(0);	
  

--- 115,127 -----
  
! 	    case 'k' : if (current > 0) {
! 			 screen_mangled = 0;
! 		         return(show_msg(--current));
! 		       }
! 		       else putchar(007);
! 		       fflush(stdout);				break;
! 	
! 	    case 'm' : clear_bottom_of_screen();
! 		       PutLine0(LINES-3,0,"Command: Mail message");
! 		       (void) send("","","", TRUE, allow_forms);
! 		       break;
  
***************
*** 84,88
  
! 	  case 'k' : if (current > 0)
! 		       show_msg(--current);
! 		     return(0);
  

--- 127,138 -----
  
! 	    case 'p' : print_msg();	
! 		       if (screen_mangled) 
! 		         strcpy(error_line, "queued for printing");
! 		       else {
! 			 ClearLine(LINES-1);
! 		         PutLine0(LINES-1, 0, 
! 			    "Queued for printing.  Command ? ");
! 			 CleartoEOLN();
! 		       }
! 		       break;
  
***************
*** 88,89
  
  

--- 138,143 -----
  
+ 	    case 'r' : clear_bottom_of_screen();
+ 		       PutLine0(LINES-3,0,"Command: reply to message");
+ 		       (void) reply();
+ 		       break;
  
***************
*** 89,92
  
! 	  case 'p' : printmsg();	
! 		     break;
  

--- 143,149 -----
  
! 	    case 's' : clear_bottom_of_screen();
! 		       PutLine0(LINES-3,0,"Command: save message");
! 		       (void) save(&intbuf);
! 		       if (resolve_mode) goto move_to_next_message;
! 		       break;
  
***************
*** 92,97
  
! 	  case 'r' : clear_bottom_of_screen();
! 		     PutLine0(LINES-3,0,"Command: reply to message");
! 		     (void) reply();
! 		     return(0);		/* must have new screen */
  

--- 149,160 -----
  
! 	    case 't' : tag_message();	
! 		       if (screen_mangled) 
! 		         strcpy(error_line, "message tagged");
! 		       else {
! 			 ClearLine(LINES-1);
! 		         PutLine0(LINES-1, 0, 
! 			    "Message tagged.  Command ? ");
! 	   	         CleartoEOLN();
! 	 	       }
! 		       break;
  
***************
*** 97,102
  
! 	  case 's' : clear_bottom_of_screen();
! 		     PutLine0(LINES-3,0,"Command: save message");
! 		     (void) save();
! 		     break;
  

--- 160,175 -----
  
! 	    case 'u' : undelete_msg(FALSE); /* undelete it, silently */
! 		       if (! resolve_mode) {
! 		         if (screen_mangled) 
! 		           strcpy(error_line, "message undeleted");
! 		         else {
! 		           ClearLine(LINES-1);
! 		           PutLine0(LINES-1, 0, 
! 			      "Message undeleted.  Command ? ");
! 			   CleartoEOLN();
! 		         }
! 		       } 
! 		       else 
! 			 goto move_to_next_message;
! 		       break;
  
***************
*** 102,105
  
! 	  case 't' : tag_message();	
! 		     break;
  

--- 175,177 -----
  
! 	    case 'x' : fflush(stdout); leave();
  
***************
*** 105,107
  
! 	  case 'x' : leave();
  

--- 177,184 -----
  
! 	    case 'i' : 
! 	    case ' ' :
! 	    case '\n':
! 	    case '\r': (void) get_page(current);
! 		       set_error("");		/* zero out pending msg   */
! 		       return(0);		/* avoid <return> looping */
  
***************
*** 107,110
  
! 	  case '\n':
! 	  case '\r': return(0);		/* avoid <return> looping */
  

--- 184,187 -----
  
! 	    case ctrl('L') : screen_mangled = 0;
! 			     return(show_msg(current));
  
***************
*** 110,113
  
! 	  default  : return(command);	/* couldn't deal with it! */
! 	}
  

--- 187,191 -----
  
! 	    default  : putchar((char) 007);	/* BEEP! */
! 		       fflush(stdout);
! 	  }
  
***************
*** 113,115
  
! 	return(1);	/* done with it! */
  }

--- 191,201 -----
  
! 	  if (screen_mangled) {
! 	     clear_bottom_of_screen();
! 	     PutLine0(LINES-3, 0, "Request (return to I)ndex page) ? ");
! 	     if (error_line[0] != '\0')
! 	       error(error_line);
! 	  }
! 
! 	  command = tolower(ReadCh());
! 	}
  }
***************
*** 120,121
  
  	MoveCursor(LINES-4, 0);

--- 206,209 -----
  
+ 	screen_mangled = 1;
+ 
  	MoveCursor(LINES-4, 0);
***************
*** 122,123
  	CleartoEOS();
  }

--- 210,215 -----
  	CleartoEOS();
+ 	PutLine0(LINES-4, 0, 
+ "--------------------------------------------------------------------------\n");
+ 
+ 	show_last_error();
  }

Index: src/options.c

***************
*** 57,59
  	    case 'c' : optionally_enter(calendar_file, 2, 23, FALSE);	break;
! 	    case 'd' : optionally_enter(pager, 3, 23, FALSE); 		break;
  	    case 'e' : optionally_enter(editor, 4, 23, FALSE);		break;

--- 57,61 -----
  	    case 'c' : optionally_enter(calendar_file, 2, 23, FALSE);	break;
! 	    case 'd' : optionally_enter(pager, 3, 23, FALSE); 		
! 		       clear_pages = (equal(pager, "builtin+") || 
! 			             equal(pager, "internal+")); 	break;
  	    case 'e' : optionally_enter(editor, 4, 23, FALSE);		break;
***************
*** 180,182
  			 else sign = 1;		/* insurance! */
! 	  		 sortby = sign * ((sortby + 1) % (STATUS+1));
  			 if (sortby == 0) sortby = sign;  /* snicker */

--- 182,184 -----
  			 else sign = 1;		/* insurance! */
! 	  		 sortby = sign * ((sortby + 1) % (STATUS+2));
  			 if (sortby == 0) sortby = sign;  /* snicker */
***************
*** 227,228
  		 	    break;
  	  case -SENDER : Centerline(LINES-2,

--- 229,233 -----
  		 	    break;
+ 	  case -MAILBOX_ORDER : Centerline(LINES-2,
+ "This sort will order most-recently-added-to-mailbox to least-recently");
+ 		 	    break;
  	  case -SENDER : Centerline(LINES-2,
***************
*** 241,242
  	                    break;
  	  case SENDER : Centerline(LINES-2,

--- 246,250 -----
  	                    break;
+ 	  case MAILBOX_ORDER : Centerline(LINES-2,
+ "This sort will order least-recently-added-to-mailbox to most-recently");
+ 		 	    break;
  	  case SENDER : Centerline(LINES-2,

End of Patch Kit #5