(declare-keys
  insert
  ('left (red/buffer/move 'prev-char))
  ('right (red/buffer/move 'next-char))
  ('up (red/buffer/move 'prev-line))
  ('down (red/buffer/move 'next-line))
  ('newline
   (red/buffer/insert-line-after #T)
   (red/buffer/move 'next-line)
   (red/buffer/move 'line-start))
  ('escape (red/buffer/set-mode 'normal))
  ('backspace (red/buffer/erase-backward))
  :fallback
  (key-seq)
  (_red/insert-mode-handler key-seq)
  )

(defun _red/insert-mode-handler
  (key-seq)
  (let (insertable (red/as-insertable-key-seq key-seq))
    (unless (nil? insertable)
      (red/buffer/write-text insertable)
      )
    )
  )
