aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/buffer.h')
-rw-r--r--src/buffer.h250
1 files changed, 152 insertions, 98 deletions
diff --git a/src/buffer.h b/src/buffer.h
index 0615f85bfe6..7a6bddee5ec 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -21,6 +21,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21#include <sys/types.h> /* for off_t, time_t */ 21#include <sys/types.h> /* for off_t, time_t */
22#include "systime.h" /* for EMACS_TIME */ 22#include "systime.h" /* for EMACS_TIME */
23 23
24INLINE_HEADER_BEGIN
25#ifndef BUFFER_INLINE
26# define BUFFER_INLINE INLINE
27#endif
28
24/* Accessing the parameters of the current buffer. */ 29/* Accessing the parameters of the current buffer. */
25 30
26/* These macros come in pairs, one for the char position 31/* These macros come in pairs, one for the char position
@@ -188,9 +193,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
188/* FIXME: should we move this into ->text->auto_save_modiff? */ 193/* FIXME: should we move this into ->text->auto_save_modiff? */
189#define BUF_AUTOSAVE_MODIFF(buf) ((buf)->auto_save_modified) 194#define BUF_AUTOSAVE_MODIFF(buf) ((buf)->auto_save_modified)
190 195
191/* Interval tree of buffer. */
192#define BUF_INTERVALS(buf) ((buf)->text->intervals)
193
194/* Marker chain of buffer. */ 196/* Marker chain of buffer. */
195#define BUF_MARKERS(buf) ((buf)->text->markers) 197#define BUF_MARKERS(buf) ((buf)->text->markers)
196 198
@@ -436,6 +438,9 @@ struct buffer_text
436 438
437 EMACS_INT overlay_modiff; /* Counts modifications to overlays. */ 439 EMACS_INT overlay_modiff; /* Counts modifications to overlays. */
438 440
441 EMACS_INT compact; /* Set to modiff each time when compact_buffer
442 is called for this buffer. */
443
439 /* Minimum value of GPT - BEG since last redisplay that finished. */ 444 /* Minimum value of GPT - BEG since last redisplay that finished. */
440 ptrdiff_t beg_unchanged; 445 ptrdiff_t beg_unchanged;
441 446
@@ -469,14 +474,10 @@ struct buffer_text
469 int inhibit_shrinking; 474 int inhibit_shrinking;
470 }; 475 };
471 476
472/* Lisp fields in struct buffer are hidden from most code and accessed 477/* Most code should use this macro to access Lisp fields in struct buffer. */
473 via the BVAR macro, below. Only select pieces of code, like the GC,
474 are allowed to use BUFFER_INTERNAL_FIELD. */
475#define BUFFER_INTERNAL_FIELD(field) field ## _
476 478
477/* Most code should use this macro to access Lisp fields in struct 479#define BVAR(buf, field) ((buf)->INTERNAL_FIELD (field))
478 buffer. */ 480#define BSET(buf, field, value) ((buf)->INTERNAL_FIELD (field) = (value))
479#define BVAR(buf, field) ((buf)->BUFFER_INTERNAL_FIELD (field))
480 481
481/* This is the structure that the buffer Lisp object points to. */ 482/* This is the structure that the buffer Lisp object points to. */
482 483
@@ -490,17 +491,17 @@ struct buffer
490 struct vectorlike_header header; 491 struct vectorlike_header header;
491 492
492 /* The name of this buffer. */ 493 /* The name of this buffer. */
493 Lisp_Object BUFFER_INTERNAL_FIELD (name); 494 Lisp_Object INTERNAL_FIELD (name);
494 495
495 /* The name of the file visited in this buffer, or nil. */ 496 /* The name of the file visited in this buffer, or nil. */
496 Lisp_Object BUFFER_INTERNAL_FIELD (filename); 497 Lisp_Object INTERNAL_FIELD (filename);
497 498
498 /* Directory for expanding relative file names. */ 499 /* Directory for expanding relative file names. */
499 Lisp_Object BUFFER_INTERNAL_FIELD (directory); 500 Lisp_Object INTERNAL_FIELD (directory);
500 501
501 /* True if this buffer has been backed up (if you write to the visited 502 /* True if this buffer has been backed up (if you write to the visited
502 file and it hasn't been backed up, then a backup will be made). */ 503 file and it hasn't been backed up, then a backup will be made). */
503 Lisp_Object BUFFER_INTERNAL_FIELD (backed_up); 504 Lisp_Object INTERNAL_FIELD (backed_up);
504 505
505 /* Length of file when last read or saved. 506 /* Length of file when last read or saved.
506 -1 means auto saving turned off because buffer shrank a lot. 507 -1 means auto saving turned off because buffer shrank a lot.
@@ -508,132 +509,132 @@ struct buffer
508 (That value is used with buffer-swap-text.) 509 (That value is used with buffer-swap-text.)
509 This is not in the struct buffer_text 510 This is not in the struct buffer_text
510 because it's not used in indirect buffers at all. */ 511 because it's not used in indirect buffers at all. */
511 Lisp_Object BUFFER_INTERNAL_FIELD (save_length); 512 Lisp_Object INTERNAL_FIELD (save_length);
512 513
513 /* File name used for auto-saving this buffer. 514 /* File name used for auto-saving this buffer.
514 This is not in the struct buffer_text 515 This is not in the struct buffer_text
515 because it's not used in indirect buffers at all. */ 516 because it's not used in indirect buffers at all. */
516 Lisp_Object BUFFER_INTERNAL_FIELD (auto_save_file_name); 517 Lisp_Object INTERNAL_FIELD (auto_save_file_name);
517 518
518 /* Non-nil if buffer read-only. */ 519 /* Non-nil if buffer read-only. */
519 Lisp_Object BUFFER_INTERNAL_FIELD (read_only); 520 Lisp_Object INTERNAL_FIELD (read_only);
520 521
521 /* "The mark". This is a marker which may 522 /* "The mark". This is a marker which may
522 point into this buffer or may point nowhere. */ 523 point into this buffer or may point nowhere. */
523 Lisp_Object BUFFER_INTERNAL_FIELD (mark); 524 Lisp_Object INTERNAL_FIELD (mark);
524 525
525 /* Alist of elements (SYMBOL . VALUE-IN-THIS-BUFFER) for all 526 /* Alist of elements (SYMBOL . VALUE-IN-THIS-BUFFER) for all
526 per-buffer variables of this buffer. For locally unbound 527 per-buffer variables of this buffer. For locally unbound
527 symbols, just the symbol appears as the element. */ 528 symbols, just the symbol appears as the element. */
528 Lisp_Object BUFFER_INTERNAL_FIELD (local_var_alist); 529 Lisp_Object INTERNAL_FIELD (local_var_alist);
529 530
530 /* Symbol naming major mode (e.g., lisp-mode). */ 531 /* Symbol naming major mode (e.g., lisp-mode). */
531 Lisp_Object BUFFER_INTERNAL_FIELD (major_mode); 532 Lisp_Object INTERNAL_FIELD (major_mode);
532 533
533 /* Pretty name of major mode (e.g., "Lisp"). */ 534 /* Pretty name of major mode (e.g., "Lisp"). */
534 Lisp_Object BUFFER_INTERNAL_FIELD (mode_name); 535 Lisp_Object INTERNAL_FIELD (mode_name);
535 536
536 /* Mode line element that controls format of mode line. */ 537 /* Mode line element that controls format of mode line. */
537 Lisp_Object BUFFER_INTERNAL_FIELD (mode_line_format); 538 Lisp_Object INTERNAL_FIELD (mode_line_format);
538 539
539 /* Analogous to mode_line_format for the line displayed at the top 540 /* Analogous to mode_line_format for the line displayed at the top
540 of windows. Nil means don't display that line. */ 541 of windows. Nil means don't display that line. */
541 Lisp_Object BUFFER_INTERNAL_FIELD (header_line_format); 542 Lisp_Object INTERNAL_FIELD (header_line_format);
542 543
543 /* Keys that are bound local to this buffer. */ 544 /* Keys that are bound local to this buffer. */
544 Lisp_Object BUFFER_INTERNAL_FIELD (keymap); 545 Lisp_Object INTERNAL_FIELD (keymap);
545 546
546 /* This buffer's local abbrev table. */ 547 /* This buffer's local abbrev table. */
547 Lisp_Object BUFFER_INTERNAL_FIELD (abbrev_table); 548 Lisp_Object INTERNAL_FIELD (abbrev_table);
548 549
549 /* This buffer's syntax table. */ 550 /* This buffer's syntax table. */
550 Lisp_Object BUFFER_INTERNAL_FIELD (syntax_table); 551 Lisp_Object INTERNAL_FIELD (syntax_table);
551 552
552 /* This buffer's category table. */ 553 /* This buffer's category table. */
553 Lisp_Object BUFFER_INTERNAL_FIELD (category_table); 554 Lisp_Object INTERNAL_FIELD (category_table);
554 555
555 /* Values of several buffer-local variables. */ 556 /* Values of several buffer-local variables. */
556 /* tab-width is buffer-local so that redisplay can find it 557 /* tab-width is buffer-local so that redisplay can find it
557 in buffers that are not current. */ 558 in buffers that are not current. */
558 Lisp_Object BUFFER_INTERNAL_FIELD (case_fold_search); 559 Lisp_Object INTERNAL_FIELD (case_fold_search);
559 Lisp_Object BUFFER_INTERNAL_FIELD (tab_width); 560 Lisp_Object INTERNAL_FIELD (tab_width);
560 Lisp_Object BUFFER_INTERNAL_FIELD (fill_column); 561 Lisp_Object INTERNAL_FIELD (fill_column);
561 Lisp_Object BUFFER_INTERNAL_FIELD (left_margin); 562 Lisp_Object INTERNAL_FIELD (left_margin);
562 563
563 /* Function to call when insert space past fill column. */ 564 /* Function to call when insert space past fill column. */
564 Lisp_Object BUFFER_INTERNAL_FIELD (auto_fill_function); 565 Lisp_Object INTERNAL_FIELD (auto_fill_function);
565 566
566 /* Case table for case-conversion in this buffer. 567 /* Case table for case-conversion in this buffer.
567 This char-table maps each char into its lower-case version. */ 568 This char-table maps each char into its lower-case version. */
568 Lisp_Object BUFFER_INTERNAL_FIELD (downcase_table); 569 Lisp_Object INTERNAL_FIELD (downcase_table);
569 570
570 /* Char-table mapping each char to its upper-case version. */ 571 /* Char-table mapping each char to its upper-case version. */
571 Lisp_Object BUFFER_INTERNAL_FIELD (upcase_table); 572 Lisp_Object INTERNAL_FIELD (upcase_table);
572 573
573 /* Char-table for conversion for case-folding search. */ 574 /* Char-table for conversion for case-folding search. */
574 Lisp_Object BUFFER_INTERNAL_FIELD (case_canon_table); 575 Lisp_Object INTERNAL_FIELD (case_canon_table);
575 576
576 /* Char-table of equivalences for case-folding search. */ 577 /* Char-table of equivalences for case-folding search. */
577 Lisp_Object BUFFER_INTERNAL_FIELD (case_eqv_table); 578 Lisp_Object INTERNAL_FIELD (case_eqv_table);
578 579
579 /* Non-nil means do not display continuation lines. */ 580 /* Non-nil means do not display continuation lines. */
580 Lisp_Object BUFFER_INTERNAL_FIELD (truncate_lines); 581 Lisp_Object INTERNAL_FIELD (truncate_lines);
581 582
582 /* Non-nil means to use word wrapping when displaying continuation lines. */ 583 /* Non-nil means to use word wrapping when displaying continuation lines. */
583 Lisp_Object BUFFER_INTERNAL_FIELD (word_wrap); 584 Lisp_Object INTERNAL_FIELD (word_wrap);
584 585
585 /* Non-nil means display ctl chars with uparrow. */ 586 /* Non-nil means display ctl chars with uparrow. */
586 Lisp_Object BUFFER_INTERNAL_FIELD (ctl_arrow); 587 Lisp_Object INTERNAL_FIELD (ctl_arrow);
587 588
588 /* Non-nil means reorder bidirectional text for display in the 589 /* Non-nil means reorder bidirectional text for display in the
589 visual order. */ 590 visual order. */
590 Lisp_Object BUFFER_INTERNAL_FIELD (bidi_display_reordering); 591 Lisp_Object INTERNAL_FIELD (bidi_display_reordering);
591 592
592 /* If non-nil, specifies which direction of text to force in all the 593 /* If non-nil, specifies which direction of text to force in all the
593 paragraphs of the buffer. Nil means determine paragraph 594 paragraphs of the buffer. Nil means determine paragraph
594 direction dynamically for each paragraph. */ 595 direction dynamically for each paragraph. */
595 Lisp_Object BUFFER_INTERNAL_FIELD (bidi_paragraph_direction); 596 Lisp_Object INTERNAL_FIELD (bidi_paragraph_direction);
596 597
597 /* Non-nil means do selective display; 598 /* Non-nil means do selective display;
598 see doc string in syms_of_buffer (buffer.c) for details. */ 599 see doc string in syms_of_buffer (buffer.c) for details. */
599 Lisp_Object BUFFER_INTERNAL_FIELD (selective_display); 600 Lisp_Object INTERNAL_FIELD (selective_display);
600 601
601 /* Non-nil means show ... at end of line followed by invisible lines. */ 602 /* Non-nil means show ... at end of line followed by invisible lines. */
602 Lisp_Object BUFFER_INTERNAL_FIELD (selective_display_ellipses); 603 Lisp_Object INTERNAL_FIELD (selective_display_ellipses);
603 604
604 /* Alist of (FUNCTION . STRING) for each minor mode enabled in buffer. */ 605 /* Alist of (FUNCTION . STRING) for each minor mode enabled in buffer. */
605 Lisp_Object BUFFER_INTERNAL_FIELD (minor_modes); 606 Lisp_Object INTERNAL_FIELD (minor_modes);
606 607
607 /* t if "self-insertion" should overwrite; `binary' if it should also 608 /* t if "self-insertion" should overwrite; `binary' if it should also
608 overwrite newlines and tabs - for editing executables and the like. */ 609 overwrite newlines and tabs - for editing executables and the like. */
609 Lisp_Object BUFFER_INTERNAL_FIELD (overwrite_mode); 610 Lisp_Object INTERNAL_FIELD (overwrite_mode);
610 611
611 /* Non-nil means abbrev mode is on. Expand abbrevs automatically. */ 612 /* Non-nil means abbrev mode is on. Expand abbrevs automatically. */
612 Lisp_Object BUFFER_INTERNAL_FIELD (abbrev_mode); 613 Lisp_Object INTERNAL_FIELD (abbrev_mode);
613 614
614 /* Display table to use for text in this buffer. */ 615 /* Display table to use for text in this buffer. */
615 Lisp_Object BUFFER_INTERNAL_FIELD (display_table); 616 Lisp_Object INTERNAL_FIELD (display_table);
616 617
617 /* t means the mark and region are currently active. */ 618 /* t means the mark and region are currently active. */
618 Lisp_Object BUFFER_INTERNAL_FIELD (mark_active); 619 Lisp_Object INTERNAL_FIELD (mark_active);
619 620
620 /* Non-nil means the buffer contents are regarded as multi-byte 621 /* Non-nil means the buffer contents are regarded as multi-byte
621 form of characters, not a binary code. */ 622 form of characters, not a binary code. */
622 Lisp_Object BUFFER_INTERNAL_FIELD (enable_multibyte_characters); 623 Lisp_Object INTERNAL_FIELD (enable_multibyte_characters);
623 624
624 /* Coding system to be used for encoding the buffer contents on 625 /* Coding system to be used for encoding the buffer contents on
625 saving. */ 626 saving. */
626 Lisp_Object BUFFER_INTERNAL_FIELD (buffer_file_coding_system); 627 Lisp_Object INTERNAL_FIELD (buffer_file_coding_system);
627 628
628 /* List of symbols naming the file format used for visited file. */ 629 /* List of symbols naming the file format used for visited file. */
629 Lisp_Object BUFFER_INTERNAL_FIELD (file_format); 630 Lisp_Object INTERNAL_FIELD (file_format);
630 631
631 /* List of symbols naming the file format used for auto-save file. */ 632 /* List of symbols naming the file format used for auto-save file. */
632 Lisp_Object BUFFER_INTERNAL_FIELD (auto_save_file_format); 633 Lisp_Object INTERNAL_FIELD (auto_save_file_format);
633 634
634 /* True if the newline position cache and width run cache are 635 /* True if the newline position cache and width run cache are
635 enabled. See search.c and indent.c. */ 636 enabled. See search.c and indent.c. */
636 Lisp_Object BUFFER_INTERNAL_FIELD (cache_long_line_scans); 637 Lisp_Object INTERNAL_FIELD (cache_long_line_scans);
637 638
638 /* If the width run cache is enabled, this table contains the 639 /* If the width run cache is enabled, this table contains the
639 character widths width_run_cache (see above) assumes. When we 640 character widths width_run_cache (see above) assumes. When we
@@ -641,102 +642,102 @@ struct buffer
641 current display table to see whether the display table has 642 current display table to see whether the display table has
642 affected the widths of any characters. If it has, we 643 affected the widths of any characters. If it has, we
643 invalidate the width run cache, and re-initialize width_table. */ 644 invalidate the width run cache, and re-initialize width_table. */
644 Lisp_Object BUFFER_INTERNAL_FIELD (width_table); 645 Lisp_Object INTERNAL_FIELD (width_table);
645 646
646 /* In an indirect buffer, or a buffer that is the base of an 647 /* In an indirect buffer, or a buffer that is the base of an
647 indirect buffer, this holds a marker that records 648 indirect buffer, this holds a marker that records
648 PT for this buffer when the buffer is not current. */ 649 PT for this buffer when the buffer is not current. */
649 Lisp_Object BUFFER_INTERNAL_FIELD (pt_marker); 650 Lisp_Object INTERNAL_FIELD (pt_marker);
650 651
651 /* In an indirect buffer, or a buffer that is the base of an 652 /* In an indirect buffer, or a buffer that is the base of an
652 indirect buffer, this holds a marker that records 653 indirect buffer, this holds a marker that records
653 BEGV for this buffer when the buffer is not current. */ 654 BEGV for this buffer when the buffer is not current. */
654 Lisp_Object BUFFER_INTERNAL_FIELD (begv_marker); 655 Lisp_Object INTERNAL_FIELD (begv_marker);
655 656
656 /* In an indirect buffer, or a buffer that is the base of an 657 /* In an indirect buffer, or a buffer that is the base of an
657 indirect buffer, this holds a marker that records 658 indirect buffer, this holds a marker that records
658 ZV for this buffer when the buffer is not current. */ 659 ZV for this buffer when the buffer is not current. */
659 Lisp_Object BUFFER_INTERNAL_FIELD (zv_marker); 660 Lisp_Object INTERNAL_FIELD (zv_marker);
660 661
661 /* This holds the point value before the last scroll operation. 662 /* This holds the point value before the last scroll operation.
662 Explicitly setting point sets this to nil. */ 663 Explicitly setting point sets this to nil. */
663 Lisp_Object BUFFER_INTERNAL_FIELD (point_before_scroll); 664 Lisp_Object INTERNAL_FIELD (point_before_scroll);
664 665
665 /* Truename of the visited file, or nil. */ 666 /* Truename of the visited file, or nil. */
666 Lisp_Object BUFFER_INTERNAL_FIELD (file_truename); 667 Lisp_Object INTERNAL_FIELD (file_truename);
667 668
668 /* Invisibility spec of this buffer. 669 /* Invisibility spec of this buffer.
669 t => any non-nil `invisible' property means invisible. 670 t => any non-nil `invisible' property means invisible.
670 A list => `invisible' property means invisible 671 A list => `invisible' property means invisible
671 if it is memq in that list. */ 672 if it is memq in that list. */
672 Lisp_Object BUFFER_INTERNAL_FIELD (invisibility_spec); 673 Lisp_Object INTERNAL_FIELD (invisibility_spec);
673 674
674 /* This is the last window that was selected with this buffer in it, 675 /* This is the last window that was selected with this buffer in it,
675 or nil if that window no longer displays this buffer. */ 676 or nil if that window no longer displays this buffer. */
676 Lisp_Object BUFFER_INTERNAL_FIELD (last_selected_window); 677 Lisp_Object INTERNAL_FIELD (last_selected_window);
677 678
678 /* Incremented each time the buffer is displayed in a window. */ 679 /* Incremented each time the buffer is displayed in a window. */
679 Lisp_Object BUFFER_INTERNAL_FIELD (display_count); 680 Lisp_Object INTERNAL_FIELD (display_count);
680 681
681 /* Widths of left and right marginal areas for windows displaying 682 /* Widths of left and right marginal areas for windows displaying
682 this buffer. */ 683 this buffer. */
683 Lisp_Object BUFFER_INTERNAL_FIELD (left_margin_cols); 684 Lisp_Object INTERNAL_FIELD (left_margin_cols);
684 Lisp_Object BUFFER_INTERNAL_FIELD (right_margin_cols); 685 Lisp_Object INTERNAL_FIELD (right_margin_cols);
685 686
686 /* Widths of left and right fringe areas for windows displaying 687 /* Widths of left and right fringe areas for windows displaying
687 this buffer. */ 688 this buffer. */
688 Lisp_Object BUFFER_INTERNAL_FIELD (left_fringe_width); 689 Lisp_Object INTERNAL_FIELD (left_fringe_width);
689 Lisp_Object BUFFER_INTERNAL_FIELD (right_fringe_width); 690 Lisp_Object INTERNAL_FIELD (right_fringe_width);
690 691
691 /* Non-nil means fringes are drawn outside display margins; 692 /* Non-nil means fringes are drawn outside display margins;
692 othersize draw them between margin areas and text. */ 693 othersize draw them between margin areas and text. */
693 Lisp_Object BUFFER_INTERNAL_FIELD (fringes_outside_margins); 694 Lisp_Object INTERNAL_FIELD (fringes_outside_margins);
694 695
695 /* Width and type of scroll bar areas for windows displaying 696 /* Width and type of scroll bar areas for windows displaying
696 this buffer. */ 697 this buffer. */
697 Lisp_Object BUFFER_INTERNAL_FIELD (scroll_bar_width); 698 Lisp_Object INTERNAL_FIELD (scroll_bar_width);
698 Lisp_Object BUFFER_INTERNAL_FIELD (vertical_scroll_bar_type); 699 Lisp_Object INTERNAL_FIELD (vertical_scroll_bar_type);
699 700
700 /* Non-nil means indicate lines not displaying text (in a style 701 /* Non-nil means indicate lines not displaying text (in a style
701 like vi). */ 702 like vi). */
702 Lisp_Object BUFFER_INTERNAL_FIELD (indicate_empty_lines); 703 Lisp_Object INTERNAL_FIELD (indicate_empty_lines);
703 704
704 /* Non-nil means indicate buffer boundaries and scrolling. */ 705 /* Non-nil means indicate buffer boundaries and scrolling. */
705 Lisp_Object BUFFER_INTERNAL_FIELD (indicate_buffer_boundaries); 706 Lisp_Object INTERNAL_FIELD (indicate_buffer_boundaries);
706 707
707 /* Logical to physical fringe bitmap mappings. */ 708 /* Logical to physical fringe bitmap mappings. */
708 Lisp_Object BUFFER_INTERNAL_FIELD (fringe_indicator_alist); 709 Lisp_Object INTERNAL_FIELD (fringe_indicator_alist);
709 710
710 /* Logical to physical cursor bitmap mappings. */ 711 /* Logical to physical cursor bitmap mappings. */
711 Lisp_Object BUFFER_INTERNAL_FIELD (fringe_cursor_alist); 712 Lisp_Object INTERNAL_FIELD (fringe_cursor_alist);
712 713
713 /* Time stamp updated each time this buffer is displayed in a window. */ 714 /* Time stamp updated each time this buffer is displayed in a window. */
714 Lisp_Object BUFFER_INTERNAL_FIELD (display_time); 715 Lisp_Object INTERNAL_FIELD (display_time);
715 716
716 /* If scrolling the display because point is below the bottom of a 717 /* If scrolling the display because point is below the bottom of a
717 window showing this buffer, try to choose a window start so 718 window showing this buffer, try to choose a window start so
718 that point ends up this number of lines from the top of the 719 that point ends up this number of lines from the top of the
719 window. Nil means that scrolling method isn't used. */ 720 window. Nil means that scrolling method isn't used. */
720 Lisp_Object BUFFER_INTERNAL_FIELD (scroll_up_aggressively); 721 Lisp_Object INTERNAL_FIELD (scroll_up_aggressively);
721 722
722 /* If scrolling the display because point is above the top of a 723 /* If scrolling the display because point is above the top of a
723 window showing this buffer, try to choose a window start so 724 window showing this buffer, try to choose a window start so
724 that point ends up this number of lines from the bottom of the 725 that point ends up this number of lines from the bottom of the
725 window. Nil means that scrolling method isn't used. */ 726 window. Nil means that scrolling method isn't used. */
726 Lisp_Object BUFFER_INTERNAL_FIELD (scroll_down_aggressively); 727 Lisp_Object INTERNAL_FIELD (scroll_down_aggressively);
727 728
728 /* Desired cursor type in this buffer. See the doc string of 729 /* Desired cursor type in this buffer. See the doc string of
729 per-buffer variable `cursor-type'. */ 730 per-buffer variable `cursor-type'. */
730 Lisp_Object BUFFER_INTERNAL_FIELD (cursor_type); 731 Lisp_Object INTERNAL_FIELD (cursor_type);
731 732
732 /* An integer > 0 means put that number of pixels below text lines 733 /* An integer > 0 means put that number of pixels below text lines
733 in the display of this buffer. */ 734 in the display of this buffer. */
734 Lisp_Object BUFFER_INTERNAL_FIELD (extra_line_spacing); 735 Lisp_Object INTERNAL_FIELD (extra_line_spacing);
735 736
736 /* Cursor type to display in non-selected windows. 737 /* Cursor type to display in non-selected windows.
737 t means to use hollow box cursor. 738 t means to use hollow box cursor.
738 See `cursor-type' for other values. */ 739 See `cursor-type' for other values. */
739 Lisp_Object BUFFER_INTERNAL_FIELD (cursor_in_non_selected_windows); 740 Lisp_Object INTERNAL_FIELD (cursor_in_non_selected_windows);
740 741
741 /* No more Lisp_Object beyond this point. Except undo_list, 742 /* No more Lisp_Object beyond this point. Except undo_list,
742 which is handled specially in Fgarbage_collect . */ 743 which is handled specially in Fgarbage_collect . */
@@ -772,6 +773,11 @@ struct buffer
772 In an ordinary buffer, it is 0. */ 773 In an ordinary buffer, it is 0. */
773 struct buffer *base_buffer; 774 struct buffer *base_buffer;
774 775
776 /* In an indirect buffer, this is -1. In an ordinary buffer,
777 it's the number of indirect buffers that share our text;
778 zero means that we're the only owner of this text. */
779 int indirections;
780
775 /* A non-zero value in slot IDX means that per-buffer variable 781 /* A non-zero value in slot IDX means that per-buffer variable
776 with index IDX has a local value in this buffer. The index IDX 782 with index IDX has a local value in this buffer. The index IDX
777 for a buffer-local variable is stored in that variable's slot 783 for a buffer-local variable is stored in that variable's slot
@@ -853,10 +859,19 @@ struct buffer
853 buffer of an indirect buffer. But we can't store it in the 859 buffer of an indirect buffer. But we can't store it in the
854 struct buffer_text because local variables have to be right in 860 struct buffer_text because local variables have to be right in
855 the struct buffer. So we copy it around in set_buffer_internal. */ 861 the struct buffer. So we copy it around in set_buffer_internal. */
856 Lisp_Object BUFFER_INTERNAL_FIELD (undo_list); 862 Lisp_Object INTERNAL_FIELD (undo_list);
857}; 863};
858 864
859 865
866/* Chain of all buffers, including killed ones. */
867
868extern struct buffer *all_buffers;
869
870/* Used to iterate over the chain above. */
871
872#define FOR_EACH_BUFFER(b) \
873 for ((b) = all_buffers; (b); (b) = (b)->header.next.buffer)
874
860/* This points to the current buffer. */ 875/* This points to the current buffer. */
861 876
862extern struct buffer *current_buffer; 877extern struct buffer *current_buffer;
@@ -894,6 +909,7 @@ extern struct buffer buffer_local_symbols;
894 909
895extern void delete_all_overlays (struct buffer *); 910extern void delete_all_overlays (struct buffer *);
896extern void reset_buffer (struct buffer *); 911extern void reset_buffer (struct buffer *);
912extern int compact_buffer (struct buffer *);
897extern void evaporate_overlays (ptrdiff_t); 913extern void evaporate_overlays (ptrdiff_t);
898extern ptrdiff_t overlays_at (EMACS_INT pos, int extend, Lisp_Object **vec_ptr, 914extern ptrdiff_t overlays_at (EMACS_INT pos, int extend, Lisp_Object **vec_ptr,
899 ptrdiff_t *len_ptr, ptrdiff_t *next_ptr, 915 ptrdiff_t *len_ptr, ptrdiff_t *next_ptr,
@@ -933,7 +949,47 @@ extern void mmap_set_vars (int);
933extern Lisp_Object Qbefore_change_functions; 949extern Lisp_Object Qbefore_change_functions;
934extern Lisp_Object Qafter_change_functions; 950extern Lisp_Object Qafter_change_functions;
935extern Lisp_Object Qfirst_change_hook; 951extern Lisp_Object Qfirst_change_hook;
936 952
953/* Get text properties of B. */
954
955BUFFER_INLINE INTERVAL
956buffer_get_intervals (struct buffer *b)
957{
958 eassert (b->text != NULL);
959 return b->text->intervals;
960}
961
962/* Set text properties of B to I. */
963
964BUFFER_INLINE void
965buffer_set_intervals (struct buffer *b, INTERVAL i)
966{
967 eassert (b->text != NULL);
968 b->text->intervals = i;
969}
970
971/* Set an appropriate overlay of B. */
972
973BUFFER_INLINE void
974buffer_set_overlays_before (struct buffer *b, struct Lisp_Overlay *o)
975{
976 b->overlays_before = o;
977}
978
979BUFFER_INLINE void
980buffer_set_overlays_after (struct buffer *b, struct Lisp_Overlay *o)
981{
982 b->overlays_after = o;
983}
984
985/* Non-zero if current buffer has overlays. */
986
987BUFFER_INLINE int
988buffer_has_overlays (void)
989{
990 return current_buffer->overlays_before || current_buffer->overlays_after;
991}
992
937/* Return character code of multi-byte form at byte position POS. If POS 993/* Return character code of multi-byte form at byte position POS. If POS
938 doesn't point the head of valid multi-byte form, only the byte at 994 doesn't point the head of valid multi-byte form, only the byte at
939 POS is returned. No range checking. 995 POS is returned. No range checking.
@@ -948,7 +1004,7 @@ extern Lisp_Object Qfirst_change_hook;
948 the buffer to the next character after fetching this one. Instead, 1004 the buffer to the next character after fetching this one. Instead,
949 use either FETCH_CHAR_ADVANCE or STRING_CHAR_AND_LENGTH. */ 1005 use either FETCH_CHAR_ADVANCE or STRING_CHAR_AND_LENGTH. */
950 1006
951static inline int 1007BUFFER_INLINE int
952FETCH_MULTIBYTE_CHAR (ptrdiff_t pos) 1008FETCH_MULTIBYTE_CHAR (ptrdiff_t pos)
953{ 1009{
954 unsigned char *p = ((pos >= GPT_BYTE ? GAP_SIZE : 0) 1010 unsigned char *p = ((pos >= GPT_BYTE ? GAP_SIZE : 0)
@@ -960,7 +1016,7 @@ FETCH_MULTIBYTE_CHAR (ptrdiff_t pos)
960 If POS doesn't point the head of valid multi-byte form, only the byte at 1016 If POS doesn't point the head of valid multi-byte form, only the byte at
961 POS is returned. No range checking. */ 1017 POS is returned. No range checking. */
962 1018
963static inline int 1019BUFFER_INLINE int
964BUF_FETCH_MULTIBYTE_CHAR (struct buffer *buf, ptrdiff_t pos) 1020BUF_FETCH_MULTIBYTE_CHAR (struct buffer *buf, ptrdiff_t pos)
965{ 1021{
966 unsigned char *p 1022 unsigned char *p
@@ -971,21 +1027,17 @@ BUF_FETCH_MULTIBYTE_CHAR (struct buffer *buf, ptrdiff_t pos)
971 1027
972/* Overlays */ 1028/* Overlays */
973 1029
974/* 1 if the OV is an overlay object. */
975
976#define OVERLAY_VALID(OV) (OVERLAYP (OV))
977
978/* Return the marker that stands for where OV starts in the buffer. */ 1030/* Return the marker that stands for where OV starts in the buffer. */
979 1031
980#define OVERLAY_START(OV) (XOVERLAY (OV)->start) 1032#define OVERLAY_START(OV) XOVERLAY (OV)->start
981 1033
982/* Return the marker that stands for where OV ends in the buffer. */ 1034/* Return the marker that stands for where OV ends in the buffer. */
983 1035
984#define OVERLAY_END(OV) (XOVERLAY (OV)->end) 1036#define OVERLAY_END(OV) XOVERLAY (OV)->end
985 1037
986/* Return the plist of overlay OV. */ 1038/* Return the plist of overlay OV. */
987 1039
988#define OVERLAY_PLIST(OV) XOVERLAY ((OV))->plist 1040#define OVERLAY_PLIST(OV) XOVERLAY (OV)->plist
989 1041
990/* Return the actual buffer position for the marker P. 1042/* Return the actual buffer position for the marker P.
991 We assume you know which buffer it's pointing into. */ 1043 We assume you know which buffer it's pointing into. */
@@ -1006,16 +1058,16 @@ extern int last_per_buffer_idx;
1006 from the start of a buffer structure. */ 1058 from the start of a buffer structure. */
1007 1059
1008#define PER_BUFFER_VAR_OFFSET(VAR) \ 1060#define PER_BUFFER_VAR_OFFSET(VAR) \
1009 offsetof (struct buffer, BUFFER_INTERNAL_FIELD (VAR)) 1061 offsetof (struct buffer, INTERNAL_FIELD (VAR))
1010 1062
1011/* Used to iterate over normal Lisp_Object fields of struct buffer (all 1063/* Used to iterate over normal Lisp_Object fields of struct buffer (all
1012 Lisp_Objects except undo_list). If you add, remove, or reorder 1064 Lisp_Objects except undo_list). If you add, remove, or reorder
1013 Lisp_Objects in a struct buffer, make sure that this is still correct. */ 1065 Lisp_Objects in a struct buffer, make sure that this is still correct. */
1014 1066
1015#define for_each_per_buffer_object_at(offset) \ 1067#define FOR_EACH_PER_BUFFER_OBJECT_AT(offset) \
1016 for (offset = PER_BUFFER_VAR_OFFSET (name); \ 1068 for (offset = PER_BUFFER_VAR_OFFSET (name); \
1017 offset <= PER_BUFFER_VAR_OFFSET (cursor_in_non_selected_windows); \ 1069 offset <= PER_BUFFER_VAR_OFFSET (cursor_in_non_selected_windows); \
1018 offset += sizeof (Lisp_Object)) 1070 offset += word_size)
1019 1071
1020/* Return the index of buffer-local variable VAR. Each per-buffer 1072/* Return the index of buffer-local variable VAR. Each per-buffer
1021 variable has an index > 0 associated with it, except when it always 1073 variable has an index > 0 associated with it, except when it always
@@ -1081,7 +1133,7 @@ extern int last_per_buffer_idx;
1081 (*(Lisp_Object *)((OFFSET) + (char *) (BUFFER))) 1133 (*(Lisp_Object *)((OFFSET) + (char *) (BUFFER)))
1082 1134
1083/* Downcase a character C, or make no change if that cannot be done. */ 1135/* Downcase a character C, or make no change if that cannot be done. */
1084static inline int 1136BUFFER_INLINE int
1085downcase (int c) 1137downcase (int c)
1086{ 1138{
1087 Lisp_Object downcase_table = BVAR (current_buffer, downcase_table); 1139 Lisp_Object downcase_table = BVAR (current_buffer, downcase_table);
@@ -1090,10 +1142,10 @@ downcase (int c)
1090} 1142}
1091 1143
1092/* 1 if C is upper case. */ 1144/* 1 if C is upper case. */
1093static inline int uppercasep (int c) { return downcase (c) != c; } 1145BUFFER_INLINE int uppercasep (int c) { return downcase (c) != c; }
1094 1146
1095/* Upcase a character C known to be not upper case. */ 1147/* Upcase a character C known to be not upper case. */
1096static inline int 1148BUFFER_INLINE int
1097upcase1 (int c) 1149upcase1 (int c)
1098{ 1150{
1099 Lisp_Object upcase_table = BVAR (current_buffer, upcase_table); 1151 Lisp_Object upcase_table = BVAR (current_buffer, upcase_table);
@@ -1102,8 +1154,10 @@ upcase1 (int c)
1102} 1154}
1103 1155
1104/* 1 if C is lower case. */ 1156/* 1 if C is lower case. */
1105static inline int lowercasep (int c) 1157BUFFER_INLINE int lowercasep (int c)
1106{ return !uppercasep (c) && upcase1 (c) != c; } 1158{ return !uppercasep (c) && upcase1 (c) != c; }
1107 1159
1108/* Upcase a character C, or make no change if that cannot be done. */ 1160/* Upcase a character C, or make no change if that cannot be done. */
1109static inline int upcase (int c) { return uppercasep (c) ? c : upcase1 (c); } 1161BUFFER_INLINE int upcase (int c) { return uppercasep (c) ? c : upcase1 (c); }
1162
1163INLINE_HEADER_END