feat(org): jupyter-repl: move cursor to prompt on self-insert-command

Ala 3384414, but for jupyter-repl, which isn't a comint-derived.

Ref: 3384414e957f
This commit is contained in:
Henrik Lissner
2025-07-03 15:43:59 +02:00
parent 47e52ab86f
commit 29ec1f40f3

View File

@ -1,5 +1,26 @@
;;; lang/org/contrib/jupyter.el -*- lexical-binding: t; -*-
;;;###if (modulep! +jupyter)
;; TODO: Move to :tools jupyter
(use-package! jupyter-repl
:defer t
:config
;; HACK: If the user is anywhere but the last prompt, typing should move them
;; there instead of unhelpfully spewing read-only errors at them.
;; REVIEW: Upstream this (maybe?)
(defun +jupyter--move-cursor-to-prompt-h ()
(and (eq this-command 'self-insert-command)
(> (save-excursion
(goto-char (point-max))
(jupyter-repl-cell-code-beginning-position))
(point))
(goto-char (point-max))))
(add-hook! 'jupyter-repl-mode-hook
(defun +jupyter--init-move-cursor-to-prompt-h ()
(add-hook 'pre-command-hook #'+jupyter--move-cursor-to-prompt-h
nil t))))
(use-package! ob-jupyter
:defer t