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 01beb39 2/2: Store value of


From: Phillip Lord
Subject: [Emacs-diffs] fix/undo-point-in-wrong-place 01beb39 2/2: Store value of point at beginning of last command.
Date: Mon, 23 Nov 2015 17:17:56 +0000

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

    Store value of point at beginning of last command.
---
 src/keyboard.c |    8 ++++++--
 src/keyboard.h |    4 ++++
 src/undo.c     |   14 +++++++-------
 3 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/src/keyboard.c b/src/keyboard.c
index 2449abb..16a14a4 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -202,8 +202,12 @@ uintmax_t num_input_events;
 
 static EMACS_INT last_auto_save;
 
-/* The value of point when the last command was started.  */
-static ptrdiff_t last_point_position;
+/* 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;
+
 
 /* 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
diff --git a/src/keyboard.h b/src/keyboard.h
index 98bc86b..350d8ba 100644
--- a/src/keyboard.h
+++ b/src/keyboard.h
@@ -245,6 +245,10 @@ 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;
+
+extern struct buffer *prev_buffer;
+
 /* Nonzero means polling for input is temporarily suppressed.  */
 extern int poll_suppress_count;
 
diff --git a/src/undo.c b/src/undo.c
index fbaa066..9c30441 100644
--- a/src/undo.c
+++ b/src/undo.c
@@ -22,7 +22,7 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 
 #include "lisp.h"
 #include "buffer.h"
-#include <stdio.h>
+#include "keyboard.h"
 
 /* The first time a command records something for undo.
    it also allocates the undo-boundary object
@@ -70,9 +70,7 @@ record_point (ptrdiff_t pt)
 
   /* If we are just after an undo boundary, and
      point wasn't at start of deleted range, record where it was.  */
-  if (at_boundary
-      && current_buffer == last_boundary_buffer
-      && last_boundary_position != pt){
+  if (at_boundary){
     bset_undo_list (current_buffer,
                    Fcons (make_number (pt),
                           BVAR (current_buffer, undo_list)));
@@ -174,9 +172,11 @@ record_delete (ptrdiff_t beg, Lisp_Object string, bool 
record_markers)
   if (EQ (BVAR (current_buffer, undo_list), Qt))
     return;
 
-  if (PT != beg ){
-    record_point (PT);
-  }
+  if (last_point_position != beg &&
+      current_buffer == prev_buffer )
+    {
+      record_point (last_point_position);
+    }
 
   if (PT == beg + SCHARS (string))
     {



reply via email to

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