2015-06-06 00:20:15 +00:00
|
|
|
;;; packages.el --- ipython Layer packages File for Spacemacs
|
|
|
|
;;
|
2018-01-04 07:00:25 +00:00
|
|
|
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors
|
2015-06-06 00:20:15 +00:00
|
|
|
;;
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
|
|
|
;;; License: GPLv3
|
|
|
|
|
2020-03-01 08:54:54 +00:00
|
|
|
(setq ipython-notebook-packages '(ein))
|
2019-09-24 05:26:25 +00:00
|
|
|
|
2015-06-08 03:36:39 +00:00
|
|
|
(defun ipython-notebook/init-ein ()
|
2015-06-06 00:20:15 +00:00
|
|
|
(use-package ein
|
|
|
|
:init
|
2020-02-29 21:37:21 +00:00
|
|
|
(spacemacs/set-leader-keys "ayl" 'ein:login
|
[ipython] Fix mode name, and remove unmaintainable code
1. Previously, the code had references to ein:notebook-mode which doesn't seem
to work (anymore), so I changed these references to ein:notebook.
2. The previous code had a big convoluted function that produced the
doc-string and that was difficult to read that depended on some other
smaller functions, though not enough of them to make the code
sufficiently modular, and therefore, it wasn't very maintainable.
Besides, when I tried the previous version with the name of the mode fixed,
spacemacs hung for a long time -- it's a mystery whether spacemacs would
have continued normally if I had waited long enough. Therefore I replaced
the doc-string with a hard coded one.
3. I added some keybindings from tkamat's fork to the code for I didn't see
a good reason not to
4. I removed the cl- prefix from "second" and "mapcan", because cl is a
deprecated package. However, I'm afraid the names without the prefix might
end up being unrecognized by previous versions of emacs.
2020-03-20 04:00:26 +00:00
|
|
|
"ayr" 'ein:run
|
|
|
|
"ays" 'ein:stop)
|
2020-02-29 21:37:21 +00:00
|
|
|
(spacemacs/declare-prefix "ay" "ipython notebook")
|
2015-06-06 00:20:15 +00:00
|
|
|
:config
|
2020-02-29 21:37:21 +00:00
|
|
|
(mapc
|
|
|
|
(lambda (mode)
|
|
|
|
(evil-define-minor-mode-key
|
[ipython] Fix mode name, and remove unmaintainable code
1. Previously, the code had references to ein:notebook-mode which doesn't seem
to work (anymore), so I changed these references to ein:notebook.
2. The previous code had a big convoluted function that produced the
doc-string and that was difficult to read that depended on some other
smaller functions, though not enough of them to make the code
sufficiently modular, and therefore, it wasn't very maintainable.
Besides, when I tried the previous version with the name of the mode fixed,
spacemacs hung for a long time -- it's a mystery whether spacemacs would
have continued normally if I had waited long enough. Therefore I replaced
the doc-string with a hard coded one.
3. I added some keybindings from tkamat's fork to the code for I didn't see
a good reason not to
4. I removed the cl- prefix from "second" and "mapcan", because cl is a
deprecated package. However, I'm afraid the names without the prefix might
end up being unrecognized by previous versions of emacs.
2020-03-20 04:00:26 +00:00
|
|
|
mode 'ein:notebook
|
|
|
|
(kbd "<C-return>") 'ein:worksheet-execute-cell-km
|
|
|
|
(kbd "<S-return>") 'ein:worksheet-execute-cell-and-goto-next-km))
|
2020-02-29 21:37:21 +00:00
|
|
|
'(insert hybrid normal))
|
2020-03-01 08:54:54 +00:00
|
|
|
(evil-define-minor-mode-key
|
[ipython] Fix mode name, and remove unmaintainable code
1. Previously, the code had references to ein:notebook-mode which doesn't seem
to work (anymore), so I changed these references to ein:notebook.
2. The previous code had a big convoluted function that produced the
doc-string and that was difficult to read that depended on some other
smaller functions, though not enough of them to make the code
sufficiently modular, and therefore, it wasn't very maintainable.
Besides, when I tried the previous version with the name of the mode fixed,
spacemacs hung for a long time -- it's a mystery whether spacemacs would
have continued normally if I had waited long enough. Therefore I replaced
the doc-string with a hard coded one.
3. I added some keybindings from tkamat's fork to the code for I didn't see
a good reason not to
4. I removed the cl- prefix from "second" and "mapcan", because cl is a
deprecated package. However, I'm afraid the names without the prefix might
end up being unrecognized by previous versions of emacs.
2020-03-20 04:00:26 +00:00
|
|
|
'normal 'ein:notebook
|
|
|
|
"gj" 'ein:worksheet-goto-next-input-km
|
|
|
|
"gk" 'ein:worksheet-goto-prev-input-km)
|
2020-02-29 21:37:21 +00:00
|
|
|
(with-eval-after-load 'ein-notebook
|
[ipython] Fix mode name, and remove unmaintainable code
1. Previously, the code had references to ein:notebook-mode which doesn't seem
to work (anymore), so I changed these references to ein:notebook.
2. The previous code had a big convoluted function that produced the
doc-string and that was difficult to read that depended on some other
smaller functions, though not enough of them to make the code
sufficiently modular, and therefore, it wasn't very maintainable.
Besides, when I tried the previous version with the name of the mode fixed,
spacemacs hung for a long time -- it's a mystery whether spacemacs would
have continued normally if I had waited long enough. Therefore I replaced
the doc-string with a hard coded one.
3. I added some keybindings from tkamat's fork to the code for I didn't see
a good reason not to
4. I removed the cl- prefix from "second" and "mapcan", because cl is a
deprecated package. However, I'm afraid the names without the prefix might
end up being unrecognized by previous versions of emacs.
2020-03-20 04:00:26 +00:00
|
|
|
(let ((bindings '(("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))))
|
2020-02-29 21:37:21 +00:00
|
|
|
(apply #'spacemacs/set-leader-keys-for-minor-mode
|
[ipython] Fix mode name, and remove unmaintainable code
1. Previously, the code had references to ein:notebook-mode which doesn't seem
to work (anymore), so I changed these references to ein:notebook.
2. The previous code had a big convoluted function that produced the
doc-string and that was difficult to read that depended on some other
smaller functions, though not enough of them to make the code
sufficiently modular, and therefore, it wasn't very maintainable.
Besides, when I tried the previous version with the name of the mode fixed,
spacemacs hung for a long time -- it's a mystery whether spacemacs would
have continued normally if I had waited long enough. Therefore I replaced
the doc-string with a hard coded one.
3. I added some keybindings from tkamat's fork to the code for I didn't see
a good reason not to
4. I removed the cl- prefix from "second" and "mapcan", because cl is a
deprecated package. However, I'm afraid the names without the prefix might
end up being unrecognized by previous versions of emacs.
2020-03-20 04:00:26 +00:00
|
|
|
(quote ein:notebook)
|
2020-02-29 21:37:21 +00:00
|
|
|
(cl-mapcan
|
|
|
|
(lambda (bind)
|
|
|
|
(if (fboundp (cl-second bind))
|
|
|
|
bind
|
|
|
|
(prog1 nil
|
|
|
|
(display-warning
|
|
|
|
'warn (format "ipython-notebook/init-ein: undefined %s"
|
|
|
|
(cl-second bind))))))
|
|
|
|
(copy-tree bindings)))
|
[ipython] Fix mode name, and remove unmaintainable code
1. Previously, the code had references to ein:notebook-mode which doesn't seem
to work (anymore), so I changed these references to ein:notebook.
2. The previous code had a big convoluted function that produced the
doc-string and that was difficult to read that depended on some other
smaller functions, though not enough of them to make the code
sufficiently modular, and therefore, it wasn't very maintainable.
Besides, when I tried the previous version with the name of the mode fixed,
spacemacs hung for a long time -- it's a mystery whether spacemacs would
have continued normally if I had waited long enough. Therefore I replaced
the doc-string with a hard coded one.
3. I added some keybindings from tkamat's fork to the code for I didn't see
a good reason not to
4. I removed the cl- prefix from "second" and "mapcan", because cl is a
deprecated package. However, I'm afraid the names without the prefix might
end up being unrecognized by previous versions of emacs.
2020-03-20 04:00:26 +00:00
|
|
|
(eval (append '(spacemacs|define-transient-state
|
|
|
|
ipython-notebook
|
|
|
|
: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_]^^ merge above [_1_.._9_] open [1st..last] ^^^^
|
|
|
|
[_y_/_p_/_d_] copy/paste [_+_/_-_] create/delete [_C-s_/_C-r_] save/rename notebook
|
|
|
|
[_u_]^^^^ change type ^^^^ [_x_]^^ close notebook
|
|
|
|
[_RET_]^^^^ execute ^^^^ [_q_]^^ quit transient-state
|
|
|
|
"
|
|
|
|
:evil-leader-for-mode (ein:notebook . ".")
|
|
|
|
:bindings
|
|
|
|
("q" nil :exit t))
|
|
|
|
bindings))))))
|