-
Notifications
You must be signed in to change notification settings - Fork 127
Spacemacs Evil Bindings
John Miller edited this page May 20, 2019
·
3 revisions
The introduction of polymode support breaks the existing spacemacs/evil bindings for ein (ala the ipython-notebook. The solution is suprisingly simple - instead of declaring bindings with spacemacs/set-leader-keys-for-major-mode instead use spacemacs/set-leader-keys-for-minor-mode. See the example code below:
(spacemacs/set-leader-keys-for-minor-mode 'ein:notebook
"y" 'ein:worksheet-copy-cell
"p" 'ein:worksheet-yank-cell
"d" 'ein:worksheet-kill-cell
"h" 'ein:notebook-worksheet-open-prev-or-last
"i" 'ein:worksheet-insert-cell-below
"I" 'ein:worksheet-insert-cell-above
"j" 'ein:worksheet-goto-next-input
"k" 'ein:worksheet-goto-prev-input
"l" 'ein:notebook-worksheet-open-next-or-first
"H" 'ein:notebook-worksheet-move-prev
"J" 'ein:worksheet-move-cell-down
"K" 'ein:worksheet-move-cell-up
"L" 'ein:notebook-worksheet-move-next
"t" 'ein:worksheet-toggle-output
"R" 'ein:worksheet-rename-sheet
"RET" 'ein:worksheet-execute-cell-and-goto-next
;; Output
"C-l" 'ein:worksheet-clear-output
"C-S-l" 'ein:worksheet-clear-all-output
;;Console
"C-o" 'ein:console-open
;; Merge cells
"C-k" 'ein:worksheet-merge-cell
"C-j" 'spacemacs/ein:worksheet-merge-cell-next
"s" 'ein:worksheet-split-cell-at-point
;; Notebook
"C-s" 'ein:notebook-save-notebook-command
"C-r" 'ein:notebook-rename-command
"1" 'ein:notebook-worksheet-open-1th
"2" 'ein:notebook-worksheet-open-2th
"3" 'ein:notebook-worksheet-open-3th
"4" 'ein:notebook-worksheet-open-4th
"5" 'ein:notebook-worksheet-open-5th
"6" 'ein:notebook-worksheet-open-6th
"7" 'ein:notebook-worksheet-open-7th
"8" 'ein:notebook-worksheet-open-8th
"9" 'ein:notebook-worksheet-open-last
"+" 'ein:notebook-worksheet-insert-next
"-" 'ein:notebook-worksheet-delete
"x" 'ein:notebook-close
"u" 'ein:worksheet-change-cell-type
"fs" 'ein:notebook-save-notebook-command)To get the transient commands working it appears the solution is to work off the ein:notebook minor mode:
(spacemacs|define-transient-state ein-evil
:title "iPython Notebook Transient State"
:doc "
Operations on Cells^^^^^^ On Worksheets^^^^ Other
----------------------------^^^^^^ ------------------------^^^^ ----------------------------------^^^^
[_k_/_j_]^^ select prev/next [_h_/_l_] select prev/next [_t_]^^ toggle output
[_K_/_J_]^^ move up/down [_H_/_L_] move left/right [_C-l_/_C-S-l_] clear/clear all output
[_C-k_/_C-j_]^^ merge above/below [_1_.._9_] open [1st..last] [_C-o_]^^ open console
[_O_/_o_]^^ insert above/below [_+_/_-_] create/delete [_C-s_/_C-r_] save/rename notebook
[_y_/_p_/_d_] copy/paste ^^^^ [_x_]^^ close notebook
[_u_]^^^^ change type ^^^^ [_q_]^^ quit transient-state
[_RET_]^^^^ execute"
:evil-leader-for-mode (ein:notebook . ".")
:bindings
("q" nil :exit t)
("?" spacemacs//ein-devel-ms-toggle-doc)
("h" ein:notebook-worksheet-open-prev-or-last)
("j" ein:worksheet-goto-next-input)
("k" ein:worksheet-goto-prev-input)
("l" ein:notebook-worksheet-open-next-or-first)
("H" ein:notebook-worksheet-move-prev)
("J" ein:worksheet-move-cell-down)
("K" ein:worksheet-move-cell-up)
("L" ein:notebook-worksheet-move-next)
("t" ein:worksheet-toggle-output)
("d" ein:worksheet-kill-cell)
("R" ein:worksheet-rename-sheet)
("y" ein:worksheet-copy-cell)
("p" ein:worksheet-yank-cell)
("o" ein:worksheet-insert-cell-below)
("O" ein:worksheet-insert-cell-above)
("u" ein:worksheet-change-cell-type)
("RET" ein:worksheet-execute-cell-and-goto-next)
;; Output
("C-l" ein:worksheet-clear-output)
("C-S-l" ein:worksheet-clear-all-output)
;;Console
("C-o" ein:console-open)
;; Merge and split cells
("C-k" ein:worksheet-merge-cell)
("C-j" spacemacs/ein:worksheet-merge-cell-next)
("s" ein:worksheet-split-cell-at-point)
;; Notebook
("C-s" ein:notebook-save-notebook-command)
("C-r" ein:notebook-rename-command)
("1" ein:notebook-worksheet-open-1th)
("2" ein:notebook-worksheet-open-2th)
("3" ein:notebook-worksheet-open-3th)
("4" ein:notebook-worksheet-open-4th)
("5" ein:notebook-worksheet-open-5th)
("6" ein:notebook-worksheet-open-6th)
("7" ein:notebook-worksheet-open-7th)
("8" ein:notebook-worksheet-open-8th)
("9" ein:notebook-worksheet-open-last)
("+" ein:notebook-worksheet-insert-next)
("-" ein:notebook-worksheet-delete)
("x" ein:notebook-close))
(spacemacs/set-leader-keys "ein" 'spacemacs/ein-devel-transient-state/body)))