{{{F fun/mt-fold
:::F fun/mt-fold
}}}
{{{F fun/error
:::F fun/error
}}}
{{{F fun/go-line
:::F fun/go-line
}}}
{{{F fun/delspaces
:::F fun/delspaces
}}}
{{{F fun/append
:::F fun/append
}}}
{{{F fun/pre-char
:::F fun/pre-char
}}}
{{{F fun/go-match
:::F fun/go-match
}}}
{{{F fun/opagemenu
:::F fun/opagemenu
}}}
{{{F fun/makes
:::F fun/makes
}}}
{{{F fun/move-mark
:::F fun/move-mark
}}}
{{{F fun/kill-mark
:::F fun/kill-mark
}}}
{{{  backward-word              move one word left
{{{  backward-text-word
{{{  word-line-up
( deffun word-line-up
   ( if test-top ( failed ) fi
     previous-line
     end-of-line
   )
)
}}}

( deffun backward-text-word
   (
     {{{  one step left
     if test-begin-line
       ( word-line-up )
     else
       ( backward-character )
     fi
     }}}
     while not(test-char-set word-char)
      {{{  back or line up
      ( if counter-0 +(store-pos -1)
         ( word-line-up )
        else
         ( backward-character )
        fi
      )
      }}}
     {{{  start-word
     while test-char-set word-char
      ( if test-begin-line
         ( return-from-macro )
        else
         ( backward-character )
        fi
      )
     forward-character
     }}}
   )
)
}}}

( deffun backward-word
   ( case
      {{{  programming
      @if-using (L-EXT)
      ( and
         ( counter>0 extended,
           test-text,
           {{{  programming-language
           or
            ( test-language "c,
              test-language "p,
              test-language "t,
              test-language "o,
              test-language "i
            )
           }}}
         )
        {{{  previous-s-expression
        ( case
           {{{  closing paren, bracket or brace
           ( test-char-set closing-fence
              ( if test-text
                 ( goto-matching-fence backward-text-word )
                else
                 ( backward-text-word )
                fi
              )
           )
           }}}
           {{{  double quote
           ( test-char ""
              ( backward-character
                while not(or(test-begin-line,test-char "" ))
                 ( backward-character )
              )
           )
           }}}
           {{{  single quote
           ( test-char "'
              ( backward-character
                while not(or(test-begin-line,test-char "' ))
                 ( backward-character )
              )
           )
           }}}
           {{{  in word
           ( test-char-set word-char ( backward-text-word ) )
           }}}
          default
           {{{  go left
           ( while not(or(test-char-set word-char,
                          test-char-set closing-fence,
                          test-char "",test-char "',
                          test-begin-line))
              ( backward-character )
           )
           }}}
          esac
        )
        }}}
      )
      @fi
      }}}
     default
      ( backward-text-word )
     esac
   )
)
}}}
{{{  forward-word               move to next word right
{{{  forward-text-word
{{{  word-line-down          go to beginning of next line for word
( defmac word-line-down
   ( if test-bottom ( failed ) fi
     next-line
     beginning-of-line
   )
)
}}}

( deffun forward-text-word
   (
     {{{  end word or next-line
     if test-end-line
       ( word-line-down )
     else
       ( while test-char-set word-char ( forward-character ) )
     fi
     }}}
     while not(test-char-set word-char)
      {{{  right or down
      ( if test-end-line ( word-line-down ) else ( forward-character ) fi )
      }}}
   )
)
}}}

( deffun forward-word
   ( case
      {{{  programming
      @if-using (L-EXT)
      ( and
         ( counter>0 extended,
           test-text,
           {{{  programming-language
           or
            ( test-language "c,
              test-language "p,
              test-language "t,
              test-language "o,
              test-language "i
            )
           }}}
         )
        {{{  next-s-expression
        ( case
           {{{  opening paren, bracket or brace
           ( test-char-set opening-fence
              ( if test-text
                 ( goto-matching-fence forward-character )
                else
                 ( forward-text-word )
                fi
              )
           )
           }}}
           {{{  double quote
           ( test-char ""
              ( forward-character
                while not(or(test-end-line,test-char "" ))
                 ( forward-character )
              )
           )
           }}}
           {{{  single quote
           ( test-char "'
              ( forward-character
                while not(or(test-end-line,test-char "' ))
                 ( forward-character )
              )
           )
           }}}
           {{{  in word
           ( test-char-set word-char ( forward-text-word ) )
           }}}
          default
            {{{  move right
            ( while not(or(test-char-set word-char,
                           test-char-set opening-fence,
                           test-char "", test-char "',
                           test-end-line))
               ( forward-character )
            )
            }}}
          esac
        )
        }}}
      )
      @fi
      }}}
     default
      ( forward-text-word )
     esac
   )
)
}}}
{{{  next-line-
( deffun next-line-
   ( if and(test-fold-line counter>0 stepping not(in-prompt))
      ( open-fold )
     fi
     next-line
   )
)
}}}
{{{  previous-line-
( deffun previous-line-
   ( previous-line
     while and(test-fold-line counter>0 stepping not(in-prompt))
      ( open-fold mtool-bot )
   )
)
}}}
{{{  page-moves
( defvar ( np-level np-height ) )
{{{  next-page-
( deffun next-page-
   (
     {{{  get number of skip-lines
     set-counter np-level cursor-level
     set-counter np-height -( screen-height area-length 1 )
     }}}
     {{{  skip and set cursor
     screen-off
     while counter>0 np-height
      {{{  skip one line
      ( next-line
        if and(counter>0 stepping test-fold-line)
         {{{  open and stop the loop
         ( open-fold
           set-counter np-height 0
         )
         }}}
        else
         {{{  decrement the number of skip-lines
         ( set-counter np-height -(np-height 1) )
         }}}
        fi
      )
      }}}
     screen-on
     set-cursor-line np-level
     }}}
   )
)
}}}
{{{  previous-page-
( deffun previous-page-
   (
     {{{  get number of skip-lines
     set-counter np-level cursor-level
     set-counter np-height -( screen-height area-length 1 )
     }}}
     {{{  skip and set cursor
     screen-off
     while counter>0 np-height
      {{{  skip one line
      ( previous-line
        if and(counter>0 stepping test-fold-line)
         {{{  open and stop the loop
         ( open-fold
           mtool-bot
           set-counter np-height 0
         )
         }}}
        else
         {{{  decrement the number of skip-lines
         ( set-counter np-height -(np-height 1) )
         }}}
        fi
      )
      }}}
     screen-on
     set-cursor-line np-level
     }}}
   )
)
}}}
( undeclare ( np-level np-height ) )
}}}
{{{  menu-start-
( deffun menu-start-
   ( switch-status-line-on
     para
     menu-start
     moves
   )
)
}}}
{{{  add-mode-file-based
( deffun add-mode-file-based
   ( set-counter stepping 1 set-user-mode STEP )
)
}}}
{{{  delete-mode-file-based
( deffun delete-mode-file-based
   ( set-counter stepping 0 reset-user-mode STEP )
)
}}}
{{{  set-read-tab-width
( deffun set-read-tab-width
   ( prompt-counter read-tab-width
      ( "read-tab-width "  "(hard-tabs= counter hard-tab ") " )
     if not(counter>0 read-tab-width)
      ( set-counter read-tab-width hard-tab )
     fi
   )
)
}}}
{{{  call-make-error-
( deffun call-make-error-
   ( set-counter command 1
     switch-to-edit-mode
     call-make-error
   )
)
}}}
{{{  call-make-
( deffun call-make-
   ( switch-status-line-on
     call-make
   )
)
}}}
{{{  lookup
( deffun lookup
   ( shell-command "fgrep "  "$ORIWORD "  ;
     @if-using (L-EXT)
        if or(test-language "c test-language "p)
         ( "*c "  "*h "  "*p )
        else
         ( "* )
        fi
     @fi
     @if-using not(L-EXT)
        "*
     @fi
     "  "|less
     newline-and-indent
     newline-and-indent
   )
)
}}}
@if-using (MOUSY)
   {{{F fun/go-mouse
   :::F fun/go-mouse
   }}}
   {{{  go-and-open-mouse
   ( deffun go-and-open-mouse
      ( if in-prompt
         ( newline-and-indent )
        else
         ( go-mouse-position
           case
            ( test-fold-line ( open-fold ) )
            ( and (test-filed counter-0 moving) ( enter-fold ) )
           esac
         )
        fi
      )
   )
   }}}
   {{{  go-and-close-mouse
   ( defvar ( g-a-c-m-l ) )
   ( deffun go-and-close-mouse
      ( if in-prompt
         ( newline-and-indent )
        else
         ( screen-off
           go-mouse-position
           set-counter g-a-c-m-l cursor-level
           close-fold
           screen-on
           set-cursor-line g-a-c-m-l
         )
        fi
      )
   )
   ( undeclare ( g-a-c-m-l ) )
   }}}
   {{{  go-mouse-and-center
   ( deffun go-mouse-and-center
      ( if in-prompt
         ( newline-and-indent )
        else
         ( @if-using ( SCR-OFF )
              screen-off
           @fi
           go-mouse-position
           @if-using ( SCR-OFF )
              screen-on
           @fi
           center-and-redraw-display
           describe-fold
         )
        fi
      )
   )
   }}}
@fi
