diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2020-07-02 19:30:14 +0200 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2020-07-02 19:30:14 +0200 |
commit | b0bbe512b4d9a25bc0bea77a77a953ac70bf5393 (patch) | |
tree | d50957344f304a3e9190d42b459c7da220ecdd74 | |
parent | 73e367fca4fb4dd61f6d4215c473448da1b072b3 (diff) | |
download | org-mode-b0bbe512b4d9a25bc0bea77a77a953ac70bf5393.tar.gz |
src: Do not undo edit buffers back to empty state
* lisp/org-src.el (org-src--edit-element): Clear undo information once
the initial contents have been inserted.
* testing/lisp/test-org-src.el (test-org-src/undo): New test.
-rw-r--r-- | lisp/org-src.el | 4 | ||||
-rw-r--r-- | testing/lisp/test-org-src.el | 11 |
2 files changed, 15 insertions, 0 deletions
diff --git a/lisp/org-src.el b/lisp/org-src.el index 6f6c544..28733d0 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -558,6 +558,10 @@ Leave point in edit buffer." (setq org-src-source-file-name source-file-name) ;; Start minor mode. (org-src-mode) + ;; Clear undo information so we cannot undo back to the + ;; initial empty buffer. + (buffer-disable-undo (current-buffer)) + (buffer-enable-undo) ;; Move mark and point in edit buffer to the corresponding ;; location. (if remote diff --git a/testing/lisp/test-org-src.el b/testing/lisp/test-org-src.el index 2837ff9..2b1527a 100644 --- a/testing/lisp/test-org-src.el +++ b/testing/lisp/test-org-src.el @@ -58,6 +58,17 @@ (goto-char (point-max)) (should-error (org-edit-special)))) +(ert-deftest test-org-src/undo () + "Undo-ing an edit buffer should not go back to empty state." + (org-test-with-temp-text " +#+begin_src emacs-lisp<point> + (message hello) +#+end_src +" + (org-edit-special) + (should-error (undo)) + (org-edit-src-exit))) + (ert-deftest test-org-src/empty-block () "Editing empty block." (org-test-with-temp-text |