Buffers

Editing in Arcus is centered on buffer-view state plus stackable buffer-mode behavior.

  • buffer-view state (:normal, :insert, :select)
  • stackable buffer-mode objects attached to the underlying buffer

Buffer-View State

Use enter-buffer-state to switch buffer-view state. It handles state enter/exit callbacks and hooks.

(let ((view (current-buffer-view)))
  (when view
    (enter-buffer-state view :insert)))

Normal/Insert/Select behavior is state-aware through view-key-state and state hooks.

Keymaps

Keymaps are CLOS objects that map keys to commands. Define keymaps with defkeymap:

(defkeymap normal-keymap ()
  (:movement
   (:h move-cursor-left "left")
   (:j move-cursor-down "down"))
  (:editing
   (:i insert-before "insert")
   (:d delete-selection "delete")))

Buffer modes

Buffer modes are objects attached to buffers. Each mode carries a name and priority (higher runs earlier).

Enable or disable with enable and disable.

For dispatch, active buffer modes are read from the current buffer and sorted by priority.

Buffer-mode keybindings

Buffer modes can contribute keys for specific buffer-view states.

Example:

(define-buffer-mode-key 'my-mode '(buffer-view :normal) :g
  'goto-definition)

(define-buffer-mode-key 'markdown-mode '(buffer-view :insert) :return
  (make-guarded-command :predicate #'md-on-list-line-p
                        :command #'md-continue-list-command))

When a buffer-view handles a key event, buffer-mode keys are checked before base state keybindings.