@@ -208,12 +208,14 @@ buffer."
208208 (let ((win (get-buffer-window )))
209209 (when win (set-window-point win (point ))))))))
210210
211+ (defvar jupyter-repl-inhibit-continuation-prompts nil
212+ " Non-nil when continuation prompts are suppressed.
213+ See `jupyter-repl-insert-continuation-prompts' ." )
214+
211215(defmacro jupyter-repl-without-continuation-prompts (&rest body )
212- " Evaluate BODY without inserting continuation prompts.
213- This is done by inhibiting modification hooks while BODY is being
214- evaluated."
216+ " Evaluate BODY without inserting continuation prompts."
215217 (declare (debug (&rest form)))
216- `(let ((inhibit-modification-hooks t ))
218+ `(let ((jupyter-repl- inhibit-continuation-prompts t ))
217219 ,@body ))
218220
219221(defmacro jupyter-repl-append-output (client req &rest body )
@@ -1322,20 +1324,25 @@ cell."
13221324(defun jupyter-repl-insert-continuation-prompts (bound )
13231325 " Insert continuation prompts if needed, stopping at BOUND.
13241326Return the new BOUND since inserting continuation prompts may add
1325- more characters than were initially in the buffer."
1326- (setq bound (set-marker (make-marker ) bound))
1327- (set-marker-insertion-type bound t )
1328- ; ; Don't record these changes as it adds unnecessary undo information which
1329- ; ; interferes with undo.
1330- (let ((buffer-undo-list t ))
1331- (while (and (< (point ) bound)
1332- (search-forward " \n " bound 'noerror ))
1333- ; ; Delete the newline that is re-added by prompt insertion
1334- ; ; FIXME: Why not just overlay the newline?
1335- (delete-char -1 )
1336- (jupyter-repl-insert-prompt 'continuation )))
1337- (prog1 (marker-position bound)
1338- (set-marker bound nil )))
1327+ more characters than were initially in the buffer.
1328+
1329+ If `jupyter-repl-inhibit-continuation-prompts' is non-nil return
1330+ BOUND without inserting any continuation prompts."
1331+ (if jupyter-repl-inhibit-continuation-prompts
1332+ bound
1333+ (setq bound (set-marker (make-marker ) bound))
1334+ (set-marker-insertion-type bound t )
1335+ ; ; Don't record these changes as it adds unnecessary undo information which
1336+ ; ; interferes with undo.
1337+ (let ((buffer-undo-list t ))
1338+ (while (and (< (point ) bound)
1339+ (search-forward " \n " bound 'noerror ))
1340+ ; ; Delete the newline that is re-added by prompt insertion
1341+ ; ; FIXME: Why not just overlay the newline?
1342+ (delete-char -1 )
1343+ (jupyter-repl-insert-prompt 'continuation )))
1344+ (prog1 (marker-position bound)
1345+ (set-marker bound nil ))))
13391346
13401347(defun jupyter-repl-mark-as-cell-code (beg end )
13411348 " Add the field property to text between (BEG . END) if within a code cell."
0 commit comments