;OCL{{{}}}
;OCL{{{  Notes
; These bindings are my personal favourite Origami bindings for daily
; work. You will feel like in Emacs, although many functions work
; different, the cursor lands not always where is lands in Emacs and other
; things.
;
; There is some experimental stuff for writing C programs, which will be
; enabled by C-mode.  My idea is to have an editor which saves me from
; typing bothering things, which supports a few aspects of C syntax but
; does not restrict me like a syntax-controlled editor does.  If you have
; any ideas what could be useful for these bindings, write me mail.
;
; In fact, I like these keybindings more than real Emacs, especially on
; machines where an Meta key (which sends escape plus character) is available!
;
; Many people wished these bindings not be called "Emacs" in the
; statusline.  True, this is not what is known as Emacs.  It is EMacs!
;
; Michael Haardt
;OCL}}}

;OCL{{{  get terminal-data
@lib emacs-fun/em-term-alias
;OCL}}}

;OCL{{{  name and command line options
( defbinding EMacs
  ( "default ">0=0 )
  ( "notime  ">0|64 )   ( "time      ">0|64^64 )
  ( "noai    ">0|32 )   ( "ai        ">0|32^32 )
  ( "magic   ">0|8  )   ( "xmagic    ">0|16    ) ( "nomagic ">0|24^24 )
  ( "posi    ">0|4 )    ( "noposi    ">0|4^4   )
  ( "c       ">0|2 )    ( "noc       ">0|2^2   )
  ( "full    ">0|1 )    ( "nofull    ">0|1^1   )
)
;OCL}}}

;OCL{{{  character-classes
(defset text-word-char (alpha digit))
(defset c-word-char (alpha digit "_))

(defset word-char (text-word-char))
;OCL}}}

;OCL{{{  keytables
( defmodes ( edit para ) )
;OCL}}}
;OCL{{{  keyboard hooks
( defvar ( prompting ) )
;OCL{{{  begin-prompt
( deffun begin-prompt ( if prompting ( para ) fi ))
;OCL}}}
;OCL{{{  end-prompt
( deffun end-prompt ( edit ))
;OCL}}}
(begin-prompt-macro begin-prompt)
(end-prompt-macro end-prompt)
;OCL}}}

;OCL{{{  code for not builtin commands
;OCL{{{  variables
( defvar ( push-noparse ) )
;OCL}}}
;OCL{{{  @use for libraries
@use
 ( FORCE-DOT-SPACES ; fill-paragraph should always use '  ' after '.'
 )
;OCL}}}
( overload-prefix ( emori- ) )
;OCL{{{  set-display-mode ; not staying in loop
( defmac set-display-mode- ( set-display-mode ) )
( undeclare ( set-display-mode ) )
( deffun set-display-mode
   ( local
      ( modify-behaviour )
      ( set modify-behaviour 1
        set-display-mode-
      )
   )
)
( undeclare ( set-display-mode- ) )
;OCL}}}
;OCL{{{  help
@use ( REF-TREE EMacs-Reference-Card-REF EMacs-Reference-Card-TREE )
@lib emacs-fun/ref.ocl
@use not( REF-TREE EMacs-Reference-Card-REF EMacs-Reference-Card-TREE )
( deffun emori-help
   ( if last-message M_ANY_Q ( ) fi
     screen-off
     help
     screen-on
     case
      ( last-message M_ANY_Q ( insert-ascii ref-call-i-back ) )
     default
      ( newline-and-indent
        set prompting true
        EMacs-Reference-Card
        set prompting false
      )
     esac
   )
)
;OCL}}}
;OCL{{{  error-buff
@lib error-buff
( deffun emori-open-error-buffer
   ( if read-repeat () fi
     set prompting true
     open-error-buffer
     set prompting false
   )
)
;OCL}}}
;OCL{{{  prefix-noparse functions
;OCL{{{  check-buff-arg
( deffun check-buff-arg
   ( if >(read-repeat 0)
      ( add-mode-no-parse
        if ocl-argument
         ( set push-noparse current-buffer-number )
        fi
      )
     fi
   )
)
;OCL}}}
;OCL{{{  reset-pushed-noparse
( deffun reset-pushed-noparse
   ( case
      ( =(push-noparse 0) ( return-from-macro ) )
      ( =(push-noparse -(current-buffer-number 1))
        ;OCL{{{  restore last and current
        ( screen-off
          save-buffer-layout
          goto-buffer-number push-noparse
          delete-mode-no-parse
          goto-buffer-number +(push-noparse 1)
          restore-buffer-layout
          delete-mode-no-parse
          screen-on
          redraw-display
        )
        ;OCL}}}
      )
      ( =(push-noparse current-buffer-number)
        ;OCL{{{  restore current
        ( delete-mode-no-parse )
        ;OCL}}}
      )
     esac
     set push-noparse 0
   )
)
;OCL}}}

( deffun emori-open-buffer ( check-buff-arg open-buffer ) )
( deffun emori-open-adjacent-buffer ( check-buff-arg open-adjacent-buffer ) )
( deffun emori-read-file ( check-buff-arg read-file ) )

( undeclare ( check-buff-arg ) )
;OCL}}}
@lib np-file
@lib delchar
@lib overwdel
@lib error
@lib next-char
@lib pre-char
@lib skippara
;OCL{{{  fill-para
@lib fillpara
;OCL{{{  emori-set-fill-column
( deffun emori-set-fill-column
   ( set prompting true
     set-fill-column
     set prompting false
   )
)
;OCL}}}
;OCL}}}
@lib go-match
@lib trans-char
@lib wordmacs
@lib buff-chg
;OCL{{{  listbuff
@lib listbuff
( deffun emori-list-buffers
   ( set prompting true
     list-buffers
     set prompting false
   )
)
;OCL}}}
@lib buff-size
;OCL{{{  tags
@use ( E-G-T-BUFF F-G-T-BUFF S-U-T-FILE T-COMP )
@lib tags-mac
;OCL{{{  emori-enter-and-go-tags-buffer
( deffun emori-enter-and-go-tags-buffer
   ( set prompting true
     enter-and-go-tags-buffer
     set prompting false
   )
)
;OCL}}}
;OCL{{{  emori-find-and-go-tags-buffer
( deffun emori-find-and-go-tags-buffer
   ( set prompting true
     find-and-go-tags-buffer
     set prompting false
   )
)
;OCL}}}
;OCL{{{  emori-set-user-tags-file
( deffun emori-set-user-tags-file
   ( set prompting true
     set-user-tags-file
     set prompting false
   )
)
;OCL}}}
@use not( E-G-T-BUFF F-G-T-BUFF S-U-T-FILE T-COMP )
;OCL}}}
@lib filetagc
;OCL{{{  emori-enter-fold
@lib search-enter
( defmac emori-enter-fold ( search-and-enter-fold ) )
;OCL}}}
;OCL{{{  exit
@lib exit
;OCL{{{  emori-exit-origami
( deffun emori-exit-origami
   ( if not(in-prompt)
      ( set prompting true
        exit-origami
        set prompting false
      )
     fi
   )
)
;OCL}}}
( undeclare ( exit-origami ) )
;OCL}}}
;OCL{{{  motion
;OCL{{{  backward-sentence
( defvar ( point-not-found ) )
( deffun backward-sentence
   ( if not(test-text) ( failed ) fi
     set point-not-found 1
     ;OCL{{{  search '.  '
     do
      ( do
         ;OCL{{{  skip char and roff-comment
         ( previous-text-character
           if test-top ( failed ) fi
           if and(test-char ". test-begin-line)
            ( previous-text-character )
           fi
           if not(or(test-char-set space test-char ". ))
            ( set point-not-found 0 )
           fi
         )
         ;OCL}}}
        while or(point-not-found not(test-char ". ))
        forward-character
        if test-char-set space
         ( forward-character
           if not(test-char-set space )
            ( backward-character
              backward-character
            )
           fi
         )
        else
         ( backward-character
         )
        fi
      )
     while not(test-char-set space )
     ;OCL}}}
     while or(test-char-set space and(test-char ". test-begin-line))
      ( if and(test-char ". test-begin-line) ( end-of-line ) fi
        forward-text-character
        if test-bottom ( failed ) fi
      )
   )
)
( undeclare ( point-not-found ) )
;OCL}}}
;OCL{{{  forward-sentence
( deffun forward-sentence
   ( if not(test-text) ( failed ) fi
     ;OCL{{{  search ".  "
     do
      (
        ;OCL{{{  search the next .
        do
         ( if test-char ".
            ( next-line
              beginning-of-line
            )
           else
            ( do
               ( if test-bottom ( failed ) fi
                 forward-text-character
               )
              while not(test-char ".)
            )
           fi
         )
        while test-begin-line
        ;OCL}}}
        forward-character
        if test-char-set space ( forward-character ) fi
      )
     while not(test-char-set space )
     ;OCL}}}
     ;OCL{{{  move to following non-space-char
     while or(test-char-set space and(test-char ". test-begin-line))
      ( if and(test-char ". test-begin-line) ( end-of-line ) fi
        forward-text-character
        if test-bottom ( failed ) fi
      )
     ;OCL}}}
   )
)
;OCL}}}
;OCL{{{  go-to-line
(defvar (ln))

(deffun go-to-line
(
  set ln read-repeat
  if >(ln 0) (goto-line-counter ln)
  else (goto-line) fi
))
;OCL}}}
;OCL}}}
;OCL{{{  editing
;OCL{{{  mode autoindent
;OCL{{{  variables
( defvar ( no-auto-indent ) )
;OCL}}}
;OCL{{{  modestrings
( defmodestring AI "Autoindent "Ai )
( deffun update-ai-statline
   ( if no-auto-indent
      ( reset-user-mode AI )
     else
      ( set-user-mode AI ) fi
   )
)
;OCL}}}
;OCL{{{  add-mode-autoindent
( deffun add-mode-autoindent ( set no-auto-indent false update-ai-statline ) )
;OCL}}}
;OCL{{{  delete-mode-autoindent
( deffun delete-mode-autoindent ( set no-auto-indent true update-ai-statline ) )
;OCL}}}
;OCL}}}
;OCL{{{  emori-newline-and-indent
@lib delspaces
( deffun emori-newline-and-indent
   ( if or(in-prompt not(no-auto-indent) not(test-text))
      ( newline-and-indent )
     else
      ( newline-and-indent
        "$
        goto-counter 1
        delspaces
        delete-character
      )
     fi
   )
)
;OCL}}}
;OCL{{{  delete-word-backward
(deffun delete-word-backward
(
  ;OCL{{{  go back one character in text
  if test-begin-line
  (
    if test-top ( return-from-macro ) fi
    previous-line
    end-of-line
  )
  else
  (
    backward-character
  ) fi
  ;OCL}}}
  ;OCL{{{  delete white space
  while not(test-char-set word-char)
  (
    if test-begin-line
    (
      if test-top ( return-from-macro ) fi
      previous-line end-of-line
    )
    else
    (
      delete-character
      backward-character
    )
    fi
  )
  ;OCL}}}
  ;OCL{{{  delete word
  while test-char-set word-char
  (
    delete-character
    if test-begin-line (return-from-macro) fi
    backward-character
  )
  ;OCL}}}
  ;OCL{{{  move forward to beginning of word
  forward-character
  ;OCL}}}
))
;OCL}}}
;OCL{{{  delete-word
(deffun delete-word
(
  ; perhaps I should better fill up to the previous x position
  if test-end-line (delete-character " ) fi
  ;OCL{{{  delete word
  while and(test-text test-char-set word-char)
  (
    if test-end-line (return-from-macro)
    else (delete-character) fi
  )
  ;OCL}}}
  ;OCL{{{  delete white space
  while and(test-text not(test-char-set word-char))
  (
    if test-end-line (return-from-macro)
    else (delete-character) fi
  )
  ;OCL}}}
))
;OCL}}}
;OCL}}}
;OCL{{{  c-mode
(defvar (c-mode))
;OCL{{{  add/delete c-mode
(defmodestring CM "C-mode "C )
;OCL{{{  add-mode-c
(deffun add-mode-c
(
  if not(in-prompt)
  (
    set c-mode 1
    set-user-mode CM
    defset word-char c-word-char
  )
  fi
))
;OCL}}}
;OCL{{{  delete-mode-wrap
(deffun delete-mode-c
(
  if not(in-prompt)
  (
    set c-mode 0
    reset-user-mode CM
    defset word-char text-word-char
  )
  fi
))
;OCL}}}
;OCL}}}
;OCL{{{  paired-parens
(deffun paired-parens (
  "(
  if and(>(c-mode 0) not(in-prompt))
  (
    ")
    backward-character
  )
  fi
))
;OCL}}}
;OCL{{{  paired-brackets
(deffun paired-brackets
(
  "[

  if and(>(c-mode 0) not(in-prompt))
  (
    "]
    backward-character
  )
  fi
))
;OCL}}}
;OCL{{{  paired-curly-brackets
( defvar ( x_pos_cb ) )
(deffun paired-curly-brackets
(
  if or(in-prompt,not(test-text),<=(c-mode 0))
  (
    "{
  )
  else
  (
    ;OCL{{{  handle begin/end-fold/fold/prompt
    case
      (or(test-begin-fold,test-top)  (end-of-line newline-and-indent))
      (or(test-end-fold,test-bottom) (beginning-of-line newline-and-indent previous-line))
    esac
    ;OCL}}}
    ;OCL{{{  correct position?
    set x_pos_cb store-pos
    beginning-of-line
    if test-char "  (
      goto-counter x_pos_cb
    ) else (
      end-of-line
      newline-and-indent
    ) fi
    ;OCL}}}
    "{ newline-and-indent "}
    previous-line
    end-of-line
    newline-and-indent
    forward-character forward-character
  )
  fi
))
;OCL}}}
;OCL{{{  paired-doublequotes
(deffun paired-doublequotes
(
  ""
  if and(>(c-mode 0) not(in-prompt))
  (
    ""
    backward-character
  )
  fi
))
;OCL}}}
;OCL{{{  paired-singlequotes
(deffun paired-singlequotes
(
  "'
  if and(>(c-mode 0) not(in-prompt))
  (
    "'
    backward-character
  )
  fi
))
;OCL}}}
;OCL{{{  semicolon
( defvar ( x_pos_sem ) )
(deffun semicolon
(
  if or(<=(c-mode 0) in-prompt) ("; )
  else
  (
    end-of-line
    backward-character
    if not(test-char ";)
    (
      if not(test-char " ) (forward-character) fi
      ";
    )
    fi
    beginning-of-line
    set x_pos_sem store-pos
    next-line
    beginning-of-line
    if test-char-set space (previous-line beginning-of-line next-line)
    else
    (
      set x_pos_sem -(x_pos_sem store-pos)
      if >(x_pos_sem 0) (previous-line end-of-line newline-and-indent) fi
    )
    fi
  )
  fi
))
;OCL}}}
;OCL{{{  make-it
(deffun make-it
(
  if not(in-prompt)
  (
    save-file
    local ( force-bourne-shell )
    ( set force-bourne-shell true
      shell-command "make newline-and-indent
    )
  )
  fi
))
;OCL}}}
;OCL{{{  compile-it
(deffun compile-it
(
  if not(in-prompt)
  (
    save-file
    local ( force-bourne-shell )
    ( set force-bourne-shell true
      shell-command "cc "  "$ORIGAMIFILE newline-and-indent
    )
  )
  fi
))
;OCL}}}
;OCL{{{  beautify-c-code
(deffun beautify-c-code
(
  if not(in-prompt)
  ( local ( force-bourne-shell )
    ( set force-bourne-shell true
      filter-buffer "cb newline-and-indent
    )
  )
  fi
))
;OCL}}}
;OCL}}}
;OCL{{{  check-out
(deffun check-out
(
  if not(in-prompt)
  (
    delete-mode-view
    local ( force-bourne-shell )
    ( set force-bourne-shell true
      shell-command "co "  "-l "  "$ORIGAMIFILE newline-and-indent
    )
  )
  fi
))
;OCL}}}
;OCL{{{  check-in
(deffun check-in
(
  if not(in-prompt)
  (
    save-file
    add-mode-view
    local ( force-bourne-shell )
    ( set force-bourne-shell true
      shell-command "ci "  "-u "  "$ORIGAMIFILE newline-and-indent
    )
  )
  fi
))
;OCL}}}
;OCL{{{  spell-it
;OCL{{{  string, displayed during pause
( defmodestring SP "SpellPause "SpellPause )
;OCL}}}
;OCL{{{  pre-spell-edit-command
( defmac pre-spell-edit-command
   ( set prompting false
     set-user-mode SP
   )
)
;OCL}}}
;OCL{{{  get lib
@use ( PRE-SPELL-EDIT-COMMAND )
@lib spell
@use not( PRE-SPELL-EDIT-COMMAND )
;OCL}}}
;OCL{{{  spell-it
(deffun spell-it
   ( set prompting true
     reset-user-mode SP
     spell-buffer
     set prompting false
   )
)
;OCL}}}
;OCL{{{  undeclares
( undeclare ( pre-spell-edit-command ) )
;OCL}}}
;OCL}}}
;OCL{{{  other-buffer
(deffun other-buffer
(
  if =(current-buffer-number used-buffers) (goto-buffer-number 1)
  else (next-buffer)
  fi
))
;OCL}}}
;OCL{{{  regions handling
;OCL{{{  variables
( defvar 16
   ( mark-used
     mark-line-m
     mark-line-no
     mark-buff
     mark-x
   )
)
( defvar
   ( mark-index
     mark-index-base
     mark-help-1
     mark-help-2
     mark-help-3
     mark-max-length
   )
)
;OCL}}}
;OCL{{{  internal functions
;OCL{{{  get-mark-index
( deffun get-mark-index
   ( set mark-index mark-index-base
     repeat 16
      ( if =(mark-buff(mark-index) current-buffer-id)
         ( return-from-macro )
        else
         ( set mark-index modulo(+(mark-index 1) 16) )
        fi
      )
     set mark-used(mark-index) false
     set mark-buff(mark-index) current-buffer-id
     set mark-index-base +(mark-index-base 1)
   )
)
;OCL}}}
;OCL{{{  go-mark-or-no
@lib go-line
( deffun ( m n ) go-mark-or-no
   (
     set go-line-arg n
     go-line
     local
      ( modify-behaviour )
      ( set modify-behaviour true
        goto-line-mark m
      )
   )
)
;OCL}}}
;OCL{{{  set-mark
( deffun set-mark
   ( set mark-line-m(mark-index) store-line-mark
     set mark-line-no(mark-index) store-line
     set mark-x(mark-index) +(store-pos set-space-enter)
     set mark-used(mark-index) true
   )
)
;OCL}}}
;OCL{{{  region-op
@lib regions
( deffun ( op ) region-op
   ( get-mark-index
     ;OCL{{{  check view mode
     if test-view ( "  return-from-macro ) fi
     ;OCL}}}
     ;OCL{{{  check set mark
     if not(mark-used(mark-index))
      ( message ( "No "  "mark "  "set! )
        return-from-macro
      )
     fi
     ;OCL}}}
     screen-off
     ;OCL{{{  get real adresses of selected region
     set-start-mark
     end-of-line
     set mark-max-length store-pos
     go-mark-or-no(mark-line-m(mark-index) mark-line-no(mark-index))
     goto -(mark-x(mark-index) set-space-enter)
     set-end-mark
     end-of-line
     if >(store-pos mark-max-length) ( set mark-max-length store-pos ) fi
     ;OCL}}}
     ;OCL{{{  fold region
     ;OCL{{{  correct mark positions (spot is left from the marked char)
     ;OCL{{{  calc -1 for one of the marks
     case
      ;OCL{{{  c over m, left end
      ( >(end-y start-y) ( set end-x -(end-x 1) ) )
      ;OCL}}}
      ;OCL{{{  c under m, left start
      ( >(start-y end-y) ( set start-x -(start-x 1) change-mark-counters ) )
      ;OCL}}}
      ;OCL{{{  start behind m, left start
      ( >(start-x end-x) ( set start-x -(start-x 1) change-mark-counters ) )
      ;OCL}}}
      ;OCL{{{  start before m, left end
      ( >(end-x start-x) ( set end-x -(end-x 1) ) )
      ;OCL}}}
      ;OCL{{{  same position and create-fold -> do at position
      ( =(op no-operation)
         ( goto start-x
           create-fold
           create-fold
           screen-on
           redraw-display
           return-from-macro
         )
      )
      ;OCL}}}
     default
      ;OCL{{{  error
      ( screen-on
        redraw-display
        message ( "empty "  "region )
        return-from-macro
      )
      ;OCL}}}
     esac
     ;OCL}}}
     ;OCL{{{  end-x <= linestart -> previous line
     if
        or
         ( <=(end-x 0)
           pre
            ( set go-line-arg end-y go-line beginning-of-line )
              or (>(store-pos end-x) test-end-line)
         )
      ( set end-y -(end-y 1)
        set end-x mark-max-length
      )
     fi
     ;OCL}}}
     ;OCL}}}
     fold-region
     if folderr
      ( screen-on
        redraw-display
        message ( M_FOLDERR )
        return-from-macro
      )
     fi
     ;OCL}}}
     set mark-used(mark-index) false
     case
      ;OCL{{{  no-operation -> ready
      ( =(op no-operation)
         ( set-mark
           screen-on
           redraw-display
           return-from-macro
         )
      )
      ;OCL}}}
      ;OCL{{{  copy-to-kill-buffer -> do and restore old
      ( =(op copy-to-kill-buffer)
         (
           ;OCL{{{  copy-kill all lines
           enter-fold
           while not(test-bottom)
            ( copy-to-kill-buffer
              next-line
            )
           exit-fold
           ;OCL}}}
           unfold-fold
           ;OCL{{{  maybe combine start
           if <>(start-splitted 0)
            ( combine-splitted-parts-start )
           fi
           ;OCL}}}
           ;OCL{{{  maybe combine end
           if <>(end-splitted 0)
            ( combine-splitted-parts-end )
           fi
           ;OCL}}}
           set-mark
           screen-on
           redraw-display
           return-from-macro
         )
      )
      ;OCL}}}
     default
      ;OCL{{{  kill and delete-line
      ( if =(op delete-line)
         ( delete-line )
        else
         ;OCL{{{  kill all lines
         ( enter-fold
           while not(test-bottom)
            ( kill-line )
           exit-fold
           unfold-fold
         )
         ;OCL}}}
        fi
        ;OCL{{{  maybe join lines
        if and(<>(start-splitted 0) <>(end-splitted 0))
         ( combine-splitted-parts-start )
        fi
        ;OCL}}}
        set-mark
        screen-on
        redraw-display
        return-from-macro
      )
      ;OCL}}}
     esac
   )
)
;OCL}}}
;OCL}}}
;OCL{{{  emori-set-mark
( deffun emori-set-mark
   ( get-mark-index
     set-mark
     message ( "[Mark "  "set] )
   )
)
;OCL}}}
;OCL{{{  change-mark-and-position
( deffun change-mark-and-position
   ( get-mark-index
     if mark-used(mark-index)
      ;OCL{{{  change
      ( set mark-help-1 mark-line-m(mark-index)
        set mark-help-2 mark-line-no(mark-index)
        set mark-help-3 mark-x(mark-index)
        set-mark
        go-mark-or-no(mark-help-1 mark-help-2)
        goto -(mark-help-3 set-space-enter)
      )
      ;OCL}}}
     else
      ;OCL{{{  set
      ( set-mark )
      ;OCL}}}
     fi
     message ( "[Mark "  "set] )
   )
)
;OCL}}}
;OCL{{{  emori-copy-region
( deffun emori-copy-region
   (
     ;OCL{{{  store view-mode
     set mark-help-1 false
     if test-view
      ( set mark-help-1 true
        delete-mode-view
      )
     fi
     ;OCL}}}
     ;OCL{{{  store change-mode
     set mark-help-2 counter test-file-changed
     ;OCL}}}
     region-op(copy-to-kill-buffer)
     ;OCL{{{  restore change-mode
     if not(mark-help-2)
      ( set-file-unchanged )
     fi
     ;OCL}}}
     ;OCL{{{  store view-mode
     if mark-help-1
      ( add-mode-view )
     fi
     ;OCL}}}
   )
)
;OCL}}}
;OCL{{{  emori-kill-region
( deffun emori-kill-region ( region-op(kill-line) ) )
;OCL}}}
;OCL{{{  emori-delete-region
( deffun emori-delete-region ( region-op(delete-line) ) )
;OCL}}}
;OCL{{{  emori-fold-region
( deffun emori-fold-region
   ( case
      ( test-folding ( create-fold ) )
     default
      ( region-op(no-operation) )
     esac
   )
)
;OCL}}}
;OCL{{{  emori-highlight-region
( defvar ( h-r-chg-pos ) )
( deffun emori-highlight-region
   ( if not(test-folding)
      ( screen-off
        change-mark-and-position
        if
         ;OCL{{{  mark is after cursor
           or
            ( >(store-line mark-line-no(mark-index))
              and
               ( =(store-line mark-line-no(mark-index))
                 >(+(store-pos set-space-enter) mark-x(mark-index))
               )
            )
         ;OCL}}}
         ;OCL{{{  move back
         ( if =(store-pos 1)
            ( previous-line
              end-of-line
              set h-r-chg-pos 1
            )
           else
            ( backward-character
              set h-r-chg-pos -1
            )
           fi
         )
         ;OCL}}}
        else
         ;OCL{{{  no correctionmove for cursor
         ( set h-r-chg-pos 0 )
         ;OCL}}}
        fi
        ;OCL{{{  start highlight
        local
         ( modify-behaviour )
         ( set modify-behaviour -2
           create-fold
         )
        ;OCL}}}
        ;OCL{{{  if cursor-mark, move forward one char
        case
         ( >(h-r-chg-pos 0)  ( next-line goto 1 ) )
         ( <>(h-r-chg-pos 0) ( forward-character ) )
        esac
        ;OCL}}}
        ;OCL{{{  move back to calling position
        change-mark-and-position
        ;OCL}}}
        screen-on
        redraw-display
        ;OCL{{{  if highlighted display, delay and redraw afterwards
        if test-folding
         ( if =(h-r-chg-pos 0)
            ;OCL{{{  move back
            ( if =(store-pos 1)
               ( previous-line
                 end-of-line
                 set h-r-chg-pos 1
               )
              else
               ( backward-character
                 set h-r-chg-pos -1
               )
              fi
            )
            ;OCL}}}
           else
            ;OCL{{{  no correctionmove for cursor
            ( set h-r-chg-pos 0 )
            ;OCL}}}
           fi
           show-cursor +(5 *(10 +(read-repeat 1)))
           create-fold
           ;OCL{{{  if cursor-mark, move forward one char
           case
            ( >(h-r-chg-pos 0)  ( next-line goto 1 ) )
            ( <>(h-r-chg-pos 0) ( forward-character ) )
           esac
           ;OCL}}}
         )
        fi
        ;OCL}}}
      )
     fi
   )
)
( undeclare ( h-r-chg-pos ) )
;OCL}}}
;OCL{{{  undeclares
( undeclare
   ( mark-used
     mark-line-m
     mark-line-no
     mark-buff
     mark-index
     mark-index-base
     mark-x
     mark-help-1
     mark-help-2
     mark-help-3
     mark-max-length
     region-op
     get-mark-index
   )
)
;OCL}}}
;OCL}}}
;OCL{{{  emori-exit-buffer
(deffun emori-exit-buffer(if =(used-buffers 1)(message(M_NO_BUFFERS))else(exit-buffer)fi))
;OCL}}}
;OCL{{{  emori-go-mouse-position
@lib go-mouse
;OCL{{{  variables
( defvar
   ( mouse-click-time
     mouse-clicked-x
     mouse-clicked-y
     mouse-moved
     mouse-down
     mouse-down-x
     mouse-down-y
     mouse-up-x
     mouse-up-y
   )
)
;OCL}}}
( deffun emori-go-mouse-position
   ( go-mouse-position
     if mouse-b
      ;OCL{{{  go to and store down event/down-movement
      ( set mouse-moved ocl-argument
        set mouse-click-time +(mouse-click-time 1)
        set mouse-down true
        set mouse-down-x store-pos
        set mouse-down-y store-line-mark
      )
      ;OCL}}}
     else
      ;OCL{{{  go and handle mark-set or open/close
      ( if or(ocl-argument mouse-moved <>(mouse-click-time -(key-count 1)))
         ;OCL{{{  additional single click action
         ( if and(mouse-down ocl-argument)
            ;OCL{{{  set mark at first position
            ( screen-off
              set mouse-up-x store-pos
              set mouse-up-y store-line-mark
              goto-line-mark mouse-down-y
              goto mouse-down-x
              emori-set-mark
              goto-line-mark mouse-up-y
              goto mouse-up-x
              screen-on
              set mouse-down false
              redraw-display
              message ( "[mouse-down: "  "Mark "  "set] )
            )
            ;OCL}}}
           fi
           set mouse-moved 0
         )
         ;OCL}}}
        else
         ;OCL{{{  additional double click action
         ( case
            ;OCL{{{  fold -> open
            ( test-fold-line ( open-fold ) )
            ;OCL}}}
            ;OCL{{{  filed-fold -> enter
            ( test-filed ( enter-fold ) )
            ;OCL}}}
           default
            ;OCL{{{  close or exit
            ( if last-message M_USE_EXIT () fi
              if last-message M_TOP () fi
              close-fold
              if or(last-message M_USE_EXIT last-message M_TOP)
               ( exit-fold )
              fi
            )
            ;OCL}}}
           esac
           ; message "double
         )
         ;OCL}}}
        fi
        set mouse-click-time key-count
      )
      ;OCL}}}
     fi
   )
)
;OCL{{{  undeclares
( undeclare
   ( mouse-click-time
     mouse-clicked-x
     mouse-clicked-y
     mouse-moved
     mouse-down
     mouse-down-x
     mouse-down-y
     mouse-up-x
     mouse-up-y
   )
)
;OCL}}}
;OCL}}}
;OCL{{{  emori-redraw-display
( deffun emori-redraw-display
   ( local
      ( ocl-argument )
      ( set ocl-argument cursor-level
        screen-off
        center-and-redraw-display
        set-cursor-line ocl-argument
        screen-on
        redraw-display
      )
   )
)
;OCL}}}
;OCL{{{  emori-delete-line
( defvar ( em-d-l-x emori-delete-line-skip-newline ) )
( deffun emori-delete-line
   ( if test-end-line
      ;OCL{{{  join or delete
      ( set em-d-l-x store-pos
        beginning-of-line
        if test-end-line
         ;OCL{{{  handle a empty line
         ( if emori-delete-line-skip-newline
            ;OCL{{{  delete it, without moving it to a buffer
            ( delete-line
              pop-delete-buffer
              set emori-delete-line-skip-newline false
            )
            ;OCL}}}
           else
            ;OCL{{{  kill/delete the empty line
            ( if modify-behaviour
               ( kill-line )
              else
               ( delete-line )
              fi
            )
            ;OCL}}}
           fi
           screen-off
           goto 1
           while <(store-pos em-d-l-x)
            ( if last-message M_ERR_PO () fi
              "  ;
              if last-message M_ERR_PO ( forward-character ) fi
            )
           screen-on
           refresh-line
         )
         ;OCL}}}
        else
         ;OCL{{{  join lines
         ( goto em-d-l-x
           raw-delete-character
         )
         ;OCL}}}
        fi
      )
      ;OCL}}}
     else
      ;OCL{{{  delete rest of line
      ( delete-to-end-of-line
        set emori-delete-line-skip-newline true
      )
      ;OCL}}}
     fi
   )
)
( undeclare ( em-d-l-x emori-delete-line-skip-newline ) )
;OCL}}}
;OCL{{{  emori-kill-line
( deffun emori-kill-line
   ( if not(in-prompt)
      ( local
         ( modify-behaviour )
         ( set modify-behaviour true
           emori-delete-line
         )
      )
     fi
   )
)
;OCL}}}
;OCL{{{  emori-delete-character
( defvar ( d-c-x ) )
( deffun emori-delete-character
   ( if or(in-prompt test-overwrite)
      ( delete-character )
     else
      ( set d-c-x store-pos
        if and(test-end-line pre ( beginning-of-line ) test-end-line)
         ( delete-line
           pop-delete-buffer
         )
        else
         ( goto d-c-x
           delete-character
         )
        fi
        while <(store-pos d-c-x)
         ( "  )
      )
     fi
   )
)
( undeclare ( d-c-x ) )
;OCL}}}
;OCL{{{  funny functions
( demand-load
   ( ( defmac SOKOBAN-RESET-KBD ( edit ) )
     @lib sokoban
     ( undeclare ( SOKOBAN-RESET-KBD ) )
     @lib towers
     ( undeclare ( towers-of-hanoi ) )
     ( defmac towers-of-hanoi ( tower-display ) )
     ( undeclare ( tower-display ) )
   )
)
;OCL}}}
;OCL}}}

;OCL{{{  hooks
;OCL{{{  read-new-file-hook
(defvar (first-read-newfile startup-x ))
;OCL{{{  start-up
(demand-load (
  (deffun start-up
  (
    ;OCL{{{  ocl-argument and modes
    if =(ocl-argument -1)
    ( add-mode-time
    ) else
    (
      ;OCL{{{  handle ocl-argument
      do
      (
        set startup-x ocl-argument
        ;OCL{{{  time
        if >=(startup-x 64)
        (
          set startup-x -(startup-x 64)
        ) else
        (
          add-mode-time
        ) fi
        ;OCL}}}
        ;OCL{{{  ai
        if >=(startup-x 32)
        (
          delete-mode-autoindent
          set startup-x -(startup-x 32)
        ) else
        (
          add-mode-autoindent
        ) fi
        ;OCL}}}
        ;OCL{{{  regular expressions
        if >=(startup-x 16)
        (
          add-mode-basic-regular-expression
          set startup-x -(startup-x 16)
        ) else
        (
          if >=(startup-x 8)
          (
            add-mode-extended-regular-expression
            set startup-x -(startup-x 8)
          ) else
          (
            delete-mode-regular-expression
          ) fi
        ) fi
        ;OCL}}}
        ;OCL{{{  posi
        if >=(startup-x 4)
        (
          add-mode-position
          set startup-x -(startup-x 4)
        ) else
        (
          delete-mode-position
        ) fi
        ;OCL}}}
        ;OCL{{{  c
        if >=(startup-x 2)
        (
          add-mode-c
          set startup-x -(startup-x 2)
        ) else
        (
          delete-mode-c
        ) fi
        ;OCL}}}
        ;OCL{{{  full shift
        if >=(startup-x 1)
        (
          add-mode-full-shift
          set startup-x -(startup-x 1)
        ) else
        (
          delete-mode-full-shift
        ) fi
        ;OCL}}}
        ;OCL{{{  error detection
        if <>(startup-x 0)
        (
          set first-read-newfile -1
          set ocl-argument 0
        ) fi
        ;OCL}}}
      ) while <>(startup-x 0)
      ;OCL}}}
    ) fi
    ;OCL}}}
    update-ai-statline
  ))
))
;OCL}}}
( deffun read-new-file-hook
(
  ;OCL{{{  startup
  if =(first-read-newfile 0)
  ( start-up
    load-function not( start-up )
  ) fi
  ;OCL}}}
  ;OCL{{{  set flags,modes,...
  reset-pushed-noparse
  ;OCL}}}
  ;OCL{{{  maybe startup complain msg
  case
   ;OCL{{{  first-read-newfile==-1 ->show error for -O
   ( =(first-read-newfile -1)
     ( set first-read-newfile 1
       message-exit ( "[ "invalid "  "initialization, "  "using "  "default! "] )
     )
   )
   ;OCL}}}
   ;OCL{{{  first-read-newfile==0  ->show error-list msg
   ( =(first-read-newfile 0)
     ( set first-read-newfile 1
       message-exit ( history error-list )
     )
   )
   ;OCL}}}
  esac
  set first-read-newfile 1
  ;OCL}}}
))
(undeclare (first-read-newfile startup-x))
;OCL}}}
;OCL{{{  abort-hook
( forward lib-abort-hooks )
( deffun abort-hook (
   set modify-behaviour 0
   lib-abort-hooks
   set prompting false
   end-prompt
   reset-pushed-noparse
   if and(test-folding <>(ocl-argument 0)) ( create-fold ) fi
   message-exit ( M_ABORTED )
) )
;OCL}}}
(abort-macro abort-hook)
(read-newfile-macro read-new-file-hook)
;OCL}}}

;OCL{{{  abort
(keybind abort (C-G))
;OCL}}}
;OCL{{{  keytable edit-or
(mode edit
;OCL{{{  motion
;OCL{{{  basic cursor
(keybind backward-character (C-B))
(terminal
  @lib emacs-fun/em-term-list
  (keybind backward-character ($left))
)

(keybind forward-character (C-F))
(terminal
  @lib emacs-fun/em-term-list
  (keybind forward-character ($right))
)

(keybind previous-line (C-P))
(terminal
  @lib emacs-fun/em-term-list
  (keybind previous-line ($up))
)

(keybind next-line (C-N))
(terminal
  @lib emacs-fun/em-term-list
  (keybind next-line ($down))
)
;OCL}}}
;OCL{{{  wordwise
(keybind backward-word (M-"b))
(keybind forward-word (M-"f))
;OCL}}}
;OCL{{{  sentence-wise
(keybind backward-sentence (M-"B))
(keybind forward-sentence (M-"F))
;OCL}}}
;OCL{{{  paragraph-wise
(keybind previous-paragraph (M-"p))
(keybind next-paragraph (M-"n))
;OCL}}}
;OCL{{{  page-wise
(keybind previous-page (M-"v))
(terminal
  @lib emacs-fun/em-term-list
  (keybind previous-page ($prev_page))
)

(keybind next-page (C-V))
(terminal
  @lib emacs-fun/em-term-list
  (keybind next-page ($next_page))
)
;OCL}}}
;OCL{{{  beginning/end of a line
(keybind beginning-of-line (C-A))
(terminal
  @lib emacs-fun/em-term-list
  (keybind beginning-of-line ($begin))
)

(keybind end-of-line (C-E))
(terminal
  @lib emacs-fun/em-term-list
  (keybind end-of-line ($end))
)
;OCL}}}
;OCL{{{  beginning/end of a fold
(keybind beginning-of-fold (M-"<))
(terminal
  @lib emacs-fun/em-term-list
  (keybind beginning-of-fold ($home))
)

(keybind end-of-fold (M-">))
;OCL}}}
;OCL{{{  go-to-line
(keybind go-to-line (M-"g))
;OCL}}}
;OCL{{{  goto-matching-fence
(keybind goto-matching-fence (M-"#))
;OCL}}}
;OCL{{{  open-fold
(keybind open-fold (C-O))
(terminal
  @lib emacs-fun/em-term-list
  (keybind open-fold ($open))
)
;OCL}}}
;OCL{{{  close-fold
(keybind close-fold (C-C))
(terminal
  @lib emacs-fun/em-term-list
  (keybind close-fold ($close))
)
;OCL}}}
;OCL{{{  enter-fold
(keybind emori-enter-fold (M-C-O))
;OCL}}}
;OCL{{{  exit-fold
(keybind exit-fold (M-C-C))
;OCL}}}
;OCL}}}
;OCL{{{  editing
;OCL{{{  newline-and-indent
(keybind emori-newline-and-indent (C-J))
(keybind emori-newline-and-indent (C-M))
;OCL}}}

;OCL{{{  delete-previous-character
(keybind delete-previous-character (C-H))
(terminal
  @lib emacs-fun/em-term-list
  (keybind delete-previous-character ($backspace))
)
;OCL}}}
;OCL{{{  emori-delete-character
(keybind emori-delete-character (C-D))
(keybind emori-delete-character (C-?))
(terminal
  @lib emacs-fun/em-term-list
  (keybind delete-character ($rubout))
)
;OCL}}}

;OCL{{{  delete-word-backward
(keybind delete-word-backward (M-C-H))
;OCL}}}
;OCL{{{  delete-word
(keybind delete-word (M-C-D))
;OCL}}}

;OCL{{{  transpose-characters
(keybind transpose-characters (C-T))
;OCL}}}

;OCL{{{  case-word-capitalize
(keybind case-word-capitalize (M-"c))
;OCL}}}
;OCL{{{  case-word-upper
(keybind case-word-upper (M-"u))
;OCL}}}
;OCL{{{  case-word-lower
(keybind case-word-lower (M-"l))
;OCL}}}

;OCL{{{  emori-delete-line
(keybind emori-delete-line (M-C-K))
(terminal
  @lib emacs-fun/em-term-list
  (keybind emori-delete-line ($delline))
)
;OCL}}}
;OCL{{{  undo-delete-line
(keybind undo-delete-line (M-C-Y))
;OCL}}}
;OCL{{{  emori-kill-line
(keybind emori-kill-line (C-K))
;OCL}}}
;OCL{{{  copy-to-kill-buffer
(keybind copy-to-kill-buffer (M-"k))
;OCL}}}
;OCL{{{  insert-folded-kill-buffer
(keybind insert-folded-kill-buffer (C-Y))
;OCL}}}
;OCL{{{  unfold-fold
(keybind unfold-fold (C-U))
;OCL}}}
;OCL{{{  auto-header
(keybind auto-header (C-X C-H))
;OCL}}}
;OCL{{{  toggle-file-fold
(keybind toggle-file-fold (C-X C-F))
;OCL}}}
;OCL{{{  toggle-attach-file-to-fold
(keybind toggle-attach-file-to-fold (C-X C-A))
;OCL}}}
;OCL}}}
;OCL{{{  regions
;OCL{{{  emori-set-mark
(keybind emori-set-mark (C-@))
;OCL}}}
;OCL{{{  change-mark-and-position
(keybind change-mark-and-position (C-X C-X))
;OCL}}}
;OCL{{{  emori-highlight-region
( keybind emori-highlight-region ( C-X "x ))
;OCL}}}

;OCL{{{  emori-delete-region
(keybind emori-delete-region (M-C-W))
;OCL}}}
;OCL{{{  emori-kill-region
(keybind emori-kill-region (C-W))
;OCL}}}
;OCL{{{  emori-copy-region
(keybind emori-copy-region (M-"w))
;OCL}}}
;OCL{{{  emori-fold-region
( keybind emori-fold-region ( M-C-@ ) )
;OCL}}}
;OCL}}}
;OCL{{{  search & replace
;OCL{{{  search-forward
(keybind search-forward (M-C-S))
;OCL}}}
;OCL{{{  search-reverse
(keybind search-reverse (M-C-R))
;OCL}}}

;OCL{{{  incremental-search-forward
(keybind incremental-search-forward (C-S))
;OCL}}}
;OCL{{{  incremental-search-reverse
(keybind incremental-search-reverse (C-R))
;OCL}}}

;OCL{{{  replace-string
(keybind replace-string (M-"R))
;OCL}}}
;OCL{{{  query-replace-string
(keybind query-replace-string (M-"r))
;OCL}}}
;OCL}}}
;OCL{{{  files
;OCL{{{  insert-file
(keybind insert-file (C-X C-I))
;OCL}}}
;OCL{{{  save-file
(keybind save-file (C-X C-S))
(terminal
  @lib emacs-fun/em-term-list
  (keybind save-file ($save))
)
;OCL}}}
;OCL{{{  write-file
(keybind write-file (C-X C-W))
;OCL}}}
;OCL{{{  emori-read-file
(keybind emori-read-file (C-X C-R))
;OCL}}}

;OCL{{{  next-file
(keybind next-file (C-X C-N))
;OCL}}}
;OCL{{{  previous-file
(keybind previous-file (C-X C-P))
;OCL}}}

;OCL{{{  set-file-unchanged
(keybind set-file-unchanged (M-"~))
;OCL}}}
;OCL}}}
;OCL{{{  tags
;OCL{{{  enter-and-go-tags-buffer
( keybind emori-enter-and-go-tags-buffer ( M-". ) )
;OCL}}}
;OCL{{{  find-and-go-tags-buffer
( keybind emori-find-and-go-tags-buffer ( M-", ) )
;OCL}}}
;OCL{{{  set-user-tags-file
( keybind emori-set-user-tags-file ( C-X "t ) )
;OCL}}}
;OCL}}}
;OCL{{{  macros
;OCL{{{  define-macro
(keybind define-macro (C-X "())
(keybind define-macro (C-X ")))
;OCL}}}
;OCL{{{  execute-macro
(keybind execute-macro (C-X "e))
;OCL}}}
;OCL}}}
;OCL{{{  shell commands
;OCL{{{  shell
(keybind shell (C-X "c))
(terminal
  @lib emacs-fun/em-term-list
  (keybind shell ($shift-command))
)
;OCL}}}
;OCL{{{  shell-command
(keybind shell-command (C-X "!))
(terminal
  @lib emacs-fun/em-term-list
  (keybind shell-command ($command))
)
;OCL}}}
;OCL{{{  filter-buffer
(keybind filter-buffer (C-X "|))
;OCL}}}
;OCL{{{  pipe-to-command
(keybind pipe-to-command (C-X ">))
;OCL}}}
;OCL{{{  pipe-from-command
(keybind pipe-from-command (C-X "<))
;OCL}}}
;OCL{{{  make-it
(keybind make-it (M-"x "m))
;OCL}}}
;OCL{{{  compile-it
(keybind compile-it (M-"x "c))
;OCL}}}
;OCL{{{  beautify-c-code
(keybind beautify-c-code (C-X "i))
;OCL}}}
;OCL{{{  version control interface
;OCL{{{  check-out
(keybind check-out (M-"x "o))
;OCL}}}
;OCL{{{  check-in
(keybind check-in (M-"x "i))
;OCL}}}
;OCL}}}
;OCL{{{  spell-it
(keybind spell-it (M-"x "s))
;OCL}}}
;OCL}}}
;OCL{{{  modes
;OCL{{{  autosave
(keybind add-mode-autosave (C-X "m "a))
(keybind delete-mode-autosave (C-X C-M "a))
;OCL}}}
;OCL{{{  c-mode
(keybind add-mode-c (C-X "m "c))
(keybind delete-mode-c (C-X C-M "c))
;OCL}}}
;OCL{{{  set-display-mode
(keybind set-display-mode ( C-X "m "d ) )
;OCL}}}
;OCL{{{  full-shift
(keybind add-mode-full-shift (C-X "m "f))
(keybind delete-mode-full-shift (C-X C-M "f))
;OCL}}}
;OCL{{{  autoindent
(keybind add-mode-autoindent (C-X "m "i))
(keybind delete-mode-autoindent (C-X C-M "i))
;OCL}}}
;OCL{{{  set-language
(keybind set-language (C-X "m "l))
;OCL}}}
;OCL{{{  regular-expression
(keybind add-mode-basic-regular-expression (C-X "m "m))
(keybind delete-mode-regular-expression (C-X C-M "m))
(keybind add-mode-extended-regular-expression (C-X "m "M))
(keybind delete-mode-regular-expression (C-X C-M "M))
;OCL}}}
;OCL{{{  no-parse
(keybind add-mode-no-parse (C-X "m "n))
(keybind delete-mode-no-parse (C-X C-M "n))
;OCL}}}
;OCL{{{  overwrite
(keybind add-mode-overwrite (C-X "m "o))
(keybind delete-mode-overwrite (C-X C-M "o))
;OCL}}}
;OCL{{{  position
(keybind add-mode-position (C-X "m "p))
(keybind delete-mode-position (C-X C-M "p))
;OCL}}}
;OCL{{{  time
(keybind add-mode-time (C-X "m "t))
(keybind delete-mode-time (C-X C-M "t))
;OCL}}}
;OCL{{{  view
(keybind add-mode-view (C-X "m "v))
(keybind delete-mode-view (C-X C-M "v))
;OCL}}}
;OCL{{{  verbose
(keybind add-mode-verbose (C-X "m "V))
(keybind delete-mode-verbose (C-X C-M "V))
;OCL}}}
;OCL{{{  wrap
(keybind add-mode-wrap (C-X "m "w))
(keybind delete-mode-wrap (C-X C-M "w))
;OCL}}}
;OCL{{{  hash-shift
(keybind add-mode-hash-shift (C-X "m "#))
(keybind delete-mode-hash-shift (C-X C-M "#))
;OCL}}}
;OCL}}}
;OCL{{{  arguments
(keybind set-argument-0 (M-"0))
(keybind set-argument-1 (M-"1))
(keybind set-argument-2 (M-"2))
(keybind set-argument-3 (M-"3))
(keybind set-argument-4 (M-"4))
(keybind set-argument-5 (M-"5))
(keybind set-argument-6 (M-"6))
(keybind set-argument-7 (M-"7))
(keybind set-argument-8 (M-"8))
(keybind set-argument-9 (M-"9))
;OCL}}}
;OCL{{{  special functions
;OCL{{{  redraw-display
(keybind emori-redraw-display (M-C-L))
(terminal
  @lib emacs-fun/em-term-list
  (keybind emori-redraw-display ($refresh))
)
;OCL}}}
;OCL{{{  center-and-redraw-display
(keybind center-and-redraw-display (C-L))
;OCL}}}

;OCL{{{  emori-help
(keybind emori-help (M-"?))
(terminal
  @lib emacs-fun/em-term-list
  (keybind emori-help ($help))
)
;OCL}}}
;OCL{{{  describe-bindings
(keybind describe-bindings (C-X "?))
(terminal
  @lib emacs-fun/em-term-list
  (keybind describe-bindings ($shift-help))
)
;OCL}}}
;OCL{{{  describe-fold
(keybind describe-fold (C-X "=))
;OCL}}}
;OCL{{{  quote-character
(keybind quote-character (C-Q))
;OCL}}}
;OCL{{{  filename-or-tag-completion
(keybind filename-or-tag-completion (M-C-I))
;OCL}}}
;OCL{{{  fill functions
;OCL{{{  fill-paragraph
(keybind fill-paragraph (M-"q))
;OCL}}}
;OCL{{{  emori-set-fill-column
(keybind emori-set-fill-column (C-X "f))
;OCL}}}
(keybind wrap-word (" ))
;OCL}}}
;OCL}}}
;OCL{{{  buffers
(keybind emori-list-buffers (C-X C-B))
(terminal
  @lib emacs-fun/em-term-list
  (keybind emori-list-buffers ($select))
)

(keybind change-buffername (C-X "b))

;OCL{{{  opening and closing buffers
(keybind emori-open-error-buffer (C-X "@))
(keybind emori-open-buffer (C-X "2))
(keybind emori-open-adjacent-buffer (C-X "3))
(keybind emori-exit-buffer (C-X "0))
;OCL}}}
;OCL{{{  changing between buffers
(keybind previous-buffer (M-C-X "p))
(keybind next-buffer (M-C-X "n))
(keybind other-buffer (C-X "o))
(keybind up-buffer (M-C-X C-P))
(keybind down-buffer (M-C-X C-N))
(keybind left-buffer (M-C-X C-B))
(keybind right-buffer (M-C-X C-F))
;OCL}}}

;OCL{{{  full-size-buffer
(keybind full-size-buffer (C-X "1))
;OCL}}}
;OCL{{{  grow-buffer
(keybind grow-buffer (M-C-X "^))
;OCL}}}
;OCL{{{  shrink-buffer
(keybind shrink-buffer (M-C-X "v))
;OCL}}}
;OCL{{{  widen-buffer
(keybind widen-buffer (M-C-X "<))
;OCL}}}
;OCL{{{  narrow-buffer
(keybind narrow-buffer (M-C-X ">))
;OCL}}}
;OCL}}}
;OCL{{{  how to get out
;OCL{{{  emori-exit-origami
(keybind emori-exit-origami (C-X C-C))
(terminal
  @lib emacs-fun/em-term-list
  (keybind emori-exit-origami ($exit))
)
;OCL}}}
;OCL{{{  save-and-exit-origami
(keybind save-and-exit-origami (M-"z))
(terminal
  @lib emacs-fun/em-term-list
  (keybind save-and-exit-origami ($shift-exit))
)
;OCL}}}
;OCL{{{  suspend-origami
(keybind suspend-origami (C-Z))
(terminal
  @lib emacs-fun/em-term-list
  (keybind suspend-origami ($suspend))
)
;OCL}}}
;OCL}}}
;OCL{{{  c-mode bindings
(keybind paired-parens ("( ))
(keybind paired-brackets ("[ ))
(keybind paired-curly-brackets ("{ ))
(keybind paired-doublequotes ("" ))
(keybind paired-singlequotes ("' ))
(keybind semicolon (";))
;OCL}}}
;OCL{{{  funny functions
( keybind sokoban ( M-"x "k ) )
( keybind towers-of-hanoi ( M-"x "t ) )
;OCL}}}
)
;OCL}}}
;OCL{{{  mode prompt/para-meter
(mode para
;OCL{{{  motion
;OCL{{{  backward-character
(keybind backward-character (C-B))
(terminal
  @lib emacs-fun/em-term-list
  (keybind backward-character ($left))
)
;OCL}}}
;OCL{{{  forward-character
(keybind forward-character (C-F))
(terminal
  @lib emacs-fun/em-term-list
  (keybind forward-character ($right))
)
;OCL}}}

;OCL{{{  previous-line
(keybind previous-line (C-P))
(terminal
  @lib emacs-fun/em-term-list
  (keybind previous-line ($up))
)
;OCL}}}
;OCL{{{  next-line
(keybind next-line (C-N))
(terminal
  @lib emacs-fun/em-term-list
  (keybind next-line ($down))
)
;OCL}}}

;OCL{{{  beginning-of-line
(keybind beginning-of-line (C-A))
(terminal
  @lib emacs-fun/em-term-list
  (keybind beginning-of-line ($begin))
)
;OCL}}}
;OCL{{{  end-of-line
(keybind end-of-line (C-E))
(terminal
  @lib emacs-fun/em-term-list
  (keybind end-of-line ($end))
)
;OCL}}}
;OCL}}}
;OCL{{{  editing
;OCL{{{  newline-and-indent
(keybind newline-and-indent (C-J))
(keybind newline-and-indent (C-M))
;OCL}}}

;OCL{{{  raw-delete-previous-character
(keybind raw-delete-previous-character (C-H))
(terminal
  @lib emacs-fun/em-term-list
  (keybind raw-delete-previous-character ($backspace))
)
;OCL}}}
;OCL{{{  raw-delete-character
(keybind raw-delete-character (C-D))
(keybind raw-delete-character (C-?))
(terminal
  @lib emacs-fun/em-term-list
  (keybind raw-delete-character ($rubout))
)
;OCL}}}

;OCL{{{  delete-to-end-of-line
(keybind delete-to-end-of-line (C-K))
(terminal
  @lib emacs-fun/em-term-list
  (keybind delete-to-end-of-line ($clreol))
)
;OCL}}}
;OCL}}}
;OCL{{{  search & replace
;OCL{{{  search-forward
(keybind search-forward (M-C-S))
;OCL}}}
;OCL{{{  search-reverse
(keybind search-reverse (M-C-R))
;OCL}}}

;OCL{{{  incremental-search-forward
(keybind incremental-search-forward (C-S))
;OCL}}}
;OCL{{{  incremental-search-reverse
(keybind incremental-search-reverse (C-R))
;OCL}}}
;OCL}}}
;OCL{{{  macros
;OCL{{{  define-macro
(keybind define-macro (C-X "())
(keybind define-macro (C-X ")))
;OCL}}}
;OCL{{{  execute-macro
(keybind execute-macro (C-X "e))
;OCL}}}
;OCL}}}
;OCL{{{  arguments
(keybind set-argument-0 (M-"0))
(keybind set-argument-1 (M-"1))
(keybind set-argument-2 (M-"2))
(keybind set-argument-3 (M-"3))
(keybind set-argument-4 (M-"4))
(keybind set-argument-5 (M-"5))
(keybind set-argument-6 (M-"6))
(keybind set-argument-7 (M-"7))
(keybind set-argument-8 (M-"8))
(keybind set-argument-9 (M-"9))
;OCL}}}
;OCL{{{  special functions
;OCL{{{  quote-character
(keybind quote-character (C-Q))
;OCL}}}
;OCL{{{  filename-completion
(keybind filename-completion (M-C-I))
;OCL}}}
;OCL}}}
)
;OCL}}}
;OCL{{{  mouse
@if-using not(AMIGA)
   ( mouse-buttons
     emori-go-mouse-position      ; Button 1 up
     no-operation                 ; Button 2 up
     emori-go-mouse-position      ; Button 3 up
     no-operation                 ; Button 4 up
     no-operation                 ; Button 5 up
     emori-go-mouse-position      ; Button 1 down
     no-operation                 ; Button 2 down
     emori-go-mouse-position      ; Button 3 down
   )
@fi
;OCL}}}

;OCL{{{  forwarded libary abort hook
( deffun lib-abort-hooks
   ( @if-using ( ABORT-HOOK-ADD )
        abort-hook-add
     @fi
   )
)
;OCL}}}

;OCL{{{  reference tree
@if-using ( )
;OCL{{{  settings
@start-reference-copy ref-sets
@ref-indent 4 77 10
@ref-top-start-box       -
@ref-top-end-box
@ref-sub-start-box       -
@ref-sub-end-box
@ref-menu 1 quit Quit ret Last next #(Next) prev Prev kill Kill ABCDEFGHIJMORSTUVWXYZ
@ref-class-id 1
@ref-see-also See also in: %s
@end-reference-copy
;OCL}}}
;OCL{{{  reference frame
@start-reference-copy ref
@ref-lib fun/tags-mac.r file-reference
@ref-lib fun/sokoban.r sokoban-call-ref
@ref-lib fun/global-ref regexp-reference cmd-reference
;OCL{{{  @ref-header EMacs-Reference-Card
@ref-title EMacs - Reference Card
@ref-author Michael Haardt
This is the reference file for EMacs, a binding for the folding-editor
Origami.
;OCL}}}
;OCL{{{  EMacs-Reference-Card
;OCL{{{  EMacs Command Line Options
You can use the following commad line options, to control the modes of
EMacs:

@ref-start-tbl Off 10 On 10 Mode 40
-Onotime  @@ -Otime   @@ time display in the statusline
-Onoposi  @@ -Oposi   @@ position display in the statusline
-Onofull  @@ -Ofull   @@ full shifting display
-Onoai    @@ -Oai     @@ autoindent
-Onomagic @@ -Omagic  @@ regular exprsession search
-Onomagic @@ -Oxmagic @@ extended regular expression search
-Onoc     @@ -Oc      @@ c-mode
@ref-end-tbl

You can also use the option '-Odefault' to use the default values:

@ref-start-picture
-Otime -Onoposi -Onofull -Oai -Onomagic -Onoc
@ref-end-picture
;OCL}}}
;OCL{{{  @cmd-opt Origami Command Line Options
;OCL}}}
;OCL{{{  @regexp Origami Regular Expressions
;OCL}}}
;OCL{{{  Messages, errors and prompts
Sometimes EMacs may want to tell you something, like when you did
something which EMacs does not allow. If it is something simple, such
as typing a control key sequence which is not associated with any
command, EMacs will just ignore it. Otherwise, it will also display an
informative error message at the bottom of the screen. Simple messages
are displayed in brackets, prompts will appear without brackets and end
with a question mark.

When starting using verbose mode, EMacs will be less ignorant and tell
you more. Look under command line switches and/or modes on how to use
modes.
;OCL}}}
;OCL{{{  The status line and the message line
The line immediately above the bottom line is referred to as the "mode
line". The mode line looks something like

@ref-start-picture
 * EMacs 1.6.79 (None)  teach-emacs
@ref-end-picture

This is a very useful "information" line.

@ref-start-item asterisk (star)
indicates that changes have been made to the file.
Immediately after opening or saving a file, there is no star.
@ref-end-item
@ref-start-item name ("EMacs" in this case)
shows the name of your compiled keybinding, which runs on top of the Origami
interpreter.
@ref-end-item
@ref-start-item words inside the parentheses
indicate the "modes" EMacs is currently in.
@ref-end-item
@ref-start-item filename ("teach-emacs" in this case)
is the name of the file you are currently editing.
@ref-end-item

If you use more than one window, each window will have its own mode
line.
;OCL}}}
;OCL{{{  Used notation of input
In the following sections, the notation below is used to describe which
commands are bound to which keys or sequences of keys.

@ref-start-item C-<chr>
Hold the CONTROL key while pressing the character <chr>.
Thus, C-F would be: hold the CONTROL key and press F. Some
people may be used to see ^F, here it is C-F.
@ref-end-item
@ref-start-item M-<chr>
If you have no Meta key, then press the ESCAPE key and release
it, then press the character <chr>. Alternatively, if your
keyboard has a meta key, then hold it down while typing <chr>.
@ref-end-item
@ref-start-item M-C-<chr>
If you have no Meta key, then press the ESCAPE key and release
it, then hold the CONTROL key while pressing the character <chr>.
Otherwise, hold down Meta and Control while typing <chr>.
@ref-end-item
;OCL}}}
;OCL{{{  Bound keys and key sequences
Each key inserts/overwrites its character at the current cursor position,
unless it is bound to a command, in which case the command will be started.
If the key is start of a key sequence to which a command is bound, EMacs will
wait for the rest of that sequence and show what was typed so far in the
message line.  Killing text means that the text will be erased from the buffer
and appended to the kill buffer whereas deleting text means just erasing it,
although a limited undo function is available.

;OCL{{{  The general abort command
@ref-start-item C-G
The EMacs command used to abort any command, no matter if it requests
input or not, is C-G. For example, you can used C-G to discard
a numeric argument, at the beginning of a command that you
don't want to finish, to abort loading big files and to abort
running macros.
@ref-end-item
;OCL}}}
;OCL{{{  Cursor motion
;OCL{{{  Basic cursor control (up, down, left, right)
Not the best, but the most basic way to move the cursor is to use the
commands previous-line, backward-character, forward-character and
next-line. Here, in a more graphical form, are the commands:

@ref-start-picture
                     Previous line, C-P
                           :
Backward, C-B .. Current cursor position .. Forward, C-F
                           :
                     Next line, C-N
@ref-end-picture

You'll probably find it easy to think of these by letter: P for
previous, N for next, B for backward and F for forward. When you go off
the top or bottom of the screen, the text beyond the edge is shifted
onto the screen so that your instructions can be carried out while
keeping the cursor on the screen. If your terminal is supported, then
the cursor keys will work as well.
;OCL}}}
;OCL{{{  Move cursor backward/forward one word
@ref-start-item M-b
backward-word, moves the cursor back one word.
@ref-end-item
@ref-start-item M-f
backward-word, moves the cursor forward one word.
@ref-end-item
;OCL}}}
;OCL{{{  Move cursor backward/forward one sentence
The end of a sentence in EMacs means a line with a period at its end or
a period followed by two spaces.

@ref-start-item M-B
backward-sentence. Moves the cursor to the beginning of the last sentence.
@ref-end-item
@ref-start-item M-F
forward-sentence. Moves the cursor to the beginning of the next sentence.
@ref-end-item
;OCL}}}
;OCL{{{  Move cursor to the previous/next paragraph
A paragraph in EMacs is text without blank lines and without a period in
the first column.

@ref-start-item M-p
previous-paragraph, moves the cursor to the previous paragraph.
@ref-end-item
@ref-start-item M-n
next-paragraph, moves the cursor to the next paragraph.
@ref-end-item
;OCL}}}
;OCL{{{  Move cursor to the previous/next page
@ref-start-item M-v
previous-page, move one page back. If your terminal is supported, then
the NextPage key will also work.
@ref-end-item
@ref-start-item C-V
next-page, move one page forward. If your terminal is supported, then
the PreviousPage key will also work.
@ref-end-item
;OCL}}}
;OCL{{{  Move cursor to the beginning/end of a line
@ref-start-item C-A
beginning-of-line, move to the beginning of line. If your terminal is
supported, the begin key will also work.
@ref-end-item
@ref-start-item C-E
end-of-line, move to the end of line. If your terminal is supported, the
end key will also work.
@ref-end-item
;OCL}}}
;OCL{{{  Move cursor to the beginning/end of a fold
@ref-start-item M-<
beginning-of-fold, move to the beginning of the entered fold.
If your terminal is supported, the home key will also work.
@ref-end-item
@ref-start-item M->
end-of-fold, move to the end of the entered fold.
@ref-end-item
;OCL}}}
;OCL{{{  Move cursor to line with a specific number
@ref-start-item M-g
go-to-line, moves the cursor to the specified line in an entered
fold. With a numeric argument, Origami jumps to that line,
otherwise a prompt asking for it will be issued.
@ref-end-item
;OCL}}}
;OCL{{{  Move cursor to matching paren, bracket or brace
@ref-start-item M-#
goto-matching-fence, move cursor to matching paren, bracket or brace. If the
cursor stands not on one of the above mentioned fences, EMacs tries to find
one of the following more complex structures (Skip1 -> Skip2 [ -> Skip3 ] ->
Skip1 .. ):
@ref-start-tbl Language 8 Skip1 10 Skip2 10 Skip3 10
all @@ #ifdef @@ #else @@ #endif
all @@ #if @@ #else @@ #endif
OCL @@ @if-using @@ @fi
@ref-end-tbl
@ref-end-item
;OCL}}}
;OCL{{{  Move cursor in and out of folds
@ref-start-item C-O
open-fold, opens the fold under the cursor. If your terminal
is supported, then the open key will work as well.
@ref-end-item
@ref-start-item C-C
close-fold, closes the current fold and folds inside it. If
your terminal is supported, then the close key will work as well.
@ref-end-item
@ref-start-item M-C-O
enter-fold, enters the fold under the cursor. If the line is not a fold,
Origami tries to follow the given include statement or prompts for a filename.
The environement variable `ORIGAMILIBPATH' may contain a `:' separated list of
directories (default is `/usr/include').
@ref-end-item
@ref-start-item M-C-C
exit-fold, exits the current fold.
@ref-end-item
;OCL}}}
;OCL}}}
;OCL{{{  Editing
;OCL{{{  Creating a new line
@ref-start-item C-M
newline-and-indent, splits the line at the cursor position.  If mode
@ref-end-item
@ref-start-item C-J
Autoindent is active, then the new line is indented as the previous
line.
@ref-end-item
;OCL}}}
;OCL{{{  Deleting characters
@ref-start-item C-H
delete-previous-character, deletes the character left to the
cursor.  Most backspace keys also send C-H.
@ref-end-item
@ref-start-item C-D
delete-character, deletes the character under the cursor.  Most
@ref-end-item
@ref-start-item C-?
delete keys also send a C-?.
@ref-end-item
;OCL}}}
;OCL{{{  Exchanging characters
@ref-start-item C-T
transpose-characters, exchanges the character under the cursor
with the character left from the cursor, then moves the cursor
forward one character.
@ref-end-item
;OCL}}}
;OCL{{{  Deleting words
@ref-start-item M-C-H
delete-word-backward, deletes word backwards from cursor position.
@ref-end-item
@ref-start-item M-C-D
delete-word, deletes word under cursor position.
@ref-end-item
;OCL}}}
;OCL{{{  Changing capitalization of words
@ref-start-item M-c
case-word-capitalize, capitalizes the word starting at cursor
position and moves the cursor forward one word.
@ref-end-item
@ref-start-item M-u
case-word-upper, changes the word to upper case starting at
cursor position and moves the cursor forward one word.
@ref-end-item
@ref-start-item M-l
case-word-lower, changes the word to lower case starting at
cursor position and moves the cursor forward one word.
@ref-end-item
;OCL}}}
;OCL{{{  Killing, deleting, and getting erased text back
@ref-start-item C-K
kill-line, kills all text from cursor position to end of line.
If the cursor was already at the end of the line, the newline
character ending the line will be killed, joining the current line
with the next line.
@ref-end-item

@ref-start-item M-C-K  |  delline
delete-line, deleted all text from cursor position to end of line.
If the cursor was already at the end of the line, the newline
character ending the line will be deleted, joining the current line
with the next line.
@ref-end-item

@ref-start-item C-Y
insert-folded-kill-buffer, moves the kill buffer in a fold and
yanks this fold back
@ref-end-item

@ref-start-item C-X C-Y
undo-delete-line, yank the last deleted line back
@ref-end-item
;OCL}}}

;OCL{{{  copy-to-kill-buffer
@ref-start-item M-k
copy-to-kill-buffer, appends the line to the kill buffer without
killing it
@ref-end-item
;OCL}}}
;OCL{{{  unfold-fold
@ref-start-item C-U
unfold-fold, removes the fold marks of the fold under the cursor
@ref-end-item
;OCL}}}
;OCL{{{  auto-header
@ref-start-item C-X C-H
auto-header, copies the first in of the fold under the cursor to
the fold header
@ref-end-item
;OCL}}}
;OCL{{{  toggle-file-fold
@ref-start-item C-X C-F
toggle-file-fold, toggles between a fold and a file-fold
@ref-end-item
;OCL}}}
;OCL{{{  toggle-attach-file-to-fold
@ref-start-item C-X C-A
toggle-attach-file-to-fold, attaches a file to a fold to create a
file-fold for an already existing file, or unlinks the file from
the fold
@ref-end-item
;OCL}}}
;OCL}}}
;OCL{{{  Regions
Regions in EMacs are parts of the buffer, one end marked by an invisible
mark, the other by the cursor. The region includes the beginning
position and excludes the ending position. Regions have to respect the
fold structure.

@ref-start-item C-@
set-mark, set an invisible mark at the current cursor position.
This function is also bound to control-space, because most keyboards
generate the same character on C-@ and control-space.
@ref-end-item
@ref-start-item C-X C-X
change-mark-and-position, set the invisible mark at the cursor
position and move the cursor to the previos location of the mark.
@ref-end-item
@ref-start-item C-X x
highlight-region, show the marked region highlighted. A set argument will
enhance the display time.
@ref-end-item
@ref-start-item M-C-W
delete-region, delete a region. This can be undone by undo-delete-line.
@ref-end-item
@ref-start-item C-W
kill-region, move the region to the kill buffer.
@ref-end-item
@ref-start-item M-w
copy-region, copy the region in the kill buffer.
@ref-end-item
@ref-start-item M-C-@
fold-region, folds the region.
@ref-end-item
;OCL}}}
;OCL{{{  Search/replace
;OCL{{{  Search for a string
@ref-start-item M-C-S
search-forward, prompts for a string and moves the cursor
to the next occurence of it.
@ref-end-item
@ref-start-item M-C-R
search-reverse, prompts for a string and moves the cursor
to the last occurence of it.
@ref-end-item
;OCL}}}
;OCL{{{  Incremental search for a string
Incremental search allows you to see the result of the search while the
search string is typed/changed.

@ref-start-item C-S
incremental-search-forward, switches to incremental search mode
with default direction forward.
@ref-end-item
@ref-start-item C-R
incremental-search-reverse, switches to incremental search mode
with default direction backward.
@ref-end-item

;OCL{{{  Functions in incremental search mode
During incremental search, you can use the following commands:

@ref-start-item <chr>
Append the character to the search pattern and search in current
search direction.
@ref-end-item
@ref-start-item C-S
Move the cursor to the next occurence of the search string and
switch to search direction forward.
@ref-end-item
@ref-start-item C-R
Move to the previous occurence and switch to searching backward.
@ref-end-item
@ref-start-item C-P
Go back in search history.
@ref-end-item
@ref-start-item C-N
Go forward in search history.
@ref-end-item
@ref-start-item C-M  |  C-J
exit incremental search, leave the cursor where it is.
@ref-end-item
@ref-start-item C-H
remove last letter from search pattern.
@ref-end-item
@ref-start-item C-G
aborts incremental search, sets the cursor to where it was before.
@ref-end-item
;OCL}}}
;OCL}}}
;OCL{{{  Search and replace
@ref-start-item M-R
replace-string, asks for a search string and a replace string
and replaces all occurences of the search string by the replace
string.
@ref-end-item
@ref-start-item M-R
query-replace-string, asks for a search string and a replace
string and gives the choice to replace the search string by the
replace string at all occurences. During query-replace-string
the following commands are available:

@ref-start-item Y
replace and go to next occurence
@ref-end-item
@ref-start-item N
don't replace and go to next occurence
@ref-end-item
@ref-start-item !
replace all further occurences
@ref-end-item
@ref-start-item A
abort
@ref-end-item
@ref-start-item .
replace this occurence and abort after
@ref-end-item
@ref-end-item
;OCL}}}
;OCL}}}
;OCL{{{  Files
@ref-start-item C-X C-I
insert-file, inserts the contents of a file at the current position into the
buffer.
@ref-end-item
@ref-start-item C-X C-S
save-file, writes the buffer back to the edited file. If your
terminal is supported, the save key will also work.
@ref-end-item
@ref-start-item C-X C-W
write-file, writes the buffer to another file.
@ref-end-item
@ref-start-item C-X C-R
read-file, reads another file into the buffer.  A set argument will read the
file without parsing.  The state of the mode parsing will not be changed.
@ref-end-item
@ref-start-item C-X C-N
next-file, reads next file from command line argument list into
the buffer.
@ref-end-item
@ref-start-item C-X C-P
previous-file, reads previous file from command line argument list into
the buffer.
@ref-end-item
@ref-start-item M-~
set-file-unchanged, marks the buffer as unchanged.
@ref-end-item
;OCL}}}
;OCL{{{  Buffers
Origami has a different buffer concept than most other emacs
implementations. Each buffer has its own (and only) window to edit it.
Buffers may not be currently visible, so list-buffers is an important
function if you get lost.

@ref-start-item C-X C-B
list-buffers, show a list of all used buffers and offers a menu
for selecting another buffer (return moves you back to the old
position). If your terminal supports it, the select key will
also work.
@ref-end-item
@ref-start-item C-X b
change-buffername, changes the name of the current buffer
@ref-end-item

;OCL{{{  Opening and closing buffers
@ref-start-item C-X "2
open-buffer, open a second buffer by parting the current window
horizontally.  A set argument will read the file without parsing.  The
state of the mode parsing will not be changed.
@ref-end-item
@ref-start-item C-X "3
open-adjacent-buffer, open a second buffer by parting the current window
vertically.  A set argument will read the file without parsing.  The state
of the mode parsing will not be changed.
@ref-end-item
@ref-start-item C-X "0
exit-buffer, close the current buffer and unify the window with
the window of the previous buffer
@ref-end-item
@ref-start-item C-X @
show a special buffer containing the last messages.
@ref-end-item
;OCL}}}
;OCL{{{  Changing between buffers
@ref-start-item M-C-X p
previous-buffer, go to the previous buffer.
@ref-end-item
@ref-start-item M-C-X n
next-buffer, go to the next buffer.
@ref-end-item
@ref-start-item C-X o
other-buffer, go cyclic to the next buffer.
@ref-end-item
@ref-start-item M-C-X C-P
up-buffer, move up one buffer
@ref-end-item
@ref-start-item M-C-X C-N
down-buffer, move down one buffer
@ref-end-item
@ref-start-item M-C-X C-B
left-buffer, move left one buffer
@ref-end-item
@ref-start-item M-C-X C-F
right-buffer, move right one buffer
@ref-end-item
;OCL}}}
;OCL{{{  Resizing buffers
@ref-start-item C-X "1
full-size-buffer, extend the size of the current buffer to screen size
@ref-end-item
@ref-start-item M-C-X ^
grow-buffer, grow current buffer vertically
@ref-end-item
@ref-start-item M-C-X v
shrink-buffer, shrink current buffer vertically
@ref-end-item
@ref-start-item M-C-X <
widen-buffer, grow current buffer horizontally
@ref-end-item
@ref-start-item M-C-X >
narrow-buffer, shrink current buffer horizontally
@ref-end-item
;OCL}}}
;OCL}}}
;OCL{{{  Modes
Unlike most other Emacs implementations, Origami does not seperate
between major and minor modes. The mode default values can be set
using command line switches:

;OCL{{{  Origami Command Line Options
;OCL}}}
;OCL{{{  EMacs Command Line Options
;OCL}}}

All modes are related to a buffer, they are set with C-X "m <mode-key>
and deleted with C-X C-M <mode-key>. The following mode-keys are
available:

@ref-start-item "a
autosave, asks for a time interval and saves the text each time
after this interval expires
@ref-end-item
@ref-start-item "c
c-mode, syntax support for C
@ref-end-item
@ref-start-item "d
show a menu for changing the used character display mode. This
mode also can only be changed, not deleted.
@ref-end-item
@ref-start-item "f
full-shift, moving over the right border of the screen will shift
the whole buffer, not only the current line.
@ref-end-item
@ref-start-item "i
autoindent, new lines will be indented as their predecessor
@ref-end-item
@ref-start-item "l
set-language, sets a new language for fold comments. This mode
can only be changed and not deleted.
@ref-end-item
@ref-start-item "m
basic-regular-expression, search/replace will use regular
expressions
@ref-end-item
@ref-start-item "M
extended-regular-expression, search/replace will use extended
expressions.
@ref-end-item
@ref-start-item "n
no-parse, reading files will be done without fold parsing
@ref-end-item
@ref-start-item "o
overwrite, new text overwrites existing text instead of being
inserted
@ref-end-item
@ref-start-item "p
position, always show current position in status line
@ref-end-item
@ref-start-item "t
time, display the time right from the filename
@ref-end-item
@ref-start-item "v
view, text can only be viewd but not changed
@ref-end-item
@ref-start-item "V
If set, EMacs will be more verbose in some situations.
@ref-end-item
@ref-start-item "w
wrap, wraps a word to the next line if neccessary
@ref-end-item
@ref-start-item "#
hash-shifting
@ref-end-item
;OCL}}}
;OCL{{{  Arguments
@ref-start-item M-<number>
set-argument-<number> (number can be a digit from 0 to 9),
set number as argument for the next executed command. Any
following typed digits will be part of the number. Most
commands simply are executed number times, when prefixed by
an argument.
@ref-end-item
;OCL}}}
;OCL{{{  Shell Commands
;OCL{{{  shell
@ref-start-item shift-command  |  C-X "c
shell, starts a sub shell
@ref-end-item
;OCL}}}
;OCL{{{  shell-command
@ref-start-item command  |  C-X "!
shell-command, starts a sub shell with a given command
@ref-end-item
;OCL}}}
;OCL{{{  filter-buffer
@ref-start-item C-X "|
filter-buffer, first saves  current file and then filters it
through the specified filter command.
@ref-end-item
;OCL}}}
;OCL{{{  pipe-to-command
@ref-start-item C-X ">
pipe-to-command, feeds the command with the current file as
standard input.
@ref-end-item
;OCL}}}
;OCL{{{  pipe-from-command
@ref-start-item C-X "<
pipe-from-command, inserts standard output from command at the
current position.
@ref-end-item
;OCL}}}
;OCL{{{  make-it
@ref-start-item M-x m
make-it, invoke make
@ref-end-item
;OCL}}}
;OCL{{{  compile-it
@ref-start-item M-x c
compile-it, invoke C compiler
@ref-end-item
;OCL}}}
;OCL{{{  beautify-c-code
@ref-start-item C-X "i
beautify-c-code, filter buffer through beautifier
@ref-end-item
;OCL}}}
;OCL{{{  check-out
@ref-start-item M-x o
check-out, checks current file out but does *not* reload the
buffer.
@ref-end-item
;OCL}}}
;OCL{{{  check-in
@ref-start-item M-x i
check-in, saves buffer and checks file in
@ref-end-item
;OCL}}}
;OCL{{{  spell-it
@ref-start-item M-x s
spell-it, runs current file through spell and starts an
interactive search and replace for all misspelled words.
@ref-end-item
;OCL}}}
;OCL}}}
;OCL{{{  More advanced functions
;OCL{{{  C-Mode
The following characters have a special meaning in C-mode:

@ref-start-picture
( [ { '  "  ;
@ref-end-picture

Just play around to get used to them, once you are they save lots of
typing. In C-mode words consist of letters, digits and underscores.
;OCL}}}
;OCL{{{  Tags
;OCL{{{  enter-and-go-tags-buffer
@ref-start-item M-.
enter-and-go-tags-buffer, prompt for tag and go to tagged
position (open buffer, if needed)

filename-or-tag-completion can also be used. In this case, the
first tag starting with the given text is used.
@ref-end-item

;OCL{{{  @tags-mac-ref Tags file
;OCL}}}
;OCL}}}
;OCL{{{  find-and-go-tags-buffer
@ref-start-item M-,
find-and-go-tags-buffer, like enter-and-go-tags-buffer, but use
the word under the cursor
@ref-end-item

;OCL{{{  @tags-mac-ref Tags file
;OCL}}}
;OCL}}}
;OCL{{{  set-user-tags-file
@ref-start-item C-X t
set-user-tags-file, define a new tags file (empty input uses
default tags files).
@ref-end-item

;OCL{{{  @tags-mac-ref Tags file
;OCL}}}
;OCL}}}
;OCL}}}
;OCL{{{  Macros
;OCL{{{  start-define-macro
@ref-start-item C-X "(
define-macro, starts recording a keyboard macro
@ref-end-item
;OCL}}}
;OCL{{{  end-define-macro
@ref-start-item C-X ")
define-macro, ends recording a keyboard macro
@ref-end-item
;OCL}}}
;OCL{{{  execute-macro
@ref-start-item C-X "e
execute-macro, executes a recorded keyboard macro
@ref-end-item
;OCL}}}
;OCL}}}

;OCL{{{  center-and-redraw-display
@ref-start-item C-L
center-and-redraw-display, redraws screen bringing the current
line to the middle of the screen.
@ref-end-item
;OCL}}}
;OCL{{{  redraw-display
@ref-start-item refresh  |  M-C-L
redraw, redraws screen e.g. after write(1)s from other people
etc.
@ref-end-item
;OCL}}}

;OCL{{{  describe-bindings
@ref-start-item shift-help  |  C-X "?
describe-bindings, shows all commands and where they are bound to
@ref-end-item
;OCL}}}
;OCL{{{  describe-fold
@ref-start-item C-X "=
describe-fold, gives you some information about your position in
the text
@ref-end-item
;OCL}}}
;OCL{{{  quote-character
@ref-start-item C-Q
quote-character, simply insert the next character and do not
parse it as a command
@ref-end-item
;OCL}}}
;OCL{{{  filename-or-tag-completion
@ref-start-item M-C-I
filename-or-tag-completion, complete a word to a filename. This
function works everywhere, not only in prompts! If
filename-or-tag-completion is used outside of prompts and if
there is no filename to complete, Emacs tries to complete the
started word as tag.
@ref-end-item

;OCL{{{  @tags-mac-ref Tags file
;OCL}}}
;OCL}}}
;OCL{{{  fill-paragraph
@ref-start-item M-q
fill-paragraph, fills paragraph from cursor to end of paragraph
@ref-end-item
;OCL}}}
;OCL{{{  set-fill-column
@ref-start-item C-X "f
set-fill-column, sets fill column to argument, or cursor position
if none is given, or asks for it if cursor if at the left margin.
@ref-end-item
;OCL}}}
;OCL}}}
;OCL{{{  How to get out
;OCL{{{  exit-origami
@ref-start-item exit  |  C-X C-C
exit-origami
@ref-end-item
;OCL}}}
;OCL{{{  save-and-exit-origami
@ref-start-item shift-exit  |  M-Z
save-and-exit-origami
@ref-end-item
;OCL}}}
;OCL{{{  suspend-origami
@ref-start-item suspend  |  C-Z
suspend-origami
@ref-end-item
;OCL}}}
;OCL}}}

;OCL{{{  Funny Functions
;OCL{{{  @ff sokoban
@ref-start-item M-X k
;OCL{{{  sokoban
;OCL}}}
@ref-end-item
;OCL}}}
;OCL{{{  @ff towers-of-hanoi
@ref-start-item M-X t
Play the well known game towers-of-hanoi at the bottom of the current buffer.
set-argument can be used, to control the height.
@ref-end-item
;OCL}}}
;OCL}}}
;OCL}}}
;OCL}}}
@end-reference-copy
;OCL}}}
@fi
;OCL}}}
