HCoop
/
bpt
/
emacs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Inline functions to examine and change buffer intervals.
[bpt/emacs.git]
/
src
/
insdel.c
diff --git
a/src/insdel.c
b/src/insdel.c
index
148ba22
..
ec0d3b3
100644
(file)
--- a/
src/insdel.c
+++ b/
src/insdel.c
@@
-25,8
+25,8
@@
along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "lisp.h"
#include "intervals.h"
#include "lisp.h"
#include "intervals.h"
-#include "buffer.h"
#include "character.h"
#include "character.h"
+#include "buffer.h"
#include "window.h"
#include "blockinput.h"
#include "region-cache.h"
#include "window.h"
#include "blockinput.h"
#include "region-cache.h"
@@
-41,8
+41,6
@@
static void insert_from_buffer_1 (struct buffer *buf,
static void gap_left (ptrdiff_t charpos, ptrdiff_t bytepos, int newgap);
static void gap_right (ptrdiff_t charpos, ptrdiff_t bytepos);
static void gap_left (ptrdiff_t charpos, ptrdiff_t bytepos, int newgap);
static void gap_right (ptrdiff_t charpos, ptrdiff_t bytepos);
-static Lisp_Object Fcombine_after_change_execute (void);
-
/* List of elements of the form (BEG-UNCHANGED END-UNCHANGED CHANGE-AMOUNT)
describing changes which happened while combine_after_change_calls
was nonzero. We use this to decide how to call them
/* List of elements of the form (BEG-UNCHANGED END-UNCHANGED CHANGE-AMOUNT)
describing changes which happened while combine_after_change_calls
was nonzero. We use this to decide how to call them
@@
-61,14
+59,10
@@
static Lisp_Object combine_after_change_buffer;
Lisp_Object Qinhibit_modification_hooks;
static void signal_before_change (ptrdiff_t, ptrdiff_t, ptrdiff_t *);
Lisp_Object Qinhibit_modification_hooks;
static void signal_before_change (ptrdiff_t, ptrdiff_t, ptrdiff_t *);
-
\f
-#define CHECK_MARKERS() \
- do \
- { \
- if (check_markers_debug_flag) \
- check_markers (); \
- } \
- while (0)
+
+/* Also used in marker.c to enable expensive marker checks. */
+
+#ifdef MARKER_DEBUG
static void
check_markers (void)
static void
check_markers (void)
@@
-88,7
+82,13
@@
check_markers (void)
abort ();
}
}
abort ();
}
}
-
\f
+
+#else /* not MARKER_DEBUG */
+
+#define check_markers() do { } while (0)
+
+#endif /* MARKER_DEBUG */
+
/* Move gap to position CHARPOS.
Note that this can quit! */
/* Move gap to position CHARPOS.
Note that this can quit! */
@@
-160,8
+160,7
@@
gap_left (ptrdiff_t charpos, ptrdiff_t bytepos, int newgap)
was specified or may be where a quit was detected. */
GPT_BYTE = bytepos;
GPT = charpos;
was specified or may be where a quit was detected. */
GPT_BYTE = bytepos;
GPT = charpos;
- if (bytepos < charpos)
- abort ();
+ eassert (charpos <= bytepos);
if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */
QUIT;
}
if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */
QUIT;
}
@@
-211,8
+210,7
@@
gap_right (ptrdiff_t charpos, ptrdiff_t bytepos)
GPT = charpos;
GPT_BYTE = bytepos;
GPT = charpos;
GPT_BYTE = bytepos;
- if (bytepos < charpos)
- abort ();
+ eassert (charpos <= bytepos);
if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */
QUIT;
}
if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */
QUIT;
}
@@
-235,9
+233,7
@@
adjust_markers_for_delete (ptrdiff_t from, ptrdiff_t from_byte,
for (m = BUF_MARKERS (current_buffer); m; m = m->next)
{
charpos = m->charpos;
for (m = BUF_MARKERS (current_buffer); m; m = m->next)
{
charpos = m->charpos;
-
- if (charpos > Z)
- abort ();
+ eassert (charpos <= Z);
/* If the marker is after the deletion,
relocate by number of chars / bytes deleted. */
/* If the marker is after the deletion,
relocate by number of chars / bytes deleted. */
@@
-377,7
+373,7
@@
adjust_markers_for_replace (ptrdiff_t from, ptrdiff_t from_byte,
}
}
}
}
-
CHECK_MARKERS
();
+
check_markers
();
}
\f
}
\f
@@
-837,8
+833,7
@@
insert_1_both (const char *string,
Z_BYTE += nbytes;
if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */
Z_BYTE += nbytes;
if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */
- if (GPT_BYTE < GPT)
- abort ();
+ eassert (GPT <= GPT_BYTE);
/* The insert may have been in the unchanged region, so check again. */
if (Z - GPT < END_UNCHANGED)
/* The insert may have been in the unchanged region, so check again. */
if (Z - GPT < END_UNCHANGED)
@@
-849,16
+844,16
@@
insert_1_both (const char *string,
PT + nchars, PT_BYTE + nbytes,
before_markers);
PT + nchars, PT_BYTE + nbytes,
before_markers);
- if (
BUF_INTERVALS (current_buffer) != 0
)
+ if (
buffer_get_intervals (current_buffer)
)
offset_intervals (current_buffer, PT, nchars);
offset_intervals (current_buffer, PT, nchars);
- if (!inherit &&
BUF_INTERVALS (current_buffer) != 0
)
+ if (!inherit &&
buffer_get_intervals (current_buffer)
)
set_text_properties (make_number (PT), make_number (PT + nchars),
Qnil, Qnil, Qnil);
adjust_point (nchars, nbytes);
set_text_properties (make_number (PT), make_number (PT + nchars),
Qnil, Qnil, Qnil);
adjust_point (nchars, nbytes);
-
CHECK_MARKERS
();
+
check_markers
();
}
\f
/* Insert the part of the text of STRING, a Lisp object assumed to be
}
\f
/* Insert the part of the text of STRING, a Lisp object assumed to be
@@
-968,8
+963,7
@@
insert_from_string_1 (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte,
Z_BYTE += outgoing_nbytes;
if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */
Z_BYTE += outgoing_nbytes;
if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */
- if (GPT_BYTE < GPT)
- abort ();
+ eassert (GPT <= GPT_BYTE);
/* The insert may have been in the unchanged region, so check again. */
if (Z - GPT < END_UNCHANGED)
/* The insert may have been in the unchanged region, so check again. */
if (Z - GPT < END_UNCHANGED)
@@
-982,7
+976,7
@@
insert_from_string_1 (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte,
offset_intervals (current_buffer, PT, nchars);
offset_intervals (current_buffer, PT, nchars);
- intervals =
STRING_INTERVALS
(string);
+ intervals =
string_get_intervals
(string);
/* Get the intervals for the part of the string we are inserting. */
if (nbytes < SBYTES (string))
intervals = copy_intervals (intervals, pos, nchars);
/* Get the intervals for the part of the string we are inserting. */
if (nbytes < SBYTES (string))
intervals = copy_intervals (intervals, pos, nchars);
@@
-993,7
+987,7
@@
insert_from_string_1 (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte,
adjust_point (nchars, outgoing_nbytes);
adjust_point (nchars, outgoing_nbytes);
-
CHECK_MARKERS
();
+
check_markers
();
}
\f
/* Insert a sequence of NCHARS chars which occupy NBYTES bytes
}
\f
/* Insert a sequence of NCHARS chars which occupy NBYTES bytes
@@
-1017,24
+1011,23
@@
insert_from_gap (ptrdiff_t nchars, ptrdiff_t nbytes)
Z_BYTE += nbytes;
if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */
Z_BYTE += nbytes;
if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */
- if (GPT_BYTE < GPT)
- abort ();
+ eassert (GPT <= GPT_BYTE);
adjust_overlays_for_insert (GPT - nchars, nchars);
adjust_markers_for_insert (GPT - nchars, GPT_BYTE - nbytes,
GPT, GPT_BYTE, 0);
adjust_overlays_for_insert (GPT - nchars, nchars);
adjust_markers_for_insert (GPT - nchars, GPT_BYTE - nbytes,
GPT, GPT_BYTE, 0);
- if (
BUF_INTERVALS (current_buffer) != 0
)
+ if (
buffer_get_intervals (current_buffer)
)
{
offset_intervals (current_buffer, GPT - nchars, nchars);
{
offset_intervals (current_buffer, GPT - nchars, nchars);
- graft_intervals_into_buffer (NULL
_INTERVAL
, GPT - nchars, nchars,
+ graft_intervals_into_buffer (NULL, GPT - nchars, nchars,
current_buffer, 0);
}
if (GPT - nchars < PT)
adjust_point (nchars, nbytes);
current_buffer, 0);
}
if (GPT - nchars < PT)
adjust_point (nchars, nbytes);
-
CHECK_MARKERS
();
+
check_markers
();
}
\f
/* Insert text from BUF, NCHARS characters starting at CHARPOS, into the
}
\f
/* Insert text from BUF, NCHARS characters starting at CHARPOS, into the
@@
-1153,8
+1146,7
@@
insert_from_buffer_1 (struct buffer *buf,
Z_BYTE += outgoing_nbytes;
if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */
Z_BYTE += outgoing_nbytes;
if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */
- if (GPT_BYTE < GPT)
- abort ();
+ eassert (GPT <= GPT_BYTE);
/* The insert may have been in the unchanged region, so check again. */
if (Z - GPT < END_UNCHANGED)
/* The insert may have been in the unchanged region, so check again. */
if (Z - GPT < END_UNCHANGED)
@@
-1165,11
+1157,11
@@
insert_from_buffer_1 (struct buffer *buf,
PT_BYTE + outgoing_nbytes,
0);
PT_BYTE + outgoing_nbytes,
0);
- if (
BUF_INTERVALS (current_buffer) != 0
)
+ if (
buffer_get_intervals (current_buffer)
)
offset_intervals (current_buffer, PT, nchars);
/* Get the intervals for the part of the string we are inserting. */
offset_intervals (current_buffer, PT, nchars);
/* Get the intervals for the part of the string we are inserting. */
- intervals =
BUF_INTERVALS
(buf);
+ intervals =
buffer_get_intervals
(buf);
if (nchars < BUF_Z (buf) - BUF_BEG (buf))
{
if (buf == current_buffer && PT <= from)
if (nchars < BUF_Z (buf) - BUF_BEG (buf))
{
if (buf == current_buffer && PT <= from)
@@
-1233,10
+1225,9
@@
adjust_after_replace (ptrdiff_t from, ptrdiff_t from_byte,
adjust_overlays_for_insert (from, len - nchars_del);
else if (len < nchars_del)
adjust_overlays_for_delete (from, nchars_del - len);
adjust_overlays_for_insert (from, len - nchars_del);
else if (len < nchars_del)
adjust_overlays_for_delete (from, nchars_del - len);
- if (BUF_INTERVALS (current_buffer) != 0)
- {
- offset_intervals (current_buffer, from, len - nchars_del);
- }
+
+ if (buffer_get_intervals (current_buffer))
+ offset_intervals (current_buffer, from, len - nchars_del);
if (from < PT)
adjust_point (len - nchars_del, len_byte - nbytes_del);
if (from < PT)
adjust_point (len - nchars_del, len_byte - nbytes_del);
@@
-1245,7
+1236,7
@@
adjust_after_replace (ptrdiff_t from, ptrdiff_t from_byte,
if (Z - GPT < END_UNCHANGED)
END_UNCHANGED = Z - GPT;
if (Z - GPT < END_UNCHANGED)
END_UNCHANGED = Z - GPT;
-
CHECK_MARKERS
();
+
check_markers
();
if (len == 0)
evaporate_overlays (from);
if (len == 0)
evaporate_overlays (from);
@@
-1298,7
+1289,7
@@
replace_range (ptrdiff_t from, ptrdiff_t to, Lisp_Object new,
ptrdiff_t outgoing_insbytes = insbytes;
Lisp_Object deletion;
ptrdiff_t outgoing_insbytes = insbytes;
Lisp_Object deletion;
-
CHECK_MARKERS
();
+
check_markers
();
GCPRO1 (new);
deletion = Qnil;
GCPRO1 (new);
deletion = Qnil;
@@
-1359,8
+1350,7
@@
replace_range (ptrdiff_t from, ptrdiff_t to, Lisp_Object new,
GPT_BYTE = from_byte;
if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */
GPT_BYTE = from_byte;
if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */
- if (GPT_BYTE < GPT)
- abort ();
+ eassert (GPT <= GPT_BYTE);
if (GPT - BEG < BEG_UNCHANGED)
BEG_UNCHANGED = GPT - BEG;
if (GPT - BEG < BEG_UNCHANGED)
BEG_UNCHANGED = GPT - BEG;
@@
-1406,8
+1396,7
@@
replace_range (ptrdiff_t from, ptrdiff_t to, Lisp_Object new,
Z_BYTE += outgoing_insbytes;
if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */
Z_BYTE += outgoing_insbytes;
if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */
- if (GPT_BYTE < GPT)
- abort ();
+ eassert (GPT <= GPT_BYTE);
/* Adjust the overlay center as needed. This must be done after
adjusting the markers that bound the overlays. */
/* Adjust the overlay center as needed. This must be done after
adjusting the markers that bound the overlays. */
@@
-1423,7
+1412,7
@@
replace_range (ptrdiff_t from, ptrdiff_t to, Lisp_Object new,
/* Get the intervals for the part of the string we are inserting--
not including the combined-before bytes. */
/* Get the intervals for the part of the string we are inserting--
not including the combined-before bytes. */
- intervals =
STRING_INTERVALS
(new);
+ intervals =
string_get_intervals
(new);
/* Insert those intervals. */
graft_intervals_into_buffer (intervals, from, inschars,
current_buffer, inherit);
/* Insert those intervals. */
graft_intervals_into_buffer (intervals, from, inschars,
current_buffer, inherit);
@@
-1437,7
+1426,7
@@
replace_range (ptrdiff_t from, ptrdiff_t to, Lisp_Object new,
if (outgoing_insbytes == 0)
evaporate_overlays (from);
if (outgoing_insbytes == 0)
evaporate_overlays (from);
-
CHECK_MARKERS
();
+
check_markers
();
MODIFF++;
CHARS_MODIFF = MODIFF;
MODIFF++;
CHARS_MODIFF = MODIFF;
@@
-1467,7
+1456,7
@@
replace_range_2 (ptrdiff_t from, ptrdiff_t from_byte,
{
ptrdiff_t nbytes_del, nchars_del;
{
ptrdiff_t nbytes_del, nchars_del;
-
CHECK_MARKERS
();
+
check_markers
();
nchars_del = to - from;
nbytes_del = to_byte - from_byte;
nchars_del = to - from;
nbytes_del = to_byte - from_byte;
@@
-1490,8
+1479,7
@@
replace_range_2 (ptrdiff_t from, ptrdiff_t from_byte,
GPT_BYTE = from_byte;
if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */
GPT_BYTE = from_byte;
if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */
- if (GPT_BYTE < GPT)
- abort ();
+ eassert (GPT <= GPT_BYTE);
if (GPT - BEG < BEG_UNCHANGED)
BEG_UNCHANGED = GPT - BEG;
if (GPT - BEG < BEG_UNCHANGED)
BEG_UNCHANGED = GPT - BEG;
@@
-1524,8
+1512,7
@@
replace_range_2 (ptrdiff_t from, ptrdiff_t from_byte,
Z_BYTE += insbytes;
if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */
Z_BYTE += insbytes;
if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */
- if (GPT_BYTE < GPT)
- abort ();
+ eassert (GPT <= GPT_BYTE);
/* Adjust the overlay center as needed. This must be done after
adjusting the markers that bound the overlays. */
/* Adjust the overlay center as needed. This must be done after
adjusting the markers that bound the overlays. */
@@
-1556,7
+1543,7
@@
replace_range_2 (ptrdiff_t from, ptrdiff_t from_byte,
if (insbytes == 0)
evaporate_overlays (from);
if (insbytes == 0)
evaporate_overlays (from);
-
CHECK_MARKERS
();
+
check_markers
();
MODIFF++;
CHARS_MODIFF = MODIFF;
MODIFF++;
CHARS_MODIFF = MODIFF;
@@
-1707,7
+1694,7
@@
del_range_2 (ptrdiff_t from, ptrdiff_t from_byte,
register ptrdiff_t nbytes_del, nchars_del;
Lisp_Object deletion;
register ptrdiff_t nbytes_del, nchars_del;
Lisp_Object deletion;
-
CHECK_MARKERS
();
+
check_markers
();
nchars_del = to - from;
nbytes_del = to_byte - from_byte;
nchars_del = to - from;
nbytes_del = to_byte - from_byte;
@@
-1763,15
+1750,14
@@
del_range_2 (ptrdiff_t from, ptrdiff_t from_byte,
needs to access the previous gap contents. */
*(GPT_ADDR) = 0;
needs to access the previous gap contents. */
*(GPT_ADDR) = 0;
- if (GPT_BYTE < GPT)
- abort ();
+ eassert (GPT <= GPT_BYTE);
if (GPT - BEG < BEG_UNCHANGED)
BEG_UNCHANGED = GPT - BEG;
if (Z - GPT < END_UNCHANGED)
END_UNCHANGED = Z - GPT;
if (GPT - BEG < BEG_UNCHANGED)
BEG_UNCHANGED = GPT - BEG;
if (Z - GPT < END_UNCHANGED)
END_UNCHANGED = Z - GPT;
-
CHECK_MARKERS
();
+
check_markers
();
evaporate_overlays (from);
evaporate_overlays (from);
@@
-1836,7
+1822,7
@@
prepare_to_modify_buffer (ptrdiff_t start, ptrdiff_t end,
if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer)
++windows_or_buffers_changed;
if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer)
++windows_or_buffers_changed;
- if (
BUF_INTERVALS (current_buffer) != 0
)
+ if (
buffer_get_intervals (current_buffer)
)
{
if (preserve_ptr)
{
{
if (preserve_ptr)
{
@@
-2203,9
+2189,6
@@
syms_of_insdel (void)
combine_after_change_list = Qnil;
combine_after_change_buffer = Qnil;
combine_after_change_list = Qnil;
combine_after_change_buffer = Qnil;
- DEFVAR_BOOL ("check-markers-debug-flag", check_markers_debug_flag,
- doc: /* Non-nil means enable debugging checks for invalid marker positions. */);
- check_markers_debug_flag = 0;
DEFVAR_LISP ("combine-after-change-calls", Vcombine_after_change_calls,
doc: /* Used internally by the `combine-after-change-calls' macro. */);
Vcombine_after_change_calls = Qnil;
DEFVAR_LISP ("combine-after-change-calls", Vcombine_after_change_calls,
doc: /* Used internally by the `combine-after-change-calls' macro. */);
Vcombine_after_change_calls = Qnil;