From 55b5f680ec7fc2d3f557ad6ef0796e399b13ebc4 Mon Sep 17 00:00:00 2001 From: Nathaniel Nicandro Date: Fri, 2 Nov 2018 09:14:29 -0500 Subject: [PATCH] Enable undo in a REPL input cell --- jupyter-repl.el | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/jupyter-repl.el b/jupyter-repl.el index b117b0d..f48e88a 100644 --- a/jupyter-repl.el +++ b/jupyter-repl.el @@ -250,7 +250,7 @@ Also handles any terminal control codes in the appended output." ;; Don't mess with font-lock and don't insert ;; continuation prompts (with-silent-modifications - (let (jit-lock-mode) + (let ((buffer-undo-list t) jit-lock-mode) (save-excursion (jupyter-repl-goto-cell ,req) (jupyter-repl-next-cell) @@ -458,7 +458,8 @@ can contain the following keywords along with their values: (let ((arg nil) (read-only t) (properties nil) - (insert-fun #'insert)) + (insert-fun #'insert) + (buffer-undo-list t)) (while (keywordp (setq arg (car args))) (cl-case arg (:read-only (setq read-only (cadr args))) @@ -1080,7 +1081,9 @@ REQ is the `jupyter-request' to associate with the current cell." (remove-text-properties beg (point) '(rear-nonsticky)) ;; font-lock-multiline to avoid improper syntactic elements from ;; spilling over to the rest of the buffer. - (add-text-properties beg (point) '(read-only t font-lock-multiline t)))) + (add-text-properties beg (point) '(read-only t font-lock-multiline t)) + ;; reset the undo list so that a completed cell doesn't get undone. + (setq buffer-undo-list '(nil)))) (defun jupyter-repl-replace-cell-code (new-code) "Replace the current cell code with NEW-CODE." @@ -2493,7 +2496,6 @@ in the appropriate direction, to the saved element." (add-hook 'after-change-functions 'jupyter-repl-do-after-change nil t) (add-hook 'pre-redisplay-functions 'jupyter-repl-preserve-window-margins nil t) ;; Initialize the REPL - (buffer-disable-undo) (jupyter-repl-initialize-hooks) (jupyter-repl-initialize-fontification) (jupyter-repl-isearch-setup)