From 5dea4a858e1ccf5145a68982fb2a311aee7f52ea Mon Sep 17 00:00:00 2001 From: fuxialexander Date: Wed, 18 Apr 2018 12:05:02 +0800 Subject: [PATCH 1/4] Fix: ein popup rules --- modules/tools/ein/config.el | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/tools/ein/config.el b/modules/tools/ein/config.el index 273358a29..2a80e2e26 100644 --- a/modules/tools/ein/config.el +++ b/modules/tools/ein/config.el @@ -11,8 +11,11 @@ (def-package! ein :commands (ein:notebooklist-open ein:notebooklist-login ein:jupyter-server-start) :init - (set! :popup "\\*ein:*" :ignore) - (set! :popup "\\*ein:notebooklist *" '((side . left)) '((size . 40) (select))) + (push (lambda (buf) (string-match-p "^\\*ein: .*" (buffer-name buf))) + doom-real-buffer-functions) + (set! :popup "\\*ein: .*" :ignore) + (set! :popup "\\*ein:tb .*" '((side . bottom) (size . 0.3)) '((quit . t) (transient) (select))) + (set! :popup "\\*ein:notebooklist *" '((side . left) (size . 50)) '((select))) ;; Ace-link on notebook list buffers (add-hook! 'ein:notebooklist-mode-hook (map! :map ein:notebooklist-mode-map From 1a329abc26dc0836401967a071d047962ab25ff5 Mon Sep 17 00:00:00 2001 From: fuxialexander Date: Wed, 18 Apr 2018 12:05:31 +0800 Subject: [PATCH 2/4] Add: +ein/hydra --- modules/tools/ein/config.el | 47 +++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/modules/tools/ein/config.el b/modules/tools/ein/config.el index 2a80e2e26..418fcb189 100644 --- a/modules/tools/ein/config.el +++ b/modules/tools/ein/config.el @@ -37,5 +37,48 @@ ein:notebook-modes '(ein:notebook-multilang-mode ein:notebook-python-mode ein:notebook-plain-mode)) ;; Avy is required for showing links in the notebook list with ace-link. - (require 'avy)) - + (require 'avy) + ;; add hydra + (def-hydra! +ein/hydra (:hint t :color red) + " + Operations on Cells^^^^^^ Other + ----------------------------^^^^^^ ----------------------------------^^^^ + [_k_/_j_]^^ select prev/next [_t_]^^ toggle output + [_K_/_J_]^^ move up/down [_C-l_/_C-S-l_] clear/clear all output + [_C-k_/_C-j_]^^ merge above/below [_C-o_]^^ open console + [_O_/_o_]^^ insert above/below [_C-s_/_C-r_] save/rename notebook + [_y_/_p_/_d_] copy/paste [_x_]^^ close notebook + [_u_]^^^^ change type [_q_]^^ quit + [_RET_]^^^^ execute +" + ("q" nil :exit t) + ("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 :exit t) + ;; 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) + ("x" ein:notebook-close :exit t))) From ae80c06067b86047133bec1a71ba53769182fd7d Mon Sep 17 00:00:00 2001 From: fuxialexander Date: Wed, 18 Apr 2018 12:06:02 +0800 Subject: [PATCH 3/4] Fix: company config and default setting of ein:jupyter-default-server-command --- modules/tools/ein/config.el | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/tools/ein/config.el b/modules/tools/ein/config.el index 418fcb189..d7a15057f 100644 --- a/modules/tools/ein/config.el +++ b/modules/tools/ein/config.el @@ -23,16 +23,21 @@ ;; Ein uses request to store http cookies. Store them in the cache dir. (setq request-storage-directory (concat doom-cache-dir "/request")) ;; Auto complete with company - (set! :company-backend '(ein:notebook-multilang-mode ein:notebook-python-mode ein:notebook-plain-mode) + (if (featurep 'company) + (setq ein:completion-backend 'ein:use-company-backend)) + (set! :company-backend + '(ein:notebook-multilang-mode + ein:notebook-python-mode + ein:notebook-plain-mode) 'ein:company-backend) :config ;; Manually load the autoloads of EIN. This takes time... (load "ein-loaddefs.el" nil t t) (setq - ;; Slide images into rows so that we can navigate buffers with images more easily + ;; Slice images into rows so that we can navigate buffers with images more easily ein:slice-image t ein:jupyter-default-notebook-directory +ein-notebook-dir - ein:jupyter-default-server-command "/usr/bin/jupyter" + ein:jupyter-default-server-command "jupyter" ein:jupyter-server-args '("--no-browser") ein:notebook-modes '(ein:notebook-multilang-mode ein:notebook-python-mode ein:notebook-plain-mode)) From 04d80fba9d9972155e84784d7e998767a6e0f7ca Mon Sep 17 00:00:00 2001 From: fuxialexander Date: Wed, 18 Apr 2018 12:11:52 +0800 Subject: [PATCH 4/4] Fix: make company config more doom-ish --- modules/tools/ein/config.el | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/modules/tools/ein/config.el b/modules/tools/ein/config.el index d7a15057f..5633bf690 100644 --- a/modules/tools/ein/config.el +++ b/modules/tools/ein/config.el @@ -23,13 +23,14 @@ ;; Ein uses request to store http cookies. Store them in the cache dir. (setq request-storage-directory (concat doom-cache-dir "/request")) ;; Auto complete with company - (if (featurep 'company) - (setq ein:completion-backend 'ein:use-company-backend)) - (set! :company-backend - '(ein:notebook-multilang-mode - ein:notebook-python-mode - ein:notebook-plain-mode) - 'ein:company-backend) + (when (featurep! :completion company) + (setq ein:completion-backend 'ein:use-company-backend) + (set! :company-backend + '(ein:notebook-multilang-mode + ein:notebook-python-mode + ein:notebook-plain-mode) + 'ein:company-backend)) + :config ;; Manually load the autoloads of EIN. This takes time... (load "ein-loaddefs.el" nil t t)