diff options
| author | Joakim Verona | 2011-06-16 00:22:07 +0200 |
|---|---|---|
| committer | Joakim Verona | 2011-06-16 00:22:07 +0200 |
| commit | a7513ade3bc0fe79430d5541d88c9dcda0932bec (patch) | |
| tree | 4383951ba698a11e9f8933a9d8c72e00aa872a10 /src/buffer.h | |
| parent | 4bd51ad5c3445b644dfb017d5b57b10a90aa325f (diff) | |
| parent | 4bba86e6210a74326e843a8fdc8409127105e1fe (diff) | |
| download | emacs-a7513ade3bc0fe79430d5541d88c9dcda0932bec.tar.gz emacs-a7513ade3bc0fe79430d5541d88c9dcda0932bec.zip | |
merge from upstream
Diffstat (limited to 'src/buffer.h')
| -rw-r--r-- | src/buffer.h | 247 |
1 files changed, 149 insertions, 98 deletions
diff --git a/src/buffer.h b/src/buffer.h index 31f96040b2d..dc1d62beb00 100644 --- a/src/buffer.h +++ b/src/buffer.h | |||
| @@ -18,6 +18,7 @@ GNU General Public License for more details. | |||
| 18 | You should have received a copy of the GNU General Public License | 18 | 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 <time.h> /* for time_t */ | ||
| 21 | 22 | ||
| 22 | /* Accessing the parameters of the current buffer. */ | 23 | /* Accessing the parameters of the current buffer. */ |
| 23 | 24 | ||
| @@ -107,27 +108,46 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 107 | #define BUF_BEG(buf) (BEG) | 108 | #define BUF_BEG(buf) (BEG) |
| 108 | #define BUF_BEG_BYTE(buf) (BEG_BYTE) | 109 | #define BUF_BEG_BYTE(buf) (BEG_BYTE) |
| 109 | 110 | ||
| 110 | /* !!!FIXME: all the BUF_BEGV/BUF_ZV/BUF_PT macros are flawed: | 111 | /* The BUF_BEGV[_BYTE], BUF_ZV[_BYTE], and BUF_PT[_BYTE] macros cannot |
| 111 | on indirect (or base) buffers, that value is only correct if that buffer | 112 | be used for assignment; use SET_BUF_* macros below for that. */ |
| 112 | is the current_buffer, or if the buffer's text hasn't been modified (via | ||
| 113 | an indirect buffer) since it was last current. */ | ||
| 114 | 113 | ||
| 115 | /* Position of beginning of accessible range of buffer. */ | 114 | /* Position of beginning of accessible range of buffer. */ |
| 116 | #define BUF_BEGV(buf) ((buf)->begv) | 115 | #define BUF_BEGV(buf) \ |
| 117 | #define BUF_BEGV_BYTE(buf) ((buf)->begv_byte) | 116 | (buf == current_buffer ? BEGV \ |
| 117 | : NILP (BVAR (buf, begv_marker)) ? buf->begv \ | ||
| 118 | : marker_position (BVAR (buf, begv_marker))) | ||
| 119 | |||
| 120 | #define BUF_BEGV_BYTE(buf) \ | ||
| 121 | (buf == current_buffer ? BEGV_BYTE \ | ||
| 122 | : NILP (BVAR (buf, begv_marker)) ? buf->begv_byte \ | ||
| 123 | : marker_byte_position (BVAR (buf, begv_marker))) | ||
| 118 | 124 | ||
| 119 | /* Position of point in buffer. */ | 125 | /* Position of point in buffer. */ |
| 120 | #define BUF_PT(buf) ((buf)->pt) | 126 | #define BUF_PT(buf) \ |
| 121 | #define BUF_PT_BYTE(buf) ((buf)->pt_byte) | 127 | (buf == current_buffer ? PT \ |
| 128 | : NILP (BVAR (buf, pt_marker)) ? buf->pt \ | ||
| 129 | : marker_position (BVAR (buf, pt_marker))) | ||
| 130 | |||
| 131 | #define BUF_PT_BYTE(buf) \ | ||
| 132 | (buf == current_buffer ? PT_BYTE \ | ||
| 133 | : NILP (BVAR (buf, pt_marker)) ? buf->pt_byte \ | ||
| 134 | : marker_byte_position (BVAR (buf, pt_marker))) | ||
| 135 | |||
| 136 | /* Position of end of accessible range of buffer. */ | ||
| 137 | #define BUF_ZV(buf) \ | ||
| 138 | (buf == current_buffer ? ZV \ | ||
| 139 | : NILP (BVAR (buf, zv_marker)) ? buf->zv \ | ||
| 140 | : marker_position (BVAR (buf, zv_marker))) | ||
| 141 | |||
| 142 | #define BUF_ZV_BYTE(buf) \ | ||
| 143 | (buf == current_buffer ? ZV_BYTE \ | ||
| 144 | : NILP (BVAR (buf, zv_marker)) ? buf->zv_byte \ | ||
| 145 | : marker_byte_position (BVAR (buf, zv_marker))) | ||
| 122 | 146 | ||
| 123 | /* Position of gap in buffer. */ | 147 | /* Position of gap in buffer. */ |
| 124 | #define BUF_GPT(buf) ((buf)->text->gpt) | 148 | #define BUF_GPT(buf) ((buf)->text->gpt) |
| 125 | #define BUF_GPT_BYTE(buf) ((buf)->text->gpt_byte) | 149 | #define BUF_GPT_BYTE(buf) ((buf)->text->gpt_byte) |
| 126 | 150 | ||
| 127 | /* Position of end of accessible range of buffer. */ | ||
| 128 | #define BUF_ZV(buf) ((buf)->zv) | ||
| 129 | #define BUF_ZV_BYTE(buf) ((buf)->zv_byte) | ||
| 130 | |||
| 131 | /* Position of end of buffer. */ | 151 | /* Position of end of buffer. */ |
| 132 | #define BUF_Z(buf) ((buf)->text->z) | 152 | #define BUF_Z(buf) ((buf)->text->z) |
| 133 | #define BUF_Z_BYTE(buf) ((buf)->text->z_byte) | 153 | #define BUF_Z_BYTE(buf) ((buf)->text->z_byte) |
| @@ -235,8 +255,6 @@ extern void enlarge_buffer_text (struct buffer *, EMACS_INT); | |||
| 235 | 255 | ||
| 236 | /* Macros for setting the BEGV, ZV or PT of a given buffer. | 256 | /* Macros for setting the BEGV, ZV or PT of a given buffer. |
| 237 | 257 | ||
| 238 | SET_BUF_PT* seet to be redundant. Get rid of them? | ||
| 239 | |||
| 240 | The ..._BOTH macros take both a charpos and a bytepos, | 258 | The ..._BOTH macros take both a charpos and a bytepos, |
| 241 | which must correspond to each other. | 259 | which must correspond to each other. |
| 242 | 260 | ||
| @@ -289,6 +307,11 @@ do \ | |||
| 289 | } \ | 307 | } \ |
| 290 | while (0) | 308 | while (0) |
| 291 | 309 | ||
| 310 | /* Maximum number of bytes in a buffer. | ||
| 311 | A buffer cannot contain more bytes than a 1-origin fixnum can represent, | ||
| 312 | nor can it be so large that C pointer arithmetic stops working. */ | ||
| 313 | #define BUF_BYTES_MAX min (MOST_POSITIVE_FIXNUM - 1, min (SIZE_MAX, PTRDIFF_MAX)) | ||
| 314 | |||
| 292 | /* Return the address of byte position N in current buffer. */ | 315 | /* Return the address of byte position N in current buffer. */ |
| 293 | 316 | ||
| 294 | #define BYTE_POS_ADDR(n) \ | 317 | #define BYTE_POS_ADDR(n) \ |
| @@ -315,13 +338,13 @@ while (0) | |||
| 315 | 338 | ||
| 316 | #define PTR_BYTE_POS(ptr) \ | 339 | #define PTR_BYTE_POS(ptr) \ |
| 317 | ((ptr) - (current_buffer)->text->beg \ | 340 | ((ptr) - (current_buffer)->text->beg \ |
| 318 | - (ptr - (current_buffer)->text->beg <= (unsigned) (GPT_BYTE - BEG_BYTE) ? 0 : GAP_SIZE) \ | 341 | - (ptr - (current_buffer)->text->beg <= GPT_BYTE - BEG_BYTE ? 0 : GAP_SIZE) \ |
| 319 | + BEG_BYTE) | 342 | + BEG_BYTE) |
| 320 | 343 | ||
| 321 | /* Return character at byte position POS. */ | 344 | /* Return character at byte position POS. */ |
| 322 | 345 | ||
| 323 | #define FETCH_CHAR(pos) \ | 346 | #define FETCH_CHAR(pos) \ |
| 324 | (!NILP (current_buffer->enable_multibyte_characters) \ | 347 | (!NILP (BVAR (current_buffer, enable_multibyte_characters)) \ |
| 325 | ? FETCH_MULTIBYTE_CHAR ((pos)) \ | 348 | ? FETCH_MULTIBYTE_CHAR ((pos)) \ |
| 326 | : FETCH_BYTE ((pos))) | 349 | : FETCH_BYTE ((pos))) |
| 327 | 350 | ||
| @@ -346,7 +369,7 @@ extern unsigned char *_fetch_multibyte_char_p; | |||
| 346 | multibyte. */ | 369 | multibyte. */ |
| 347 | 370 | ||
| 348 | #define FETCH_CHAR_AS_MULTIBYTE(pos) \ | 371 | #define FETCH_CHAR_AS_MULTIBYTE(pos) \ |
| 349 | (!NILP (current_buffer->enable_multibyte_characters) \ | 372 | (!NILP (BVAR (current_buffer, enable_multibyte_characters)) \ |
| 350 | ? FETCH_MULTIBYTE_CHAR ((pos)) \ | 373 | ? FETCH_MULTIBYTE_CHAR ((pos)) \ |
| 351 | : UNIBYTE_TO_CHAR (FETCH_BYTE ((pos)))) | 374 | : UNIBYTE_TO_CHAR (FETCH_BYTE ((pos)))) |
| 352 | 375 | ||
| @@ -374,7 +397,7 @@ extern unsigned char *_fetch_multibyte_char_p; | |||
| 374 | 397 | ||
| 375 | #define BUF_PTR_BYTE_POS(buf, ptr) \ | 398 | #define BUF_PTR_BYTE_POS(buf, ptr) \ |
| 376 | ((ptr) - (buf)->text->beg \ | 399 | ((ptr) - (buf)->text->beg \ |
| 377 | - (ptr - (buf)->text->beg <= (unsigned) (BUF_GPT_BYTE ((buf)) - BEG_BYTE)\ | 400 | - (ptr - (buf)->text->beg <= BUF_GPT_BYTE (buf) - BEG_BYTE \ |
| 378 | ? 0 : BUF_GAP_SIZE ((buf))) \ | 401 | ? 0 : BUF_GAP_SIZE ((buf))) \ |
| 379 | + BEG_BYTE) | 402 | + BEG_BYTE) |
| 380 | 403 | ||
| @@ -464,6 +487,15 @@ struct buffer_text | |||
| 464 | int inhibit_shrinking; | 487 | int inhibit_shrinking; |
| 465 | }; | 488 | }; |
| 466 | 489 | ||
| 490 | /* Lisp fields in struct buffer are hidden from most code and accessed | ||
| 491 | via the BVAR macro, below. Only select pieces of code, like the GC, | ||
| 492 | are allowed to use BUFFER_INTERNAL_FIELD. */ | ||
| 493 | #define BUFFER_INTERNAL_FIELD(field) field ## _ | ||
| 494 | |||
| 495 | /* Most code should use this macro to access Lisp fields in struct | ||
| 496 | buffer. */ | ||
| 497 | #define BVAR(buf, field) ((buf)->BUFFER_INTERNAL_FIELD (field)) | ||
| 498 | |||
| 467 | /* This is the structure that the buffer Lisp object points to. */ | 499 | /* This is the structure that the buffer Lisp object points to. */ |
| 468 | 500 | ||
| 469 | struct buffer | 501 | struct buffer |
| @@ -473,14 +505,13 @@ struct buffer | |||
| 473 | 505 | ||
| 474 | Check out mark_buffer (alloc.c) to see why. */ | 506 | Check out mark_buffer (alloc.c) to see why. */ |
| 475 | 507 | ||
| 476 | EMACS_UINT size; | 508 | /* HEADER.NEXT is the next buffer, in chain of all buffers, |
| 477 | 509 | including killed buffers. | |
| 478 | /* Next buffer, in chain of all buffers including killed buffers. | ||
| 479 | This chain is used only for garbage collection, in order to | 510 | This chain is used only for garbage collection, in order to |
| 480 | collect killed buffers properly. | 511 | collect killed buffers properly. |
| 481 | Note that vectors and most pseudovectors are all on one chain, | 512 | Note that vectors and most pseudovectors are all on one chain, |
| 482 | but buffers are on a separate chain of their own. */ | 513 | but buffers are on a separate chain of their own. */ |
| 483 | struct buffer *next; | 514 | struct vectorlike_header header; |
| 484 | 515 | ||
| 485 | /* This structure holds the coordinates of the buffer contents | 516 | /* This structure holds the coordinates of the buffer contents |
| 486 | in ordinary buffers. In indirect buffers, this is not used. */ | 517 | in ordinary buffers. In indirect buffers, this is not used. */ |
| @@ -520,7 +551,7 @@ struct buffer | |||
| 520 | -1 means visited file was nonexistent. | 551 | -1 means visited file was nonexistent. |
| 521 | 0 means visited file modtime unknown; in no case complain | 552 | 0 means visited file modtime unknown; in no case complain |
| 522 | about any mismatch on next save attempt. */ | 553 | about any mismatch on next save attempt. */ |
| 523 | int modtime; | 554 | time_t modtime; |
| 524 | /* Size of the file when modtime was set. This is used to detect the | 555 | /* Size of the file when modtime was set. This is used to detect the |
| 525 | case where the file grew while we were reading it, so the modtime | 556 | case where the file grew while we were reading it, so the modtime |
| 526 | is still the same (since it's rounded up to seconds) but we're actually | 557 | is still the same (since it's rounded up to seconds) but we're actually |
| @@ -587,138 +618,132 @@ struct buffer | |||
| 587 | because local variables have to be right in the struct buffer. | 618 | because local variables have to be right in the struct buffer. |
| 588 | So we copy it around in set_buffer_internal. | 619 | So we copy it around in set_buffer_internal. |
| 589 | This comes before `name' because it is marked in a special way. */ | 620 | This comes before `name' because it is marked in a special way. */ |
| 590 | Lisp_Object undo_list; | 621 | Lisp_Object BUFFER_INTERNAL_FIELD (undo_list); |
| 591 | 622 | ||
| 592 | /* The name of this buffer. */ | 623 | /* The name of this buffer. */ |
| 593 | Lisp_Object name; | 624 | Lisp_Object BUFFER_INTERNAL_FIELD (name); |
| 594 | 625 | ||
| 595 | /* The name of the file visited in this buffer, or nil. */ | 626 | /* The name of the file visited in this buffer, or nil. */ |
| 596 | Lisp_Object filename; | 627 | Lisp_Object BUFFER_INTERNAL_FIELD (filename); |
| 597 | /* Dir for expanding relative file names. */ | 628 | /* Dir for expanding relative file names. */ |
| 598 | Lisp_Object directory; | 629 | Lisp_Object BUFFER_INTERNAL_FIELD (directory); |
| 599 | /* True if this buffer has been backed up (if you write to the | 630 | /* True if this buffer has been backed up (if you write to the |
| 600 | visited file and it hasn't been backed up, then a backup will | 631 | visited file and it hasn't been backed up, then a backup will |
| 601 | be made). */ | 632 | be made). */ |
| 602 | /* This isn't really used by the C code, so could be deleted. */ | 633 | /* This isn't really used by the C code, so could be deleted. */ |
| 603 | Lisp_Object backed_up; | 634 | Lisp_Object BUFFER_INTERNAL_FIELD (backed_up); |
| 604 | /* Length of file when last read or saved. | 635 | /* Length of file when last read or saved. |
| 605 | -1 means auto saving turned off because buffer shrank a lot. | 636 | -1 means auto saving turned off because buffer shrank a lot. |
| 606 | -2 means don't turn off auto saving if buffer shrinks. | 637 | -2 means don't turn off auto saving if buffer shrinks. |
| 607 | (That value is used with buffer-swap-text.) | 638 | (That value is used with buffer-swap-text.) |
| 608 | This is not in the struct buffer_text | 639 | This is not in the struct buffer_text |
| 609 | because it's not used in indirect buffers at all. */ | 640 | because it's not used in indirect buffers at all. */ |
| 610 | Lisp_Object save_length; | 641 | Lisp_Object BUFFER_INTERNAL_FIELD (save_length); |
| 611 | /* File name used for auto-saving this buffer. | 642 | /* File name used for auto-saving this buffer. |
| 612 | This is not in the struct buffer_text | 643 | This is not in the struct buffer_text |
| 613 | because it's not used in indirect buffers at all. */ | 644 | because it's not used in indirect buffers at all. */ |
| 614 | Lisp_Object auto_save_file_name; | 645 | Lisp_Object BUFFER_INTERNAL_FIELD (auto_save_file_name); |
| 615 | 646 | ||
| 616 | /* Non-nil if buffer read-only. */ | 647 | /* Non-nil if buffer read-only. */ |
| 617 | Lisp_Object read_only; | 648 | Lisp_Object BUFFER_INTERNAL_FIELD (read_only); |
| 618 | /* "The mark". This is a marker which may | 649 | /* "The mark". This is a marker which may |
| 619 | point into this buffer or may point nowhere. */ | 650 | point into this buffer or may point nowhere. */ |
| 620 | Lisp_Object mark; | 651 | Lisp_Object BUFFER_INTERNAL_FIELD (mark); |
| 621 | 652 | ||
| 622 | /* Alist of elements (SYMBOL . VALUE-IN-THIS-BUFFER) for all | 653 | /* Alist of elements (SYMBOL . VALUE-IN-THIS-BUFFER) for all |
| 623 | per-buffer variables of this buffer. For locally unbound | 654 | per-buffer variables of this buffer. For locally unbound |
| 624 | symbols, just the symbol appears as the element. */ | 655 | symbols, just the symbol appears as the element. */ |
| 625 | Lisp_Object local_var_alist; | 656 | Lisp_Object BUFFER_INTERNAL_FIELD (local_var_alist); |
| 626 | 657 | ||
| 627 | /* Symbol naming major mode (eg, lisp-mode). */ | 658 | /* Symbol naming major mode (eg, lisp-mode). */ |
| 628 | Lisp_Object major_mode; | 659 | Lisp_Object BUFFER_INTERNAL_FIELD (major_mode); |
| 629 | /* Pretty name of major mode (eg, "Lisp"). */ | 660 | /* Pretty name of major mode (eg, "Lisp"). */ |
| 630 | Lisp_Object mode_name; | 661 | Lisp_Object BUFFER_INTERNAL_FIELD (mode_name); |
| 631 | /* Mode line element that controls format of mode line. */ | 662 | /* Mode line element that controls format of mode line. */ |
| 632 | Lisp_Object mode_line_format; | 663 | Lisp_Object BUFFER_INTERNAL_FIELD (mode_line_format); |
| 633 | 664 | ||
| 634 | /* Analogous to mode_line_format for the line displayed at the top | 665 | /* Analogous to mode_line_format for the line displayed at the top |
| 635 | of windows. Nil means don't display that line. */ | 666 | of windows. Nil means don't display that line. */ |
| 636 | Lisp_Object header_line_format; | 667 | Lisp_Object BUFFER_INTERNAL_FIELD (header_line_format); |
| 637 | 668 | ||
| 638 | /* Keys that are bound local to this buffer. */ | 669 | /* Keys that are bound local to this buffer. */ |
| 639 | Lisp_Object keymap; | 670 | Lisp_Object BUFFER_INTERNAL_FIELD (keymap); |
| 640 | /* This buffer's local abbrev table. */ | 671 | /* This buffer's local abbrev table. */ |
| 641 | Lisp_Object abbrev_table; | 672 | Lisp_Object BUFFER_INTERNAL_FIELD (abbrev_table); |
| 642 | /* This buffer's syntax table. */ | 673 | /* This buffer's syntax table. */ |
| 643 | Lisp_Object syntax_table; | 674 | Lisp_Object BUFFER_INTERNAL_FIELD (syntax_table); |
| 644 | /* This buffer's category table. */ | 675 | /* This buffer's category table. */ |
| 645 | Lisp_Object category_table; | 676 | Lisp_Object BUFFER_INTERNAL_FIELD (category_table); |
| 646 | 677 | ||
| 647 | /* Values of several buffer-local variables. */ | 678 | /* Values of several buffer-local variables. */ |
| 648 | /* tab-width is buffer-local so that redisplay can find it | 679 | /* tab-width is buffer-local so that redisplay can find it |
| 649 | in buffers that are not current. */ | 680 | in buffers that are not current. */ |
| 650 | Lisp_Object case_fold_search; | 681 | Lisp_Object BUFFER_INTERNAL_FIELD (case_fold_search); |
| 651 | Lisp_Object tab_width; | 682 | Lisp_Object BUFFER_INTERNAL_FIELD (tab_width); |
| 652 | Lisp_Object fill_column; | 683 | Lisp_Object BUFFER_INTERNAL_FIELD (fill_column); |
| 653 | Lisp_Object left_margin; | 684 | Lisp_Object BUFFER_INTERNAL_FIELD (left_margin); |
| 654 | /* Function to call when insert space past fill column. */ | 685 | /* Function to call when insert space past fill column. */ |
| 655 | Lisp_Object auto_fill_function; | 686 | Lisp_Object BUFFER_INTERNAL_FIELD (auto_fill_function); |
| 656 | /* nil: text, t: binary. | ||
| 657 | This value is meaningful only on certain operating systems. */ | ||
| 658 | /* Actually, we don't need this flag any more because end-of-line | ||
| 659 | is handled correctly according to the buffer-file-coding-system | ||
| 660 | of the buffer. Just keeping it for backward compatibility. */ | ||
| 661 | Lisp_Object buffer_file_type; | ||
| 662 | 687 | ||
| 663 | /* Case table for case-conversion in this buffer. | 688 | /* Case table for case-conversion in this buffer. |
| 664 | This char-table maps each char into its lower-case version. */ | 689 | This char-table maps each char into its lower-case version. */ |
| 665 | Lisp_Object downcase_table; | 690 | Lisp_Object BUFFER_INTERNAL_FIELD (downcase_table); |
| 666 | /* Char-table mapping each char to its upper-case version. */ | 691 | /* Char-table mapping each char to its upper-case version. */ |
| 667 | Lisp_Object upcase_table; | 692 | Lisp_Object BUFFER_INTERNAL_FIELD (upcase_table); |
| 668 | /* Char-table for conversion for case-folding search. */ | 693 | /* Char-table for conversion for case-folding search. */ |
| 669 | Lisp_Object case_canon_table; | 694 | Lisp_Object BUFFER_INTERNAL_FIELD (case_canon_table); |
| 670 | /* Char-table of equivalences for case-folding search. */ | 695 | /* Char-table of equivalences for case-folding search. */ |
| 671 | Lisp_Object case_eqv_table; | 696 | Lisp_Object BUFFER_INTERNAL_FIELD (case_eqv_table); |
| 672 | 697 | ||
| 673 | /* Non-nil means do not display continuation lines. */ | 698 | /* Non-nil means do not display continuation lines. */ |
| 674 | Lisp_Object truncate_lines; | 699 | Lisp_Object BUFFER_INTERNAL_FIELD (truncate_lines); |
| 675 | /* Non-nil means to use word wrapping when displaying continuation lines. */ | 700 | /* Non-nil means to use word wrapping when displaying continuation lines. */ |
| 676 | Lisp_Object word_wrap; | 701 | Lisp_Object BUFFER_INTERNAL_FIELD (word_wrap); |
| 677 | /* Non-nil means display ctl chars with uparrow. */ | 702 | /* Non-nil means display ctl chars with uparrow. */ |
| 678 | Lisp_Object ctl_arrow; | 703 | Lisp_Object BUFFER_INTERNAL_FIELD (ctl_arrow); |
| 679 | /* Non-nil means reorder bidirectional text for display in the | 704 | /* Non-nil means reorder bidirectional text for display in the |
| 680 | visual order. */ | 705 | visual order. */ |
| 681 | Lisp_Object bidi_display_reordering; | 706 | Lisp_Object BUFFER_INTERNAL_FIELD (bidi_display_reordering); |
| 682 | /* If non-nil, specifies which direction of text to force in all the | 707 | /* If non-nil, specifies which direction of text to force in all the |
| 683 | paragraphs of the buffer. Nil means determine paragraph | 708 | paragraphs of the buffer. Nil means determine paragraph |
| 684 | direction dynamically for each paragraph. */ | 709 | direction dynamically for each paragraph. */ |
| 685 | Lisp_Object bidi_paragraph_direction; | 710 | Lisp_Object BUFFER_INTERNAL_FIELD (bidi_paragraph_direction); |
| 686 | /* Non-nil means do selective display; | 711 | /* Non-nil means do selective display; |
| 687 | see doc string in syms_of_buffer (buffer.c) for details. */ | 712 | see doc string in syms_of_buffer (buffer.c) for details. */ |
| 688 | Lisp_Object selective_display; | 713 | Lisp_Object BUFFER_INTERNAL_FIELD (selective_display); |
| 689 | #ifndef old | 714 | #ifndef old |
| 690 | /* Non-nil means show ... at end of line followed by invisible lines. */ | 715 | /* Non-nil means show ... at end of line followed by invisible lines. */ |
| 691 | Lisp_Object selective_display_ellipses; | 716 | Lisp_Object BUFFER_INTERNAL_FIELD (selective_display_ellipses); |
| 692 | #endif | 717 | #endif |
| 693 | /* Alist of (FUNCTION . STRING) for each minor mode enabled in buffer. */ | 718 | /* Alist of (FUNCTION . STRING) for each minor mode enabled in buffer. */ |
| 694 | Lisp_Object minor_modes; | 719 | Lisp_Object BUFFER_INTERNAL_FIELD (minor_modes); |
| 695 | /* t if "self-insertion" should overwrite; `binary' if it should also | 720 | /* t if "self-insertion" should overwrite; `binary' if it should also |
| 696 | overwrite newlines and tabs - for editing executables and the like. */ | 721 | overwrite newlines and tabs - for editing executables and the like. */ |
| 697 | Lisp_Object overwrite_mode; | 722 | Lisp_Object BUFFER_INTERNAL_FIELD (overwrite_mode); |
| 698 | /* non-nil means abbrev mode is on. Expand abbrevs automatically. */ | 723 | /* non-nil means abbrev mode is on. Expand abbrevs automatically. */ |
| 699 | Lisp_Object abbrev_mode; | 724 | Lisp_Object BUFFER_INTERNAL_FIELD (abbrev_mode); |
| 700 | /* Display table to use for text in this buffer. */ | 725 | /* Display table to use for text in this buffer. */ |
| 701 | Lisp_Object display_table; | 726 | Lisp_Object BUFFER_INTERNAL_FIELD (display_table); |
| 702 | /* t means the mark and region are currently active. */ | 727 | /* t means the mark and region are currently active. */ |
| 703 | Lisp_Object mark_active; | 728 | Lisp_Object BUFFER_INTERNAL_FIELD (mark_active); |
| 704 | 729 | ||
| 705 | /* Non-nil means the buffer contents are regarded as multi-byte | 730 | /* Non-nil means the buffer contents are regarded as multi-byte |
| 706 | form of characters, not a binary code. */ | 731 | form of characters, not a binary code. */ |
| 707 | Lisp_Object enable_multibyte_characters; | 732 | Lisp_Object BUFFER_INTERNAL_FIELD (enable_multibyte_characters); |
| 708 | 733 | ||
| 709 | /* Coding system to be used for encoding the buffer contents on | 734 | /* Coding system to be used for encoding the buffer contents on |
| 710 | saving. */ | 735 | saving. */ |
| 711 | Lisp_Object buffer_file_coding_system; | 736 | Lisp_Object BUFFER_INTERNAL_FIELD (buffer_file_coding_system); |
| 712 | 737 | ||
| 713 | /* List of symbols naming the file format used for visited file. */ | 738 | /* List of symbols naming the file format used for visited file. */ |
| 714 | Lisp_Object file_format; | 739 | Lisp_Object BUFFER_INTERNAL_FIELD (file_format); |
| 715 | 740 | ||
| 716 | /* List of symbols naming the file format used for auto-save file. */ | 741 | /* List of symbols naming the file format used for auto-save file. */ |
| 717 | Lisp_Object auto_save_file_format; | 742 | Lisp_Object BUFFER_INTERNAL_FIELD (auto_save_file_format); |
| 718 | 743 | ||
| 719 | /* True if the newline position cache and width run cache are | 744 | /* True if the newline position cache and width run cache are |
| 720 | enabled. See search.c and indent.c. */ | 745 | enabled. See search.c and indent.c. */ |
| 721 | Lisp_Object cache_long_line_scans; | 746 | Lisp_Object BUFFER_INTERNAL_FIELD (cache_long_line_scans); |
| 722 | 747 | ||
| 723 | /* If the width run cache is enabled, this table contains the | 748 | /* If the width run cache is enabled, this table contains the |
| 724 | character widths width_run_cache (see above) assumes. When we | 749 | character widths width_run_cache (see above) assumes. When we |
| @@ -726,99 +751,99 @@ struct buffer | |||
| 726 | current display table to see whether the display table has | 751 | current display table to see whether the display table has |
| 727 | affected the widths of any characters. If it has, we | 752 | affected the widths of any characters. If it has, we |
| 728 | invalidate the width run cache, and re-initialize width_table. */ | 753 | invalidate the width run cache, and re-initialize width_table. */ |
| 729 | Lisp_Object width_table; | 754 | Lisp_Object BUFFER_INTERNAL_FIELD (width_table); |
| 730 | 755 | ||
| 731 | /* In an indirect buffer, or a buffer that is the base of an | 756 | /* In an indirect buffer, or a buffer that is the base of an |
| 732 | indirect buffer, this holds a marker that records | 757 | indirect buffer, this holds a marker that records |
| 733 | PT for this buffer when the buffer is not current. */ | 758 | PT for this buffer when the buffer is not current. */ |
| 734 | Lisp_Object pt_marker; | 759 | Lisp_Object BUFFER_INTERNAL_FIELD (pt_marker); |
| 735 | 760 | ||
| 736 | /* In an indirect buffer, or a buffer that is the base of an | 761 | /* In an indirect buffer, or a buffer that is the base of an |
| 737 | indirect buffer, this holds a marker that records | 762 | indirect buffer, this holds a marker that records |
| 738 | BEGV for this buffer when the buffer is not current. */ | 763 | BEGV for this buffer when the buffer is not current. */ |
| 739 | Lisp_Object begv_marker; | 764 | Lisp_Object BUFFER_INTERNAL_FIELD (begv_marker); |
| 740 | 765 | ||
| 741 | /* In an indirect buffer, or a buffer that is the base of an | 766 | /* In an indirect buffer, or a buffer that is the base of an |
| 742 | indirect buffer, this holds a marker that records | 767 | indirect buffer, this holds a marker that records |
| 743 | ZV for this buffer when the buffer is not current. */ | 768 | ZV for this buffer when the buffer is not current. */ |
| 744 | Lisp_Object zv_marker; | 769 | Lisp_Object BUFFER_INTERNAL_FIELD (zv_marker); |
| 745 | 770 | ||
| 746 | /* This holds the point value before the last scroll operation. | 771 | /* This holds the point value before the last scroll operation. |
| 747 | Explicitly setting point sets this to nil. */ | 772 | Explicitly setting point sets this to nil. */ |
| 748 | Lisp_Object point_before_scroll; | 773 | Lisp_Object BUFFER_INTERNAL_FIELD (point_before_scroll); |
| 749 | 774 | ||
| 750 | /* Truename of the visited file, or nil. */ | 775 | /* Truename of the visited file, or nil. */ |
| 751 | Lisp_Object file_truename; | 776 | Lisp_Object BUFFER_INTERNAL_FIELD (file_truename); |
| 752 | 777 | ||
| 753 | /* Invisibility spec of this buffer. | 778 | /* Invisibility spec of this buffer. |
| 754 | t => any non-nil `invisible' property means invisible. | 779 | t => any non-nil `invisible' property means invisible. |
| 755 | A list => `invisible' property means invisible | 780 | A list => `invisible' property means invisible |
| 756 | if it is memq in that list. */ | 781 | if it is memq in that list. */ |
| 757 | Lisp_Object invisibility_spec; | 782 | Lisp_Object BUFFER_INTERNAL_FIELD (invisibility_spec); |
| 758 | 783 | ||
| 759 | /* This is the last window that was selected with this buffer in it, | 784 | /* This is the last window that was selected with this buffer in it, |
| 760 | or nil if that window no longer displays this buffer. */ | 785 | or nil if that window no longer displays this buffer. */ |
| 761 | Lisp_Object last_selected_window; | 786 | Lisp_Object BUFFER_INTERNAL_FIELD (last_selected_window); |
| 762 | 787 | ||
| 763 | /* Incremented each time the buffer is displayed in a window. */ | 788 | /* Incremented each time the buffer is displayed in a window. */ |
| 764 | Lisp_Object display_count; | 789 | Lisp_Object BUFFER_INTERNAL_FIELD (display_count); |
| 765 | 790 | ||
| 766 | /* Widths of left and right marginal areas for windows displaying | 791 | /* Widths of left and right marginal areas for windows displaying |
| 767 | this buffer. */ | 792 | this buffer. */ |
| 768 | Lisp_Object left_margin_cols, right_margin_cols; | 793 | Lisp_Object BUFFER_INTERNAL_FIELD (left_margin_cols), BUFFER_INTERNAL_FIELD (right_margin_cols); |
| 769 | 794 | ||
| 770 | /* Widths of left and right fringe areas for windows displaying | 795 | /* Widths of left and right fringe areas for windows displaying |
| 771 | this buffer. */ | 796 | this buffer. */ |
| 772 | Lisp_Object left_fringe_width, right_fringe_width; | 797 | Lisp_Object BUFFER_INTERNAL_FIELD (left_fringe_width), BUFFER_INTERNAL_FIELD (right_fringe_width); |
| 773 | 798 | ||
| 774 | /* Non-nil means fringes are drawn outside display margins; | 799 | /* Non-nil means fringes are drawn outside display margins; |
| 775 | othersize draw them between margin areas and text. */ | 800 | othersize draw them between margin areas and text. */ |
| 776 | Lisp_Object fringes_outside_margins; | 801 | Lisp_Object BUFFER_INTERNAL_FIELD (fringes_outside_margins); |
| 777 | 802 | ||
| 778 | /* Width and type of scroll bar areas for windows displaying | 803 | /* Width and type of scroll bar areas for windows displaying |
| 779 | this buffer. */ | 804 | this buffer. */ |
| 780 | Lisp_Object scroll_bar_width, vertical_scroll_bar_type; | 805 | Lisp_Object BUFFER_INTERNAL_FIELD (scroll_bar_width), BUFFER_INTERNAL_FIELD (vertical_scroll_bar_type); |
| 781 | 806 | ||
| 782 | /* Non-nil means indicate lines not displaying text (in a style | 807 | /* Non-nil means indicate lines not displaying text (in a style |
| 783 | like vi). */ | 808 | like vi). */ |
| 784 | Lisp_Object indicate_empty_lines; | 809 | Lisp_Object BUFFER_INTERNAL_FIELD (indicate_empty_lines); |
| 785 | 810 | ||
| 786 | /* Non-nil means indicate buffer boundaries and scrolling. */ | 811 | /* Non-nil means indicate buffer boundaries and scrolling. */ |
| 787 | Lisp_Object indicate_buffer_boundaries; | 812 | Lisp_Object BUFFER_INTERNAL_FIELD (indicate_buffer_boundaries); |
| 788 | 813 | ||
| 789 | /* Logical to physical fringe bitmap mappings. */ | 814 | /* Logical to physical fringe bitmap mappings. */ |
| 790 | Lisp_Object fringe_indicator_alist; | 815 | Lisp_Object BUFFER_INTERNAL_FIELD (fringe_indicator_alist); |
| 791 | 816 | ||
| 792 | /* Logical to physical cursor bitmap mappings. */ | 817 | /* Logical to physical cursor bitmap mappings. */ |
| 793 | Lisp_Object fringe_cursor_alist; | 818 | Lisp_Object BUFFER_INTERNAL_FIELD (fringe_cursor_alist); |
| 794 | 819 | ||
| 795 | /* Time stamp updated each time this buffer is displayed in a window. */ | 820 | /* Time stamp updated each time this buffer is displayed in a window. */ |
| 796 | Lisp_Object display_time; | 821 | Lisp_Object BUFFER_INTERNAL_FIELD (display_time); |
| 797 | 822 | ||
| 798 | /* If scrolling the display because point is below the bottom of a | 823 | /* If scrolling the display because point is below the bottom of a |
| 799 | window showing this buffer, try to choose a window start so | 824 | window showing this buffer, try to choose a window start so |
| 800 | that point ends up this number of lines from the top of the | 825 | that point ends up this number of lines from the top of the |
| 801 | window. Nil means that scrolling method isn't used. */ | 826 | window. Nil means that scrolling method isn't used. */ |
| 802 | Lisp_Object scroll_up_aggressively; | 827 | Lisp_Object BUFFER_INTERNAL_FIELD (scroll_up_aggressively); |
| 803 | 828 | ||
| 804 | /* If scrolling the display because point is above the top of a | 829 | /* If scrolling the display because point is above the top of a |
| 805 | window showing this buffer, try to choose a window start so | 830 | window showing this buffer, try to choose a window start so |
| 806 | that point ends up this number of lines from the bottom of the | 831 | that point ends up this number of lines from the bottom of the |
| 807 | window. Nil means that scrolling method isn't used. */ | 832 | window. Nil means that scrolling method isn't used. */ |
| 808 | Lisp_Object scroll_down_aggressively; | 833 | Lisp_Object BUFFER_INTERNAL_FIELD (scroll_down_aggressively); |
| 809 | 834 | ||
| 810 | /* Desired cursor type in this buffer. See the doc string of | 835 | /* Desired cursor type in this buffer. See the doc string of |
| 811 | per-buffer variable `cursor-type'. */ | 836 | per-buffer variable `cursor-type'. */ |
| 812 | Lisp_Object cursor_type; | 837 | Lisp_Object BUFFER_INTERNAL_FIELD (cursor_type); |
| 813 | 838 | ||
| 814 | /* An integer > 0 means put that number of pixels below text lines | 839 | /* An integer > 0 means put that number of pixels below text lines |
| 815 | in the display of this buffer. */ | 840 | in the display of this buffer. */ |
| 816 | Lisp_Object extra_line_spacing; | 841 | Lisp_Object BUFFER_INTERNAL_FIELD (extra_line_spacing); |
| 817 | 842 | ||
| 818 | /* *Cursor type to display in non-selected windows. | 843 | /* *Cursor type to display in non-selected windows. |
| 819 | t means to use hollow box cursor. | 844 | t means to use hollow box cursor. |
| 820 | See `cursor-type' for other values. */ | 845 | See `cursor-type' for other values. */ |
| 821 | Lisp_Object cursor_in_non_selected_windows; | 846 | Lisp_Object BUFFER_INTERNAL_FIELD (cursor_in_non_selected_windows); |
| 822 | }; | 847 | }; |
| 823 | 848 | ||
| 824 | 849 | ||
| @@ -897,7 +922,6 @@ extern void mmap_set_vars (int); | |||
| 897 | EXFUN (Fbuffer_live_p, 1); | 922 | EXFUN (Fbuffer_live_p, 1); |
| 898 | EXFUN (Fbuffer_name, 1); | 923 | EXFUN (Fbuffer_name, 1); |
| 899 | EXFUN (Fnext_overlay_change, 1); | 924 | EXFUN (Fnext_overlay_change, 1); |
| 900 | EXFUN (Fdelete_overlay, 1); | ||
| 901 | EXFUN (Fbuffer_local_value, 2); | 925 | EXFUN (Fbuffer_local_value, 2); |
| 902 | 926 | ||
| 903 | extern Lisp_Object Qbefore_change_functions; | 927 | extern Lisp_Object Qbefore_change_functions; |
| @@ -942,7 +966,7 @@ extern int last_per_buffer_idx; | |||
| 942 | from the start of a buffer structure. */ | 966 | from the start of a buffer structure. */ |
| 943 | 967 | ||
| 944 | #define PER_BUFFER_VAR_OFFSET(VAR) \ | 968 | #define PER_BUFFER_VAR_OFFSET(VAR) \ |
| 945 | offsetof (struct buffer, VAR) | 969 | offsetof (struct buffer, BUFFER_INTERNAL_FIELD (VAR)) |
| 946 | 970 | ||
| 947 | /* Return the index of buffer-local variable VAR. Each per-buffer | 971 | /* Return the index of buffer-local variable VAR. Each per-buffer |
| 948 | variable has an index > 0 associated with it, except when it always | 972 | variable has an index > 0 associated with it, except when it always |
| @@ -1006,4 +1030,31 @@ extern int last_per_buffer_idx; | |||
| 1006 | 1030 | ||
| 1007 | #define PER_BUFFER_VALUE(BUFFER, OFFSET) \ | 1031 | #define PER_BUFFER_VALUE(BUFFER, OFFSET) \ |
| 1008 | (*(Lisp_Object *)((OFFSET) + (char *) (BUFFER))) | 1032 | (*(Lisp_Object *)((OFFSET) + (char *) (BUFFER))) |
| 1033 | |||
| 1034 | /* Downcase a character C, or make no change if that cannot be done. */ | ||
| 1035 | static inline int | ||
| 1036 | downcase (int c) | ||
| 1037 | { | ||
| 1038 | Lisp_Object downcase_table = BVAR (current_buffer, downcase_table); | ||
| 1039 | Lisp_Object down = CHAR_TABLE_REF (downcase_table, c); | ||
| 1040 | return NATNUMP (down) ? XFASTINT (down) : c; | ||
| 1041 | } | ||
| 1042 | |||
| 1043 | /* 1 if C is upper case. */ | ||
| 1044 | static inline int uppercasep (int c) { return downcase (c) != c; } | ||
| 1045 | |||
| 1046 | /* Upcase a character C known to be not upper case. */ | ||
| 1047 | static inline int | ||
| 1048 | upcase1 (int c) | ||
| 1049 | { | ||
| 1050 | Lisp_Object upcase_table = BVAR (current_buffer, upcase_table); | ||
| 1051 | Lisp_Object up = CHAR_TABLE_REF (upcase_table, c); | ||
| 1052 | return NATNUMP (up) ? XFASTINT (up) : c; | ||
| 1053 | } | ||
| 1054 | |||
| 1055 | /* 1 if C is lower case. */ | ||
| 1056 | static inline int lowercasep (int c) | ||
| 1057 | { return !uppercasep (c) && upcase1 (c) != c; } | ||
| 1009 | 1058 | ||
| 1059 | /* Upcase a character C, or make no change if that cannot be done. */ | ||
| 1060 | static inline int upcase (int c) { return uppercasep (c) ? c : upcase1 (c); } | ||