aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c428
1 files changed, 219 insertions, 209 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 8b7f524e27a..56d6231f5f8 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -19,6 +19,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19 19
20#include <config.h> 20#include <config.h>
21 21
22#define BUFFER_INLINE EXTERN_INLINE
23
22#include <sys/types.h> 24#include <sys/types.h>
23#include <sys/stat.h> 25#include <sys/stat.h>
24#include <sys/param.h> 26#include <sys/param.h>
@@ -97,7 +99,7 @@ static Lisp_Object Vbuffer_local_symbols;
97/* Maximum length of an overlay vector. */ 99/* Maximum length of an overlay vector. */
98#define OVERLAY_COUNT_MAX \ 100#define OVERLAY_COUNT_MAX \
99 ((ptrdiff_t) min (MOST_POSITIVE_FIXNUM, \ 101 ((ptrdiff_t) min (MOST_POSITIVE_FIXNUM, \
100 min (PTRDIFF_MAX, SIZE_MAX) / sizeof (Lisp_Object))) 102 min (PTRDIFF_MAX, SIZE_MAX) / word_size))
101 103
102/* Flags indicating which built-in buffer-local variables 104/* Flags indicating which built-in buffer-local variables
103 are permanent locals. */ 105 are permanent locals. */
@@ -191,9 +193,9 @@ followed by the rest of the buffers. */)
191 Lisp_Object args[3]; 193 Lisp_Object args[3];
192 194
193 CHECK_FRAME (frame); 195 CHECK_FRAME (frame);
194 framelist = Fcopy_sequence (FVAR (XFRAME (frame), buffer_list)); 196 framelist = Fcopy_sequence (XFRAME (frame)->buffer_list);
195 prevlist = Fnreverse (Fcopy_sequence 197 prevlist = Fnreverse (Fcopy_sequence
196 (FVAR (XFRAME (frame), buried_buffer_list))); 198 (XFRAME (frame)->buried_buffer_list));
197 199
198 /* Remove from GENERAL any buffer that duplicates one in 200 /* Remove from GENERAL any buffer that duplicates one in
199 FRAMELIST or PREVLIST. */ 201 FRAMELIST or PREVLIST. */
@@ -358,7 +360,7 @@ even if it is dead. The return value is never nil. */)
358 BUF_CHARS_MODIFF (b) = 1; 360 BUF_CHARS_MODIFF (b) = 1;
359 BUF_OVERLAY_MODIFF (b) = 1; 361 BUF_OVERLAY_MODIFF (b) = 1;
360 BUF_SAVE_MODIFF (b) = 1; 362 BUF_SAVE_MODIFF (b) = 1;
361 BUF_INTERVALS (b) = 0; 363 buffer_set_intervals (b, NULL);
362 BUF_UNCHANGED_MODIFIED (b) = 1; 364 BUF_UNCHANGED_MODIFIED (b) = 1;
363 BUF_OVERLAY_UNCHANGED_MODIFIED (b) = 1; 365 BUF_OVERLAY_UNCHANGED_MODIFIED (b) = 1;
364 BUF_END_UNCHANGED (b) = 0; 366 BUF_END_UNCHANGED (b) = 0;
@@ -368,7 +370,7 @@ even if it is dead. The return value is never nil. */)
368 370
369 b->newline_cache = 0; 371 b->newline_cache = 0;
370 b->width_run_cache = 0; 372 b->width_run_cache = 0;
371 BVAR (b, width_table) = Qnil; 373 BSET (b, width_table, Qnil);
372 b->prevent_redisplay_optimizations_p = 1; 374 b->prevent_redisplay_optimizations_p = 1;
373 375
374 /* Put this on the chain of all buffers including killed ones. */ 376 /* Put this on the chain of all buffers including killed ones. */
@@ -377,20 +379,20 @@ even if it is dead. The return value is never nil. */)
377 379
378 /* An ordinary buffer normally doesn't need markers 380 /* An ordinary buffer normally doesn't need markers
379 to handle BEGV and ZV. */ 381 to handle BEGV and ZV. */
380 BVAR (b, pt_marker) = Qnil; 382 BSET (b, pt_marker, Qnil);
381 BVAR (b, begv_marker) = Qnil; 383 BSET (b, begv_marker, Qnil);
382 BVAR (b, zv_marker) = Qnil; 384 BSET (b, zv_marker, Qnil);
383 385
384 name = Fcopy_sequence (buffer_or_name); 386 name = Fcopy_sequence (buffer_or_name);
385 STRING_SET_INTERVALS (name, NULL_INTERVAL); 387 string_set_intervals (name, NULL);
386 BVAR (b, name) = name; 388 BSET (b, name, name);
387 389
388 BVAR (b, undo_list) = (SREF (name, 0) != ' ') ? Qnil : Qt; 390 BSET (b, undo_list, (SREF (name, 0) != ' ') ? Qnil : Qt);
389 391
390 reset_buffer (b); 392 reset_buffer (b);
391 reset_buffer_local_variables (b, 1); 393 reset_buffer_local_variables (b, 1);
392 394
393 BVAR (b, mark) = Fmake_marker (); 395 BSET (b, mark, Fmake_marker ());
394 BUF_MARKERS (b) = NULL; 396 BUF_MARKERS (b) = NULL;
395 397
396 /* Put this in the alist of all live buffers. */ 398 /* Put this in the alist of all live buffers. */
@@ -417,17 +419,17 @@ copy_overlays (struct buffer *b, struct Lisp_Overlay *list)
417 Lisp_Object overlay, start, end; 419 Lisp_Object overlay, start, end;
418 struct Lisp_Marker *m; 420 struct Lisp_Marker *m;
419 421
420 eassert (MARKERP (MVAR (list, start))); 422 eassert (MARKERP (list->start));
421 m = XMARKER (MVAR (list, start)); 423 m = XMARKER (list->start);
422 start = build_marker (b, m->charpos, m->bytepos); 424 start = build_marker (b, m->charpos, m->bytepos);
423 XMARKER (start)->insertion_type = m->insertion_type; 425 XMARKER (start)->insertion_type = m->insertion_type;
424 426
425 eassert (MARKERP (MVAR (list, end))); 427 eassert (MARKERP (list->end));
426 m = XMARKER (MVAR (list, end)); 428 m = XMARKER (list->end);
427 end = build_marker (b, m->charpos, m->bytepos); 429 end = build_marker (b, m->charpos, m->bytepos);
428 XMARKER (end)->insertion_type = m->insertion_type; 430 XMARKER (end)->insertion_type = m->insertion_type;
429 431
430 overlay = build_overlay (start, end, Fcopy_sequence (MVAR (list, plist))); 432 overlay = build_overlay (start, end, Fcopy_sequence (list->plist));
431 if (tail) 433 if (tail)
432 tail = tail->next = XOVERLAY (overlay); 434 tail = tail->next = XOVERLAY (overlay);
433 else 435 else
@@ -472,12 +474,12 @@ clone_per_buffer_values (struct buffer *from, struct buffer *to)
472 474
473 memcpy (to->local_flags, from->local_flags, sizeof to->local_flags); 475 memcpy (to->local_flags, from->local_flags, sizeof to->local_flags);
474 476
475 to->overlays_before = copy_overlays (to, from->overlays_before); 477 buffer_set_overlays_before (to, copy_overlays (to, from->overlays_before));
476 to->overlays_after = copy_overlays (to, from->overlays_after); 478 buffer_set_overlays_after (to, copy_overlays (to, from->overlays_after));
477 479
478 /* Get (a copy of) the alist of Lisp-level local variables of FROM 480 /* Get (a copy of) the alist of Lisp-level local variables of FROM
479 and install that in TO. */ 481 and install that in TO. */
480 BVAR (to, local_var_alist) = buffer_lisp_local_variables (from, 1); 482 BSET (to, local_var_alist, buffer_lisp_local_variables (from, 1));
481} 483}
482 484
483 485
@@ -580,15 +582,15 @@ CLONE nil means the indirect buffer's state is reset to default values. */)
580 582
581 b->newline_cache = 0; 583 b->newline_cache = 0;
582 b->width_run_cache = 0; 584 b->width_run_cache = 0;
583 BVAR (b, width_table) = Qnil; 585 BSET (b, width_table, Qnil);
584 586
585 /* Put this on the chain of all buffers including killed ones. */ 587 /* Put this on the chain of all buffers including killed ones. */
586 b->header.next.buffer = all_buffers; 588 b->header.next.buffer = all_buffers;
587 all_buffers = b; 589 all_buffers = b;
588 590
589 name = Fcopy_sequence (name); 591 name = Fcopy_sequence (name);
590 STRING_SET_INTERVALS (name, NULL_INTERVAL); 592 string_set_intervals (name, NULL);
591 BVAR (b, name) = name; 593 BSET (b, name, name);
592 594
593 reset_buffer (b); 595 reset_buffer (b);
594 reset_buffer_local_variables (b, 1); 596 reset_buffer_local_variables (b, 1);
@@ -597,10 +599,10 @@ CLONE nil means the indirect buffer's state is reset to default values. */)
597 XSETBUFFER (buf, b); 599 XSETBUFFER (buf, b);
598 Vbuffer_alist = nconc2 (Vbuffer_alist, Fcons (Fcons (name, buf), Qnil)); 600 Vbuffer_alist = nconc2 (Vbuffer_alist, Fcons (Fcons (name, buf), Qnil));
599 601
600 BVAR (b, mark) = Fmake_marker (); 602 BSET (b, mark, Fmake_marker ());
601 603
602 /* The multibyte status belongs to the base buffer. */ 604 /* The multibyte status belongs to the base buffer. */
603 BVAR (b, enable_multibyte_characters) = BVAR (b->base_buffer, enable_multibyte_characters); 605 BSET (b, enable_multibyte_characters, BVAR (b->base_buffer, enable_multibyte_characters));
604 606
605 /* Make sure the base buffer has markers for its narrowing. */ 607 /* Make sure the base buffer has markers for its narrowing. */
606 if (NILP (BVAR (b->base_buffer, pt_marker))) 608 if (NILP (BVAR (b->base_buffer, pt_marker)))
@@ -608,14 +610,14 @@ CLONE nil means the indirect buffer's state is reset to default values. */)
608 eassert (NILP (BVAR (b->base_buffer, begv_marker))); 610 eassert (NILP (BVAR (b->base_buffer, begv_marker)));
609 eassert (NILP (BVAR (b->base_buffer, zv_marker))); 611 eassert (NILP (BVAR (b->base_buffer, zv_marker)));
610 612
611 BVAR (b->base_buffer, pt_marker) 613 BSET (b->base_buffer, pt_marker,
612 = build_marker (b->base_buffer, b->base_buffer->pt, b->base_buffer->pt_byte); 614 build_marker (b->base_buffer, b->base_buffer->pt, b->base_buffer->pt_byte));
613 615
614 BVAR (b->base_buffer, begv_marker) 616 BSET (b->base_buffer, begv_marker,
615 = build_marker (b->base_buffer, b->base_buffer->begv, b->base_buffer->begv_byte); 617 build_marker (b->base_buffer, b->base_buffer->begv, b->base_buffer->begv_byte));
616 618
617 BVAR (b->base_buffer, zv_marker) 619 BSET (b->base_buffer, zv_marker,
618 = build_marker (b->base_buffer, b->base_buffer->zv, b->base_buffer->zv_byte); 620 build_marker (b->base_buffer, b->base_buffer->zv, b->base_buffer->zv_byte));
619 621
620 XMARKER (BVAR (b->base_buffer, zv_marker))->insertion_type = 1; 622 XMARKER (BVAR (b->base_buffer, zv_marker))->insertion_type = 1;
621 } 623 }
@@ -623,9 +625,9 @@ CLONE nil means the indirect buffer's state is reset to default values. */)
623 if (NILP (clone)) 625 if (NILP (clone))
624 { 626 {
625 /* Give the indirect buffer markers for its narrowing. */ 627 /* Give the indirect buffer markers for its narrowing. */
626 BVAR (b, pt_marker) = build_marker (b, b->pt, b->pt_byte); 628 BSET (b, pt_marker, build_marker (b, b->pt, b->pt_byte));
627 BVAR (b, begv_marker) = build_marker (b, b->begv, b->begv_byte); 629 BSET (b, begv_marker, build_marker (b, b->begv, b->begv_byte));
628 BVAR (b, zv_marker) = build_marker (b, b->zv, b->zv_byte); 630 BSET (b, zv_marker, build_marker (b, b->zv, b->zv_byte));
629 XMARKER (BVAR (b, zv_marker))->insertion_type = 1; 631 XMARKER (BVAR (b, zv_marker))->insertion_type = 1;
630 } 632 }
631 else 633 else
@@ -633,11 +635,11 @@ CLONE nil means the indirect buffer's state is reset to default values. */)
633 struct buffer *old_b = current_buffer; 635 struct buffer *old_b = current_buffer;
634 636
635 clone_per_buffer_values (b->base_buffer, b); 637 clone_per_buffer_values (b->base_buffer, b);
636 BVAR (b, filename) = Qnil; 638 BSET (b, filename, Qnil);
637 BVAR (b, file_truename) = Qnil; 639 BSET (b, file_truename, Qnil);
638 BVAR (b, display_count) = make_number (0); 640 BSET (b, display_count, make_number (0));
639 BVAR (b, backed_up) = Qnil; 641 BSET (b, backed_up, Qnil);
640 BVAR (b, auto_save_file_name) = Qnil; 642 BSET (b, auto_save_file_name, Qnil);
641 set_buffer_internal_1 (b); 643 set_buffer_internal_1 (b);
642 Fset (intern ("buffer-save-without-query"), Qnil); 644 Fset (intern ("buffer-save-without-query"), Qnil);
643 Fset (intern ("buffer-file-number"), Qnil); 645 Fset (intern ("buffer-file-number"), Qnil);
@@ -657,11 +659,11 @@ CLONE nil means the indirect buffer's state is reset to default values. */)
657static void 659static void
658drop_overlay (struct buffer *b, struct Lisp_Overlay *ov) 660drop_overlay (struct buffer *b, struct Lisp_Overlay *ov)
659{ 661{
660 eassert (b == XBUFFER (Fmarker_buffer (MVAR (ov, start)))); 662 eassert (b == XBUFFER (Fmarker_buffer (ov->start)));
661 modify_overlay (b, marker_position (MVAR (ov, start)), 663 modify_overlay (b, marker_position (ov->start),
662 marker_position (MVAR (ov, end))); 664 marker_position (ov->end));
663 Fset_marker (MVAR (ov, start), Qnil, Qnil); 665 Fset_marker (ov->start, Qnil, Qnil);
664 Fset_marker (MVAR (ov, end), Qnil, Qnil); 666 Fset_marker (ov->end, Qnil, Qnil);
665 667
666} 668}
667 669
@@ -686,7 +688,8 @@ delete_all_overlays (struct buffer *b)
686 ov->next = NULL; 688 ov->next = NULL;
687 } 689 }
688 690
689 b->overlays_before = b->overlays_after = NULL; 691 buffer_set_overlays_before (b, NULL);
692 buffer_set_overlays_after (b, NULL);
690} 693}
691 694
692/* Reinitialize everything about a buffer except its name and contents 695/* Reinitialize everything about a buffer except its name and contents
@@ -699,9 +702,10 @@ delete_all_overlays (struct buffer *b)
699void 702void
700reset_buffer (register struct buffer *b) 703reset_buffer (register struct buffer *b)
701{ 704{
702 BVAR (b, filename) = Qnil; 705 BSET (b, filename, Qnil);
703 BVAR (b, file_truename) = Qnil; 706 BSET (b, file_truename, Qnil);
704 BVAR (b, directory) = (current_buffer) ? BVAR (current_buffer, directory) : Qnil; 707 BSET (b, directory,
708 (current_buffer) ? BVAR (current_buffer, directory) : Qnil);
705 b->modtime = make_emacs_time (0, UNKNOWN_MODTIME_NSECS); 709 b->modtime = make_emacs_time (0, UNKNOWN_MODTIME_NSECS);
706 b->modtime_size = -1; 710 b->modtime_size = -1;
707 XSETFASTINT (BVAR (b, save_length), 0); 711 XSETFASTINT (BVAR (b, save_length), 0);
@@ -709,24 +713,25 @@ reset_buffer (register struct buffer *b)
709 /* It is more conservative to start out "changed" than "unchanged". */ 713 /* It is more conservative to start out "changed" than "unchanged". */
710 b->clip_changed = 0; 714 b->clip_changed = 0;
711 b->prevent_redisplay_optimizations_p = 1; 715 b->prevent_redisplay_optimizations_p = 1;
712 BVAR (b, backed_up) = Qnil; 716 BSET (b, backed_up, Qnil);
713 BUF_AUTOSAVE_MODIFF (b) = 0; 717 BUF_AUTOSAVE_MODIFF (b) = 0;
714 b->auto_save_failure_time = 0; 718 b->auto_save_failure_time = 0;
715 BVAR (b, auto_save_file_name) = Qnil; 719 BSET (b, auto_save_file_name, Qnil);
716 BVAR (b, read_only) = Qnil; 720 BSET (b, read_only, Qnil);
717 b->overlays_before = NULL; 721 buffer_set_overlays_before (b, NULL);
718 b->overlays_after = NULL; 722 buffer_set_overlays_after (b, NULL);
719 b->overlay_center = BEG; 723 b->overlay_center = BEG;
720 BVAR (b, mark_active) = Qnil; 724 BSET (b, mark_active, Qnil);
721 BVAR (b, point_before_scroll) = Qnil; 725 BSET (b, point_before_scroll, Qnil);
722 BVAR (b, file_format) = Qnil; 726 BSET (b, file_format, Qnil);
723 BVAR (b, auto_save_file_format) = Qt; 727 BSET (b, auto_save_file_format, Qt);
724 BVAR (b, last_selected_window) = Qnil; 728 BSET (b, last_selected_window, Qnil);
725 XSETINT (BVAR (b, display_count), 0); 729 BSET (b, display_count, make_number (0));
726 BVAR (b, display_time) = Qnil; 730 BSET (b, display_time, Qnil);
727 BVAR (b, enable_multibyte_characters) = BVAR (&buffer_defaults, enable_multibyte_characters); 731 BSET (b, enable_multibyte_characters,
728 BVAR (b, cursor_type) = BVAR (&buffer_defaults, cursor_type); 732 BVAR (&buffer_defaults, enable_multibyte_characters));
729 BVAR (b, extra_line_spacing) = BVAR (&buffer_defaults, extra_line_spacing); 733 BSET (b, cursor_type, BVAR (&buffer_defaults, cursor_type));
734 BSET (b, extra_line_spacing, BVAR (&buffer_defaults, extra_line_spacing));
730 735
731 b->display_error_modiff = 0; 736 b->display_error_modiff = 0;
732} 737}
@@ -750,10 +755,10 @@ reset_buffer_local_variables (register struct buffer *b, int permanent_too)
750 things that depend on the major mode. 755 things that depend on the major mode.
751 default-major-mode is handled at a higher level. 756 default-major-mode is handled at a higher level.
752 We ignore it here. */ 757 We ignore it here. */
753 BVAR (b, major_mode) = Qfundamental_mode; 758 BSET (b, major_mode, Qfundamental_mode);
754 BVAR (b, keymap) = Qnil; 759 BSET (b, keymap, Qnil);
755 BVAR (b, mode_name) = QSFundamental; 760 BSET (b, mode_name, QSFundamental);
756 BVAR (b, minor_modes) = Qnil; 761 BSET (b, minor_modes, Qnil);
757 762
758 /* If the standard case table has been altered and invalidated, 763 /* If the standard case table has been altered and invalidated,
759 fix up its insides first. */ 764 fix up its insides first. */
@@ -762,15 +767,15 @@ reset_buffer_local_variables (register struct buffer *b, int permanent_too)
762 && CHAR_TABLE_P (XCHAR_TABLE (Vascii_downcase_table)->extras[2]))) 767 && CHAR_TABLE_P (XCHAR_TABLE (Vascii_downcase_table)->extras[2])))
763 Fset_standard_case_table (Vascii_downcase_table); 768 Fset_standard_case_table (Vascii_downcase_table);
764 769
765 BVAR (b, downcase_table) = Vascii_downcase_table; 770 BSET (b, downcase_table, Vascii_downcase_table);
766 BVAR (b, upcase_table) = XCHAR_TABLE (Vascii_downcase_table)->extras[0]; 771 BSET (b, upcase_table, XCHAR_TABLE (Vascii_downcase_table)->extras[0]);
767 BVAR (b, case_canon_table) = XCHAR_TABLE (Vascii_downcase_table)->extras[1]; 772 BSET (b, case_canon_table, XCHAR_TABLE (Vascii_downcase_table)->extras[1]);
768 BVAR (b, case_eqv_table) = XCHAR_TABLE (Vascii_downcase_table)->extras[2]; 773 BSET (b, case_eqv_table, XCHAR_TABLE (Vascii_downcase_table)->extras[2]);
769 BVAR (b, invisibility_spec) = Qt; 774 BSET (b, invisibility_spec, Qt);
770 775
771 /* Reset all (or most) per-buffer variables to their defaults. */ 776 /* Reset all (or most) per-buffer variables to their defaults. */
772 if (permanent_too) 777 if (permanent_too)
773 BVAR (b, local_var_alist) = Qnil; 778 BSET (b, local_var_alist, Qnil);
774 else 779 else
775 { 780 {
776 Lisp_Object tmp, prop, last = Qnil; 781 Lisp_Object tmp, prop, last = Qnil;
@@ -804,7 +809,7 @@ reset_buffer_local_variables (register struct buffer *b, int permanent_too)
804 } 809 }
805 /* Delete this local variable. */ 810 /* Delete this local variable. */
806 else if (NILP (last)) 811 else if (NILP (last))
807 BVAR (b, local_var_alist) = XCDR (tmp); 812 BSET (b, local_var_alist, XCDR (tmp));
808 else 813 else
809 XSETCDR (last, XCDR (tmp)); 814 XSETCDR (last, XCDR (tmp));
810 } 815 }
@@ -1281,7 +1286,7 @@ This does not change the name of the visited file (if any). */)
1281 error ("Buffer name `%s' is in use", SDATA (newname)); 1286 error ("Buffer name `%s' is in use", SDATA (newname));
1282 } 1287 }
1283 1288
1284 BVAR (current_buffer, name) = newname; 1289 BSET (current_buffer, name, newname);
1285 1290
1286 /* Catch redisplay's attention. Unless we do this, the mode lines for 1291 /* Catch redisplay's attention. Unless we do this, the mode lines for
1287 any windows displaying current_buffer will stay unchanged. */ 1292 any windows displaying current_buffer will stay unchanged. */
@@ -1325,7 +1330,7 @@ exists, return the buffer `*scratch*' (creating it if necessary). */)
1325 1330
1326 pred = frame_buffer_predicate (frame); 1331 pred = frame_buffer_predicate (frame);
1327 /* Consider buffers that have been seen in the frame first. */ 1332 /* Consider buffers that have been seen in the frame first. */
1328 tail = FVAR (XFRAME (frame), buffer_list); 1333 tail = XFRAME (frame)->buffer_list;
1329 for (; CONSP (tail); tail = XCDR (tail)) 1334 for (; CONSP (tail); tail = XCDR (tail))
1330 { 1335 {
1331 buf = XCAR (tail); 1336 buf = XCAR (tail);
@@ -1426,7 +1431,7 @@ No argument or nil as argument means do this for the current buffer. */)
1426 } 1431 }
1427 1432
1428 if (EQ (BVAR (XBUFFER (real_buffer), undo_list), Qt)) 1433 if (EQ (BVAR (XBUFFER (real_buffer), undo_list), Qt))
1429 BVAR (XBUFFER (real_buffer), undo_list) = Qnil; 1434 BSET (XBUFFER (real_buffer), undo_list, Qnil);
1430 1435
1431 return Qnil; 1436 return Qnil;
1432} 1437}
@@ -1558,7 +1563,7 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1558 since anything can happen within do_yes_or_no_p. */ 1563 since anything can happen within do_yes_or_no_p. */
1559 1564
1560 /* Don't kill the minibuffer now current. */ 1565 /* Don't kill the minibuffer now current. */
1561 if (EQ (buffer, WVAR (XWINDOW (minibuf_window), buffer))) 1566 if (EQ (buffer, XWINDOW (minibuf_window)->buffer))
1562 return Qnil; 1567 return Qnil;
1563 1568
1564 /* When we kill an ordinary buffer which shares it's buffer text 1569 /* When we kill an ordinary buffer which shares it's buffer text
@@ -1609,7 +1614,7 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1609 /* If the buffer now current is shown in the minibuffer and our buffer 1614 /* If the buffer now current is shown in the minibuffer and our buffer
1610 is the sole other buffer give up. */ 1615 is the sole other buffer give up. */
1611 XSETBUFFER (tem, current_buffer); 1616 XSETBUFFER (tem, current_buffer);
1612 if (EQ (tem, WVAR (XWINDOW (minibuf_window), buffer)) 1617 if (EQ (tem, XWINDOW (minibuf_window)->buffer)
1613 && EQ (buffer, Fother_buffer (buffer, Qnil, Qnil))) 1618 && EQ (buffer, Fother_buffer (buffer, Qnil, Qnil)))
1614 return Qnil; 1619 return Qnil;
1615 1620
@@ -1686,7 +1691,7 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1686 m = next; 1691 m = next;
1687 } 1692 }
1688 BUF_MARKERS (b) = NULL; 1693 BUF_MARKERS (b) = NULL;
1689 BUF_INTERVALS (b) = NULL_INTERVAL; 1694 buffer_set_intervals (b, NULL);
1690 1695
1691 /* Perhaps we should explicitly free the interval tree here... */ 1696 /* Perhaps we should explicitly free the interval tree here... */
1692 } 1697 }
@@ -1698,7 +1703,7 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1698 swap_out_buffer_local_variables (b); 1703 swap_out_buffer_local_variables (b);
1699 reset_buffer_local_variables (b, 1); 1704 reset_buffer_local_variables (b, 1);
1700 1705
1701 BVAR (b, name) = Qnil; 1706 BSET (b, name, Qnil);
1702 1707
1703 BLOCK_INPUT; 1708 BLOCK_INPUT;
1704 if (b->base_buffer) 1709 if (b->base_buffer)
@@ -1722,9 +1727,9 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1722 free_region_cache (b->width_run_cache); 1727 free_region_cache (b->width_run_cache);
1723 b->width_run_cache = 0; 1728 b->width_run_cache = 0;
1724 } 1729 }
1725 BVAR (b, width_table) = Qnil; 1730 BSET (b, width_table, Qnil);
1726 UNBLOCK_INPUT; 1731 UNBLOCK_INPUT;
1727 BVAR (b, undo_list) = Qnil; 1732 BSET (b, undo_list, Qnil);
1728 1733
1729 /* Run buffer-list-update-hook. */ 1734 /* Run buffer-list-update-hook. */
1730 if (!NILP (Vrun_hooks)) 1735 if (!NILP (Vrun_hooks))
@@ -1765,8 +1770,8 @@ record_buffer (Lisp_Object buffer)
1765 Vinhibit_quit = tem; 1770 Vinhibit_quit = tem;
1766 1771
1767 /* Update buffer list of selected frame. */ 1772 /* Update buffer list of selected frame. */
1768 FVAR (f, buffer_list) = Fcons (buffer, Fdelq (buffer, FVAR (f, buffer_list))); 1773 FSET (f, buffer_list, Fcons (buffer, Fdelq (buffer, f->buffer_list)));
1769 FVAR (f, buried_buffer_list) = Fdelq (buffer, FVAR (f, buried_buffer_list)); 1774 FSET (f, buried_buffer_list, Fdelq (buffer, f->buried_buffer_list));
1770 1775
1771 /* Run buffer-list-update-hook. */ 1776 /* Run buffer-list-update-hook. */
1772 if (!NILP (Vrun_hooks)) 1777 if (!NILP (Vrun_hooks))
@@ -1803,9 +1808,9 @@ DEFUN ("bury-buffer-internal", Fbury_buffer_internal, Sbury_buffer_internal,
1803 Vinhibit_quit = tem; 1808 Vinhibit_quit = tem;
1804 1809
1805 /* Update buffer lists of selected frame. */ 1810 /* Update buffer lists of selected frame. */
1806 FVAR (f, buffer_list) = Fdelq (buffer, FVAR (f, buffer_list)); 1811 FSET (f, buffer_list, Fdelq (buffer, f->buffer_list));
1807 FVAR (f, buried_buffer_list) 1812 FSET (f, buried_buffer_list,
1808 = Fcons (buffer, Fdelq (buffer, FVAR (f, buried_buffer_list))); 1813 Fcons (buffer, Fdelq (buffer, f->buried_buffer_list)));
1809 1814
1810 /* Run buffer-list-update-hook. */ 1815 /* Run buffer-list-update-hook. */
1811 if (!NILP (Vrun_hooks)) 1816 if (!NILP (Vrun_hooks))
@@ -1905,7 +1910,7 @@ set_buffer_internal_1 (register struct buffer *b)
1905 /* Put the undo list back in the base buffer, so that it appears 1910 /* Put the undo list back in the base buffer, so that it appears
1906 that an indirect buffer shares the undo list of its base. */ 1911 that an indirect buffer shares the undo list of its base. */
1907 if (old_buf->base_buffer) 1912 if (old_buf->base_buffer)
1908 BVAR (old_buf->base_buffer, undo_list) = BVAR (old_buf, undo_list); 1913 BSET (old_buf->base_buffer, undo_list, BVAR (old_buf, undo_list));
1909 1914
1910 /* If the old current buffer has markers to record PT, BEGV and ZV 1915 /* If the old current buffer has markers to record PT, BEGV and ZV
1911 when it is not current, update them now. */ 1916 when it is not current, update them now. */
@@ -1915,7 +1920,7 @@ set_buffer_internal_1 (register struct buffer *b)
1915 /* Get the undo list from the base buffer, so that it appears 1920 /* Get the undo list from the base buffer, so that it appears
1916 that an indirect buffer shares the undo list of its base. */ 1921 that an indirect buffer shares the undo list of its base. */
1917 if (b->base_buffer) 1922 if (b->base_buffer)
1918 BVAR (b, undo_list) = BVAR (b->base_buffer, undo_list); 1923 BSET (b, undo_list, BVAR (b->base_buffer, undo_list));
1919 1924
1920 /* If the new current buffer has markers to record PT, BEGV and ZV 1925 /* If the new current buffer has markers to record PT, BEGV and ZV
1921 when it is not current, fetch them now. */ 1926 when it is not current, fetch them now. */
@@ -2113,8 +2118,8 @@ DEFUN ("buffer-swap-text", Fbuffer_swap_text, Sbuffer_swap_text,
2113#define swapfield_(field, type) \ 2118#define swapfield_(field, type) \
2114 do { \ 2119 do { \
2115 type tmp##field = BVAR (other_buffer, field); \ 2120 type tmp##field = BVAR (other_buffer, field); \
2116 BVAR (other_buffer, field) = BVAR (current_buffer, field); \ 2121 BSET (other_buffer, field, BVAR (current_buffer, field)); \
2117 BVAR (current_buffer, field) = tmp##field; \ 2122 BSET (current_buffer, field, tmp##field); \
2118 } while (0) 2123 } while (0)
2119 2124
2120 swapfield (own_text, struct buffer_text); 2125 swapfield (own_text, struct buffer_text);
@@ -2154,8 +2159,8 @@ DEFUN ("buffer-swap-text", Fbuffer_swap_text, Sbuffer_swap_text,
2154 swapfield_ (pt_marker, Lisp_Object); 2159 swapfield_ (pt_marker, Lisp_Object);
2155 swapfield_ (begv_marker, Lisp_Object); 2160 swapfield_ (begv_marker, Lisp_Object);
2156 swapfield_ (zv_marker, Lisp_Object); 2161 swapfield_ (zv_marker, Lisp_Object);
2157 BVAR (current_buffer, point_before_scroll) = Qnil; 2162 BSET (current_buffer, point_before_scroll, Qnil);
2158 BVAR (other_buffer, point_before_scroll) = Qnil; 2163 BSET (other_buffer, point_before_scroll, Qnil);
2159 2164
2160 current_buffer->text->modiff++; other_buffer->text->modiff++; 2165 current_buffer->text->modiff++; other_buffer->text->modiff++;
2161 current_buffer->text->chars_modiff++; other_buffer->text->chars_modiff++; 2166 current_buffer->text->chars_modiff++; other_buffer->text->chars_modiff++;
@@ -2191,13 +2196,13 @@ DEFUN ("buffer-swap-text", Fbuffer_swap_text, Sbuffer_swap_text,
2191 while (NILP (Fmemq (w, ws))) 2196 while (NILP (Fmemq (w, ws)))
2192 { 2197 {
2193 ws = Fcons (w, ws); 2198 ws = Fcons (w, ws);
2194 if (MARKERP (WVAR (XWINDOW (w), pointm)) 2199 if (MARKERP (XWINDOW (w)->pointm)
2195 && (EQ (WVAR (XWINDOW (w), buffer), buf1) 2200 && (EQ (XWINDOW (w)->buffer, buf1)
2196 || EQ (WVAR (XWINDOW (w), buffer), buf2))) 2201 || EQ (XWINDOW (w)->buffer, buf2)))
2197 Fset_marker (WVAR (XWINDOW (w), pointm), 2202 Fset_marker (XWINDOW (w)->pointm,
2198 make_number 2203 make_number
2199 (BUF_BEGV (XBUFFER (WVAR (XWINDOW (w), buffer)))), 2204 (BUF_BEGV (XBUFFER (XWINDOW (w)->buffer))),
2200 WVAR (XWINDOW (w), buffer)); 2205 XWINDOW (w)->buffer);
2201 w = Fnext_window (w, Qt, Qt); 2206 w = Fnext_window (w, Qt, Qt);
2202 } 2207 }
2203 } 2208 }
@@ -2244,7 +2249,7 @@ current buffer is cleared. */)
2244 2249
2245 /* Don't record these buffer changes. We will put a special undo entry 2250 /* Don't record these buffer changes. We will put a special undo entry
2246 instead. */ 2251 instead. */
2247 BVAR (current_buffer, undo_list) = Qt; 2252 BSET (current_buffer, undo_list, Qt);
2248 2253
2249 /* If the cached position is for this buffer, clear it out. */ 2254 /* If the cached position is for this buffer, clear it out. */
2250 clear_charpos_cache (current_buffer); 2255 clear_charpos_cache (current_buffer);
@@ -2266,7 +2271,7 @@ current buffer is cleared. */)
2266 to calculate the old correspondences. */ 2271 to calculate the old correspondences. */
2267 set_intervals_multibyte (0); 2272 set_intervals_multibyte (0);
2268 2273
2269 BVAR (current_buffer, enable_multibyte_characters) = Qnil; 2274 BSET (current_buffer, enable_multibyte_characters, Qnil);
2270 2275
2271 Z = Z_BYTE; 2276 Z = Z_BYTE;
2272 BEGV = BEGV_BYTE; 2277 BEGV = BEGV_BYTE;
@@ -2404,7 +2409,7 @@ current buffer is cleared. */)
2404 2409
2405 /* Do this first, so that chars_in_text asks the right question. 2410 /* Do this first, so that chars_in_text asks the right question.
2406 set_intervals_multibyte needs it too. */ 2411 set_intervals_multibyte needs it too. */
2407 BVAR (current_buffer, enable_multibyte_characters) = Qt; 2412 BSET (current_buffer, enable_multibyte_characters, Qt);
2408 2413
2409 GPT_BYTE = advance_to_char_boundary (GPT_BYTE); 2414 GPT_BYTE = advance_to_char_boundary (GPT_BYTE);
2410 GPT = chars_in_text (BEG_ADDR, GPT_BYTE - BEG_BYTE) + BEG; 2415 GPT = chars_in_text (BEG_ADDR, GPT_BYTE - BEG_BYTE) + BEG;
@@ -2462,10 +2467,11 @@ current buffer is cleared. */)
2462 if (!EQ (old_undo, Qt)) 2467 if (!EQ (old_undo, Qt))
2463 { 2468 {
2464 /* Represent all the above changes by a special undo entry. */ 2469 /* Represent all the above changes by a special undo entry. */
2465 BVAR (current_buffer, undo_list) = Fcons (list3 (Qapply, 2470 BSET (current_buffer, undo_list,
2466 intern ("set-buffer-multibyte"), 2471 Fcons (list3 (Qapply,
2467 NILP (flag) ? Qt : Qnil), 2472 intern ("set-buffer-multibyte"),
2468 old_undo); 2473 NILP (flag) ? Qt : Qnil),
2474 old_undo));
2469 } 2475 }
2470 2476
2471 UNGCPRO; 2477 UNGCPRO;
@@ -3232,7 +3238,7 @@ recenter_overlay_lists (struct buffer *buf, ptrdiff_t pos)
3232 if (prev) 3238 if (prev)
3233 prev->next = next; 3239 prev->next = next;
3234 else 3240 else
3235 buf->overlays_before = next; 3241 buffer_set_overlays_before (buf, next);
3236 3242
3237 /* Search thru overlays_after for where to put it. */ 3243 /* Search thru overlays_after for where to put it. */
3238 other_prev = NULL; 3244 other_prev = NULL;
@@ -3254,7 +3260,7 @@ recenter_overlay_lists (struct buffer *buf, ptrdiff_t pos)
3254 if (other_prev) 3260 if (other_prev)
3255 other_prev->next = tail; 3261 other_prev->next = tail;
3256 else 3262 else
3257 buf->overlays_after = tail; 3263 buffer_set_overlays_after (buf, tail);
3258 tail = prev; 3264 tail = prev;
3259 } 3265 }
3260 else 3266 else
@@ -3290,7 +3296,7 @@ recenter_overlay_lists (struct buffer *buf, ptrdiff_t pos)
3290 if (prev) 3296 if (prev)
3291 prev->next = next; 3297 prev->next = next;
3292 else 3298 else
3293 buf->overlays_after = next; 3299 buffer_set_overlays_after (buf, next);
3294 3300
3295 /* Search thru overlays_before for where to put it. */ 3301 /* Search thru overlays_before for where to put it. */
3296 other_prev = NULL; 3302 other_prev = NULL;
@@ -3312,7 +3318,7 @@ recenter_overlay_lists (struct buffer *buf, ptrdiff_t pos)
3312 if (other_prev) 3318 if (other_prev)
3313 other_prev->next = tail; 3319 other_prev->next = tail;
3314 else 3320 else
3315 buf->overlays_before = tail; 3321 buffer_set_overlays_before (buf, tail);
3316 tail = prev; 3322 tail = prev;
3317 } 3323 }
3318 } 3324 }
@@ -3417,7 +3423,7 @@ fix_start_end_in_overlays (register ptrdiff_t start, register ptrdiff_t end)
3417 beforep = tail; 3423 beforep = tail;
3418 } 3424 }
3419 if (!parent) 3425 if (!parent)
3420 current_buffer->overlays_before = tail->next; 3426 buffer_set_overlays_before (current_buffer, tail->next);
3421 else 3427 else
3422 parent->next = tail->next; 3428 parent->next = tail->next;
3423 tail = tail->next; 3429 tail = tail->next;
@@ -3463,7 +3469,7 @@ fix_start_end_in_overlays (register ptrdiff_t start, register ptrdiff_t end)
3463 beforep = tail; 3469 beforep = tail;
3464 } 3470 }
3465 if (!parent) 3471 if (!parent)
3466 current_buffer->overlays_after = tail->next; 3472 buffer_set_overlays_after (current_buffer, tail->next);
3467 else 3473 else
3468 parent->next = tail->next; 3474 parent->next = tail->next;
3469 tail = tail->next; 3475 tail = tail->next;
@@ -3477,14 +3483,14 @@ fix_start_end_in_overlays (register ptrdiff_t start, register ptrdiff_t end)
3477 if (beforep) 3483 if (beforep)
3478 { 3484 {
3479 beforep->next = current_buffer->overlays_before; 3485 beforep->next = current_buffer->overlays_before;
3480 current_buffer->overlays_before = before_list; 3486 buffer_set_overlays_before (current_buffer, before_list);
3481 } 3487 }
3482 recenter_overlay_lists (current_buffer, current_buffer->overlay_center); 3488 recenter_overlay_lists (current_buffer, current_buffer->overlay_center);
3483 3489
3484 if (afterp) 3490 if (afterp)
3485 { 3491 {
3486 afterp->next = current_buffer->overlays_after; 3492 afterp->next = current_buffer->overlays_after;
3487 current_buffer->overlays_after = after_list; 3493 buffer_set_overlays_after (current_buffer, after_list);
3488 } 3494 }
3489 recenter_overlay_lists (current_buffer, current_buffer->overlay_center); 3495 recenter_overlay_lists (current_buffer, current_buffer->overlay_center);
3490} 3496}
@@ -3561,7 +3567,7 @@ fix_overlays_before (struct buffer *bp, ptrdiff_t prev, ptrdiff_t pos)
3561 if (!right_pair) 3567 if (!right_pair)
3562 { 3568 {
3563 found->next = bp->overlays_before; 3569 found->next = bp->overlays_before;
3564 bp->overlays_before = found; 3570 buffer_set_overlays_before (bp, found);
3565 } 3571 }
3566 else 3572 else
3567 { 3573 {
@@ -3639,13 +3645,13 @@ for the rear of the overlay advance when text is inserted there
3639 { 3645 {
3640 if (b->overlays_after) 3646 if (b->overlays_after)
3641 XOVERLAY (overlay)->next = b->overlays_after; 3647 XOVERLAY (overlay)->next = b->overlays_after;
3642 b->overlays_after = XOVERLAY (overlay); 3648 buffer_set_overlays_after (b, XOVERLAY (overlay));
3643 } 3649 }
3644 else 3650 else
3645 { 3651 {
3646 if (b->overlays_before) 3652 if (b->overlays_before)
3647 XOVERLAY (overlay)->next = b->overlays_before; 3653 XOVERLAY (overlay)->next = b->overlays_before;
3648 b->overlays_before = XOVERLAY (overlay); 3654 buffer_set_overlays_before (b, XOVERLAY (overlay));
3649 } 3655 }
3650 3656
3651 /* This puts it in the right list, and in the right order. */ 3657 /* This puts it in the right list, and in the right order. */
@@ -3673,7 +3679,7 @@ modify_overlay (struct buffer *buf, ptrdiff_t start, ptrdiff_t end)
3673 3679
3674 /* If this is a buffer not in the selected window, 3680 /* If this is a buffer not in the selected window,
3675 we must do other windows. */ 3681 we must do other windows. */
3676 if (buf != XBUFFER (WVAR (XWINDOW (selected_window), buffer))) 3682 if (buf != XBUFFER (XWINDOW (selected_window)->buffer))
3677 windows_or_buffers_changed = 1; 3683 windows_or_buffers_changed = 1;
3678 /* If multiple windows show this buffer, we must do other windows. */ 3684 /* If multiple windows show this buffer, we must do other windows. */
3679 else if (buffer_shared > 1) 3685 else if (buffer_shared > 1)
@@ -3703,6 +3709,18 @@ unchain_overlay (struct Lisp_Overlay *list, struct Lisp_Overlay *overlay)
3703 return list; 3709 return list;
3704} 3710}
3705 3711
3712/* Remove OVERLAY from both overlay lists of B. */
3713
3714static void
3715unchain_both (struct buffer *b, Lisp_Object overlay)
3716{
3717 struct Lisp_Overlay *ov = XOVERLAY (overlay);
3718
3719 buffer_set_overlays_before (b, unchain_overlay (b->overlays_before, ov));
3720 buffer_set_overlays_after (b, unchain_overlay (b->overlays_after, ov));
3721 eassert (XOVERLAY (overlay)->next == NULL);
3722}
3723
3706DEFUN ("move-overlay", Fmove_overlay, Smove_overlay, 3, 4, 0, 3724DEFUN ("move-overlay", Fmove_overlay, Smove_overlay, 3, 4, 0,
3707 doc: /* Set the endpoints of OVERLAY to BEG and END in BUFFER. 3725 doc: /* Set the endpoints of OVERLAY to BEG and END in BUFFER.
3708If BUFFER is omitted, leave OVERLAY in the same buffer it inhabits now. 3726If BUFFER is omitted, leave OVERLAY in the same buffer it inhabits now.
@@ -3753,11 +3771,7 @@ buffer. */)
3753 o_beg = OVERLAY_POSITION (OVERLAY_START (overlay)); 3771 o_beg = OVERLAY_POSITION (OVERLAY_START (overlay));
3754 o_end = OVERLAY_POSITION (OVERLAY_END (overlay)); 3772 o_end = OVERLAY_POSITION (OVERLAY_END (overlay));
3755 3773
3756 ob->overlays_before = 3774 unchain_both (ob, overlay);
3757 unchain_overlay (ob->overlays_before, XOVERLAY (overlay));
3758 ob->overlays_after =
3759 unchain_overlay (ob->overlays_after, XOVERLAY (overlay));
3760 eassert (XOVERLAY (overlay)->next == NULL);
3761 } 3775 }
3762 3776
3763 /* Set the overlay boundaries, which may clip them. */ 3777 /* Set the overlay boundaries, which may clip them. */
@@ -3798,12 +3812,12 @@ buffer. */)
3798 if (n_end < b->overlay_center) 3812 if (n_end < b->overlay_center)
3799 { 3813 {
3800 XOVERLAY (overlay)->next = b->overlays_after; 3814 XOVERLAY (overlay)->next = b->overlays_after;
3801 b->overlays_after = XOVERLAY (overlay); 3815 buffer_set_overlays_after (b, XOVERLAY (overlay));
3802 } 3816 }
3803 else 3817 else
3804 { 3818 {
3805 XOVERLAY (overlay)->next = b->overlays_before; 3819 XOVERLAY (overlay)->next = b->overlays_before;
3806 b->overlays_before = XOVERLAY (overlay); 3820 buffer_set_overlays_before (b, XOVERLAY (overlay));
3807 } 3821 }
3808 3822
3809 /* This puts it in the right list, and in the right order. */ 3823 /* This puts it in the right list, and in the right order. */
@@ -3829,12 +3843,7 @@ DEFUN ("delete-overlay", Fdelete_overlay, Sdelete_overlay, 1, 1, 0,
3829 b = XBUFFER (buffer); 3843 b = XBUFFER (buffer);
3830 specbind (Qinhibit_quit, Qt); 3844 specbind (Qinhibit_quit, Qt);
3831 3845
3832 b->overlays_before 3846 unchain_both (b, overlay);
3833 = unchain_overlay (b->overlays_before, XOVERLAY (overlay));
3834 b->overlays_after
3835 = unchain_overlay (b->overlays_after, XOVERLAY (overlay));
3836 eassert (XOVERLAY (overlay)->next == NULL);
3837
3838 drop_overlay (b, XOVERLAY (overlay)); 3847 drop_overlay (b, XOVERLAY (overlay));
3839 3848
3840 /* When deleting an overlay with before or after strings, turn off 3849 /* When deleting an overlay with before or after strings, turn off
@@ -3887,7 +3896,7 @@ OVERLAY. */)
3887{ 3896{
3888 CHECK_OVERLAY (overlay); 3897 CHECK_OVERLAY (overlay);
3889 3898
3890 return Fcopy_sequence (MVAR (XOVERLAY (overlay), plist)); 3899 return Fcopy_sequence (XOVERLAY (overlay)->plist);
3891} 3900}
3892 3901
3893 3902
@@ -4031,6 +4040,7 @@ However, the overlays you get are the real objects that the buffer uses. */)
4031{ 4040{
4032 struct Lisp_Overlay *ol; 4041 struct Lisp_Overlay *ol;
4033 Lisp_Object before = Qnil, after = Qnil, tmp; 4042 Lisp_Object before = Qnil, after = Qnil, tmp;
4043
4034 for (ol = current_buffer->overlays_before; ol; ol = ol->next) 4044 for (ol = current_buffer->overlays_before; ol; ol = ol->next)
4035 { 4045 {
4036 XSETMISC (tmp, ol); 4046 XSETMISC (tmp, ol);
@@ -4041,6 +4051,7 @@ However, the overlays you get are the real objects that the buffer uses. */)
4041 XSETMISC (tmp, ol); 4051 XSETMISC (tmp, ol);
4042 after = Fcons (tmp, after); 4052 after = Fcons (tmp, after);
4043 } 4053 }
4054
4044 return Fcons (Fnreverse (before), Fnreverse (after)); 4055 return Fcons (Fnreverse (before), Fnreverse (after));
4045} 4056}
4046 4057
@@ -4063,7 +4074,7 @@ DEFUN ("overlay-get", Foverlay_get, Soverlay_get, 2, 2, 0,
4063 (Lisp_Object overlay, Lisp_Object prop) 4074 (Lisp_Object overlay, Lisp_Object prop)
4064{ 4075{
4065 CHECK_OVERLAY (overlay); 4076 CHECK_OVERLAY (overlay);
4066 return lookup_char_property (MVAR (XOVERLAY (overlay), plist), prop, 0); 4077 return lookup_char_property (XOVERLAY (overlay)->plist, prop, 0);
4067} 4078}
4068 4079
4069DEFUN ("overlay-put", Foverlay_put, Soverlay_put, 3, 3, 0, 4080DEFUN ("overlay-put", Foverlay_put, Soverlay_put, 3, 3, 0,
@@ -4078,7 +4089,7 @@ VALUE will be returned.*/)
4078 4089
4079 buffer = Fmarker_buffer (OVERLAY_START (overlay)); 4090 buffer = Fmarker_buffer (OVERLAY_START (overlay));
4080 4091
4081 for (tail = MVAR (XOVERLAY (overlay), plist); 4092 for (tail = XOVERLAY (overlay)->plist;
4082 CONSP (tail) && CONSP (XCDR (tail)); 4093 CONSP (tail) && CONSP (XCDR (tail));
4083 tail = XCDR (XCDR (tail))) 4094 tail = XCDR (XCDR (tail)))
4084 if (EQ (XCAR (tail), prop)) 4095 if (EQ (XCAR (tail), prop))
@@ -4089,8 +4100,8 @@ VALUE will be returned.*/)
4089 } 4100 }
4090 /* It wasn't in the list, so add it to the front. */ 4101 /* It wasn't in the list, so add it to the front. */
4091 changed = !NILP (value); 4102 changed = !NILP (value);
4092 MVAR (XOVERLAY (overlay), plist) 4103 set_overlay_plist
4093 = Fcons (prop, Fcons (value, MVAR (XOVERLAY (overlay), plist))); 4104 (overlay, Fcons (prop, Fcons (value, XOVERLAY (overlay)->plist)));
4094 found: 4105 found:
4095 if (! NILP (buffer)) 4106 if (! NILP (buffer))
4096 { 4107 {
@@ -4265,7 +4276,7 @@ report_overlay_modification (Lisp_Object start, Lisp_Object end, int after,
4265 ptrdiff_t i; 4276 ptrdiff_t i;
4266 4277
4267 memcpy (copy, XVECTOR (last_overlay_modification_hooks)->contents, 4278 memcpy (copy, XVECTOR (last_overlay_modification_hooks)->contents,
4268 size * sizeof (Lisp_Object)); 4279 size * word_size);
4269 gcpro1.var = copy; 4280 gcpro1.var = copy;
4270 gcpro1.nvars = size; 4281 gcpro1.nvars = size;
4271 4282
@@ -4884,8 +4895,7 @@ init_buffer_once (void)
4884 sure that this is still correct. Otherwise, mark_vectorlike may not 4895 sure that this is still correct. Otherwise, mark_vectorlike may not
4885 trace all Lisp_Objects in buffer_defaults and buffer_local_symbols. */ 4896 trace all Lisp_Objects in buffer_defaults and buffer_local_symbols. */
4886 const int pvecsize 4897 const int pvecsize
4887 = (offsetof (struct buffer, own_text) - sizeof (struct vectorlike_header)) 4898 = (offsetof (struct buffer, own_text) - header_size) / word_size;
4888 / sizeof (Lisp_Object);
4889 4899
4890 memset (buffer_permanent_local_flags, 0, sizeof buffer_permanent_local_flags); 4900 memset (buffer_permanent_local_flags, 0, sizeof buffer_permanent_local_flags);
4891 4901
@@ -4903,8 +4913,8 @@ init_buffer_once (void)
4903 /* No one will share the text with these buffers, but let's play it safe. */ 4913 /* No one will share the text with these buffers, but let's play it safe. */
4904 buffer_defaults.indirections = 0; 4914 buffer_defaults.indirections = 0;
4905 buffer_local_symbols.indirections = 0; 4915 buffer_local_symbols.indirections = 0;
4906 BUF_INTERVALS (&buffer_defaults) = 0; 4916 buffer_set_intervals (&buffer_defaults, NULL);
4907 BUF_INTERVALS (&buffer_local_symbols) = 0; 4917 buffer_set_intervals (&buffer_local_symbols, NULL);
4908 XSETPVECTYPESIZE (&buffer_defaults, PVEC_BUFFER, pvecsize); 4918 XSETPVECTYPESIZE (&buffer_defaults, PVEC_BUFFER, pvecsize);
4909 XSETBUFFER (Vbuffer_defaults, &buffer_defaults); 4919 XSETBUFFER (Vbuffer_defaults, &buffer_defaults);
4910 XSETPVECTYPESIZE (&buffer_local_symbols, PVEC_BUFFER, pvecsize); 4920 XSETPVECTYPESIZE (&buffer_local_symbols, PVEC_BUFFER, pvecsize);
@@ -4914,55 +4924,55 @@ init_buffer_once (void)
4914 /* Must do these before making the first buffer! */ 4924 /* Must do these before making the first buffer! */
4915 4925
4916 /* real setup is done in bindings.el */ 4926 /* real setup is done in bindings.el */
4917 BVAR (&buffer_defaults, mode_line_format) = build_pure_c_string ("%-"); 4927 BSET (&buffer_defaults, mode_line_format, build_pure_c_string ("%-"));
4918 BVAR (&buffer_defaults, header_line_format) = Qnil; 4928 BSET (&buffer_defaults, header_line_format, Qnil);
4919 BVAR (&buffer_defaults, abbrev_mode) = Qnil; 4929 BSET (&buffer_defaults, abbrev_mode, Qnil);
4920 BVAR (&buffer_defaults, overwrite_mode) = Qnil; 4930 BSET (&buffer_defaults, overwrite_mode, Qnil);
4921 BVAR (&buffer_defaults, case_fold_search) = Qt; 4931 BSET (&buffer_defaults, case_fold_search, Qt);
4922 BVAR (&buffer_defaults, auto_fill_function) = Qnil; 4932 BSET (&buffer_defaults, auto_fill_function, Qnil);
4923 BVAR (&buffer_defaults, selective_display) = Qnil; 4933 BSET (&buffer_defaults, selective_display, Qnil);
4924 BVAR (&buffer_defaults, selective_display_ellipses) = Qt; 4934 BSET (&buffer_defaults, selective_display_ellipses, Qt);
4925 BVAR (&buffer_defaults, abbrev_table) = Qnil; 4935 BSET (&buffer_defaults, abbrev_table, Qnil);
4926 BVAR (&buffer_defaults, display_table) = Qnil; 4936 BSET (&buffer_defaults, display_table, Qnil);
4927 BVAR (&buffer_defaults, undo_list) = Qnil; 4937 BSET (&buffer_defaults, undo_list, Qnil);
4928 BVAR (&buffer_defaults, mark_active) = Qnil; 4938 BSET (&buffer_defaults, mark_active, Qnil);
4929 BVAR (&buffer_defaults, file_format) = Qnil; 4939 BSET (&buffer_defaults, file_format, Qnil);
4930 BVAR (&buffer_defaults, auto_save_file_format) = Qt; 4940 BSET (&buffer_defaults, auto_save_file_format, Qt);
4931 buffer_defaults.overlays_before = NULL; 4941 buffer_set_overlays_before (&buffer_defaults, NULL);
4932 buffer_defaults.overlays_after = NULL; 4942 buffer_set_overlays_after (&buffer_defaults, NULL);
4933 buffer_defaults.overlay_center = BEG; 4943 buffer_defaults.overlay_center = BEG;
4934 4944
4935 XSETFASTINT (BVAR (&buffer_defaults, tab_width), 8); 4945 XSETFASTINT (BVAR (&buffer_defaults, tab_width), 8);
4936 BVAR (&buffer_defaults, truncate_lines) = Qnil; 4946 BSET (&buffer_defaults, truncate_lines, Qnil);
4937 BVAR (&buffer_defaults, word_wrap) = Qnil; 4947 BSET (&buffer_defaults, word_wrap, Qnil);
4938 BVAR (&buffer_defaults, ctl_arrow) = Qt; 4948 BSET (&buffer_defaults, ctl_arrow, Qt);
4939 BVAR (&buffer_defaults, bidi_display_reordering) = Qt; 4949 BSET (&buffer_defaults, bidi_display_reordering, Qt);
4940 BVAR (&buffer_defaults, bidi_paragraph_direction) = Qnil; 4950 BSET (&buffer_defaults, bidi_paragraph_direction, Qnil);
4941 BVAR (&buffer_defaults, cursor_type) = Qt; 4951 BSET (&buffer_defaults, cursor_type, Qt);
4942 BVAR (&buffer_defaults, extra_line_spacing) = Qnil; 4952 BSET (&buffer_defaults, extra_line_spacing, Qnil);
4943 BVAR (&buffer_defaults, cursor_in_non_selected_windows) = Qt; 4953 BSET (&buffer_defaults, cursor_in_non_selected_windows, Qt);
4944 4954
4945 BVAR (&buffer_defaults, enable_multibyte_characters) = Qt; 4955 BSET (&buffer_defaults, enable_multibyte_characters, Qt);
4946 BVAR (&buffer_defaults, buffer_file_coding_system) = Qnil; 4956 BSET (&buffer_defaults, buffer_file_coding_system, Qnil);
4947 XSETFASTINT (BVAR (&buffer_defaults, fill_column), 70); 4957 XSETFASTINT (BVAR (&buffer_defaults, fill_column), 70);
4948 XSETFASTINT (BVAR (&buffer_defaults, left_margin), 0); 4958 XSETFASTINT (BVAR (&buffer_defaults, left_margin), 0);
4949 BVAR (&buffer_defaults, cache_long_line_scans) = Qnil; 4959 BSET (&buffer_defaults, cache_long_line_scans, Qnil);
4950 BVAR (&buffer_defaults, file_truename) = Qnil; 4960 BSET (&buffer_defaults, file_truename, Qnil);
4951 XSETFASTINT (BVAR (&buffer_defaults, display_count), 0); 4961 XSETFASTINT (BVAR (&buffer_defaults, display_count), 0);
4952 XSETFASTINT (BVAR (&buffer_defaults, left_margin_cols), 0); 4962 XSETFASTINT (BVAR (&buffer_defaults, left_margin_cols), 0);
4953 XSETFASTINT (BVAR (&buffer_defaults, right_margin_cols), 0); 4963 XSETFASTINT (BVAR (&buffer_defaults, right_margin_cols), 0);
4954 BVAR (&buffer_defaults, left_fringe_width) = Qnil; 4964 BSET (&buffer_defaults, left_fringe_width, Qnil);
4955 BVAR (&buffer_defaults, right_fringe_width) = Qnil; 4965 BSET (&buffer_defaults, right_fringe_width, Qnil);
4956 BVAR (&buffer_defaults, fringes_outside_margins) = Qnil; 4966 BSET (&buffer_defaults, fringes_outside_margins, Qnil);
4957 BVAR (&buffer_defaults, scroll_bar_width) = Qnil; 4967 BSET (&buffer_defaults, scroll_bar_width, Qnil);
4958 BVAR (&buffer_defaults, vertical_scroll_bar_type) = Qt; 4968 BSET (&buffer_defaults, vertical_scroll_bar_type, Qt);
4959 BVAR (&buffer_defaults, indicate_empty_lines) = Qnil; 4969 BSET (&buffer_defaults, indicate_empty_lines, Qnil);
4960 BVAR (&buffer_defaults, indicate_buffer_boundaries) = Qnil; 4970 BSET (&buffer_defaults, indicate_buffer_boundaries, Qnil);
4961 BVAR (&buffer_defaults, fringe_indicator_alist) = Qnil; 4971 BSET (&buffer_defaults, fringe_indicator_alist, Qnil);
4962 BVAR (&buffer_defaults, fringe_cursor_alist) = Qnil; 4972 BSET (&buffer_defaults, fringe_cursor_alist, Qnil);
4963 BVAR (&buffer_defaults, scroll_up_aggressively) = Qnil; 4973 BSET (&buffer_defaults, scroll_up_aggressively, Qnil);
4964 BVAR (&buffer_defaults, scroll_down_aggressively) = Qnil; 4974 BSET (&buffer_defaults, scroll_down_aggressively, Qnil);
4965 BVAR (&buffer_defaults, display_time) = Qnil; 4975 BSET (&buffer_defaults, display_time, Qnil);
4966 4976
4967 /* Assign the local-flags to the slots that have default values. 4977 /* Assign the local-flags to the slots that have default values.
4968 The local flag is a bit that is used in the buffer 4978 The local flag is a bit that is used in the buffer
@@ -4970,28 +4980,28 @@ init_buffer_once (void)
4970 The local flag bits are in the local_var_flags slot of the buffer. */ 4980 The local flag bits are in the local_var_flags slot of the buffer. */
4971 4981
4972 /* Nothing can work if this isn't true */ 4982 /* Nothing can work if this isn't true */
4973 { verify (sizeof (EMACS_INT) == sizeof (Lisp_Object)); } 4983 { verify (sizeof (EMACS_INT) == word_size); }
4974 4984
4975 /* 0 means not a lisp var, -1 means always local, else mask */ 4985 /* 0 means not a lisp var, -1 means always local, else mask */
4976 memset (&buffer_local_flags, 0, sizeof buffer_local_flags); 4986 memset (&buffer_local_flags, 0, sizeof buffer_local_flags);
4977 XSETINT (BVAR (&buffer_local_flags, filename), -1); 4987 BSET (&buffer_local_flags, filename, make_number (-1));
4978 XSETINT (BVAR (&buffer_local_flags, directory), -1); 4988 BSET (&buffer_local_flags, directory, make_number (-1));
4979 XSETINT (BVAR (&buffer_local_flags, backed_up), -1); 4989 BSET (&buffer_local_flags, backed_up, make_number (-1));
4980 XSETINT (BVAR (&buffer_local_flags, save_length), -1); 4990 BSET (&buffer_local_flags, save_length, make_number (-1));
4981 XSETINT (BVAR (&buffer_local_flags, auto_save_file_name), -1); 4991 BSET (&buffer_local_flags, auto_save_file_name, make_number (-1));
4982 XSETINT (BVAR (&buffer_local_flags, read_only), -1); 4992 BSET (&buffer_local_flags, read_only, make_number (-1));
4983 XSETINT (BVAR (&buffer_local_flags, major_mode), -1); 4993 BSET (&buffer_local_flags, major_mode, make_number (-1));
4984 XSETINT (BVAR (&buffer_local_flags, mode_name), -1); 4994 BSET (&buffer_local_flags, mode_name, make_number (-1));
4985 XSETINT (BVAR (&buffer_local_flags, undo_list), -1); 4995 BSET (&buffer_local_flags, undo_list, make_number (-1));
4986 XSETINT (BVAR (&buffer_local_flags, mark_active), -1); 4996 BSET (&buffer_local_flags, mark_active, make_number (-1));
4987 XSETINT (BVAR (&buffer_local_flags, point_before_scroll), -1); 4997 BSET (&buffer_local_flags, point_before_scroll, make_number (-1));
4988 XSETINT (BVAR (&buffer_local_flags, file_truename), -1); 4998 BSET (&buffer_local_flags, file_truename, make_number (-1));
4989 XSETINT (BVAR (&buffer_local_flags, invisibility_spec), -1); 4999 BSET (&buffer_local_flags, invisibility_spec, make_number (-1));
4990 XSETINT (BVAR (&buffer_local_flags, file_format), -1); 5000 BSET (&buffer_local_flags, file_format, make_number (-1));
4991 XSETINT (BVAR (&buffer_local_flags, auto_save_file_format), -1); 5001 BSET (&buffer_local_flags, auto_save_file_format, make_number (-1));
4992 XSETINT (BVAR (&buffer_local_flags, display_count), -1); 5002 BSET (&buffer_local_flags, display_count, make_number (-1));
4993 XSETINT (BVAR (&buffer_local_flags, display_time), -1); 5003 BSET (&buffer_local_flags, display_time, make_number (-1));
4994 XSETINT (BVAR (&buffer_local_flags, enable_multibyte_characters), -1); 5004 BSET (&buffer_local_flags, enable_multibyte_characters, make_number (-1));
4995 5005
4996 idx = 1; 5006 idx = 1;
4997 XSETFASTINT (BVAR (&buffer_local_flags, mode_line_format), idx); ++idx; 5007 XSETFASTINT (BVAR (&buffer_local_flags, mode_line_format), idx); ++idx;
@@ -5047,7 +5057,7 @@ init_buffer_once (void)
5047 QSFundamental = build_pure_c_string ("Fundamental"); 5057 QSFundamental = build_pure_c_string ("Fundamental");
5048 5058
5049 Qfundamental_mode = intern_c_string ("fundamental-mode"); 5059 Qfundamental_mode = intern_c_string ("fundamental-mode");
5050 BVAR (&buffer_defaults, major_mode) = Qfundamental_mode; 5060 BSET (&buffer_defaults, major_mode, Qfundamental_mode);
5051 5061
5052 Qmode_class = intern_c_string ("mode-class"); 5062 Qmode_class = intern_c_string ("mode-class");
5053 5063
@@ -5110,13 +5120,13 @@ init_buffer (void)
5110 len++; 5120 len++;
5111 } 5121 }
5112 5122
5113 BVAR (current_buffer, directory) = make_unibyte_string (pwd, len); 5123 BSET (current_buffer, directory, make_unibyte_string (pwd, len));
5114 if (! NILP (BVAR (&buffer_defaults, enable_multibyte_characters))) 5124 if (! NILP (BVAR (&buffer_defaults, enable_multibyte_characters)))
5115 /* At this moment, we still don't know how to decode the 5125 /* At this moment, we still don't know how to decode the
5116 directory name. So, we keep the bytes in multibyte form so 5126 directory name. So, we keep the bytes in multibyte form so
5117 that ENCODE_FILE correctly gets the original bytes. */ 5127 that ENCODE_FILE correctly gets the original bytes. */
5118 BVAR (current_buffer, directory) 5128 BSET (current_buffer, directory,
5119 = string_to_multibyte (BVAR (current_buffer, directory)); 5129 string_to_multibyte (BVAR (current_buffer, directory)));
5120 5130
5121 /* Add /: to the front of the name 5131 /* Add /: to the front of the name
5122 if it would otherwise be treated as magic. */ 5132 if it would otherwise be treated as magic. */
@@ -5127,11 +5137,11 @@ init_buffer (void)
5127 However, it is not necessary to turn / into /:/. 5137 However, it is not necessary to turn / into /:/.
5128 So avoid doing that. */ 5138 So avoid doing that. */
5129 && strcmp ("/", SSDATA (BVAR (current_buffer, directory)))) 5139 && strcmp ("/", SSDATA (BVAR (current_buffer, directory))))
5130 BVAR (current_buffer, directory) 5140 BSET (current_buffer, directory,
5131 = concat2 (build_string ("/:"), BVAR (current_buffer, directory)); 5141 concat2 (build_string ("/:"), BVAR (current_buffer, directory)));
5132 5142
5133 temp = get_minibuffer (0); 5143 temp = get_minibuffer (0);
5134 BVAR (XBUFFER (temp), directory) = BVAR (current_buffer, directory); 5144 BSET (XBUFFER (temp), directory, BVAR (current_buffer, directory));
5135 5145
5136 free (pwd); 5146 free (pwd);
5137} 5147}