emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] fix/no-undo-boundary-on-secondary-buffer-change 1f9be1a 1/


From: Phillip Lord
Subject: [Emacs-diffs] fix/no-undo-boundary-on-secondary-buffer-change 1f9be1a 1/2: Half of Stefans fixes applied!
Date: Tue, 10 Nov 2015 20:47:12 +0000

branch: fix/no-undo-boundary-on-secondary-buffer-change
commit 1f9be1aced5ad52eaa2899e7c88f6b1290a02a3f
Author: Phillip Lord <address@hidden>
Commit: Phillip Lord <address@hidden>

    Half of Stefans fixes applied!
---
 lisp/simple.el |   12 ++++++----
 src/cmds.c     |   10 +++++---
 src/keyboard.c |    9 ++-----
 src/undo.c     |   58 +------------------------------------------------------
 4 files changed, 18 insertions(+), 71 deletions(-)

diff --git a/lisp/simple.el b/lisp/simple.el
index 660bf04..306bc67 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -2245,6 +2245,7 @@ as an argument limits undo to changes within the current 
region."
     ;; the next command should not be a "consecutive undo".
     ;; So set `this-command' to something other than `undo'.
     (setq this-command 'undo-start)
+
     (unless (and (eq last-command 'undo)
                 (or (eq pending-undo-list t)
                     ;; If something (a timer or filter?) changed the buffer
@@ -2761,7 +2762,7 @@ with < or <= based on USE-<."
 (defvar-local undo-last-boundary nil
   "Describe the cause of the last undo-boundary.
 
-If nil, the last boundary was caused by an explicit call to
+If 'explicit, the last boundary was caused by an explicit call to
 `undo-boundary', that is one not called by the code in this
 section.
 
@@ -2784,8 +2785,8 @@ If set to non-nil, this will effectively disable the 
timer.")
 
 (defvar undo--this-command-amalgamating nil
   "Non-nil if `this-command' should be amalgamated.
-This variable is set to nil by the command loop and is set by
-`undo--auto-pre-amalgamating-command'." )
+This variable is set to nil by `undo--auto-boundary' and is set
+by `undo-auto--amalgamate'." )
 
 (defun undo--needs-boundary-p ()
   "Return non-nil if `buffer-undo-list' needs a boundary at the start."
@@ -2855,9 +2856,10 @@ See also `undo--buffer-undoably-changed'.")
     (undo--auto-boundary
      (if undo--this-command-amalgamating
          'amalgamate
-       'command))))
+       'command)))
+  (setq undo--this-command-amalgamating nil))
 
-(defun undo--auto-pre-amalgamating-command ()
+(defun undo-auto--amalgamate ()
   "Amalgamate undo if necessary.
 This function is called before `self-insert-command', and removes
 the previous `undo-boundary' if a series of `self-insert-command'
diff --git a/src/cmds.c b/src/cmds.c
index a2b011d..39de5fc 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -235,7 +235,7 @@ because it respects values of `delete-active-region' and 
`overwrite-mode'.  */)
   CHECK_NUMBER (n);
 
   if (abs (XINT (n)) < 2)
-    call0(Qundo__auto_pre_amalgamating_command);
+    call0 (Qundo_auto__amalgamate);
 
   pos = PT + XINT (n);
   if (NILP (killflag))
@@ -281,7 +281,7 @@ At the end, it runs `post-self-insert-hook'.  */)
     error ("Negative repetition argument %"pI"d", XFASTINT (n));
 
   if (XFASTINT (n) < 2)
-    call0 (Qundo__auto_pre_amalgamating_command);
+    call0 (Qundo_auto__amalgamate);
 
   /* Barf if the key that invoked this was not a character.  */
   if (!CHARACTERP (last_command_event))
@@ -290,6 +290,8 @@ At the end, it runs `post-self-insert-hook'.  */)
     int character = translate_char (Vtranslation_table_for_input,
                                    XINT (last_command_event));
     int val = internal_self_insert (character, XFASTINT (n));
+    if (val==2)
+      Fset (Qundo__this_command_amalgamating, Qnil);
     frame_make_pointer_invisible (SELECTED_FRAME ());
   }
 
@@ -494,8 +496,8 @@ internal_self_insert (int c, EMACS_INT n)
 void
 syms_of_cmds (void)
 {
-  DEFSYM (Qundo__auto_pre_amalgamating_command,
-          "undo--auto-pre-amalgamating-command" );
+  DEFSYM (Qundo_auto__amalgamate,
+          "undo-auto--amalgamate" );
 
   DEFSYM (Qkill_forward_chars, "kill-forward-chars");
 
diff --git a/src/keyboard.c b/src/keyboard.c
index 3660669..c62ebfc 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -1344,10 +1344,6 @@ command_loop_1 (void)
       while (pending_malloc_warning)
        display_malloc_warning ();
 
-      /* Ensure that we have added appropriate undo-boundaries as a
-         result of changes from the last command. */
-      call0 (Qundo__auto_add_boundary);
-
       Vdeactivate_mark = Qnil;
 
       /* Don't ignore mouse movements for more than a single command
@@ -1506,7 +1502,9 @@ command_loop_1 (void)
               }
 #endif
 
-            Fset (Qundo__this_command_amalgamating, Qnil);
+            /* Ensure that we have added appropriate undo-boundaries as a
+               result of changes from the last command. */
+            call0 (Qundo__auto_add_boundary);
 
             call1 (Qcommand_execute, Vthis_command);
 
@@ -11090,7 +11088,6 @@ syms_of_keyboard (void)
   DEFSYM (Qpre_command_hook, "pre-command-hook");
   DEFSYM (Qpost_command_hook, "post-command-hook");
 
-  DEFSYM (Qundo__this_command_amalgamating, "undo--this-command-amalgamating");
   DEFSYM (Qundo__auto_add_boundary, "undo--auto-add-boundary");
 
   DEFSYM (Qdeferred_action_function, "deferred-action-function");
diff --git a/src/undo.c b/src/undo.c
index dd4f3e6..4958aa5 100644
--- a/src/undo.c
+++ b/src/undo.c
@@ -293,64 +293,10 @@ but another undo command will undo to the previous 
boundary.  */)
   last_boundary_position = PT;
   last_boundary_buffer = current_buffer;
 
-  Fset (Qundo_last_boundary,Qnil);
+  Fset (Qundo_last_boundary, Qexplicit);
   return Qnil;
 }
 
-DEFUN ("undo-size", Fundo_size, Sundo_size, 0, 1, 0,
-       doc: /* Return the size of `buffer-undo-list'.
-
-If n count till the end of the nth boundary, or the whole list iff n
-is zero.
-
-Returns nil if `buffer-undo-list' is t; that is there is no undo list.
-Otherwise, returns the size of `buffer-undo-list' in bytes.*/)
-     (Lisp_Object n)
-{
-  /* We do not have an undo_list anyway.*/
-  if (EQ (BVAR (current_buffer, undo_list), Qt))
-    return Qnil;
-
-  Lisp_Object prev, next;
-  EMACS_INT size_so_far = 0, boundary_so_far = 0, num = 0;
-  if( ! NILP( n ) )
-    {
-      CHECK_NUMBER(n);
-      num = XINT(n);
-    }
-
-  prev = Qnil;
-  next = BVAR (current_buffer, undo_list);
-
-  while(CONSP (next))
-    {
-      Lisp_Object elt;
-      elt = XCAR (next);
-
-      size_so_far += sizeof (struct Lisp_Cons);
-      if (CONSP (elt))
-        {
-          /* We have a boundary, so check we do not have too many.*/
-          if (NILP (elt))
-            {
-              boundary_so_far = boundary_so_far + 1;
-              if(boundary_so_far >= num)
-                break;
-            }
-
-          if (STRINGP (XCAR (elt)))
-            size_so_far += (sizeof (struct Lisp_String) - 1
-                            + SCHARS (XCAR (elt)));
-        }
-
-      /* and advance */
-      prev = next;
-      next = XCDR (next);
-    }
-
-  return make_number (size_so_far);
- }
-
 /* At garbage collection time, make an undo list shorter at the end,
    returning the truncated list.  How this is done depends on the
    variables undo-limit, undo-strong-limit and undo-outer-limit.
@@ -492,6 +438,7 @@ syms_of_undo (void)
   DEFSYM (Qinhibit_read_only, "inhibit-read-only");
   DEFSYM (Qundo__undoable_change, "undo--undoable-change");
   DEFSYM (Qundo_last_boundary, "undo-last-boundary");
+  DEFSYM (Qexplicit, "explicit");
 
   /* Marker for function call undo list elements.  */
   DEFSYM (Qapply, "apply");
@@ -501,7 +448,6 @@ syms_of_undo (void)
 
   last_boundary_buffer = NULL;
 
-  defsubr (&Sundo_size);
   defsubr (&Sundo_boundary);
 
   DEFVAR_INT ("undo-limit", undo_limit,



reply via email to

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