help.txt keybindings.txt                                              salza.dk


                               Keybindings


Keybindings are stored in major modes.

==============================================================================
Modify keybindings

Below is an example of how to define or redefine a keybinding for an already  
existing mode.

It has been written with all details to make it clear how the parts are 
assembled.

Evaluate the code by selecting everything (of the code) and type c p p. After 
 that pressing C-t (Ctrl+T) the cursor will move 10 times to the right. Try  
it. 

    (ns user
      (:require [liq.editor :as editor]
                [liq.buffer :as buffer]))

    (defn move10
      [buf]
      (buffer/right buf 10))

    (defn move10action
      []
      (editor/apply-to-buffer move10))

    (editor/add-key-bindings :help-mode :normal {"C-t" move10action})

Editing the state directly, I think, should not be discouraged. Evaluate the 
form below and press f5 a couple of times afterwards:

    (swap! editor/state
           assoc-in [::editor/modes :clojure-mode :normal "f5"]
           #(editor/message (str (rand-int 100) " You pressed f5")))