Some (more) jupyter stuff
This commit is contained in:
parent
e158df3fd1
commit
386e65c0f4
33
init.el
33
init.el
@ -2144,7 +2144,7 @@ Note that this erases the buffer before doing anything."
|
|||||||
|
|
||||||
;; C/C++ and jupyter
|
;; C/C++ and jupyter
|
||||||
(defvar my/jupyter-extra-language-associations
|
(defvar my/jupyter-extra-language-associations
|
||||||
'((c . c++)))
|
'(("c" . "c++")))
|
||||||
|
|
||||||
(defun my/-find-jupyter-buffer-for-lang (lang)
|
(defun my/-find-jupyter-buffer-for-lang (lang)
|
||||||
"Find a Jupyter buffer supporint LANG."
|
"Find a Jupyter buffer supporint LANG."
|
||||||
@ -2158,7 +2158,8 @@ Note that this erases the buffer before doing anything."
|
|||||||
jupyter-current-client))))))
|
jupyter-current-client))))))
|
||||||
(buffer-list))))
|
(buffer-list))))
|
||||||
(when-let (((not res))
|
(when-let (((not res))
|
||||||
(real (alist-get lang my/jupyter-extra-language-associations)))
|
(real (alist-get lang my/jupyter-extra-language-associations nil
|
||||||
|
nil #'cl-equalp)))
|
||||||
(setq res (my/-find-jupyter-buffer-for-lang real)))
|
(setq res (my/-find-jupyter-buffer-for-lang real)))
|
||||||
res))
|
res))
|
||||||
|
|
||||||
@ -2188,13 +2189,8 @@ current buffer is a Jupyter buffer, just use that."
|
|||||||
major-mode))))
|
major-mode))))
|
||||||
(if-let ((buffer (my/-jupyter-find-proper-buffer)))
|
(if-let ((buffer (my/-jupyter-find-proper-buffer)))
|
||||||
(with-current-buffer buffer
|
(with-current-buffer buffer
|
||||||
(goto-char (point-max))
|
(let ((jupyter-repl-echo-eval-p t))
|
||||||
(let ((cur (jupyter-repl-cell-code)))
|
(jupyter-eval-string code)))
|
||||||
(jupyter-repl-clear-input)
|
|
||||||
(insert code)
|
|
||||||
(jupyter-repl-ret t)
|
|
||||||
(goto-char (point-max))
|
|
||||||
(insert cur)))
|
|
||||||
(unless no-error (user-error "No Jupyter buffer found for mode: %s"
|
(unless no-error (user-error "No Jupyter buffer found for mode: %s"
|
||||||
major-mode))))
|
major-mode))))
|
||||||
|
|
||||||
@ -2231,23 +2227,8 @@ current buffer is a Jupyter buffer, just use that."
|
|||||||
(back-to-indentation)
|
(back-to-indentation)
|
||||||
(unless (> (point) start)
|
(unless (> (point) start)
|
||||||
(goto-char start)))
|
(goto-char start)))
|
||||||
(if-let
|
(if-let ((thing (treesit-thing-at-point "_" 'nested))
|
||||||
((root (treesit-buffer-root-node))
|
(code (treesit-node-text thing)))
|
||||||
(res (car (or (treesit-query-range
|
|
||||||
root
|
|
||||||
'([(expression_statement) (call_expression)
|
|
||||||
(declaration)]
|
|
||||||
@exp)
|
|
||||||
(point) (1+ (point)))
|
|
||||||
(treesit-query-range
|
|
||||||
root
|
|
||||||
'([(binary_expression) (update_expression)] @exp)
|
|
||||||
(point) (1+ (point)))
|
|
||||||
(treesit-query-range
|
|
||||||
root
|
|
||||||
'((return_statement (_) @exp))
|
|
||||||
(point) (1+ (point))))))
|
|
||||||
(code (buffer-substring-no-properties (car res) (cdr res))))
|
|
||||||
(progn
|
(progn
|
||||||
(when (string-suffix-p ";" code)
|
(when (string-suffix-p ";" code)
|
||||||
(setq code (substring code 0 (1- (length code)))))
|
(setq code (substring code 0 (1- (length code)))))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user