emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] fix/undo-point-in-wrong-place 3e18fc2: Store point and buf


From: Phillip Lord
Subject: [Emacs-diffs] fix/undo-point-in-wrong-place 3e18fc2: Store point and buffer in independent variables.
Date: Thu, 26 Nov 2015 10:22:44 +0000

branch: fix/undo-point-in-wrong-place
commit 3e18fc27829247c2a9ff0d65766bd4030aaedd6a
Author: Phillip Lord <address@hidden>
Commit: Phillip Lord <address@hidden>

    Store point and buffer in independent variables.
---
 src/keyboard.c |   11 ++++++-----
 src/keyboard.h |    3 ++-
 src/undo.c     |    9 ++++++---
 3 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/src/keyboard.c b/src/keyboard.c
index 16a14a4..e2e114b 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -203,11 +203,7 @@ uintmax_t num_input_events;
 static EMACS_INT last_auto_save;
 
 /* The value of point when the last command was started. */
-ptrdiff_t last_point_position;
-
-/* The current buffer when the last command was started. */
-struct buffer *prev_buffer;
-
+static ptrdiff_t last_point_position;
 
 /* The frame in which the last input event occurred, or Qmacro if the
    last event came from a macro.  We use this to determine when to
@@ -1453,6 +1449,11 @@ command_loop_1 (void)
                result of changes from the last command. */
             call0 (Qundo_auto__add_boundary);
 
+            /* Record point and buffer, so we can put point into the undo
+               information if necessary. */
+            point_before_last_command_or_undo = PT;
+            buffer_before_last_command_or_undo = current_buffer;
+
             call1 (Qcommand_execute, Vthis_command);
 
 #ifdef HAVE_WINDOW_SYSTEM
diff --git a/src/keyboard.h b/src/keyboard.h
index 350d8ba..d4aa745 100644
--- a/src/keyboard.h
+++ b/src/keyboard.h
@@ -245,7 +245,8 @@ extern KBOARD *current_kboard;
 /* Total number of times read_char has returned, modulo UINTMAX_MAX + 1.  */
 extern uintmax_t num_input_events;
 
-extern ptrdiff_t last_point_position;
+ptrdiff_t point_before_last_command_or_undo;
+struct buffer *buffer_before_last_command_or_undo;
 
 extern struct buffer *prev_buffer;
 
diff --git a/src/undo.c b/src/undo.c
index 9c30441..279f32f 100644
--- a/src/undo.c
+++ b/src/undo.c
@@ -172,10 +172,10 @@ record_delete (ptrdiff_t beg, Lisp_Object string, bool 
record_markers)
   if (EQ (BVAR (current_buffer, undo_list), Qt))
     return;
 
-  if (last_point_position != beg &&
-      current_buffer == prev_buffer )
+  if (point_before_last_command_or_undo != beg &&
+      buffer_before_last_command_or_undo == current_buffer)
     {
-      record_point (last_point_position);
+      record_point (point_before_last_command_or_undo);
     }
 
   if (PT == beg + SCHARS (string))
@@ -294,6 +294,9 @@ but another undo command will undo to the previous 
boundary.  */)
     }
 
   Fset (Qundo_auto__last_boundary_cause, Qexplicit);
+  point_before_last_command_or_undo = PT;
+  buffer_before_last_command_or_undo = current_buffer;
+
   return Qnil;
 }
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]