diff options
| author | Dmitry Antipov | 2012-07-03 07:57:52 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2012-07-03 07:57:52 +0400 |
| commit | 36429c89cbd7282a7614a358e5edb4d37f4a3f47 (patch) | |
| tree | eafca213d91a33d626e60caec38ccc21bdd394fe /src/buffer.h | |
| parent | b544fef2ac730e5fc8c072b33584d9b48d25f6fa (diff) | |
| download | emacs-36429c89cbd7282a7614a358e5edb4d37f4a3f47.tar.gz emacs-36429c89cbd7282a7614a358e5edb4d37f4a3f47.zip | |
Cleanup basic buffer management.
* buffer.h (struct buffer): Change layout to use generic vector
marking code. Fix some comments. Change type of 'clip_changed'
to bitfield. Remove unused #ifndef old.
(FIRST_FIELD_PER_BUFFER, LAST_FIELD_PER_BUFFER): Remove.
(GET_OVERLAYS_AT): Fix indentation.
(for_each_per_buffer_object_at): New macro.
* buffer.c (clone_per_buffer_values, reset_buffer_local_variables)
(Fbuffer_local_variables): Use it.
(init_buffer_once, syms_of_buffer): Remove unused #ifndef old.
* alloc.c (allocate_buffer): Adjust to match new layout of
struct buffer. Fix comment.
(mark_overlay): New function.
(mark_buffer): Use it. Use mark_vectorlike to mark normal
Lisp area of struct buffer.
(mark_object): Use it. Adjust marking of misc objects
and related comments.
Diffstat (limited to 'src/buffer.h')
| -rw-r--r-- | src/buffer.h | 310 |
1 files changed, 170 insertions, 140 deletions
diff --git a/src/buffer.h b/src/buffer.h index b1ace4663cf..b48791f306f 100644 --- a/src/buffer.h +++ b/src/buffer.h | |||
| @@ -482,142 +482,26 @@ struct buffer_text | |||
| 482 | 482 | ||
| 483 | struct buffer | 483 | struct buffer |
| 484 | { | 484 | { |
| 485 | /* Everything before the `name' slot must be of a non-Lisp_Object type, | 485 | /* HEADER.NEXT is the next buffer, in chain of all buffers, including killed |
| 486 | and every slot after `name' must be a Lisp_Object. | 486 | buffers. This chain, starting from all_buffers, is used only for garbage |
| 487 | 487 | collection, in order to collect killed buffers properly. Note that large | |
| 488 | Check out mark_buffer (alloc.c) to see why. */ | 488 | vectors and large pseudo-vector objects are all on another chain starting |
| 489 | 489 | from large_vectors. */ | |
| 490 | /* HEADER.NEXT is the next buffer, in chain of all buffers, | ||
| 491 | including killed buffers. | ||
| 492 | This chain is used only for garbage collection, in order to | ||
| 493 | collect killed buffers properly. | ||
| 494 | Note that vectors and most pseudovectors are all on one chain, | ||
| 495 | but buffers are on a separate chain of their own. */ | ||
| 496 | struct vectorlike_header header; | 490 | struct vectorlike_header header; |
| 497 | 491 | ||
| 498 | /* This structure holds the coordinates of the buffer contents | ||
| 499 | in ordinary buffers. In indirect buffers, this is not used. */ | ||
| 500 | struct buffer_text own_text; | ||
| 501 | |||
| 502 | /* This points to the `struct buffer_text' that used for this buffer. | ||
| 503 | In an ordinary buffer, this is the own_text field above. | ||
| 504 | In an indirect buffer, this is the own_text field of another buffer. */ | ||
| 505 | struct buffer_text *text; | ||
| 506 | |||
| 507 | /* Char position of point in buffer. */ | ||
| 508 | ptrdiff_t pt; | ||
| 509 | /* Byte position of point in buffer. */ | ||
| 510 | ptrdiff_t pt_byte; | ||
| 511 | /* Char position of beginning of accessible range. */ | ||
| 512 | ptrdiff_t begv; | ||
| 513 | /* Byte position of beginning of accessible range. */ | ||
| 514 | ptrdiff_t begv_byte; | ||
| 515 | /* Char position of end of accessible range. */ | ||
| 516 | ptrdiff_t zv; | ||
| 517 | /* Byte position of end of accessible range. */ | ||
| 518 | ptrdiff_t zv_byte; | ||
| 519 | |||
| 520 | /* In an indirect buffer, this points to the base buffer. | ||
| 521 | In an ordinary buffer, it is 0. */ | ||
| 522 | struct buffer *base_buffer; | ||
| 523 | |||
| 524 | /* A non-zero value in slot IDX means that per-buffer variable | ||
| 525 | with index IDX has a local value in this buffer. The index IDX | ||
| 526 | for a buffer-local variable is stored in that variable's slot | ||
| 527 | in buffer_local_flags as a Lisp integer. If the index is -1, | ||
| 528 | this means the variable is always local in all buffers. */ | ||
| 529 | #define MAX_PER_BUFFER_VARS 50 | ||
| 530 | char local_flags[MAX_PER_BUFFER_VARS]; | ||
| 531 | |||
| 532 | /* Set to the modtime of the visited file when read or written. | ||
| 533 | EMACS_NSECS (modtime) == NONEXISTENT_MODTIME_NSECS means | ||
| 534 | visited file was nonexistent. EMACS_NSECS (modtime) == | ||
| 535 | UNKNOWN_MODTIME_NSECS means visited file modtime unknown; | ||
| 536 | in no case complain about any mismatch on next save attempt. */ | ||
| 537 | #define NONEXISTENT_MODTIME_NSECS (-1) | ||
| 538 | #define UNKNOWN_MODTIME_NSECS (-2) | ||
| 539 | EMACS_TIME modtime; | ||
| 540 | /* Size of the file when modtime was set. This is used to detect the | ||
| 541 | case where the file grew while we were reading it, so the modtime | ||
| 542 | is still the same (since it's rounded up to seconds) but we're actually | ||
| 543 | not up-to-date. -1 means the size is unknown. Only meaningful if | ||
| 544 | modtime is actually set. */ | ||
| 545 | off_t modtime_size; | ||
| 546 | /* The value of text->modiff at the last auto-save. */ | ||
| 547 | EMACS_INT auto_save_modified; | ||
| 548 | /* The value of text->modiff at the last display error. | ||
| 549 | Redisplay of this buffer is inhibited until it changes again. */ | ||
| 550 | EMACS_INT display_error_modiff; | ||
| 551 | /* The time at which we detected a failure to auto-save, | ||
| 552 | Or 0 if we didn't have a failure. */ | ||
| 553 | time_t auto_save_failure_time; | ||
| 554 | /* Position in buffer at which display started | ||
| 555 | the last time this buffer was displayed. */ | ||
| 556 | ptrdiff_t last_window_start; | ||
| 557 | |||
| 558 | /* Set nonzero whenever the narrowing is changed in this buffer. */ | ||
| 559 | int clip_changed; | ||
| 560 | |||
| 561 | /* If the long line scan cache is enabled (i.e. the buffer-local | ||
| 562 | variable cache-long-line-scans is non-nil), newline_cache | ||
| 563 | points to the newline cache, and width_run_cache points to the | ||
| 564 | width run cache. | ||
| 565 | |||
| 566 | The newline cache records which stretches of the buffer are | ||
| 567 | known *not* to contain newlines, so that they can be skipped | ||
| 568 | quickly when we search for newlines. | ||
| 569 | |||
| 570 | The width run cache records which stretches of the buffer are | ||
| 571 | known to contain characters whose widths are all the same. If | ||
| 572 | the width run cache maps a character to a value > 0, that value is | ||
| 573 | the character's width; if it maps a character to zero, we don't | ||
| 574 | know what its width is. This allows compute_motion to process | ||
| 575 | such regions very quickly, using algebra instead of inspecting | ||
| 576 | each character. See also width_table, below. */ | ||
| 577 | struct region_cache *newline_cache; | ||
| 578 | struct region_cache *width_run_cache; | ||
| 579 | |||
| 580 | /* Non-zero means don't use redisplay optimizations for | ||
| 581 | displaying this buffer. */ | ||
| 582 | unsigned prevent_redisplay_optimizations_p : 1; | ||
| 583 | |||
| 584 | /* List of overlays that end at or before the current center, | ||
| 585 | in order of end-position. */ | ||
| 586 | struct Lisp_Overlay *overlays_before; | ||
| 587 | |||
| 588 | /* List of overlays that end after the current center, | ||
| 589 | in order of start-position. */ | ||
| 590 | struct Lisp_Overlay *overlays_after; | ||
| 591 | |||
| 592 | /* Position where the overlay lists are centered. */ | ||
| 593 | ptrdiff_t overlay_center; | ||
| 594 | |||
| 595 | /* Everything from here down must be a Lisp_Object. */ | ||
| 596 | /* buffer-local Lisp variables start at `undo_list', | ||
| 597 | tho only the ones from `name' on are GC'd normally. */ | ||
| 598 | #define FIRST_FIELD_PER_BUFFER undo_list | ||
| 599 | |||
| 600 | /* Changes in the buffer are recorded here for undo. | ||
| 601 | t means don't record anything. | ||
| 602 | This information belongs to the base buffer of an indirect buffer, | ||
| 603 | But we can't store it in the struct buffer_text | ||
| 604 | because local variables have to be right in the struct buffer. | ||
| 605 | So we copy it around in set_buffer_internal. | ||
| 606 | This comes before `name' because it is marked in a special way. */ | ||
| 607 | Lisp_Object BUFFER_INTERNAL_FIELD (undo_list); | ||
| 608 | |||
| 609 | /* The name of this buffer. */ | 492 | /* The name of this buffer. */ |
| 610 | Lisp_Object BUFFER_INTERNAL_FIELD (name); | 493 | Lisp_Object BUFFER_INTERNAL_FIELD (name); |
| 611 | 494 | ||
| 612 | /* The name of the file visited in this buffer, or nil. */ | 495 | /* The name of the file visited in this buffer, or nil. */ |
| 613 | Lisp_Object BUFFER_INTERNAL_FIELD (filename); | 496 | Lisp_Object BUFFER_INTERNAL_FIELD (filename); |
| 614 | /* Dir for expanding relative file names. */ | 497 | |
| 498 | /* Directory for expanding relative file names. */ | ||
| 615 | Lisp_Object BUFFER_INTERNAL_FIELD (directory); | 499 | Lisp_Object BUFFER_INTERNAL_FIELD (directory); |
| 616 | /* True if this buffer has been backed up (if you write to the | 500 | |
| 617 | visited file and it hasn't been backed up, then a backup will | 501 | /* True if this buffer has been backed up (if you write to the visited |
| 618 | be made). */ | 502 | file and it hasn't been backed up, then a backup will be made). */ |
| 619 | /* This isn't really used by the C code, so could be deleted. */ | ||
| 620 | Lisp_Object BUFFER_INTERNAL_FIELD (backed_up); | 503 | Lisp_Object BUFFER_INTERNAL_FIELD (backed_up); |
| 504 | |||
| 621 | /* Length of file when last read or saved. | 505 | /* Length of file when last read or saved. |
| 622 | -1 means auto saving turned off because buffer shrank a lot. | 506 | -1 means auto saving turned off because buffer shrank a lot. |
| 623 | -2 means don't turn off auto saving if buffer shrinks. | 507 | -2 means don't turn off auto saving if buffer shrinks. |
| @@ -625,6 +509,7 @@ struct buffer | |||
| 625 | This is not in the struct buffer_text | 509 | This is not in the struct buffer_text |
| 626 | because it's not used in indirect buffers at all. */ | 510 | because it's not used in indirect buffers at all. */ |
| 627 | Lisp_Object BUFFER_INTERNAL_FIELD (save_length); | 511 | Lisp_Object BUFFER_INTERNAL_FIELD (save_length); |
| 512 | |||
| 628 | /* File name used for auto-saving this buffer. | 513 | /* File name used for auto-saving this buffer. |
| 629 | This is not in the struct buffer_text | 514 | This is not in the struct buffer_text |
| 630 | because it's not used in indirect buffers at all. */ | 515 | because it's not used in indirect buffers at all. */ |
| @@ -632,6 +517,7 @@ struct buffer | |||
| 632 | 517 | ||
| 633 | /* Non-nil if buffer read-only. */ | 518 | /* Non-nil if buffer read-only. */ |
| 634 | Lisp_Object BUFFER_INTERNAL_FIELD (read_only); | 519 | Lisp_Object BUFFER_INTERNAL_FIELD (read_only); |
| 520 | |||
| 635 | /* "The mark". This is a marker which may | 521 | /* "The mark". This is a marker which may |
| 636 | point into this buffer or may point nowhere. */ | 522 | point into this buffer or may point nowhere. */ |
| 637 | Lisp_Object BUFFER_INTERNAL_FIELD (mark); | 523 | Lisp_Object BUFFER_INTERNAL_FIELD (mark); |
| @@ -641,10 +527,12 @@ struct buffer | |||
| 641 | symbols, just the symbol appears as the element. */ | 527 | symbols, just the symbol appears as the element. */ |
| 642 | Lisp_Object BUFFER_INTERNAL_FIELD (local_var_alist); | 528 | Lisp_Object BUFFER_INTERNAL_FIELD (local_var_alist); |
| 643 | 529 | ||
| 644 | /* Symbol naming major mode (eg, lisp-mode). */ | 530 | /* Symbol naming major mode (e.g., lisp-mode). */ |
| 645 | Lisp_Object BUFFER_INTERNAL_FIELD (major_mode); | 531 | Lisp_Object BUFFER_INTERNAL_FIELD (major_mode); |
| 646 | /* Pretty name of major mode (eg, "Lisp"). */ | 532 | |
| 533 | /* Pretty name of major mode (e.g., "Lisp"). */ | ||
| 647 | Lisp_Object BUFFER_INTERNAL_FIELD (mode_name); | 534 | Lisp_Object BUFFER_INTERNAL_FIELD (mode_name); |
| 535 | |||
| 648 | /* Mode line element that controls format of mode line. */ | 536 | /* Mode line element that controls format of mode line. */ |
| 649 | Lisp_Object BUFFER_INTERNAL_FIELD (mode_line_format); | 537 | Lisp_Object BUFFER_INTERNAL_FIELD (mode_line_format); |
| 650 | 538 | ||
| @@ -654,10 +542,13 @@ struct buffer | |||
| 654 | 542 | ||
| 655 | /* Keys that are bound local to this buffer. */ | 543 | /* Keys that are bound local to this buffer. */ |
| 656 | Lisp_Object BUFFER_INTERNAL_FIELD (keymap); | 544 | Lisp_Object BUFFER_INTERNAL_FIELD (keymap); |
| 545 | |||
| 657 | /* This buffer's local abbrev table. */ | 546 | /* This buffer's local abbrev table. */ |
| 658 | Lisp_Object BUFFER_INTERNAL_FIELD (abbrev_table); | 547 | Lisp_Object BUFFER_INTERNAL_FIELD (abbrev_table); |
| 548 | |||
| 659 | /* This buffer's syntax table. */ | 549 | /* This buffer's syntax table. */ |
| 660 | Lisp_Object BUFFER_INTERNAL_FIELD (syntax_table); | 550 | Lisp_Object BUFFER_INTERNAL_FIELD (syntax_table); |
| 551 | |||
| 661 | /* This buffer's category table. */ | 552 | /* This buffer's category table. */ |
| 662 | Lisp_Object BUFFER_INTERNAL_FIELD (category_table); | 553 | Lisp_Object BUFFER_INTERNAL_FIELD (category_table); |
| 663 | 554 | ||
| @@ -668,48 +559,61 @@ struct buffer | |||
| 668 | Lisp_Object BUFFER_INTERNAL_FIELD (tab_width); | 559 | Lisp_Object BUFFER_INTERNAL_FIELD (tab_width); |
| 669 | Lisp_Object BUFFER_INTERNAL_FIELD (fill_column); | 560 | Lisp_Object BUFFER_INTERNAL_FIELD (fill_column); |
| 670 | Lisp_Object BUFFER_INTERNAL_FIELD (left_margin); | 561 | Lisp_Object BUFFER_INTERNAL_FIELD (left_margin); |
| 562 | |||
| 671 | /* Function to call when insert space past fill column. */ | 563 | /* Function to call when insert space past fill column. */ |
| 672 | Lisp_Object BUFFER_INTERNAL_FIELD (auto_fill_function); | 564 | Lisp_Object BUFFER_INTERNAL_FIELD (auto_fill_function); |
| 673 | 565 | ||
| 674 | /* Case table for case-conversion in this buffer. | 566 | /* Case table for case-conversion in this buffer. |
| 675 | This char-table maps each char into its lower-case version. */ | 567 | This char-table maps each char into its lower-case version. */ |
| 676 | Lisp_Object BUFFER_INTERNAL_FIELD (downcase_table); | 568 | Lisp_Object BUFFER_INTERNAL_FIELD (downcase_table); |
| 569 | |||
| 677 | /* Char-table mapping each char to its upper-case version. */ | 570 | /* Char-table mapping each char to its upper-case version. */ |
| 678 | Lisp_Object BUFFER_INTERNAL_FIELD (upcase_table); | 571 | Lisp_Object BUFFER_INTERNAL_FIELD (upcase_table); |
| 572 | |||
| 679 | /* Char-table for conversion for case-folding search. */ | 573 | /* Char-table for conversion for case-folding search. */ |
| 680 | Lisp_Object BUFFER_INTERNAL_FIELD (case_canon_table); | 574 | Lisp_Object BUFFER_INTERNAL_FIELD (case_canon_table); |
| 575 | |||
| 681 | /* Char-table of equivalences for case-folding search. */ | 576 | /* Char-table of equivalences for case-folding search. */ |
| 682 | Lisp_Object BUFFER_INTERNAL_FIELD (case_eqv_table); | 577 | Lisp_Object BUFFER_INTERNAL_FIELD (case_eqv_table); |
| 683 | 578 | ||
| 684 | /* Non-nil means do not display continuation lines. */ | 579 | /* Non-nil means do not display continuation lines. */ |
| 685 | Lisp_Object BUFFER_INTERNAL_FIELD (truncate_lines); | 580 | Lisp_Object BUFFER_INTERNAL_FIELD (truncate_lines); |
| 581 | |||
| 686 | /* Non-nil means to use word wrapping when displaying continuation lines. */ | 582 | /* Non-nil means to use word wrapping when displaying continuation lines. */ |
| 687 | Lisp_Object BUFFER_INTERNAL_FIELD (word_wrap); | 583 | Lisp_Object BUFFER_INTERNAL_FIELD (word_wrap); |
| 584 | |||
| 688 | /* Non-nil means display ctl chars with uparrow. */ | 585 | /* Non-nil means display ctl chars with uparrow. */ |
| 689 | Lisp_Object BUFFER_INTERNAL_FIELD (ctl_arrow); | 586 | Lisp_Object BUFFER_INTERNAL_FIELD (ctl_arrow); |
| 587 | |||
| 690 | /* Non-nil means reorder bidirectional text for display in the | 588 | /* Non-nil means reorder bidirectional text for display in the |
| 691 | visual order. */ | 589 | visual order. */ |
| 692 | Lisp_Object BUFFER_INTERNAL_FIELD (bidi_display_reordering); | 590 | Lisp_Object BUFFER_INTERNAL_FIELD (bidi_display_reordering); |
| 591 | |||
| 693 | /* If non-nil, specifies which direction of text to force in all the | 592 | /* If non-nil, specifies which direction of text to force in all the |
| 694 | paragraphs of the buffer. Nil means determine paragraph | 593 | paragraphs of the buffer. Nil means determine paragraph |
| 695 | direction dynamically for each paragraph. */ | 594 | direction dynamically for each paragraph. */ |
| 696 | Lisp_Object BUFFER_INTERNAL_FIELD (bidi_paragraph_direction); | 595 | Lisp_Object BUFFER_INTERNAL_FIELD (bidi_paragraph_direction); |
| 596 | |||
| 697 | /* Non-nil means do selective display; | 597 | /* Non-nil means do selective display; |
| 698 | see doc string in syms_of_buffer (buffer.c) for details. */ | 598 | see doc string in syms_of_buffer (buffer.c) for details. */ |
| 699 | Lisp_Object BUFFER_INTERNAL_FIELD (selective_display); | 599 | Lisp_Object BUFFER_INTERNAL_FIELD (selective_display); |
| 700 | #ifndef old | 600 | |
| 701 | /* Non-nil means show ... at end of line followed by invisible lines. */ | 601 | /* Non-nil means show ... at end of line followed by invisible lines. */ |
| 702 | Lisp_Object BUFFER_INTERNAL_FIELD (selective_display_ellipses); | 602 | Lisp_Object BUFFER_INTERNAL_FIELD (selective_display_ellipses); |
| 703 | #endif | 603 | |
| 704 | /* Alist of (FUNCTION . STRING) for each minor mode enabled in buffer. */ | 604 | /* Alist of (FUNCTION . STRING) for each minor mode enabled in buffer. */ |
| 705 | Lisp_Object BUFFER_INTERNAL_FIELD (minor_modes); | 605 | Lisp_Object BUFFER_INTERNAL_FIELD (minor_modes); |
| 606 | |||
| 706 | /* t if "self-insertion" should overwrite; `binary' if it should also | 607 | /* t if "self-insertion" should overwrite; `binary' if it should also |
| 707 | overwrite newlines and tabs - for editing executables and the like. */ | 608 | overwrite newlines and tabs - for editing executables and the like. */ |
| 708 | Lisp_Object BUFFER_INTERNAL_FIELD (overwrite_mode); | 609 | Lisp_Object BUFFER_INTERNAL_FIELD (overwrite_mode); |
| 709 | /* non-nil means abbrev mode is on. Expand abbrevs automatically. */ | 610 | |
| 611 | /* Non-nil means abbrev mode is on. Expand abbrevs automatically. */ | ||
| 710 | Lisp_Object BUFFER_INTERNAL_FIELD (abbrev_mode); | 612 | Lisp_Object BUFFER_INTERNAL_FIELD (abbrev_mode); |
| 613 | |||
| 711 | /* Display table to use for text in this buffer. */ | 614 | /* Display table to use for text in this buffer. */ |
| 712 | Lisp_Object BUFFER_INTERNAL_FIELD (display_table); | 615 | Lisp_Object BUFFER_INTERNAL_FIELD (display_table); |
| 616 | |||
| 713 | /* t means the mark and region are currently active. */ | 617 | /* t means the mark and region are currently active. */ |
| 714 | Lisp_Object BUFFER_INTERNAL_FIELD (mark_active); | 618 | Lisp_Object BUFFER_INTERNAL_FIELD (mark_active); |
| 715 | 619 | ||
| @@ -776,11 +680,13 @@ struct buffer | |||
| 776 | 680 | ||
| 777 | /* Widths of left and right marginal areas for windows displaying | 681 | /* Widths of left and right marginal areas for windows displaying |
| 778 | this buffer. */ | 682 | this buffer. */ |
| 779 | Lisp_Object BUFFER_INTERNAL_FIELD (left_margin_cols), BUFFER_INTERNAL_FIELD (right_margin_cols); | 683 | Lisp_Object BUFFER_INTERNAL_FIELD (left_margin_cols); |
| 684 | Lisp_Object BUFFER_INTERNAL_FIELD (right_margin_cols); | ||
| 780 | 685 | ||
| 781 | /* Widths of left and right fringe areas for windows displaying | 686 | /* Widths of left and right fringe areas for windows displaying |
| 782 | this buffer. */ | 687 | this buffer. */ |
| 783 | Lisp_Object BUFFER_INTERNAL_FIELD (left_fringe_width), BUFFER_INTERNAL_FIELD (right_fringe_width); | 688 | Lisp_Object BUFFER_INTERNAL_FIELD (left_fringe_width); |
| 689 | Lisp_Object BUFFER_INTERNAL_FIELD (right_fringe_width); | ||
| 784 | 690 | ||
| 785 | /* Non-nil means fringes are drawn outside display margins; | 691 | /* Non-nil means fringes are drawn outside display margins; |
| 786 | othersize draw them between margin areas and text. */ | 692 | othersize draw them between margin areas and text. */ |
| @@ -788,7 +694,8 @@ struct buffer | |||
| 788 | 694 | ||
| 789 | /* Width and type of scroll bar areas for windows displaying | 695 | /* Width and type of scroll bar areas for windows displaying |
| 790 | this buffer. */ | 696 | this buffer. */ |
| 791 | Lisp_Object BUFFER_INTERNAL_FIELD (scroll_bar_width), BUFFER_INTERNAL_FIELD (vertical_scroll_bar_type); | 697 | Lisp_Object BUFFER_INTERNAL_FIELD (scroll_bar_width); |
| 698 | Lisp_Object BUFFER_INTERNAL_FIELD (vertical_scroll_bar_type); | ||
| 792 | 699 | ||
| 793 | /* Non-nil means indicate lines not displaying text (in a style | 700 | /* Non-nil means indicate lines not displaying text (in a style |
| 794 | like vi). */ | 701 | like vi). */ |
| @@ -826,13 +733,127 @@ struct buffer | |||
| 826 | in the display of this buffer. */ | 733 | in the display of this buffer. */ |
| 827 | Lisp_Object BUFFER_INTERNAL_FIELD (extra_line_spacing); | 734 | Lisp_Object BUFFER_INTERNAL_FIELD (extra_line_spacing); |
| 828 | 735 | ||
| 829 | /* *Cursor type to display in non-selected windows. | 736 | /* Cursor type to display in non-selected windows. |
| 830 | t means to use hollow box cursor. | 737 | t means to use hollow box cursor. |
| 831 | See `cursor-type' for other values. */ | 738 | See `cursor-type' for other values. */ |
| 832 | Lisp_Object BUFFER_INTERNAL_FIELD (cursor_in_non_selected_windows); | 739 | Lisp_Object BUFFER_INTERNAL_FIELD (cursor_in_non_selected_windows); |
| 833 | 740 | ||
| 834 | /* This must be the last field in the above list. */ | 741 | /* No more Lisp_Object beyond this point. Except undo_list, |
| 835 | #define LAST_FIELD_PER_BUFFER cursor_in_non_selected_windows | 742 | which is handled specially in Fgarbage_collect . */ |
| 743 | |||
| 744 | /* This structure holds the coordinates of the buffer contents | ||
| 745 | in ordinary buffers. In indirect buffers, this is not used. */ | ||
| 746 | struct buffer_text own_text; | ||
| 747 | |||
| 748 | /* This points to the `struct buffer_text' that used for this buffer. | ||
| 749 | In an ordinary buffer, this is the own_text field above. | ||
| 750 | In an indirect buffer, this is the own_text field of another buffer. */ | ||
| 751 | struct buffer_text *text; | ||
| 752 | |||
| 753 | /* Char position of point in buffer. */ | ||
| 754 | ptrdiff_t pt; | ||
| 755 | |||
| 756 | /* Byte position of point in buffer. */ | ||
| 757 | ptrdiff_t pt_byte; | ||
| 758 | |||
| 759 | /* Char position of beginning of accessible range. */ | ||
| 760 | ptrdiff_t begv; | ||
| 761 | |||
| 762 | /* Byte position of beginning of accessible range. */ | ||
| 763 | ptrdiff_t begv_byte; | ||
| 764 | |||
| 765 | /* Char position of end of accessible range. */ | ||
| 766 | ptrdiff_t zv; | ||
| 767 | |||
| 768 | /* Byte position of end of accessible range. */ | ||
| 769 | ptrdiff_t zv_byte; | ||
| 770 | |||
| 771 | /* In an indirect buffer, this points to the base buffer. | ||
| 772 | In an ordinary buffer, it is 0. */ | ||
| 773 | struct buffer *base_buffer; | ||
| 774 | |||
| 775 | /* 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 | ||
| 777 | for a buffer-local variable is stored in that variable's slot | ||
| 778 | in buffer_local_flags as a Lisp integer. If the index is -1, | ||
| 779 | this means the variable is always local in all buffers. */ | ||
| 780 | #define MAX_PER_BUFFER_VARS 50 | ||
| 781 | char local_flags[MAX_PER_BUFFER_VARS]; | ||
| 782 | |||
| 783 | /* Set to the modtime of the visited file when read or written. | ||
| 784 | EMACS_NSECS (modtime) == NONEXISTENT_MODTIME_NSECS means | ||
| 785 | visited file was nonexistent. EMACS_NSECS (modtime) == | ||
| 786 | UNKNOWN_MODTIME_NSECS means visited file modtime unknown; | ||
| 787 | in no case complain about any mismatch on next save attempt. */ | ||
| 788 | #define NONEXISTENT_MODTIME_NSECS (-1) | ||
| 789 | #define UNKNOWN_MODTIME_NSECS (-2) | ||
| 790 | EMACS_TIME modtime; | ||
| 791 | |||
| 792 | /* Size of the file when modtime was set. This is used to detect the | ||
| 793 | case where the file grew while we were reading it, so the modtime | ||
| 794 | is still the same (since it's rounded up to seconds) but we're actually | ||
| 795 | not up-to-date. -1 means the size is unknown. Only meaningful if | ||
| 796 | modtime is actually set. */ | ||
| 797 | off_t modtime_size; | ||
| 798 | |||
| 799 | /* The value of text->modiff at the last auto-save. */ | ||
| 800 | EMACS_INT auto_save_modified; | ||
| 801 | |||
| 802 | /* The value of text->modiff at the last display error. | ||
| 803 | Redisplay of this buffer is inhibited until it changes again. */ | ||
| 804 | EMACS_INT display_error_modiff; | ||
| 805 | |||
| 806 | /* The time at which we detected a failure to auto-save, | ||
| 807 | Or 0 if we didn't have a failure. */ | ||
| 808 | time_t auto_save_failure_time; | ||
| 809 | |||
| 810 | /* Position in buffer at which display started | ||
| 811 | the last time this buffer was displayed. */ | ||
| 812 | ptrdiff_t last_window_start; | ||
| 813 | |||
| 814 | /* If the long line scan cache is enabled (i.e. the buffer-local | ||
| 815 | variable cache-long-line-scans is non-nil), newline_cache | ||
| 816 | points to the newline cache, and width_run_cache points to the | ||
| 817 | width run cache. | ||
| 818 | |||
| 819 | The newline cache records which stretches of the buffer are | ||
| 820 | known *not* to contain newlines, so that they can be skipped | ||
| 821 | quickly when we search for newlines. | ||
| 822 | |||
| 823 | The width run cache records which stretches of the buffer are | ||
| 824 | known to contain characters whose widths are all the same. If | ||
| 825 | the width run cache maps a character to a value > 0, that value is | ||
| 826 | the character's width; if it maps a character to zero, we don't | ||
| 827 | know what its width is. This allows compute_motion to process | ||
| 828 | such regions very quickly, using algebra instead of inspecting | ||
| 829 | each character. See also width_table, below. */ | ||
| 830 | struct region_cache *newline_cache; | ||
| 831 | struct region_cache *width_run_cache; | ||
| 832 | |||
| 833 | /* Non-zero means don't use redisplay optimizations for | ||
| 834 | displaying this buffer. */ | ||
| 835 | unsigned prevent_redisplay_optimizations_p : 1; | ||
| 836 | |||
| 837 | /* Non-zero whenever the narrowing is changed in this buffer. */ | ||
| 838 | unsigned clip_changed : 1; | ||
| 839 | |||
| 840 | /* List of overlays that end at or before the current center, | ||
| 841 | in order of end-position. */ | ||
| 842 | struct Lisp_Overlay *overlays_before; | ||
| 843 | |||
| 844 | /* List of overlays that end after the current center, | ||
| 845 | in order of start-position. */ | ||
| 846 | struct Lisp_Overlay *overlays_after; | ||
| 847 | |||
| 848 | /* Position where the overlay lists are centered. */ | ||
| 849 | ptrdiff_t overlay_center; | ||
| 850 | |||
| 851 | /* Changes in the buffer are recorded here for undo, and t means | ||
| 852 | don't record anything. This information belongs to the base | ||
| 853 | 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 | ||
| 855 | the struct buffer. So we copy it around in set_buffer_internal. */ | ||
| 856 | Lisp_Object BUFFER_INTERNAL_FIELD (undo_list); | ||
| 836 | }; | 857 | }; |
| 837 | 858 | ||
| 838 | 859 | ||
| @@ -896,10 +917,10 @@ extern void mmap_set_vars (int); | |||
| 896 | 917 | ||
| 897 | #define GET_OVERLAYS_AT(posn, overlays, noverlays, nextp, chrq) \ | 918 | #define GET_OVERLAYS_AT(posn, overlays, noverlays, nextp, chrq) \ |
| 898 | do { \ | 919 | do { \ |
| 899 | ptrdiff_t maxlen = 40; \ | 920 | ptrdiff_t maxlen = 40; \ |
| 900 | overlays = (Lisp_Object *) alloca (maxlen * sizeof (Lisp_Object)); \ | 921 | overlays = (Lisp_Object *) alloca (maxlen * sizeof (Lisp_Object)); \ |
| 901 | noverlays = overlays_at (posn, 0, &overlays, &maxlen, \ | 922 | noverlays = overlays_at (posn, 0, &overlays, &maxlen, \ |
| 902 | nextp, NULL, chrq); \ | 923 | nextp, NULL, chrq); \ |
| 903 | if (noverlays > maxlen) \ | 924 | if (noverlays > maxlen) \ |
| 904 | { \ | 925 | { \ |
| 905 | maxlen = noverlays; \ | 926 | maxlen = noverlays; \ |
| @@ -992,6 +1013,15 @@ extern int last_per_buffer_idx; | |||
| 992 | #define PER_BUFFER_VAR_OFFSET(VAR) \ | 1013 | #define PER_BUFFER_VAR_OFFSET(VAR) \ |
| 993 | offsetof (struct buffer, BUFFER_INTERNAL_FIELD (VAR)) | 1014 | offsetof (struct buffer, BUFFER_INTERNAL_FIELD (VAR)) |
| 994 | 1015 | ||
| 1016 | /* Used to iterate over normal Lisp_Object fields of struct buffer (all | ||
| 1017 | Lisp_Objects except undo_list). If you add, remove, or reorder | ||
| 1018 | Lisp_Objects in a struct buffer, make sure that this is still correct. */ | ||
| 1019 | |||
| 1020 | #define for_each_per_buffer_object_at(offset) \ | ||
| 1021 | for (offset = PER_BUFFER_VAR_OFFSET (name); \ | ||
| 1022 | offset <= PER_BUFFER_VAR_OFFSET (cursor_in_non_selected_windows); \ | ||
| 1023 | offset += sizeof (Lisp_Object)) | ||
| 1024 | |||
| 995 | /* Return the index of buffer-local variable VAR. Each per-buffer | 1025 | /* Return the index of buffer-local variable VAR. Each per-buffer |
| 996 | variable has an index > 0 associated with it, except when it always | 1026 | variable has an index > 0 associated with it, except when it always |
| 997 | has buffer-local values, in which case the index is -1. If this is | 1027 | has buffer-local values, in which case the index is -1. If this is |