X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/d4aa48db8ed36b1fc7e7b0e6bd35049353f7f96e..e8fee30c4f5ca621344982e771ea51445c09b2c8:/src/insdel.c diff --git a/src/insdel.c b/src/insdel.c index 5cde53864b..a41f03b1ba 100644 --- a/src/insdel.c +++ b/src/insdel.c @@ -1,13 +1,14 @@ /* 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 Free Software Foundation, Inc. + 2002, 2003, 2004, 2005, 2006, 2007, 2008 + 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 @@ -15,16 +16,14 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 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 . */ #include #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" @@ -652,22 +651,11 @@ copy_text (from_addr, to_addr, nbytes, 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; @@ -1173,6 +1161,50 @@ insert_from_string_1 (string, pos, pos_byte, nchars, nbytes, current_buffer, inherit); adjust_point (nchars, outgoing_nbytes); + + CHECK_MARKERS (); +} + +/* Insert a sequence of NCHARS chars which occupy NBYTES bytes + starting at GPT_ADDR. */ + +void +insert_from_gap (nchars, nbytes) + register EMACS_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 (); } /* Insert text from BUF, NCHARS characters starting at CHARPOS, into the @@ -1318,7 +1350,7 @@ insert_from_buffer_1 (buf, from, nchars, inherit) /* 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;