aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl Heuer1994-04-08 00:44:35 +0000
committerKarl Heuer1994-04-08 00:44:35 +0000
commit395ec62efe4fc1a970356ffd3cf163496152eea2 (patch)
tree15ec251bd549be3928665e690d4155dcdc0628ca
parent25e907da8b54041d823bd0852536b9956e2fcfe2 (diff)
downloademacs-395ec62efe4fc1a970356ffd3cf163496152eea2.tar.gz
emacs-395ec62efe4fc1a970356ffd3cf163496152eea2.zip
(insert_1): New function, extracted from insert.
(insert_from_string_1): Likewise, taken from insert_from_string. (insert, insert_from_string): Call the new functions. (insert_before_markers, insert_from_string_before_markers): Adjust the markers before calling the after-change function.
-rw-r--r--src/insdel.c58
1 files changed, 42 insertions, 16 deletions
diff --git a/src/insdel.c b/src/insdel.c
index 6d5986e6fe1..06cd05d4eba 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -25,6 +25,9 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
25#include "window.h" 25#include "window.h"
26#include "blockinput.h" 26#include "blockinput.h"
27 27
28static void insert_1 ();
29static void insert_from_string_1 ();
30
28/* Move gap to position `pos'. 31/* Move gap to position `pos'.
29 Note that this can quit! */ 32 Note that this can quit! */
30 33
@@ -284,10 +287,19 @@ insert (string, length)
284 register unsigned char *string; 287 register unsigned char *string;
285 register length; 288 register length;
286{ 289{
287 register Lisp_Object temp; 290 if (length > 0)
291 {
292 insert_1 (string, length);
293 signal_after_change (point-length, 0, length);
294 }
295}
288 296
289 if (length < 1) 297static void
290 return; 298insert_1 (string, length)
299 register unsigned char *string;
300 register length;
301{
302 register Lisp_Object temp;
291 303
292 /* Make sure point-max won't overflow after this insertion. */ 304 /* Make sure point-max won't overflow after this insertion. */
293 XSET (temp, Lisp_Int, length + Z); 305 XSET (temp, Lisp_Int, length + Z);
@@ -314,8 +326,6 @@ insert (string, length)
314 ZV += length; 326 ZV += length;
315 Z += length; 327 Z += length;
316 SET_PT (point + length); 328 SET_PT (point + length);
317
318 signal_after_change (point-length, 0, length);
319} 329}
320 330
321/* Insert the part of the text of STRING, a Lisp object assumed to be 331/* Insert the part of the text of STRING, a Lisp object assumed to be
@@ -332,12 +342,22 @@ insert_from_string (string, pos, length, inherit)
332 register int pos, length; 342 register int pos, length;
333 int inherit; 343 int inherit;
334{ 344{
345 if (length > 0)
346 {
347 insert_from_string_1 (string, pos, length, inherit);
348 signal_after_change (point-length, 0, length);
349 }
350}
351
352static void
353insert_from_string_1 (string, pos, length, inherit)
354 Lisp_Object string;
355 register int pos, length;
356 int inherit;
357{
335 register Lisp_Object temp; 358 register Lisp_Object temp;
336 struct gcpro gcpro1; 359 struct gcpro gcpro1;
337 360
338 if (length < 1)
339 return;
340
341 /* Make sure point-max won't overflow after this insertion. */ 361 /* Make sure point-max won't overflow after this insertion. */
342 XSET (temp, Lisp_Int, length + Z); 362 XSET (temp, Lisp_Int, length + Z);
343 if (length + Z != XINT (temp)) 363 if (length + Z != XINT (temp))
@@ -370,8 +390,6 @@ insert_from_string (string, pos, length, inherit)
370 current_buffer, inherit); 390 current_buffer, inherit);
371 391
372 SET_PT (point + length); 392 SET_PT (point + length);
373
374 signal_after_change (point-length, 0, length);
375} 393}
376 394
377/* Insert the character C before point */ 395/* Insert the character C before point */
@@ -401,9 +419,13 @@ insert_before_markers (string, length)
401 unsigned char *string; 419 unsigned char *string;
402 register int length; 420 register int length;
403{ 421{
404 register int opoint = point; 422 if (length > 0)
405 insert (string, length); 423 {
406 adjust_markers (opoint - 1, opoint, length); 424 register int opoint = point;
425 insert_1 (string, length);
426 adjust_markers (opoint - 1, opoint, length);
427 signal_after_change (point-length, 0, length);
428 }
407} 429}
408 430
409/* Insert part of a Lisp string, relocating markers after. */ 431/* Insert part of a Lisp string, relocating markers after. */
@@ -413,9 +435,13 @@ insert_from_string_before_markers (string, pos, length, inherit)
413 register int pos, length; 435 register int pos, length;
414 int inherit; 436 int inherit;
415{ 437{
416 register int opoint = point; 438 if (length > 0)
417 insert_from_string (string, pos, length, inherit); 439 {
418 adjust_markers (opoint - 1, opoint, length); 440 register int opoint = point;
441 insert_from_string_1 (string, pos, length, inherit);
442 adjust_markers (opoint - 1, opoint, length);
443 signal_after_change (point-length, 0, length);
444 }
419} 445}
420 446
421/* Delete characters in current buffer 447/* Delete characters in current buffer