diff -rc alpine-1.10/alpine/mailcmd.c alpine-1.10.searchheader/alpine/mailcmd.c
*** alpine-1.10/alpine/mailcmd.c	2008-02-29 10:18:49.000000000 -0800
--- alpine-1.10.searchheader/alpine/mailcmd.c	2008-03-17 20:33:48.000000000 -0700
***************
*** 252,257 ****
--- 252,258 ----
      {'r', 'r', "R", N_("Recipient")},
      {'p', 'p', "P", N_("Participant")},
      {'b', 'b', "B", N_("Body")},
+     {'h', 'h', "H", N_("Header")},
      {-1, 0, NULL, NULL}
  };
  
***************
*** 7679,7685 ****
      int          not = 0, me = 0;
      char         sstring[80], savedsstring[80], tmp[128];
      char        *p, *sval = NULL;
!     char         buftmp[MAILTMPLEN];
      ESCKEY_S     ekey[8];
      ENVELOPE    *env = NULL;
      HelpType     help;
--- 7680,7686 ----
      int          not = 0, me = 0;
      char         sstring[80], savedsstring[80], tmp[128];
      char        *p, *sval = NULL;
!     char         buftmp[MAILTMPLEN], namehdr[80];
      ESCKEY_S     ekey[8];
      ENVELOPE    *env = NULL;
      HelpType     help;
***************
*** 7766,7771 ****
--- 7767,7806 ----
  	sval = "BODYTEXT";
  	break;
  
+       case 'h' :
+ 	strcpy(tmp, "Name of HEADER to match : ");
+ 	flags = OE_APPEND_CURRENT;
+ 	namehdr[0] = '\0';
+ 	r = 'x';
+ 	while (r == 'x'){
+ 	       int done = 0;
+ 
+ 	       r = optionally_enter(namehdr, -FOOTER_ROWS(ps_global), 0,
+ 				 sizeof(namehdr), tmp, ekey, NO_HELP, &flags);
+ 	       if (r == 1){
+ 		  cmd_cancelled("Selection by text");
+ 		  return(1);
+ 	       }
+ 	       removing_leading_white_space(namehdr);
+ 	       while(!done){
+ 	          while ((namehdr[0] != '\0') && /* remove trailing ":" */
+ 			(namehdr[strlen(namehdr) - 1] == ':'))
+ 		     namehdr[strlen(namehdr) - 1] = '\0';
+ 		  if ((namehdr[0] != '\0') 
+ 		     && isspace((unsigned char) namehdr[strlen(namehdr) - 1]))
+ 		       removing_trailing_white_space(namehdr);
+ 		  else
+ 		    done++;
+ 	       }
+ 	       if (strchr(namehdr,' ') || strchr(namehdr,'\t') ||
+ 		   strchr(namehdr,':'))
+ 		  namehdr[0] = '\0';
+ 	       if (namehdr[0] == '\0')
+ 	         r = 'x';
+ 	}
+ 	sval = namehdr;
+ 	break;
+ 
        case 'x':
  	break;
  
***************
*** 7962,7968 ****
      flagsforhist = (not ? 0x1 : 0) + (me ? 0x2 : 0);
      save_hist(history, sstring, flagsforhist, NULL);
  
!     rv = agg_text_select(stream, msgmap, type, not, me, sstring, "utf-8", limitsrch);
      if(we_cancel)
        cancel_busy_cue(0);
  
--- 7997,8003 ----
      flagsforhist = (not ? 0x1 : 0) + (me ? 0x2 : 0);
      save_hist(history, sstring, flagsforhist, NULL);
  
!     rv = agg_text_select(stream, msgmap, type, namehdr, not, me, sstring, "utf-8", limitsrch);
      if(we_cancel)
        cancel_busy_cue(0);
  
diff -rc alpine-1.10/pith/mailcmd.c alpine-1.10.searchheader/pith/mailcmd.c
*** alpine-1.10/pith/mailcmd.c	2008-03-05 10:56:28.000000000 -0800
--- alpine-1.10.searchheader/pith/mailcmd.c	2008-03-17 20:33:48.000000000 -0700
***************
*** 2158,2165 ****
  
  
  int
! agg_text_select(MAILSTREAM *stream, MSGNO_S *msgmap, char type, int not,
! 		int check_for_my_addresses,
  		char *sstring, char *charset, SEARCHSET **limitsrch)
  {
      int		 old_imap, we_cancel;
--- 2158,2165 ----
  
  
  int
! agg_text_select(MAILSTREAM *stream, MSGNO_S *msgmap, char type, char *namehdr,
! 		int not, int check_for_my_addresses,
  		char *sstring, char *charset, SEARCHSET **limitsrch)
  {
      int		 old_imap, we_cancel;
***************
*** 2308,2313 ****
--- 2308,2317 ----
  
    if(!mepgm)
      switch(type){
+       case 'h' :	                        /* Any header */
+         pgm->header = mail_newsearchheader (namehdr, sstring);
+       break;
+ 
        case 'r' :				/* TO or CC */
  	if(old_imap){
  	    /* No OR on old servers */
diff -rc alpine-1.10/pith/mailcmd.h alpine-1.10.searchheader/pith/mailcmd.h
*** alpine-1.10/pith/mailcmd.h	2007-11-08 12:39:45.000000000 -0800
--- alpine-1.10.searchheader/pith/mailcmd.h	2008-03-17 20:33:48.000000000 -0700
***************
*** 65,71 ****
  void	   cross_delete_crossposts(MAILSTREAM *);
  long	   zoom_index(struct pine *, MAILSTREAM *, MSGNO_S *);
  int	   unzoom_index(struct pine *, MAILSTREAM *, MSGNO_S *);
! int	   agg_text_select(MAILSTREAM *, MSGNO_S *, char, int, int, char *,
  			   char *, SEARCHSET **);
  int	   agg_flag_select(MAILSTREAM *, int, int, SEARCHSET **);
  char	  *get_uname(char *, char *, int);
--- 65,71 ----
  void	   cross_delete_crossposts(MAILSTREAM *);
  long	   zoom_index(struct pine *, MAILSTREAM *, MSGNO_S *);
  int	   unzoom_index(struct pine *, MAILSTREAM *, MSGNO_S *);
! int	   agg_text_select(MAILSTREAM *, MSGNO_S *, char, char *, int, int, char *,
  			   char *, SEARCHSET **);
  int	   agg_flag_select(MAILSTREAM *, int, int, SEARCHSET **);
  char	  *get_uname(char *, char *, int);
diff -rc alpine-1.10/web/src/alpined.d/alpined.c alpine-1.10.searchheader/web/src/alpined.d/alpined.c
*** alpine-1.10/web/src/alpined.d/alpined.c	2008-03-14 14:51:18.000000000 -0700
--- alpine-1.10.searchheader/web/src/alpined.d/alpined.c	2008-03-17 20:33:48.000000000 -0700
***************
*** 6068,6074 ****
  				/* BUG: fix charset not to be NULL below */
  				if(agg_text_select(ps_global->mail_stream,
  						   ps_global->msgmap,
! 						   field, not, 0, text, NULL, NULL))
  				  /* BUG: plug in "charset" above? */
  				  return(peSelectError(interp, "programmer botch"));
  			    }
--- 6068,6074 ----
  				/* BUG: fix charset not to be NULL below */
  				if(agg_text_select(ps_global->mail_stream,
  						   ps_global->msgmap,
! 						   field, NULL, not, 0, text, NULL, NULL))
  				  /* BUG: plug in "charset" above? */
  				  return(peSelectError(interp, "programmer botch"));
  			    }
