Query for a kernel with point at the last place a user left it

`jupyter-org-closest-jupyter-language` falls back to asking a user for a
kernel, when it does so `point` is at the beginning of the buffer. Make sure
`point` is at the location where the user last left it.

* jupyter-org-extensions.el (jupyter-org-closest-jupyter-language): Do it.
This commit is contained in:
Nathaniel Nicandro 2020-04-08 08:09:04 -05:00
parent 026c3fac61
commit c36f6fd63a

View file

@ -65,8 +65,8 @@ blocks could be found in the buffer.
Distance is line based, not character based. Also, `point' is Distance is line based, not character based. Also, `point' is
assumed to not be inside a source block." assumed to not be inside a source block."
(org-save-outline-visibility nil (org-save-outline-visibility nil
(save-excursion (or (save-excursion
(or (and (null query) (and (null query)
(cl-loop (cl-loop
with start = (line-number-at-pos) with start = (line-number-at-pos)
with previous = (ignore-errors with previous = (ignore-errors
@ -102,12 +102,12 @@ assumed to not be inside a source block."
(funcall maybe-return-lang) (funcall maybe-return-lang)
(setq next (ignore-errors (setq next (ignore-errors
(org-babel-next-src-block) (org-babel-next-src-block)
(point))))))) (point))))))))
;; If all else fails, query for the language to use ;; If all else fails, query for the language to use
(let* ((kernelspec (jupyter-completing-read-kernelspec)) (let* ((kernelspec (jupyter-completing-read-kernelspec))
(lang (plist-get (cddr kernelspec) :language))) (lang (plist-get (cddr kernelspec) :language)))
(if (org-babel-jupyter-language-p lang) lang (if (org-babel-jupyter-language-p lang) lang
(format "jupyter-%s" lang))))))) (format "jupyter-%s" lang))))))
(defun jupyter-org-between-block-end-and-result-p () (defun jupyter-org-between-block-end-and-result-p ()
"If `point' is between a src-block and its result, return the result end. "If `point' is between a src-block and its result, return the result end.