/* Buffer insertion/deletion and gap motion for GNU Emacs.
Copyright (C) 1985, 1986, 1993, 1994, 1995, 1997, 1998, 1999, 2000, 2001,
- 2002, 2003, 2004, 2005, 2006, 2007, 2008
+ 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
Free Software Foundation, Inc.
This file is part of GNU Emacs.
-GNU Emacs is free software; you can redistribute it and/or modify
+GNU Emacs is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
-along with GNU Emacs; see the file COPYING. If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA. */
+along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
+#include <setjmp.h>
#include "lisp.h"
#include "intervals.h"
#include "buffer.h"
#define NULL 0
#endif
-static void insert_from_string_1 P_ ((Lisp_Object, int, int, int, int, int, int));
-static void insert_from_buffer_1 ();
-static void gap_left P_ ((int, int, int));
-static void gap_right P_ ((int, int));
-static void adjust_markers_gap_motion P_ ((int, int, int));
-static void adjust_markers_for_insert P_ ((int, int, int, int, int));
-void adjust_markers_for_delete P_ ((int, int, int, int));
-static void adjust_markers_for_replace P_ ((int, int, int, int, int, int));
-static void adjust_point P_ ((int, int));
+static void insert_from_string_1 (Lisp_Object string,
+ EMACS_INT pos, EMACS_INT pos_byte,
+ EMACS_INT nchars, EMACS_INT nbytes,
+ int inherit, int before_markers);
+static void insert_from_buffer_1 (struct buffer *buf,
+ EMACS_INT from, EMACS_INT nchars,
+ int inherit);
+static void gap_left (EMACS_INT charpos, EMACS_INT bytepos, int newgap);
+static void gap_right (EMACS_INT charpos, EMACS_INT bytepos);
+static void adjust_markers_gap_motion (EMACS_INT from, EMACS_INT to,
+ EMACS_INT amount);
+static void adjust_markers_for_insert (EMACS_INT from, EMACS_INT from_byte,
+ EMACS_INT to, EMACS_INT to_byte,
+ int before_markers);
+static void adjust_markers_for_replace (EMACS_INT, EMACS_INT, EMACS_INT,
+ EMACS_INT, EMACS_INT, EMACS_INT);
+static void adjust_point (EMACS_INT nchars, EMACS_INT nbytes);
Lisp_Object Fcombine_after_change_execute ();
Note that this can quit! */
void
-move_gap (charpos)
- int charpos;
+move_gap (EMACS_INT charpos)
{
move_gap_both (charpos, charpos_to_bytepos (charpos));
}
Note that this can quit! */
void
-move_gap_both (charpos, bytepos)
- int charpos, bytepos;
+move_gap_both (EMACS_INT charpos, EMACS_INT bytepos)
{
if (bytepos < GPT_BYTE)
gap_left (charpos, bytepos, 0);
If NEWGAP is nonzero, then don't update beg_unchanged and end_unchanged. */
static void
-gap_left (charpos, bytepos, newgap)
- register int charpos, bytepos;
- int newgap;
+gap_left (EMACS_INT charpos, EMACS_INT bytepos, int newgap)
{
register unsigned char *to, *from;
- register int i;
- int new_s1;
+ register EMACS_INT i;
+ EMACS_INT new_s1;
if (!newgap)
BUF_COMPUTE_UNCHANGED (current_buffer, charpos, GPT);
QUIT;
}
-/* Move the gap to a position greater than than the current GPT.
+/* Move the gap to a position greater than the current GPT.
BYTEPOS describes the new position as a byte position,
and CHARPOS is the corresponding char position. */
static void
-gap_right (charpos, bytepos)
- register int charpos, bytepos;
+gap_right (EMACS_INT charpos, EMACS_INT bytepos)
{
register unsigned char *to, *from;
- register int i;
- int new_s1;
+ register EMACS_INT i;
+ EMACS_INT new_s1;
BUF_COMPUTE_UNCHANGED (current_buffer, charpos, GPT);
int adjust_markers_test;
static void
-adjust_markers_gap_motion (from, to, amount)
- register int from, to, amount;
+adjust_markers_gap_motion (EMACS_INT from, EMACS_INT to, EMACS_INT amount)
{
/* Now that a marker has a bytepos, not counting the gap,
nothing needs to be done here. */
#if 0
Lisp_Object marker;
register struct Lisp_Marker *m;
- register int mpos;
+ register EMACS_INT mpos;
marker = BUF_MARKERS (current_buffer);
or inside of the range being deleted. */
void
-adjust_markers_for_delete (from, from_byte, to, to_byte)
- register int from, from_byte, to, to_byte;
+adjust_markers_for_delete (EMACS_INT from, EMACS_INT from_byte,
+ EMACS_INT to, EMACS_INT to_byte)
{
Lisp_Object marker;
register struct Lisp_Marker *m;
- register int charpos;
+ register EMACS_INT charpos;
for (m = BUF_MARKERS (current_buffer); m; m = m->next)
{
re-inserted text after undoing a deletion, and must be
adjusted to move them to the correct place. */
XSETMISC (marker, m);
- record_marker_adjustment (marker, from - charpos);
+ record_marker_adjustment (marker, from - charpos);
}
else if (charpos < to)
{ /* Before-insertion markers will automatically move forward
upon re-inserting the deleted text, so we have to arrange
for them to move backward to the correct position. */
XSETMISC (marker, m);
- record_marker_adjustment (marker, charpos - to);
+ record_marker_adjustment (marker, to - charpos);
}
m->charpos = from;
m->bytepos = from_byte;
or BEFORE_MARKERS is true. */
static void
-adjust_markers_for_insert (from, from_byte, to, to_byte, before_markers)
- register int from, from_byte, to, to_byte;
- int before_markers;
+adjust_markers_for_insert (EMACS_INT from, EMACS_INT from_byte,
+ EMACS_INT to, EMACS_INT to_byte, int before_markers)
{
struct Lisp_Marker *m;
int adjusted = 0;
- int nchars = to - from;
- int nbytes = to_byte - from_byte;
+ EMACS_INT nchars = to - from;
+ EMACS_INT nbytes = to_byte - from_byte;
for (m = BUF_MARKERS (current_buffer); m; m = m->next)
{
intervals. */
static void
-adjust_point (nchars, nbytes)
- int nchars, nbytes;
+adjust_point (EMACS_INT nchars, EMACS_INT nbytes)
{
BUF_PT (current_buffer) += nchars;
BUF_PT_BYTE (current_buffer) += nbytes;
an insertion. */
static void
-adjust_markers_for_replace (from, from_byte, old_chars, old_bytes,
- new_chars, new_bytes)
- int from, from_byte, old_chars, old_bytes, new_chars, new_bytes;
+adjust_markers_for_replace (EMACS_INT from, EMACS_INT from_byte,
+ EMACS_INT old_chars, EMACS_INT old_bytes,
+ EMACS_INT new_chars, EMACS_INT new_bytes)
{
register struct Lisp_Marker *m;
- int prev_to_byte = from_byte + old_bytes;
- int diff_chars = new_chars - old_chars;
- int diff_bytes = new_bytes - old_bytes;
+ EMACS_INT prev_to_byte = from_byte + old_bytes;
+ EMACS_INT diff_chars = new_chars - old_chars;
+ EMACS_INT diff_bytes = new_bytes - old_bytes;
for (m = BUF_MARKERS (current_buffer); m; m = m->next)
{
/* Make the gap NBYTES_ADDED bytes longer. */
void
-make_gap_larger (nbytes_added)
- int nbytes_added;
+make_gap_larger (EMACS_INT nbytes_added)
{
Lisp_Object tem;
- int real_gap_loc;
- int real_gap_loc_byte;
- int old_gap_size;
+ EMACS_INT real_gap_loc;
+ EMACS_INT real_gap_loc_byte;
+ EMACS_INT old_gap_size;
/* If we have to get more space, get enough to last a while. */
nbytes_added += 2000;
- /* Don't allow a buffer size that won't fit in an int
- even if it will fit in a Lisp integer.
- That won't work because so many places use `int'.
-
- Make sure we don't introduce overflows in the calculation. */
-
- if (Z_BYTE - BEG_BYTE + GAP_SIZE
- >= (((EMACS_INT) 1 << (min (VALBITS, BITS_PER_INT) - 1)) - 1
- - nbytes_added))
- error ("Buffer exceeds maximum size");
+ { EMACS_INT total_size = Z_BYTE - BEG_BYTE + GAP_SIZE + nbytes_added;
+ if (total_size < 0
+ /* Don't allow a buffer size that won't fit in a Lisp integer. */
+ || total_size != XINT (make_number (total_size))
+ /* Don't allow a buffer size that won't fit in an int
+ even if it will fit in a Lisp integer.
+ That won't work because so many places still use `int'. */
+ || total_size != (EMACS_INT) (int) total_size)
+ error ("Buffer exceeds maximum size");
+ }
enlarge_buffer_text (current_buffer, nbytes_added);
/* Make the gap NBYTES_REMOVED bytes shorter. */
void
-make_gap_smaller (nbytes_removed)
- int nbytes_removed;
+make_gap_smaller (EMACS_INT nbytes_removed)
{
Lisp_Object tem;
- int real_gap_loc;
- int real_gap_loc_byte;
- int real_Z;
- int real_Z_byte;
- int real_beg_unchanged;
- int new_gap_size;
+ EMACS_INT real_gap_loc;
+ EMACS_INT real_gap_loc_byte;
+ EMACS_INT real_Z;
+ EMACS_INT real_Z_byte;
+ EMACS_INT real_beg_unchanged;
+ EMACS_INT new_gap_size;
/* Make sure the gap is at least 20 bytes. */
if (GAP_SIZE - nbytes_removed < 20)
}
void
-make_gap (nbytes_added)
- int nbytes_added;
+make_gap (EMACS_INT nbytes_added)
{
if (nbytes_added >= 0)
make_gap_larger (nbytes_added);
Return the number of bytes stored at TO_ADDR. */
-int
-copy_text (from_addr, to_addr, nbytes,
- from_multibyte, to_multibyte)
- const unsigned char *from_addr;
- unsigned char *to_addr;
- int nbytes;
- int from_multibyte, to_multibyte;
+EMACS_INT
+copy_text (const unsigned char *from_addr, unsigned char *to_addr,
+ EMACS_INT nbytes, int from_multibyte, int to_multibyte)
{
if (from_multibyte == to_multibyte)
{
}
else if (from_multibyte)
{
- int nchars = 0;
- int bytes_left = nbytes;
+ EMACS_INT nchars = 0;
+ EMACS_INT bytes_left = nbytes;
Lisp_Object tbl = Qnil;
while (bytes_left > 0)
{
int thislen, c;
- c = STRING_CHAR_AND_LENGTH (from_addr, bytes_left, thislen);
- if (!ASCII_CHAR_P (c))
- c = multibyte_char_to_unibyte (c, tbl);
+ c = STRING_CHAR_AND_LENGTH (from_addr, thislen);
+ if (! ASCII_CHAR_P (c))
+ c &= 0xFF;
*to_addr++ = c;
from_addr += thislen;
bytes_left -= thislen;
{
int c = *from_addr++;
- if (c >= 0200)
+ if (!ASCII_CHAR_P (c))
{
- c = unibyte_char_to_multibyte (c);
+ c = BYTE8_TO_CHAR (c);
to_addr += CHAR_STRING (c, to_addr);
nbytes--;
}
to convert some single-byte text to multibyte.
The single-byte text consists of NBYTES bytes at PTR. */
-int
-count_size_as_multibyte (ptr, nbytes)
- const unsigned char *ptr;
- int nbytes;
+EMACS_INT
+count_size_as_multibyte (const unsigned char *ptr, EMACS_INT nbytes)
{
- int i;
- int outgoing_nbytes = 0;
+ EMACS_INT i;
+ EMACS_INT outgoing_nbytes = 0;
for (i = 0; i < nbytes; i++)
{
unsigned int c = *ptr++;
- if (c < 0200)
+ if (ASCII_CHAR_P (c))
outgoing_nbytes++;
else
{
- c = unibyte_char_to_multibyte (c);
+ c = BYTE8_TO_CHAR (c);
outgoing_nbytes += CHAR_BYTES (c);
}
}
prepare_to_modify_buffer could relocate the text. */
void
-insert (string, nbytes)
- register const unsigned char *string;
- register int nbytes;
+insert (const unsigned char *string, EMACS_INT nbytes)
{
if (nbytes > 0)
{
- int len = chars_in_text (string, nbytes), opoint;
+ EMACS_INT len = chars_in_text (string, nbytes), opoint;
insert_1_both (string, len, nbytes, 0, 1, 0);
opoint = PT - len;
signal_after_change (opoint, 0, len);
/* Likewise, but inherit text properties from neighboring characters. */
void
-insert_and_inherit (string, nbytes)
- register const unsigned char *string;
- register int nbytes;
+insert_and_inherit (const unsigned char *string, EMACS_INT nbytes)
{
if (nbytes > 0)
{
- int len = chars_in_text (string, nbytes), opoint;
+ EMACS_INT len = chars_in_text (string, nbytes), opoint;
insert_1_both (string, len, nbytes, 1, 1, 0);
opoint = PT - len;
signal_after_change (opoint, 0, len);
/* Insert the character C before point. Do not inherit text properties. */
void
-insert_char (c)
- int c;
+insert_char (int c)
{
unsigned char str[MAX_MULTIBYTE_LENGTH];
int len;
/* Insert the null-terminated string S before point. */
void
-insert_string (s)
- const char *s;
+insert_string (const char *s)
{
insert (s, strlen (s));
}
since gc could happen and relocate it. */
void
-insert_before_markers (string, nbytes)
- const unsigned char *string;
- register int nbytes;
+insert_before_markers (const unsigned char *string, EMACS_INT nbytes)
{
if (nbytes > 0)
{
- int len = chars_in_text (string, nbytes), opoint;
+ EMACS_INT len = chars_in_text (string, nbytes), opoint;
insert_1_both (string, len, nbytes, 0, 1, 1);
opoint = PT - len;
signal_after_change (opoint, 0, len);
/* Likewise, but inherit text properties from neighboring characters. */
void
-insert_before_markers_and_inherit (string, nbytes)
- const unsigned char *string;
- register int nbytes;
+insert_before_markers_and_inherit (const unsigned char *string,
+ EMACS_INT nbytes)
{
if (nbytes > 0)
{
- int len = chars_in_text (string, nbytes), opoint;
+ EMACS_INT len = chars_in_text (string, nbytes), opoint;
insert_1_both (string, len, nbytes, 1, 1, 1);
opoint = PT - len;
signal_after_change (opoint, 0, len);
/* Subroutine used by the insert functions above. */
void
-insert_1 (string, nbytes, inherit, prepare, before_markers)
- register const unsigned char *string;
- register int nbytes;
- int inherit, prepare, before_markers;
+insert_1 (const unsigned char *string, EMACS_INT nbytes,
+ int inherit, int prepare, int before_markers)
{
insert_1_both (string, chars_in_text (string, nbytes), nbytes,
inherit, prepare, before_markers);
which combine in this way. Otherwise, return 0. */
int
-count_combining_before (string, length, pos, pos_byte)
- const unsigned char *string;
- int length;
- int pos, pos_byte;
+count_combining_before (const unsigned char *string, EMACS_INT length,
+ EMACS_INT pos, EMACS_INT pos_byte)
{
int len, combining_bytes;
const unsigned char *p;
which combine in this way. Otherwise, return 0. */
int
-count_combining_after (string, length, pos, pos_byte)
- const unsigned char *string;
- int length;
- int pos, pos_byte;
+count_combining_after (const unsigned char *string,
+ EMACS_INT length, EMACS_INT pos, EMACS_INT pos_byte)
{
- int opos_byte = pos_byte;
- int i;
- int bytes;
+ EMACS_INT opos_byte = pos_byte;
+ EMACS_INT i;
+ EMACS_INT bytes;
unsigned char *bufp;
if (NILP (current_buffer->enable_multibyte_characters))
are the same as in insert_1. */
void
-insert_1_both (string, nchars, nbytes, inherit, prepare, before_markers)
- register const unsigned char *string;
- register int nchars, nbytes;
- int inherit, prepare, before_markers;
+insert_1_both (const unsigned char *string,
+ EMACS_INT nchars, EMACS_INT nbytes,
+ int inherit, int prepare, int before_markers)
{
if (nchars == 0)
return;
without insert noticing. */
void
-insert_from_string (string, pos, pos_byte, length, length_byte, inherit)
- Lisp_Object string;
- register int pos, pos_byte, length, length_byte;
- int inherit;
+insert_from_string (Lisp_Object string, EMACS_INT pos, EMACS_INT pos_byte,
+ EMACS_INT length, EMACS_INT length_byte, int inherit)
{
- int opoint = PT;
+ EMACS_INT opoint = PT;
if (SCHARS (string) == 0)
return;
at the place where the insertion happens are adjusted to point after it. */
void
-insert_from_string_before_markers (string, pos, pos_byte,
- length, length_byte, inherit)
- Lisp_Object string;
- register int pos, pos_byte, length, length_byte;
- int inherit;
+insert_from_string_before_markers (Lisp_Object string,
+ EMACS_INT pos, EMACS_INT pos_byte,
+ EMACS_INT length, EMACS_INT length_byte,
+ int inherit)
{
- int opoint = PT;
+ EMACS_INT opoint = PT;
if (SCHARS (string) == 0)
return;
/* Subroutine of the insertion functions above. */
static void
-insert_from_string_1 (string, pos, pos_byte, nchars, nbytes,
- inherit, before_markers)
- Lisp_Object string;
- register int pos, pos_byte, nchars, nbytes;
- int inherit, before_markers;
+insert_from_string_1 (Lisp_Object string, EMACS_INT pos, EMACS_INT pos_byte,
+ EMACS_INT nchars, EMACS_INT nbytes,
+ int inherit, int before_markers)
{
struct gcpro gcpro1;
- int outgoing_nbytes = nbytes;
+ EMACS_INT outgoing_nbytes = nbytes;
INTERVAL intervals;
/* Make OUTGOING_NBYTES describe the text
starting at GPT_ADDR. */
void
-insert_from_gap (nchars, nbytes)
- register EMACS_INT nchars, nbytes;
+insert_from_gap (EMACS_INT nchars, EMACS_INT nbytes)
{
if (NILP (current_buffer->enable_multibyte_characters))
nchars = nbytes;
and relocate BUF's text before the bcopy happens. */
void
-insert_from_buffer (buf, charpos, nchars, inherit)
- struct buffer *buf;
- int charpos, nchars;
- int inherit;
+insert_from_buffer (struct buffer *buf,
+ EMACS_INT charpos, EMACS_INT nchars, int inherit)
{
- int opoint = PT;
+ EMACS_INT opoint = PT;
insert_from_buffer_1 (buf, charpos, nchars, inherit);
signal_after_change (opoint, 0, PT - opoint);
}
static void
-insert_from_buffer_1 (buf, from, nchars, inherit)
- struct buffer *buf;
- int from, nchars;
- int inherit;
+insert_from_buffer_1 (struct buffer *buf,
+ EMACS_INT from, EMACS_INT nchars, int inherit)
{
register Lisp_Object temp;
- int chunk, chunk_expanded;
- int from_byte = buf_charpos_to_bytepos (buf, from);
- int to_byte = buf_charpos_to_bytepos (buf, from + nchars);
- int incoming_nbytes = to_byte - from_byte;
- int outgoing_nbytes = incoming_nbytes;
+ EMACS_INT chunk, chunk_expanded;
+ EMACS_INT from_byte = buf_charpos_to_bytepos (buf, from);
+ EMACS_INT to_byte = buf_charpos_to_bytepos (buf, from + nchars);
+ EMACS_INT incoming_nbytes = to_byte - from_byte;
+ EMACS_INT outgoing_nbytes = incoming_nbytes;
INTERVAL intervals;
/* Make OUTGOING_NBYTES describe the text
outgoing_nbytes = nchars;
else if (NILP (buf->enable_multibyte_characters))
{
- int outgoing_before_gap = 0;
- int outgoing_after_gap = 0;
+ EMACS_INT outgoing_before_gap = 0;
+ EMACS_INT outgoing_after_gap = 0;
if (from < BUF_GPT (buf))
{
/* Get the intervals for the part of the string we are inserting. */
intervals = BUF_INTERVALS (buf);
- if (outgoing_nbytes < BUF_Z_BYTE (buf) - BUF_BEG_BYTE (buf))
+ if (nchars < BUF_Z (buf) - BUF_BEG (buf))
{
if (buf == current_buffer && PT <= from)
from += nchars;
PREV_TEXT nil means the new text was just inserted. */
void
-adjust_after_replace (from, from_byte, prev_text, len, len_byte)
- int from, from_byte, len, len_byte;
- Lisp_Object prev_text;
+adjust_after_replace (EMACS_INT from, EMACS_INT from_byte,
+ Lisp_Object prev_text, EMACS_INT len, EMACS_INT len_byte)
{
- int nchars_del = 0, nbytes_del = 0;
+ EMACS_INT nchars_del = 0, nbytes_del = 0;
#ifdef BYTE_COMBINING_DEBUG
if (count_combining_before (GPT_ADDR, len_byte, from, from_byte)
This is for use when undo is not enabled in the current buffer. */
void
-adjust_after_replace_noundo (from, from_byte, nchars_del, nbytes_del, len, len_byte)
- int from, from_byte, nchars_del, nbytes_del, len, len_byte;
+adjust_after_replace_noundo (EMACS_INT from, EMACS_INT from_byte,
+ EMACS_INT nchars_del, EMACS_INT nbytes_del,
+ EMACS_INT len, EMACS_INT len_byte)
{
#ifdef BYTE_COMBINING_DEBUG
if (count_combining_before (GPT_ADDR, len_byte, from, from_byte)
- FROM) may be incorrect, the correct length is NEWLEN. */
void
-adjust_after_insert (from, from_byte, to, to_byte, newlen)
- int from, from_byte, to, to_byte, newlen;
+adjust_after_insert (EMACS_INT from, EMACS_INT from_byte,
+ EMACS_INT to, EMACS_INT to_byte, EMACS_INT newlen)
{
- int len = to - from, len_byte = to_byte - from_byte;
+ EMACS_INT len = to - from, len_byte = to_byte - from_byte;
if (GPT != to)
move_gap_both (to, to_byte);
But if MARKERS is 0, don't relocate markers. */
void
-replace_range (from, to, new, prepare, inherit, markers)
- Lisp_Object new;
- int from, to, prepare, inherit, markers;
+replace_range (EMACS_INT from, EMACS_INT to, Lisp_Object new,
+ int prepare, int inherit, int markers)
{
- int inschars = SCHARS (new);
- int insbytes = SBYTES (new);
- int from_byte, to_byte;
- int nbytes_del, nchars_del;
+ EMACS_INT inschars = SCHARS (new);
+ EMACS_INT insbytes = SBYTES (new);
+ EMACS_INT from_byte, to_byte;
+ EMACS_INT nbytes_del, nchars_del;
register Lisp_Object temp;
struct gcpro gcpro1;
INTERVAL intervals;
- int outgoing_insbytes = insbytes;
+ EMACS_INT outgoing_insbytes = insbytes;
Lisp_Object deletion;
CHECK_MARKERS ();
if (prepare)
{
- int range_length = to - from;
+ EMACS_INT range_length = to - from;
prepare_to_modify_buffer (from, to, &from);
to = from + range_length;
}
prepare_to_modify_buffer and never call signal_after_change. */
void
-replace_range_2 (from, from_byte, to, to_byte, ins, inschars, insbytes, markers)
- int from, from_byte, to, to_byte;
- char *ins;
- int inschars, insbytes, markers;
+replace_range_2 (EMACS_INT from, EMACS_INT from_byte,
+ EMACS_INT to, EMACS_INT to_byte,
+ char *ins, EMACS_INT inschars, EMACS_INT insbytes,
+ int markers)
{
- int nbytes_del, nchars_del;
+ EMACS_INT nbytes_del, nchars_del;
Lisp_Object temp;
CHECK_MARKERS ();
If TO comes before FROM, we delete nothing. */
void
-del_range (from, to)
- register int from, to;
+del_range (EMACS_INT from, EMACS_INT to)
{
del_range_1 (from, to, 1, 0);
}
RET_STRING says to return the deleted text. */
Lisp_Object
-del_range_1 (from, to, prepare, ret_string)
- int from, to, prepare, ret_string;
+del_range_1 (EMACS_INT from, EMACS_INT to, int prepare, int ret_string)
{
- int from_byte, to_byte;
+ EMACS_INT from_byte, to_byte;
Lisp_Object deletion;
struct gcpro gcpro1;
if (prepare)
{
- int range_length = to - from;
+ EMACS_INT range_length = to - from;
prepare_to_modify_buffer (from, to, &from);
to = min (ZV, from + range_length);
}
/* Like del_range_1 but args are byte positions, not char positions. */
void
-del_range_byte (from_byte, to_byte, prepare)
- int from_byte, to_byte, prepare;
+del_range_byte (EMACS_INT from_byte, EMACS_INT to_byte, int prepare)
{
- int from, to;
+ EMACS_INT from, to;
/* Make args be valid */
if (from_byte < BEGV_BYTE)
if (prepare)
{
- int old_from = from, old_to = Z - to;
- int range_length = to - from;
+ EMACS_INT old_from = from, old_to = Z - to;
+ EMACS_INT range_length = to - from;
prepare_to_modify_buffer (from, to, &from);
to = from + range_length;
and bytepos. */
void
-del_range_both (from, from_byte, to, to_byte, prepare)
- int from, from_byte, to, to_byte, prepare;
+del_range_both (EMACS_INT from, EMACS_INT from_byte,
+ EMACS_INT to, EMACS_INT to_byte, int prepare)
{
/* Make args be valid */
if (from_byte < BEGV_BYTE)
if (prepare)
{
- int old_from = from, old_to = Z - to;
- int range_length = to - from;
+ EMACS_INT old_from = from, old_to = Z - to;
+ EMACS_INT range_length = to - from;
prepare_to_modify_buffer (from, to, &from);
to = from + range_length;
If RET_STRING is true, the deleted area is returned as a string. */
Lisp_Object
-del_range_2 (from, from_byte, to, to_byte, ret_string)
- int from, from_byte, to, to_byte, ret_string;
+del_range_2 (EMACS_INT from, EMACS_INT from_byte,
+ EMACS_INT to, EMACS_INT to_byte, int ret_string)
{
- register int nbytes_del, nchars_del;
+ register EMACS_INT nbytes_del, nchars_del;
Lisp_Object deletion;
CHECK_MARKERS ();
Z -= nchars_del;
GPT = from;
GPT_BYTE = from_byte;
- if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */
+ if (GAP_SIZE > 0 && !current_buffer->text->inhibit_shrinking)
+ /* Put an anchor, unless called from decode_coding_object which
+ needs to access the previous gap contents. */
+ *(GPT_ADDR) = 0;
if (GPT_BYTE < GPT)
abort ();
Otherwise set CHARS_MODIFF to the new value of MODIFF. */
void
-modify_region (buffer, start, end, preserve_chars_modiff)
- struct buffer *buffer;
- int start, end, preserve_chars_modiff;
+modify_region (struct buffer *buffer, EMACS_INT start, EMACS_INT end,
+ int preserve_chars_modiff)
{
struct buffer *old_buffer = current_buffer;
by holding its value temporarily in a marker. */
void
-prepare_to_modify_buffer (start, end, preserve_ptr)
- int start, end;
- int *preserve_ptr;
+prepare_to_modify_buffer (EMACS_INT start, EMACS_INT end,
+ EMACS_INT *preserve_ptr)
{
struct buffer *base_buffer;
by holding its value temporarily in a marker. */
void
-signal_before_change (start_int, end_int, preserve_ptr)
- int start_int, end_int;
- int *preserve_ptr;
+signal_before_change (EMACS_INT start_int, EMACS_INT end_int,
+ EMACS_INT *preserve_ptr)
{
Lisp_Object start, end;
Lisp_Object start_marker, end_marker;
after the change. */
void
-signal_after_change (charpos, lendel, lenins)
- int charpos, lendel, lenins;
+signal_after_change (EMACS_INT charpos, EMACS_INT lendel, EMACS_INT lenins)
{
int count = SPECPDL_INDEX ();
if (inhibit_modification_hooks)
()
{
int count = SPECPDL_INDEX ();
- int beg, end, change;
- int begpos, endpos;
+ EMACS_INT beg, end, change;
+ EMACS_INT begpos, endpos;
Lisp_Object tail;
if (NILP (combine_after_change_list))
tail = XCDR (tail))
{
Lisp_Object elt;
- int thisbeg, thisend, thischange;
+ EMACS_INT thisbeg, thisend, thischange;
/* Extract the info from the next element. */
elt = XCAR (tail);
This affects `before-change-functions' and `after-change-functions',
as well as hooks attached to text properties and overlays. */);
inhibit_modification_hooks = 0;
- Qinhibit_modification_hooks = intern ("inhibit-modification-hooks");
+ Qinhibit_modification_hooks = intern_c_string ("inhibit-modification-hooks");
staticpro (&Qinhibit_modification_hooks);
defsubr (&Scombine_after_change_execute);