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
|
||||
(defvar my/jupyter-extra-language-associations
|
||||
'((c . c++)))
|
||||
'(("c" . "c++")))
|
||||
|
||||
(defun my/-find-jupyter-buffer-for-lang (lang)
|
||||
"Find a Jupyter buffer supporint LANG."
|
||||
@ -2158,7 +2158,8 @@ Note that this erases the buffer before doing anything."
|
||||
jupyter-current-client))))))
|
||||
(buffer-list))))
|
||||
(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)))
|
||||
res))
|
||||
|
||||
@ -2188,13 +2189,8 @@ current buffer is a Jupyter buffer, just use that."
|
||||
major-mode))))
|
||||
(if-let ((buffer (my/-jupyter-find-proper-buffer)))
|
||||
(with-current-buffer buffer
|
||||
(goto-char (point-max))
|
||||
(let ((cur (jupyter-repl-cell-code)))
|
||||
(jupyter-repl-clear-input)
|
||||
(insert code)
|
||||
(jupyter-repl-ret t)
|
||||
(goto-char (point-max))
|
||||
(insert cur)))
|
||||
(let ((jupyter-repl-echo-eval-p t))
|
||||
(jupyter-eval-string code)))
|
||||
(unless no-error (user-error "No Jupyter buffer found for mode: %s"
|
||||
major-mode))))
|
||||
|
||||
@ -2231,23 +2227,8 @@ current buffer is a Jupyter buffer, just use that."
|
||||
(back-to-indentation)
|
||||
(unless (> (point) start)
|
||||
(goto-char start)))
|
||||
(if-let
|
||||
((root (treesit-buffer-root-node))
|
||||
(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))))
|
||||
(if-let ((thing (treesit-thing-at-point "_" 'nested))
|
||||
(code (treesit-node-text thing)))
|
||||
(progn
|
||||
(when (string-suffix-p ";" code)
|
||||
(setq code (substring code 0 (1- (length code)))))
|
||||
|
Loading…
x
Reference in New Issue
Block a user