(declare-key normal '(z z)
             (when (red/buffer/path)
               (red/buffer/write)
               )
             (red/quit)
             )
(declare-key normal '(Z Z) (red/quit #t))

(declare-key normal 'a (red/buffer/set-mode 'insert-after))
(declare-key normal 'i (red/buffer/set-mode 'insert-before))
(declare-key normal 'I
             (red/buffer/move 'line-start)
             (red/buffer/set-mode 'insert-before))
(declare-key normal 'A
             (red/buffer/move 'line-end)
             (red/buffer/set-mode 'insert-after))

(declare-key normal '(g g) (red/buffer/move 'first-line))
(declare-key normal 'G (red/buffer/move 'last-line))

(declare-key normal 'h (red/buffer/move 'prev-char))
(declare-key normal 'l (red/buffer/move 'next-char))
(declare-key normal 'k (red/buffer/move 'prev-line))
(declare-key normal 'j (red/buffer/move 'next-line))
(declare-key normal 'J (red/buffer/move 'next-page))
(declare-key normal 'K (red/buffer/move 'prev-page))
(declare-key normal 'o
             (red/buffer/insert-line-after)
             (red/buffer/move 'next-line)
             (red/buffer/set-mode 'insert-before))
(declare-key normal 'O
             (red/buffer/insert-line-before)
             (red/buffer/set-mode 'insert-before))
(declare-key normal '(d d)
             (red/buffer/kill-line)
             (red/buffer/move 'prev-line))
(declare-key normal 'newline
             (red/buffer/move 'next-line)
             (red/buffer/move 'line-start))

(declare-key normal 'left (red/buffer/move 'prev-char))
(declare-key normal 'right (red/buffer/move 'next-char))
(declare-key normal 'up (red/buffer/move 'prev-line))
(declare-key normal 'down (red/buffer/move 'next-line))
(declare-key normal 'home (red/buffer/move 'line-start))
(declare-key normal 'end (red/buffer/move 'line-end))

(declare-key insert 'left (red/buffer/move 'prev-char))
(declare-key insert 'right (red/buffer/move 'next-char))
(declare-key insert 'up (red/buffer/move 'prev-line))
(declare-key insert 'down (red/buffer/move 'next-line))
(declare-key insert 'home (red/buffer/move 'line-start))
(declare-key insert 'end (red/buffer/move 'line-end))
(declare-key insert 'backspace (red/buffer/erase-backward))
(declare-key insert 'newline
             (red/buffer/insert-line-after #t)
             (red/buffer/move 'next-line)
             (red/buffer/move 'line-start)
             (red/buffer/set-mode 'insert-before)
             )
