]> code.delx.au - gnu-emacs/commitdiff
Fix auto-save and locking for indirect buffers.
authorChong Yidong <cyd@gnu.org>
Sat, 22 Sep 2012 03:07:39 +0000 (11:07 +0800)
committerChong Yidong <cyd@gnu.org>
Sat, 22 Sep 2012 03:07:39 +0000 (11:07 +0800)
* lisp/simple.el (undo): Handle indirect buffers.

* buffer.c (Fset_buffer_modified_p): Handle indirect buffers.

Fixes: debbugs:8207
lisp/ChangeLog
lisp/simple.el
src/ChangeLog
src/buffer.c

index e6fa549e8671b62d1f6e4557b12df20688ccf252..950e7e4b4da4f2d56efef7d920efaa30527bfa43 100644 (file)
@@ -1,3 +1,7 @@
+2012-09-22  Chong Yidong  <cyd@gnu.org>
+
+       * simple.el (undo): Handle indirect buffers (Bug#8207).
+
 2012-09-21  Leo Liu  <sdl.web@gmail.com>
 
        IDO: Disable match re-ordering for buffer switching.
index d87ae3c5c15d24b24faaf12efe0884f086d3f0f6..3e11e6838c7bc3ec6206ad45d5658cc7ca2d1616 100644 (file)
@@ -1855,9 +1855,13 @@ as an argument limits undo to changes within the current region."
   ;; another undo command will find the undo history empty
   ;; and will get another error.  To begin undoing the undos,
   ;; you must type some other command.
-  (let ((modified (buffer-modified-p))
-       (recent-save (recent-auto-save-p))
-       message)
+  (let* ((modified (buffer-modified-p))
+        ;; For an indirect buffer, look in the base buffer for the
+        ;; auto-save data.
+        (base-buffer (or (buffer-base-buffer) (current-buffer)))
+        (recent-save (with-current-buffer base-buffer
+                       (recent-auto-save-p)))
+        message)
     ;; If we get an error in undo-start,
     ;; the next command should not be a "consecutive undo".
     ;; So set `this-command' to something other than `undo'.
@@ -1935,7 +1939,8 @@ as an argument limits undo to changes within the current region."
     ;; Record what the current undo list says,
     ;; so the next command can tell if the buffer was modified in between.
     (and modified (not (buffer-modified-p))
-        (delete-auto-save-file-if-necessary recent-save))
+        (with-current-buffer base-buffer
+          (delete-auto-save-file-if-necessary recent-save)))
     ;; Display a message announcing success.
     (if message
        (message "%s" message))))
index 0d441761ce58a530e43b31af00bcc5cdf429bf57..439b5c06e277bbaee37cfd2b4d34a3e50c37b2e1 100644 (file)
@@ -1,3 +1,8 @@
+2012-09-22  Chong Yidong  <cyd@gnu.org>
+
+       * buffer.c (Fset_buffer_modified_p): Handle indirect buffers
+       (Bug#8207).
+
 2012-09-22  Kenichi Handa  <handa@gnu.org>
 
        * composite.c (composition_reseat_it): Handle the case that a
index b020edb99628ed3bea3d87331912eaf687250835..22624e33a4b77f292c155014942c89e8352b6d2d 100644 (file)
@@ -1341,9 +1341,13 @@ A non-nil FLAG means mark the buffer modified.  */)
   /* If buffer becoming modified, lock the file.
      If buffer becoming unmodified, unlock the file.  */
 
-  fn = BVAR (current_buffer, file_truename);
+  struct buffer *b = current_buffer->base_buffer
+    ? current_buffer->base_buffer
+    : current_buffer;
+
+  fn = BVAR (b, file_truename);
   /* Test buffer-file-name so that binding it to nil is effective.  */
-  if (!NILP (fn) && ! NILP (BVAR (current_buffer, filename)))
+  if (!NILP (fn) && ! NILP (BVAR (b, filename)))
     {
       bool already = SAVE_MODIFF < MODIFF;
       if (!already && !NILP (flag))