Skip to content

Commit

Permalink
Query for a kernel with point at the last place a user left it
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
nnicandro committed Apr 22, 2021
1 parent 026c3fa commit c36f6fd
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions jupyter-org-extensions.el
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ blocks could be found in the buffer.
Distance is line based, not character based. Also, `point' is
assumed to not be inside a source block."
(org-save-outline-visibility nil
(save-excursion
(or (and (null query)
(or (save-excursion
(and (null query)
(cl-loop
with start = (line-number-at-pos)
with previous = (ignore-errors
Expand Down Expand Up @@ -102,12 +102,12 @@ assumed to not be inside a source block."
(funcall maybe-return-lang)
(setq next (ignore-errors
(org-babel-next-src-block)
(point)))))))
;; If all else fails, query for the language to use
(let* ((kernelspec (jupyter-completing-read-kernelspec))
(lang (plist-get (cddr kernelspec) :language)))
(if (org-babel-jupyter-language-p lang) lang
(format "jupyter-%s" lang)))))))
(point))))))))
;; If all else fails, query for the language to use
(let* ((kernelspec (jupyter-completing-read-kernelspec))
(lang (plist-get (cddr kernelspec) :language)))
(if (org-babel-jupyter-language-p lang) lang
(format "jupyter-%s" lang))))))

(defun jupyter-org-between-block-end-and-result-p ()
"If `point' is between a src-block and its result, return the result end.
Expand Down

0 comments on commit c36f6fd

Please sign in to comment.