From cb53665e553b6d8b644b2e166d97be2bab753a98 Mon Sep 17 00:00:00 2001 From: Aaron Ecay Date: Wed, 28 Aug 2013 11:50:53 -0400 Subject: [PATCH] Fix org-src-edit interaction with undo. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * org-src.el (org-edit-src-exit): Place an undo boundary before writing changes back to parent buffer. The previous code attempted to preserve the undo information in the indirect buffer editing the source code, but this interacts poorly with the undo system, and can lead to undo operations scrambling the buffer. The new approach means that edits made in the indirect buffer cannot be undone piece-by-piece (instead, all changes made in the indirect buffer constitute one “change” from the point of view of undo), but the misbehavior of undo is (hopefully) now avoided. --- lisp/org-src.el | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lisp/org-src.el b/lisp/org-src.el index f2091ef01..f870b2c71 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -753,14 +753,14 @@ with \",*\", \",#+\", \",,*\" and \",,#+\"." (kill-buffer buffer)) (goto-char beg) (when allow-write-back-p - (let ((buffer-undo-list t)) - (delete-region beg (max beg end)) - (unless (string-match "\\`[ \t]*\\'" code) - (insert code)) - ;; Make sure the overlay stays in place + (undo-boundary) + (delete-region beg (max beg end)) + (unless (string-match "\\`[ \t]*\\'" code) + (insert code)) + ;; Make sure the overlay stays in place (when (eq context 'save) (move-overlay ovl beg (point))) - (goto-char beg) - (if single (just-one-space)))) + (goto-char beg) + (if single (just-one-space))) (if (memq t (mapcar (lambda (overlay) (eq (overlay-get overlay 'invisible) 'org-hide-block)) -- 2.11.4.GIT