Prechádzať zdrojové kódy

Fix org-src-edit interaction with undo.

* 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.
Aaron Ecay 11 rokov pred
rodič
commit
cb53665e55
1 zmenil súbory, kde vykonal 7 pridanie a 7 odobranie
  1. 7 7
      lisp/org-src.el

+ 7 - 7
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))