[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] fix/segfault-undoable-change-prepare-for-buffer 01644fe: r
From: |
Phillip Lord |
Subject: |
[Emacs-diffs] fix/segfault-undoable-change-prepare-for-buffer 01644fe: run_undoable_changes now called from insdel. |
Date: |
Tue, 17 Nov 2015 20:48:06 +0000 |
branch: fix/segfault-undoable-change-prepare-for-buffer
commit 01644fe5d4c463612d479384b9404e45558aff1d
Author: Phillip Lord <address@hidden>
Commit: Phillip Lord <address@hidden>
run_undoable_changes now called from insdel.
The original calls from inside undo.c are not always at a safe position
to call lisp, as they originate in varied positions within insdel.c.
Calling them directly from prepare_to_modify_buffer_1 ensures that they
are always run at the same point.
---
src/insdel.c | 14 ++++++++++++++
src/undo.c | 19 -------------------
2 files changed, 14 insertions(+), 19 deletions(-)
diff --git a/src/insdel.c b/src/insdel.c
index 24807b1..0b1b0c2 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -30,6 +30,7 @@ along with GNU Emacs. If not, see
<http://www.gnu.org/licenses/>. */
#include "window.h"
#include "region-cache.h"
+
static void insert_from_string_1 (Lisp_Object, ptrdiff_t, ptrdiff_t, ptrdiff_t,
ptrdiff_t, bool, bool);
static void insert_from_buffer_1 (struct buffer *, ptrdiff_t, ptrdiff_t, bool);
@@ -1765,6 +1766,15 @@ modify_text (ptrdiff_t start, ptrdiff_t end)
bset_point_before_scroll (current_buffer, Qnil);
}
+static void
+run_undoable_change (void)
+{
+ if (EQ (BVAR (current_buffer, undo_list), Qt))
+ return;
+
+ call0 (Qundo_auto__undoable_change);
+}
+
/* Check that it is okay to modify the buffer between START and END,
which are char positions.
@@ -1786,6 +1796,8 @@ prepare_to_modify_buffer_1 (ptrdiff_t start, ptrdiff_t
end,
if (!NILP (BVAR (current_buffer, read_only)))
Fbarf_if_buffer_read_only (temp);
+ run_undoable_change();
+
bset_redisplay (current_buffer);
if (buffer_intervals (current_buffer))
@@ -2187,6 +2199,8 @@ syms_of_insdel (void)
combine_after_change_list = Qnil;
combine_after_change_buffer = Qnil;
+ DEFSYM (Qundo_auto__undoable_change, "undo-auto--undoable-change");
+
DEFVAR_LISP ("combine-after-change-calls", Vcombine_after_change_calls,
doc: /* Used internally by the function
`combine-after-change-calls' macro. */);
Vcombine_after_change_calls = Qnil;
diff --git a/src/undo.c b/src/undo.c
index 214beae..104c3bb 100644
--- a/src/undo.c
+++ b/src/undo.c
@@ -34,12 +34,6 @@ static ptrdiff_t last_boundary_position;
an undo-boundary. */
static Lisp_Object pending_boundary;
-static void
-run_undoable_change (void)
-{
- call0 (Qundo_auto__undoable_change);
-}
-
/* Record point as it was at beginning of this command (if necessary)
and prepare the undo info for recording a change.
PT is the position of point that will naturally occur as a result of the
@@ -58,8 +52,6 @@ record_point (ptrdiff_t pt)
if (NILP (pending_boundary))
pending_boundary = Fcons (Qnil, Qnil);
- run_undoable_change ();
-
at_boundary = ! CONSP (BVAR (current_buffer, undo_list))
|| NILP (XCAR (BVAR (current_buffer, undo_list)));
@@ -130,8 +122,6 @@ record_marker_adjustments (ptrdiff_t from, ptrdiff_t to)
if (NILP (pending_boundary))
pending_boundary = Fcons (Qnil, Qnil);
- run_undoable_change ();
-
for (m = BUF_MARKERS (current_buffer); m; m = m->next)
{
charpos = m->charpos;
@@ -243,11 +233,6 @@ record_property_change (ptrdiff_t beg, ptrdiff_t length,
if (NILP (pending_boundary))
pending_boundary = Fcons (Qnil, Qnil);
- /* Switch temporarily to the buffer that was changed. */
- set_buffer_internal (buf);
-
- run_undoable_change ();
-
if (MODIFF <= SAVE_MODIFF)
record_first_change ();
@@ -256,9 +241,6 @@ record_property_change (ptrdiff_t beg, ptrdiff_t length,
entry = Fcons (Qnil, Fcons (prop, Fcons (value, Fcons (lbeg, lend))));
bset_undo_list (current_buffer,
Fcons (entry, BVAR (current_buffer, undo_list)));
-
- /* Reset the buffer */
- set_buffer_internal (obuf);
}
DEFUN ("undo-boundary", Fundo_boundary, Sundo_boundary, 0, 0, 0,
@@ -432,7 +414,6 @@ void
syms_of_undo (void)
{
DEFSYM (Qinhibit_read_only, "inhibit-read-only");
- DEFSYM (Qundo_auto__undoable_change, "undo-auto--undoable-change");
DEFSYM (Qundo_auto__last_boundary_cause, "undo-auto--last-boundary-cause");
DEFSYM (Qexplicit, "explicit");