#include "lisp.h"
#include "intervals.h"
#include "buffer.h"
-#include "charset.h"
+#include "character.h"
#include "window.h"
#include "blockinput.h"
#include "region-cache.h"
for (m = BUF_MARKERS (current_buffer); m; m = m->next)
{
- /* In a single-byte buffer, a marker's two positions must be
- equal. */
- if (Z == Z_BYTE)
- {
- if (m->charpos != m->bytepos)
- abort ();
- }
+ eassert (m->bytepos >= m->charpos
+ && m->bytepos - m->charpos <= Z_BYTE - Z);
if (m->bytepos == from_byte)
{
BUF_PT_BYTE (current_buffer) += nbytes;
/* In a single-byte buffer, the two positions must be equal. */
- if (ZV == ZV_BYTE
- && PT != PT_BYTE)
- abort ();
+ eassert (PT_BYTE >= PT && PT_BYTE - PT <= ZV_BYTE - ZV);
}
\f
/* Adjust markers for a replacement of a text at FROM (FROM_BYTE) of
int bytes_left = nbytes;
Lisp_Object tbl = Qnil;
- /* We set the variable tbl to the reverse table of
- Vnonascii_translation_table in advance. */
- if (CHAR_TABLE_P (Vnonascii_translation_table))
- {
- tbl = Fchar_table_extra_slot (Vnonascii_translation_table,
- make_number (0));
- if (!CHAR_TABLE_P (tbl))
- tbl = Qnil;
- }
-
- /* Convert multibyte to single byte. */
while (bytes_left > 0)
{
int thislen, c;
c = STRING_CHAR_AND_LENGTH (from_addr, bytes_left, thislen);
- if (!SINGLE_BYTE_CHAR_P (c))
+ if (!ASCII_CHAR_P (c))
c = multibyte_char_to_unibyte (c, tbl);
*to_addr++ = c;
from_addr += thislen;
current_buffer, inherit);
adjust_point (nchars, outgoing_nbytes);
+
+ CHECK_MARKERS ();
+}
+\f
+/* Insert a sequence of NCHARS chars which occupy NBYTES bytes
+ starting at GPT_ADDR. */
+
+void
+insert_from_gap (nchars, nbytes)
+ register int nchars, nbytes;
+{
+ if (NILP (current_buffer->enable_multibyte_characters))
+ nchars = nbytes;
+
+ record_insert (GPT, nchars);
+ MODIFF++;
+
+ GAP_SIZE -= nbytes;
+ GPT += nchars;
+ ZV += nchars;
+ Z += nchars;
+ GPT_BYTE += nbytes;
+ ZV_BYTE += nbytes;
+ Z_BYTE += nbytes;
+ if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */
+
+ if (GPT_BYTE < GPT)
+ abort ();
+
+ 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)
+ {
+ offset_intervals (current_buffer, GPT - nchars, nchars);
+ graft_intervals_into_buffer (NULL_INTERVAL, GPT - nchars, nchars,
+ current_buffer, 0);
+ }
+
+ if (GPT - nchars < PT)
+ adjust_point (nchars, nbytes);
+
+ CHECK_MARKERS ();
}
\f
/* Insert text from BUF, NCHARS characters starting at CHARPOS, into the
(! NILP (end_marker) ? Fmarker_position (end_marker) : end)
/* Set a variable to nil if an error occurred.
- VAL is a cons-cell whose car is the variable name, and whose cdr is
- either nil (to mean that there was indeed an error), or non-nil to mean
- that the was no error (which thus causes this function to do
- nothing). */
+ Don't change the variable if there was no error.
+ VAL is a cons-cell (VARIABLE . NO-ERROR-FLAG).
+ VARIABLE is the variable to maybe set to nil.
+ NO-ERROR-FLAG is nil if there was an error,
+ anything else meaning no error (so this function does nothing). */
Lisp_Object
reset_var_on_error (val)
Lisp_Object val;