diff options
| author | Joakim Verona | 2012-07-27 02:22:03 +0200 |
|---|---|---|
| committer | Joakim Verona | 2012-07-27 02:22:03 +0200 |
| commit | 5fb63197843dcae66f2fe0ddd6f4a9d560e9db2f (patch) | |
| tree | 5c55f1096a656a9759f0b53a0b5d1a2289bd366f /src/buffer.h | |
| parent | 0c5c85cf2b350c965bb1ffa5b2d77c2adebc406b (diff) | |
| parent | 562157c814037dcba58a20cd6908a95992c22283 (diff) | |
| download | emacs-5fb63197843dcae66f2fe0ddd6f4a9d560e9db2f.tar.gz emacs-5fb63197843dcae66f2fe0ddd6f4a9d560e9db2f.zip | |
upstream
Diffstat (limited to 'src/buffer.h')
| -rw-r--r-- | src/buffer.h | 341 |
1 files changed, 192 insertions, 149 deletions
diff --git a/src/buffer.h b/src/buffer.h index 8e0604e90c2..61f9e72fcfd 100644 --- a/src/buffer.h +++ b/src/buffer.h | |||
| @@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License | |||
| 19 | along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | 19 | along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ |
| 20 | 20 | ||
| 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 | 23 | ||
| 23 | /* Accessing the parameters of the current buffer. */ | 24 | /* Accessing the parameters of the current buffer. */ |
| 24 | 25 | ||
| @@ -435,6 +436,9 @@ struct buffer_text | |||
| 435 | 436 | ||
| 436 | EMACS_INT overlay_modiff; /* Counts modifications to overlays. */ | 437 | EMACS_INT overlay_modiff; /* Counts modifications to overlays. */ |
| 437 | 438 | ||
| 439 | EMACS_INT compact; /* Set to modiff each time when compact_buffer | ||
| 440 | is called for this buffer. */ | ||
| 441 | |||
| 438 | /* Minimum value of GPT - BEG since last redisplay that finished. */ | 442 | /* Minimum value of GPT - BEG since last redisplay that finished. */ |
| 439 | ptrdiff_t beg_unchanged; | 443 | ptrdiff_t beg_unchanged; |
| 440 | 444 | ||
| @@ -481,139 +485,26 @@ struct buffer_text | |||
| 481 | 485 | ||
| 482 | struct buffer | 486 | struct buffer |
| 483 | { | 487 | { |
| 484 | /* Everything before the `name' slot must be of a non-Lisp_Object type, | 488 | /* HEADER.NEXT is the next buffer, in chain of all buffers, including killed |
| 485 | and every slot after `name' must be a Lisp_Object. | 489 | buffers. This chain, starting from all_buffers, is used only for garbage |
| 486 | 490 | collection, in order to collect killed buffers properly. Note that large | |
| 487 | Check out mark_buffer (alloc.c) to see why. */ | 491 | vectors and large pseudo-vector objects are all on another chain starting |
| 488 | 492 | from large_vectors. */ | |
| 489 | /* HEADER.NEXT is the next buffer, in chain of all buffers, | ||
| 490 | including killed buffers. | ||
| 491 | This chain is used only for garbage collection, in order to | ||
| 492 | collect killed buffers properly. | ||
| 493 | Note that vectors and most pseudovectors are all on one chain, | ||
| 494 | but buffers are on a separate chain of their own. */ | ||
| 495 | struct vectorlike_header header; | 493 | struct vectorlike_header header; |
| 496 | 494 | ||
| 497 | /* This structure holds the coordinates of the buffer contents | ||
| 498 | in ordinary buffers. In indirect buffers, this is not used. */ | ||
| 499 | struct buffer_text own_text; | ||
| 500 | |||
| 501 | /* This points to the `struct buffer_text' that used for this buffer. | ||
| 502 | In an ordinary buffer, this is the own_text field above. | ||
| 503 | In an indirect buffer, this is the own_text field of another buffer. */ | ||
| 504 | struct buffer_text *text; | ||
| 505 | |||
| 506 | /* Char position of point in buffer. */ | ||
| 507 | ptrdiff_t pt; | ||
| 508 | /* Byte position of point in buffer. */ | ||
| 509 | ptrdiff_t pt_byte; | ||
| 510 | /* Char position of beginning of accessible range. */ | ||
| 511 | ptrdiff_t begv; | ||
| 512 | /* Byte position of beginning of accessible range. */ | ||
| 513 | ptrdiff_t begv_byte; | ||
| 514 | /* Char position of end of accessible range. */ | ||
| 515 | ptrdiff_t zv; | ||
| 516 | /* Byte position of end of accessible range. */ | ||
| 517 | ptrdiff_t zv_byte; | ||
| 518 | |||
| 519 | /* In an indirect buffer, this points to the base buffer. | ||
| 520 | In an ordinary buffer, it is 0. */ | ||
| 521 | struct buffer *base_buffer; | ||
| 522 | |||
| 523 | /* A non-zero value in slot IDX means that per-buffer variable | ||
| 524 | with index IDX has a local value in this buffer. The index IDX | ||
| 525 | for a buffer-local variable is stored in that variable's slot | ||
| 526 | in buffer_local_flags as a Lisp integer. If the index is -1, | ||
| 527 | this means the variable is always local in all buffers. */ | ||
| 528 | #define MAX_PER_BUFFER_VARS 50 | ||
| 529 | char local_flags[MAX_PER_BUFFER_VARS]; | ||
| 530 | |||
| 531 | /* Set to the modtime of the visited file when read or written. | ||
| 532 | -1 means visited file was nonexistent. | ||
| 533 | 0 means visited file modtime unknown; in no case complain | ||
| 534 | about any mismatch on next save attempt. */ | ||
| 535 | time_t modtime; | ||
| 536 | /* Size of the file when modtime was set. This is used to detect the | ||
| 537 | case where the file grew while we were reading it, so the modtime | ||
| 538 | is still the same (since it's rounded up to seconds) but we're actually | ||
| 539 | not up-to-date. -1 means the size is unknown. Only meaningful if | ||
| 540 | modtime is actually set. */ | ||
| 541 | off_t modtime_size; | ||
| 542 | /* The value of text->modiff at the last auto-save. */ | ||
| 543 | EMACS_INT auto_save_modified; | ||
| 544 | /* The value of text->modiff at the last display error. | ||
| 545 | Redisplay of this buffer is inhibited until it changes again. */ | ||
| 546 | EMACS_INT display_error_modiff; | ||
| 547 | /* The time at which we detected a failure to auto-save, | ||
| 548 | Or 0 if we didn't have a failure. */ | ||
| 549 | time_t auto_save_failure_time; | ||
| 550 | /* Position in buffer at which display started | ||
| 551 | the last time this buffer was displayed. */ | ||
| 552 | ptrdiff_t last_window_start; | ||
| 553 | |||
| 554 | /* Set nonzero whenever the narrowing is changed in this buffer. */ | ||
| 555 | int clip_changed; | ||
| 556 | |||
| 557 | /* If the long line scan cache is enabled (i.e. the buffer-local | ||
| 558 | variable cache-long-line-scans is non-nil), newline_cache | ||
| 559 | points to the newline cache, and width_run_cache points to the | ||
| 560 | width run cache. | ||
| 561 | |||
| 562 | The newline cache records which stretches of the buffer are | ||
| 563 | known *not* to contain newlines, so that they can be skipped | ||
| 564 | quickly when we search for newlines. | ||
| 565 | |||
| 566 | The width run cache records which stretches of the buffer are | ||
| 567 | known to contain characters whose widths are all the same. If | ||
| 568 | the width run cache maps a character to a value > 0, that value is | ||
| 569 | the character's width; if it maps a character to zero, we don't | ||
| 570 | know what its width is. This allows compute_motion to process | ||
| 571 | such regions very quickly, using algebra instead of inspecting | ||
| 572 | each character. See also width_table, below. */ | ||
| 573 | struct region_cache *newline_cache; | ||
| 574 | struct region_cache *width_run_cache; | ||
| 575 | |||
| 576 | /* Non-zero means don't use redisplay optimizations for | ||
| 577 | displaying this buffer. */ | ||
| 578 | unsigned prevent_redisplay_optimizations_p : 1; | ||
| 579 | |||
| 580 | /* List of overlays that end at or before the current center, | ||
| 581 | in order of end-position. */ | ||
| 582 | struct Lisp_Overlay *overlays_before; | ||
| 583 | |||
| 584 | /* List of overlays that end after the current center, | ||
| 585 | in order of start-position. */ | ||
| 586 | struct Lisp_Overlay *overlays_after; | ||
| 587 | |||
| 588 | /* Position where the overlay lists are centered. */ | ||
| 589 | ptrdiff_t overlay_center; | ||
| 590 | |||
| 591 | /* Everything from here down must be a Lisp_Object. */ | ||
| 592 | /* buffer-local Lisp variables start at `undo_list', | ||
| 593 | tho only the ones from `name' on are GC'd normally. */ | ||
| 594 | #define FIRST_FIELD_PER_BUFFER undo_list | ||
| 595 | |||
| 596 | /* Changes in the buffer are recorded here for undo. | ||
| 597 | t means don't record anything. | ||
| 598 | This information belongs to the base buffer of an indirect buffer, | ||
| 599 | But we can't store it in the struct buffer_text | ||
| 600 | because local variables have to be right in the struct buffer. | ||
| 601 | So we copy it around in set_buffer_internal. | ||
| 602 | This comes before `name' because it is marked in a special way. */ | ||
| 603 | Lisp_Object BUFFER_INTERNAL_FIELD (undo_list); | ||
| 604 | |||
| 605 | /* The name of this buffer. */ | 495 | /* The name of this buffer. */ |
| 606 | Lisp_Object BUFFER_INTERNAL_FIELD (name); | 496 | Lisp_Object BUFFER_INTERNAL_FIELD (name); |
| 607 | 497 | ||
| 608 | /* The name of the file visited in this buffer, or nil. */ | 498 | /* The name of the file visited in this buffer, or nil. */ |
| 609 | Lisp_Object BUFFER_INTERNAL_FIELD (filename); | 499 | Lisp_Object BUFFER_INTERNAL_FIELD (filename); |
| 610 | /* Dir for expanding relative file names. */ | 500 | |
| 501 | /* Directory for expanding relative file names. */ | ||
| 611 | Lisp_Object BUFFER_INTERNAL_FIELD (directory); | 502 | Lisp_Object BUFFER_INTERNAL_FIELD (directory); |
| 612 | /* True if this buffer has been backed up (if you write to the | 503 | |
| 613 | visited file and it hasn't been backed up, then a backup will | 504 | /* True if this buffer has been backed up (if you write to the visited |
| 614 | be made). */ | 505 | file and it hasn't been backed up, then a backup will be made). */ |
| 615 | /* This isn't really used by the C code, so could be deleted. */ | ||
| 616 | Lisp_Object BUFFER_INTERNAL_FIELD (backed_up); | 506 | Lisp_Object BUFFER_INTERNAL_FIELD (backed_up); |
| 507 | |||
| 617 | /* Length of file when last read or saved. | 508 | /* Length of file when last read or saved. |
| 618 | -1 means auto saving turned off because buffer shrank a lot. | 509 | -1 means auto saving turned off because buffer shrank a lot. |
| 619 | -2 means don't turn off auto saving if buffer shrinks. | 510 | -2 means don't turn off auto saving if buffer shrinks. |
| @@ -621,6 +512,7 @@ struct buffer | |||
| 621 | This is not in the struct buffer_text | 512 | This is not in the struct buffer_text |
| 622 | because it's not used in indirect buffers at all. */ | 513 | because it's not used in indirect buffers at all. */ |
| 623 | Lisp_Object BUFFER_INTERNAL_FIELD (save_length); | 514 | Lisp_Object BUFFER_INTERNAL_FIELD (save_length); |
| 515 | |||
| 624 | /* File name used for auto-saving this buffer. | 516 | /* File name used for auto-saving this buffer. |
| 625 | This is not in the struct buffer_text | 517 | This is not in the struct buffer_text |
| 626 | because it's not used in indirect buffers at all. */ | 518 | because it's not used in indirect buffers at all. */ |
| @@ -628,6 +520,7 @@ struct buffer | |||
| 628 | 520 | ||
| 629 | /* Non-nil if buffer read-only. */ | 521 | /* Non-nil if buffer read-only. */ |
| 630 | Lisp_Object BUFFER_INTERNAL_FIELD (read_only); | 522 | Lisp_Object BUFFER_INTERNAL_FIELD (read_only); |
| 523 | |||
| 631 | /* "The mark". This is a marker which may | 524 | /* "The mark". This is a marker which may |
| 632 | point into this buffer or may point nowhere. */ | 525 | point into this buffer or may point nowhere. */ |
| 633 | Lisp_Object BUFFER_INTERNAL_FIELD (mark); | 526 | Lisp_Object BUFFER_INTERNAL_FIELD (mark); |
| @@ -637,10 +530,12 @@ struct buffer | |||
| 637 | symbols, just the symbol appears as the element. */ | 530 | symbols, just the symbol appears as the element. */ |
| 638 | Lisp_Object BUFFER_INTERNAL_FIELD (local_var_alist); | 531 | Lisp_Object BUFFER_INTERNAL_FIELD (local_var_alist); |
| 639 | 532 | ||
| 640 | /* Symbol naming major mode (eg, lisp-mode). */ | 533 | /* Symbol naming major mode (e.g., lisp-mode). */ |
| 641 | Lisp_Object BUFFER_INTERNAL_FIELD (major_mode); | 534 | Lisp_Object BUFFER_INTERNAL_FIELD (major_mode); |
| 642 | /* Pretty name of major mode (eg, "Lisp"). */ | 535 | |
| 536 | /* Pretty name of major mode (e.g., "Lisp"). */ | ||
| 643 | Lisp_Object BUFFER_INTERNAL_FIELD (mode_name); | 537 | Lisp_Object BUFFER_INTERNAL_FIELD (mode_name); |
| 538 | |||
| 644 | /* Mode line element that controls format of mode line. */ | 539 | /* Mode line element that controls format of mode line. */ |
| 645 | Lisp_Object BUFFER_INTERNAL_FIELD (mode_line_format); | 540 | Lisp_Object BUFFER_INTERNAL_FIELD (mode_line_format); |
| 646 | 541 | ||
| @@ -650,10 +545,13 @@ struct buffer | |||
| 650 | 545 | ||
| 651 | /* Keys that are bound local to this buffer. */ | 546 | /* Keys that are bound local to this buffer. */ |
| 652 | Lisp_Object BUFFER_INTERNAL_FIELD (keymap); | 547 | Lisp_Object BUFFER_INTERNAL_FIELD (keymap); |
| 548 | |||
| 653 | /* This buffer's local abbrev table. */ | 549 | /* This buffer's local abbrev table. */ |
| 654 | Lisp_Object BUFFER_INTERNAL_FIELD (abbrev_table); | 550 | Lisp_Object BUFFER_INTERNAL_FIELD (abbrev_table); |
| 551 | |||
| 655 | /* This buffer's syntax table. */ | 552 | /* This buffer's syntax table. */ |
| 656 | Lisp_Object BUFFER_INTERNAL_FIELD (syntax_table); | 553 | Lisp_Object BUFFER_INTERNAL_FIELD (syntax_table); |
| 554 | |||
| 657 | /* This buffer's category table. */ | 555 | /* This buffer's category table. */ |
| 658 | Lisp_Object BUFFER_INTERNAL_FIELD (category_table); | 556 | Lisp_Object BUFFER_INTERNAL_FIELD (category_table); |
| 659 | 557 | ||
| @@ -664,48 +562,61 @@ struct buffer | |||
| 664 | Lisp_Object BUFFER_INTERNAL_FIELD (tab_width); | 562 | Lisp_Object BUFFER_INTERNAL_FIELD (tab_width); |
| 665 | Lisp_Object BUFFER_INTERNAL_FIELD (fill_column); | 563 | Lisp_Object BUFFER_INTERNAL_FIELD (fill_column); |
| 666 | Lisp_Object BUFFER_INTERNAL_FIELD (left_margin); | 564 | Lisp_Object BUFFER_INTERNAL_FIELD (left_margin); |
| 565 | |||
| 667 | /* Function to call when insert space past fill column. */ | 566 | /* Function to call when insert space past fill column. */ |
| 668 | Lisp_Object BUFFER_INTERNAL_FIELD (auto_fill_function); | 567 | Lisp_Object BUFFER_INTERNAL_FIELD (auto_fill_function); |
| 669 | 568 | ||
| 670 | /* Case table for case-conversion in this buffer. | 569 | /* Case table for case-conversion in this buffer. |
| 671 | This char-table maps each char into its lower-case version. */ | 570 | This char-table maps each char into its lower-case version. */ |
| 672 | Lisp_Object BUFFER_INTERNAL_FIELD (downcase_table); | 571 | Lisp_Object BUFFER_INTERNAL_FIELD (downcase_table); |
| 572 | |||
| 673 | /* Char-table mapping each char to its upper-case version. */ | 573 | /* Char-table mapping each char to its upper-case version. */ |
| 674 | Lisp_Object BUFFER_INTERNAL_FIELD (upcase_table); | 574 | Lisp_Object BUFFER_INTERNAL_FIELD (upcase_table); |
| 575 | |||
| 675 | /* Char-table for conversion for case-folding search. */ | 576 | /* Char-table for conversion for case-folding search. */ |
| 676 | Lisp_Object BUFFER_INTERNAL_FIELD (case_canon_table); | 577 | Lisp_Object BUFFER_INTERNAL_FIELD (case_canon_table); |
| 578 | |||
| 677 | /* Char-table of equivalences for case-folding search. */ | 579 | /* Char-table of equivalences for case-folding search. */ |
| 678 | Lisp_Object BUFFER_INTERNAL_FIELD (case_eqv_table); | 580 | Lisp_Object BUFFER_INTERNAL_FIELD (case_eqv_table); |
| 679 | 581 | ||
| 680 | /* Non-nil means do not display continuation lines. */ | 582 | /* Non-nil means do not display continuation lines. */ |
| 681 | Lisp_Object BUFFER_INTERNAL_FIELD (truncate_lines); | 583 | Lisp_Object BUFFER_INTERNAL_FIELD (truncate_lines); |
| 584 | |||
| 682 | /* Non-nil means to use word wrapping when displaying continuation lines. */ | 585 | /* Non-nil means to use word wrapping when displaying continuation lines. */ |
| 683 | Lisp_Object BUFFER_INTERNAL_FIELD (word_wrap); | 586 | Lisp_Object BUFFER_INTERNAL_FIELD (word_wrap); |
| 587 | |||
| 684 | /* Non-nil means display ctl chars with uparrow. */ | 588 | /* Non-nil means display ctl chars with uparrow. */ |
| 685 | Lisp_Object BUFFER_INTERNAL_FIELD (ctl_arrow); | 589 | Lisp_Object BUFFER_INTERNAL_FIELD (ctl_arrow); |
| 590 | |||
| 686 | /* Non-nil means reorder bidirectional text for display in the | 591 | /* Non-nil means reorder bidirectional text for display in the |
| 687 | visual order. */ | 592 | visual order. */ |
| 688 | Lisp_Object BUFFER_INTERNAL_FIELD (bidi_display_reordering); | 593 | Lisp_Object BUFFER_INTERNAL_FIELD (bidi_display_reordering); |
| 594 | |||
| 689 | /* If non-nil, specifies which direction of text to force in all the | 595 | /* If non-nil, specifies which direction of text to force in all the |
| 690 | paragraphs of the buffer. Nil means determine paragraph | 596 | paragraphs of the buffer. Nil means determine paragraph |
| 691 | direction dynamically for each paragraph. */ | 597 | direction dynamically for each paragraph. */ |
| 692 | Lisp_Object BUFFER_INTERNAL_FIELD (bidi_paragraph_direction); | 598 | Lisp_Object BUFFER_INTERNAL_FIELD (bidi_paragraph_direction); |
| 599 | |||
| 693 | /* Non-nil means do selective display; | 600 | /* Non-nil means do selective display; |
| 694 | see doc string in syms_of_buffer (buffer.c) for details. */ | 601 | see doc string in syms_of_buffer (buffer.c) for details. */ |
| 695 | Lisp_Object BUFFER_INTERNAL_FIELD (selective_display); | 602 | Lisp_Object BUFFER_INTERNAL_FIELD (selective_display); |
| 696 | #ifndef old | 603 | |
| 697 | /* Non-nil means show ... at end of line followed by invisible lines. */ | 604 | /* Non-nil means show ... at end of line followed by invisible lines. */ |
| 698 | Lisp_Object BUFFER_INTERNAL_FIELD (selective_display_ellipses); | 605 | Lisp_Object BUFFER_INTERNAL_FIELD (selective_display_ellipses); |
| 699 | #endif | 606 | |
| 700 | /* Alist of (FUNCTION . STRING) for each minor mode enabled in buffer. */ | 607 | /* Alist of (FUNCTION . STRING) for each minor mode enabled in buffer. */ |
| 701 | Lisp_Object BUFFER_INTERNAL_FIELD (minor_modes); | 608 | Lisp_Object BUFFER_INTERNAL_FIELD (minor_modes); |
| 609 | |||
| 702 | /* t if "self-insertion" should overwrite; `binary' if it should also | 610 | /* t if "self-insertion" should overwrite; `binary' if it should also |
| 703 | overwrite newlines and tabs - for editing executables and the like. */ | 611 | overwrite newlines and tabs - for editing executables and the like. */ |
| 704 | Lisp_Object BUFFER_INTERNAL_FIELD (overwrite_mode); | 612 | Lisp_Object BUFFER_INTERNAL_FIELD (overwrite_mode); |
| 705 | /* non-nil means abbrev mode is on. Expand abbrevs automatically. */ | 613 | |
| 614 | /* Non-nil means abbrev mode is on. Expand abbrevs automatically. */ | ||
| 706 | Lisp_Object BUFFER_INTERNAL_FIELD (abbrev_mode); | 615 | Lisp_Object BUFFER_INTERNAL_FIELD (abbrev_mode); |
| 616 | |||
| 707 | /* Display table to use for text in this buffer. */ | 617 | /* Display table to use for text in this buffer. */ |
| 708 | Lisp_Object BUFFER_INTERNAL_FIELD (display_table); | 618 | Lisp_Object BUFFER_INTERNAL_FIELD (display_table); |
| 619 | |||
| 709 | /* t means the mark and region are currently active. */ | 620 | /* t means the mark and region are currently active. */ |
| 710 | Lisp_Object BUFFER_INTERNAL_FIELD (mark_active); | 621 | Lisp_Object BUFFER_INTERNAL_FIELD (mark_active); |
| 711 | 622 | ||
| @@ -772,11 +683,13 @@ struct buffer | |||
| 772 | 683 | ||
| 773 | /* Widths of left and right marginal areas for windows displaying | 684 | /* Widths of left and right marginal areas for windows displaying |
| 774 | this buffer. */ | 685 | this buffer. */ |
| 775 | Lisp_Object BUFFER_INTERNAL_FIELD (left_margin_cols), BUFFER_INTERNAL_FIELD (right_margin_cols); | 686 | Lisp_Object BUFFER_INTERNAL_FIELD (left_margin_cols); |
| 687 | Lisp_Object BUFFER_INTERNAL_FIELD (right_margin_cols); | ||
| 776 | 688 | ||
| 777 | /* Widths of left and right fringe areas for windows displaying | 689 | /* Widths of left and right fringe areas for windows displaying |
| 778 | this buffer. */ | 690 | this buffer. */ |
| 779 | Lisp_Object BUFFER_INTERNAL_FIELD (left_fringe_width), BUFFER_INTERNAL_FIELD (right_fringe_width); | 691 | Lisp_Object BUFFER_INTERNAL_FIELD (left_fringe_width); |
| 692 | Lisp_Object BUFFER_INTERNAL_FIELD (right_fringe_width); | ||
| 780 | 693 | ||
| 781 | /* Non-nil means fringes are drawn outside display margins; | 694 | /* Non-nil means fringes are drawn outside display margins; |
| 782 | othersize draw them between margin areas and text. */ | 695 | othersize draw them between margin areas and text. */ |
| @@ -784,7 +697,8 @@ struct buffer | |||
| 784 | 697 | ||
| 785 | /* Width and type of scroll bar areas for windows displaying | 698 | /* Width and type of scroll bar areas for windows displaying |
| 786 | this buffer. */ | 699 | this buffer. */ |
| 787 | Lisp_Object BUFFER_INTERNAL_FIELD (scroll_bar_width), BUFFER_INTERNAL_FIELD (vertical_scroll_bar_type); | 700 | Lisp_Object BUFFER_INTERNAL_FIELD (scroll_bar_width); |
| 701 | Lisp_Object BUFFER_INTERNAL_FIELD (vertical_scroll_bar_type); | ||
| 788 | 702 | ||
| 789 | /* Non-nil means indicate lines not displaying text (in a style | 703 | /* Non-nil means indicate lines not displaying text (in a style |
| 790 | like vi). */ | 704 | like vi). */ |
| @@ -822,16 +736,144 @@ struct buffer | |||
| 822 | in the display of this buffer. */ | 736 | in the display of this buffer. */ |
| 823 | Lisp_Object BUFFER_INTERNAL_FIELD (extra_line_spacing); | 737 | Lisp_Object BUFFER_INTERNAL_FIELD (extra_line_spacing); |
| 824 | 738 | ||
| 825 | /* *Cursor type to display in non-selected windows. | 739 | /* Cursor type to display in non-selected windows. |
| 826 | t means to use hollow box cursor. | 740 | t means to use hollow box cursor. |
| 827 | See `cursor-type' for other values. */ | 741 | See `cursor-type' for other values. */ |
| 828 | Lisp_Object BUFFER_INTERNAL_FIELD (cursor_in_non_selected_windows); | 742 | Lisp_Object BUFFER_INTERNAL_FIELD (cursor_in_non_selected_windows); |
| 829 | 743 | ||
| 830 | /* This must be the last field in the above list. */ | 744 | /* No more Lisp_Object beyond this point. Except undo_list, |
| 831 | #define LAST_FIELD_PER_BUFFER cursor_in_non_selected_windows | 745 | which is handled specially in Fgarbage_collect . */ |
| 746 | |||
| 747 | /* This structure holds the coordinates of the buffer contents | ||
| 748 | in ordinary buffers. In indirect buffers, this is not used. */ | ||
| 749 | struct buffer_text own_text; | ||
| 750 | |||
| 751 | /* This points to the `struct buffer_text' that used for this buffer. | ||
| 752 | In an ordinary buffer, this is the own_text field above. | ||
| 753 | In an indirect buffer, this is the own_text field of another buffer. */ | ||
| 754 | struct buffer_text *text; | ||
| 755 | |||
| 756 | /* Char position of point in buffer. */ | ||
| 757 | ptrdiff_t pt; | ||
| 758 | |||
| 759 | /* Byte position of point in buffer. */ | ||
| 760 | ptrdiff_t pt_byte; | ||
| 761 | |||
| 762 | /* Char position of beginning of accessible range. */ | ||
| 763 | ptrdiff_t begv; | ||
| 764 | |||
| 765 | /* Byte position of beginning of accessible range. */ | ||
| 766 | ptrdiff_t begv_byte; | ||
| 767 | |||
| 768 | /* Char position of end of accessible range. */ | ||
| 769 | ptrdiff_t zv; | ||
| 770 | |||
| 771 | /* Byte position of end of accessible range. */ | ||
| 772 | ptrdiff_t zv_byte; | ||
| 773 | |||
| 774 | /* In an indirect buffer, this points to the base buffer. | ||
| 775 | In an ordinary buffer, it is 0. */ | ||
| 776 | struct buffer *base_buffer; | ||
| 777 | |||
| 778 | /* In an indirect buffer, this is -1. In an ordinary buffer, | ||
| 779 | it's the number of indirect buffers that share our text; | ||
| 780 | zero means that we're the only owner of this text. */ | ||
| 781 | ptrdiff_t indirections; | ||
| 782 | |||
| 783 | /* A non-zero value in slot IDX means that per-buffer variable | ||
| 784 | with index IDX has a local value in this buffer. The index IDX | ||
| 785 | for a buffer-local variable is stored in that variable's slot | ||
| 786 | in buffer_local_flags as a Lisp integer. If the index is -1, | ||
| 787 | this means the variable is always local in all buffers. */ | ||
| 788 | #define MAX_PER_BUFFER_VARS 50 | ||
| 789 | char local_flags[MAX_PER_BUFFER_VARS]; | ||
| 790 | |||
| 791 | /* Set to the modtime of the visited file when read or written. | ||
| 792 | EMACS_NSECS (modtime) == NONEXISTENT_MODTIME_NSECS means | ||
| 793 | visited file was nonexistent. EMACS_NSECS (modtime) == | ||
| 794 | UNKNOWN_MODTIME_NSECS means visited file modtime unknown; | ||
| 795 | in no case complain about any mismatch on next save attempt. */ | ||
| 796 | #define NONEXISTENT_MODTIME_NSECS (-1) | ||
| 797 | #define UNKNOWN_MODTIME_NSECS (-2) | ||
| 798 | EMACS_TIME modtime; | ||
| 799 | |||
| 800 | /* Size of the file when modtime was set. This is used to detect the | ||
| 801 | case where the file grew while we were reading it, so the modtime | ||
| 802 | is still the same (since it's rounded up to seconds) but we're actually | ||
| 803 | not up-to-date. -1 means the size is unknown. Only meaningful if | ||
| 804 | modtime is actually set. */ | ||
| 805 | off_t modtime_size; | ||
| 806 | |||
| 807 | /* The value of text->modiff at the last auto-save. */ | ||
| 808 | EMACS_INT auto_save_modified; | ||
| 809 | |||
| 810 | /* The value of text->modiff at the last display error. | ||
| 811 | Redisplay of this buffer is inhibited until it changes again. */ | ||
| 812 | EMACS_INT display_error_modiff; | ||
| 813 | |||
| 814 | /* The time at which we detected a failure to auto-save, | ||
| 815 | Or 0 if we didn't have a failure. */ | ||
| 816 | time_t auto_save_failure_time; | ||
| 817 | |||
| 818 | /* Position in buffer at which display started | ||
| 819 | the last time this buffer was displayed. */ | ||
| 820 | ptrdiff_t last_window_start; | ||
| 821 | |||
| 822 | /* If the long line scan cache is enabled (i.e. the buffer-local | ||
| 823 | variable cache-long-line-scans is non-nil), newline_cache | ||
| 824 | points to the newline cache, and width_run_cache points to the | ||
| 825 | width run cache. | ||
| 826 | |||
| 827 | The newline cache records which stretches of the buffer are | ||
| 828 | known *not* to contain newlines, so that they can be skipped | ||
| 829 | quickly when we search for newlines. | ||
| 830 | |||
| 831 | The width run cache records which stretches of the buffer are | ||
| 832 | known to contain characters whose widths are all the same. If | ||
| 833 | the width run cache maps a character to a value > 0, that value is | ||
| 834 | the character's width; if it maps a character to zero, we don't | ||
| 835 | know what its width is. This allows compute_motion to process | ||
| 836 | such regions very quickly, using algebra instead of inspecting | ||
| 837 | each character. See also width_table, below. */ | ||
| 838 | struct region_cache *newline_cache; | ||
| 839 | struct region_cache *width_run_cache; | ||
| 840 | |||
| 841 | /* Non-zero means don't use redisplay optimizations for | ||
| 842 | displaying this buffer. */ | ||
| 843 | unsigned prevent_redisplay_optimizations_p : 1; | ||
| 844 | |||
| 845 | /* Non-zero whenever the narrowing is changed in this buffer. */ | ||
| 846 | unsigned clip_changed : 1; | ||
| 847 | |||
| 848 | /* List of overlays that end at or before the current center, | ||
| 849 | in order of end-position. */ | ||
| 850 | struct Lisp_Overlay *overlays_before; | ||
| 851 | |||
| 852 | /* List of overlays that end after the current center, | ||
| 853 | in order of start-position. */ | ||
| 854 | struct Lisp_Overlay *overlays_after; | ||
| 855 | |||
| 856 | /* Position where the overlay lists are centered. */ | ||
| 857 | ptrdiff_t overlay_center; | ||
| 858 | |||
| 859 | /* Changes in the buffer are recorded here for undo, and t means | ||
| 860 | don't record anything. This information belongs to the base | ||
| 861 | buffer of an indirect buffer. But we can't store it in the | ||
| 862 | struct buffer_text because local variables have to be right in | ||
| 863 | the struct buffer. So we copy it around in set_buffer_internal. */ | ||
| 864 | Lisp_Object BUFFER_INTERNAL_FIELD (undo_list); | ||
| 832 | }; | 865 | }; |
| 833 | 866 | ||
| 834 | 867 | ||
| 868 | /* Chain of all buffers, including killed ones. */ | ||
| 869 | |||
| 870 | extern struct buffer *all_buffers; | ||
| 871 | |||
| 872 | /* Used to iterate over the chain above. */ | ||
| 873 | |||
| 874 | #define FOR_EACH_BUFFER(b) \ | ||
| 875 | for ((b) = all_buffers; (b); (b) = (b)->header.next.buffer) | ||
| 876 | |||
| 835 | /* This points to the current buffer. */ | 877 | /* This points to the current buffer. */ |
| 836 | 878 | ||
| 837 | extern struct buffer *current_buffer; | 879 | extern struct buffer *current_buffer; |
| @@ -869,6 +911,7 @@ extern struct buffer buffer_local_symbols; | |||
| 869 | 911 | ||
| 870 | extern void delete_all_overlays (struct buffer *); | 912 | extern void delete_all_overlays (struct buffer *); |
| 871 | extern void reset_buffer (struct buffer *); | 913 | extern void reset_buffer (struct buffer *); |
| 914 | extern int compact_buffer (struct buffer *); | ||
| 872 | extern void evaporate_overlays (ptrdiff_t); | 915 | extern void evaporate_overlays (ptrdiff_t); |
| 873 | extern ptrdiff_t overlays_at (EMACS_INT pos, int extend, Lisp_Object **vec_ptr, | 916 | extern ptrdiff_t overlays_at (EMACS_INT pos, int extend, Lisp_Object **vec_ptr, |
| 874 | ptrdiff_t *len_ptr, ptrdiff_t *next_ptr, | 917 | ptrdiff_t *len_ptr, ptrdiff_t *next_ptr, |
| @@ -882,7 +925,7 @@ extern void set_buffer_internal_1 (struct buffer *); | |||
| 882 | extern void set_buffer_temp (struct buffer *); | 925 | extern void set_buffer_temp (struct buffer *); |
| 883 | extern Lisp_Object buffer_local_value_1 (Lisp_Object, Lisp_Object); | 926 | extern Lisp_Object buffer_local_value_1 (Lisp_Object, Lisp_Object); |
| 884 | extern void record_buffer (Lisp_Object); | 927 | extern void record_buffer (Lisp_Object); |
| 885 | extern void buffer_slot_type_mismatch (Lisp_Object, int) NO_RETURN; | 928 | extern _Noreturn void buffer_slot_type_mismatch (Lisp_Object, int); |
| 886 | extern void fix_overlays_before (struct buffer *, ptrdiff_t, ptrdiff_t); | 929 | extern void fix_overlays_before (struct buffer *, ptrdiff_t, ptrdiff_t); |
| 887 | extern void mmap_set_vars (int); | 930 | extern void mmap_set_vars (int); |
| 888 | 931 | ||
| @@ -892,24 +935,19 @@ extern void mmap_set_vars (int); | |||
| 892 | 935 | ||
| 893 | #define GET_OVERLAYS_AT(posn, overlays, noverlays, nextp, chrq) \ | 936 | #define GET_OVERLAYS_AT(posn, overlays, noverlays, nextp, chrq) \ |
| 894 | do { \ | 937 | do { \ |
| 895 | ptrdiff_t maxlen = 40; \ | 938 | ptrdiff_t maxlen = 40; \ |
| 896 | overlays = (Lisp_Object *) alloca (maxlen * sizeof (Lisp_Object)); \ | 939 | overlays = alloca (maxlen * sizeof *overlays); \ |
| 897 | noverlays = overlays_at (posn, 0, &overlays, &maxlen, \ | 940 | noverlays = overlays_at (posn, 0, &overlays, &maxlen, \ |
| 898 | nextp, NULL, chrq); \ | 941 | nextp, NULL, chrq); \ |
| 899 | if (noverlays > maxlen) \ | 942 | if (noverlays > maxlen) \ |
| 900 | { \ | 943 | { \ |
| 901 | maxlen = noverlays; \ | 944 | maxlen = noverlays; \ |
| 902 | overlays = (Lisp_Object *) alloca (maxlen * sizeof (Lisp_Object)); \ | 945 | overlays = alloca (maxlen * sizeof *overlays); \ |
| 903 | noverlays = overlays_at (posn, 0, &overlays, &maxlen, \ | 946 | noverlays = overlays_at (posn, 0, &overlays, &maxlen, \ |
| 904 | nextp, NULL, chrq); \ | 947 | nextp, NULL, chrq); \ |
| 905 | } \ | 948 | } \ |
| 906 | } while (0) | 949 | } while (0) |
| 907 | 950 | ||
| 908 | EXFUN (Fbuffer_live_p, 1); | ||
| 909 | EXFUN (Fbuffer_name, 1); | ||
| 910 | EXFUN (Fnext_overlay_change, 1); | ||
| 911 | EXFUN (Fbuffer_local_value, 2); | ||
| 912 | |||
| 913 | extern Lisp_Object Qbefore_change_functions; | 951 | extern Lisp_Object Qbefore_change_functions; |
| 914 | extern Lisp_Object Qafter_change_functions; | 952 | extern Lisp_Object Qafter_change_functions; |
| 915 | extern Lisp_Object Qfirst_change_hook; | 953 | extern Lisp_Object Qfirst_change_hook; |
| @@ -951,10 +989,6 @@ BUF_FETCH_MULTIBYTE_CHAR (struct buffer *buf, ptrdiff_t pos) | |||
| 951 | 989 | ||
| 952 | /* Overlays */ | 990 | /* Overlays */ |
| 953 | 991 | ||
| 954 | /* 1 if the OV is an overlay object. */ | ||
| 955 | |||
| 956 | #define OVERLAY_VALID(OV) (OVERLAYP (OV)) | ||
| 957 | |||
| 958 | /* Return the marker that stands for where OV starts in the buffer. */ | 992 | /* Return the marker that stands for where OV starts in the buffer. */ |
| 959 | 993 | ||
| 960 | #define OVERLAY_START(OV) (XOVERLAY (OV)->start) | 994 | #define OVERLAY_START(OV) (XOVERLAY (OV)->start) |
| @@ -988,6 +1022,15 @@ extern int last_per_buffer_idx; | |||
| 988 | #define PER_BUFFER_VAR_OFFSET(VAR) \ | 1022 | #define PER_BUFFER_VAR_OFFSET(VAR) \ |
| 989 | offsetof (struct buffer, BUFFER_INTERNAL_FIELD (VAR)) | 1023 | offsetof (struct buffer, BUFFER_INTERNAL_FIELD (VAR)) |
| 990 | 1024 | ||
| 1025 | /* Used to iterate over normal Lisp_Object fields of struct buffer (all | ||
| 1026 | Lisp_Objects except undo_list). If you add, remove, or reorder | ||
| 1027 | Lisp_Objects in a struct buffer, make sure that this is still correct. */ | ||
| 1028 | |||
| 1029 | #define FOR_EACH_PER_BUFFER_OBJECT_AT(offset) \ | ||
| 1030 | for (offset = PER_BUFFER_VAR_OFFSET (name); \ | ||
| 1031 | offset <= PER_BUFFER_VAR_OFFSET (cursor_in_non_selected_windows); \ | ||
| 1032 | offset += sizeof (Lisp_Object)) | ||
| 1033 | |||
| 991 | /* Return the index of buffer-local variable VAR. Each per-buffer | 1034 | /* Return the index of buffer-local variable VAR. Each per-buffer |
| 992 | variable has an index > 0 associated with it, except when it always | 1035 | variable has an index > 0 associated with it, except when it always |
| 993 | has buffer-local values, in which case the index is -1. If this is | 1036 | has buffer-local values, in which case the index is -1. If this is |