/* The search-and-mark macro marks a block from the cursor position */
/* until the first occurence of the char you type. */

init()
{
  assign_key("search_and_mark", 178);     /* ALT M */
}

search_and_mark()
{
  int ch;

  mark();
  message("Type character to find: ");
  ch = get_tty_char();
  if (ch == '\E')            /* <ESC> - abort operation */
    clear_mark();
  else if (ch == '\n')       /* mark till the end of the paragraph */
  {
    if (nextpara())  up();
    setprompt(1);
    mark();
  }
  else
  {
    if (fsearch(chr(ch)))     /* search for the char the user typed */
    {
      setprompt(1);          /* found!!! - prompt user for operation */
      mark();
    }
    else
    {
      message("Char not found - press <RETURN> to continue");
      ch = get_tty_char();
      clear_mark();
    }
  }
}
