diff options
| author | Eli Zaretskii | 2013-09-05 11:01:04 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2013-09-05 11:01:04 +0300 |
| commit | 41306318777a942420bc4feadbfacf662ea179dc (patch) | |
| tree | 669e5cca02f95d6064ce73c0d3fbbf91b8c8b563 /src/buffer.h | |
| parent | 141f1ff7a40cda10f0558e891dd196a943a5082e (diff) | |
| parent | 257b3b03cb1cff917e0b3b7832ad3eab5b59f257 (diff) | |
| download | emacs-41306318777a942420bc4feadbfacf662ea179dc.tar.gz emacs-41306318777a942420bc4feadbfacf662ea179dc.zip | |
Merge from trunk after a lot of time.
Diffstat (limited to 'src/buffer.h')
| -rw-r--r-- | src/buffer.h | 912 |
1 files changed, 601 insertions, 311 deletions
diff --git a/src/buffer.h b/src/buffer.h index 97d891f044b..169a15c7d0f 100644 --- a/src/buffer.h +++ b/src/buffer.h | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | /* Header file for the buffer manipulation primitives. | 1 | /* Header file for the buffer manipulation primitives. |
| 2 | 2 | ||
| 3 | Copyright (C) 1985-1986, 1993-1995, 1997-2012 | 3 | Copyright (C) 1985-1986, 1993-1995, 1997-2013 Free Software Foundation, |
| 4 | Free Software Foundation, Inc. | 4 | Inc. |
| 5 | 5 | ||
| 6 | This file is part of GNU Emacs. | 6 | This file is part of GNU Emacs. |
| 7 | 7 | ||
| @@ -18,7 +18,13 @@ 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 <sys/types.h> /* for off_t, time_t */ | 21 | #include <sys/types.h> |
| 22 | #include <time.h> | ||
| 23 | |||
| 24 | INLINE_HEADER_BEGIN | ||
| 25 | #ifndef BUFFER_INLINE | ||
| 26 | # define BUFFER_INLINE INLINE | ||
| 27 | #endif | ||
| 22 | 28 | ||
| 23 | /* Accessing the parameters of the current buffer. */ | 29 | /* Accessing the parameters of the current buffer. */ |
| 24 | 30 | ||
| @@ -76,9 +82,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 76 | /* Size of gap. */ | 82 | /* Size of gap. */ |
| 77 | #define GAP_SIZE (current_buffer->text->gap_size) | 83 | #define GAP_SIZE (current_buffer->text->gap_size) |
| 78 | 84 | ||
| 79 | /* Is the current buffer narrowed? */ | ||
| 80 | #define NARROWED ((BEGV != BEG) || (ZV != Z)) | ||
| 81 | |||
| 82 | /* Modification count. */ | 85 | /* Modification count. */ |
| 83 | #define MODIFF (current_buffer->text->modiff) | 86 | #define MODIFF (current_buffer->text->modiff) |
| 84 | 87 | ||
| @@ -167,10 +170,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 167 | /* Size of gap. */ | 170 | /* Size of gap. */ |
| 168 | #define BUF_GAP_SIZE(buf) ((buf)->text->gap_size) | 171 | #define BUF_GAP_SIZE(buf) ((buf)->text->gap_size) |
| 169 | 172 | ||
| 170 | /* Is this buffer narrowed? */ | ||
| 171 | #define BUF_NARROWED(buf) ((BUF_BEGV (buf) != BUF_BEG (buf)) \ | ||
| 172 | || (BUF_ZV (buf) != BUF_Z (buf))) | ||
| 173 | |||
| 174 | /* Modification count. */ | 173 | /* Modification count. */ |
| 175 | #define BUF_MODIFF(buf) ((buf)->text->modiff) | 174 | #define BUF_MODIFF(buf) ((buf)->text->modiff) |
| 176 | 175 | ||
| @@ -187,8 +186,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 187 | /* FIXME: should we move this into ->text->auto_save_modiff? */ | 186 | /* FIXME: should we move this into ->text->auto_save_modiff? */ |
| 188 | #define BUF_AUTOSAVE_MODIFF(buf) ((buf)->auto_save_modified) | 187 | #define BUF_AUTOSAVE_MODIFF(buf) ((buf)->auto_save_modified) |
| 189 | 188 | ||
| 190 | /* Interval tree of buffer. */ | 189 | /* Compaction count. */ |
| 191 | #define BUF_INTERVALS(buf) ((buf)->text->intervals) | 190 | #define BUF_COMPACT(buf) ((buf)->text->compact) |
| 192 | 191 | ||
| 193 | /* Marker chain of buffer. */ | 192 | /* Marker chain of buffer. */ |
| 194 | #define BUF_MARKERS(buf) ((buf)->text->markers) | 193 | #define BUF_MARKERS(buf) ((buf)->text->markers) |
| @@ -250,6 +249,7 @@ extern void temp_set_point (struct buffer *, ptrdiff_t); | |||
| 250 | extern void set_point_both (ptrdiff_t, ptrdiff_t); | 249 | extern void set_point_both (ptrdiff_t, ptrdiff_t); |
| 251 | extern void temp_set_point_both (struct buffer *, | 250 | extern void temp_set_point_both (struct buffer *, |
| 252 | ptrdiff_t, ptrdiff_t); | 251 | ptrdiff_t, ptrdiff_t); |
| 252 | extern void set_point_from_marker (Lisp_Object); | ||
| 253 | extern void enlarge_buffer_text (struct buffer *, ptrdiff_t); | 253 | extern void enlarge_buffer_text (struct buffer *, ptrdiff_t); |
| 254 | 254 | ||
| 255 | 255 | ||
| @@ -288,24 +288,24 @@ extern void enlarge_buffer_text (struct buffer *, ptrdiff_t); | |||
| 288 | /* Access a Lisp position value in POS, | 288 | /* Access a Lisp position value in POS, |
| 289 | and store the charpos in CHARPOS and the bytepos in BYTEPOS. */ | 289 | and store the charpos in CHARPOS and the bytepos in BYTEPOS. */ |
| 290 | 290 | ||
| 291 | #define DECODE_POSITION(charpos, bytepos, pos) \ | 291 | #define DECODE_POSITION(charpos, bytepos, pos) \ |
| 292 | do \ | 292 | do \ |
| 293 | { \ | 293 | { \ |
| 294 | Lisp_Object __pos = (pos); \ | 294 | Lisp_Object __pos = (pos); \ |
| 295 | if (NUMBERP (__pos)) \ | 295 | if (NUMBERP (__pos)) \ |
| 296 | { \ | 296 | { \ |
| 297 | charpos = __pos; \ | 297 | charpos = __pos; \ |
| 298 | bytepos = buf_charpos_to_bytepos (current_buffer, __pos); \ | 298 | bytepos = buf_charpos_to_bytepos (current_buffer, __pos); \ |
| 299 | } \ | 299 | } \ |
| 300 | else if (MARKERP (__pos)) \ | 300 | else if (MARKERP (__pos)) \ |
| 301 | { \ | 301 | { \ |
| 302 | charpos = marker_position (__pos); \ | 302 | charpos = marker_position (__pos); \ |
| 303 | bytepos = marker_byte_position (__pos); \ | 303 | bytepos = marker_byte_position (__pos); \ |
| 304 | } \ | 304 | } \ |
| 305 | else \ | 305 | else \ |
| 306 | wrong_type_argument (Qinteger_or_marker_p, __pos); \ | 306 | wrong_type_argument (Qinteger_or_marker_p, __pos); \ |
| 307 | } \ | 307 | } \ |
| 308 | while (0) | 308 | while (0) |
| 309 | 309 | ||
| 310 | /* Maximum number of bytes in a buffer. | 310 | /* Maximum number of bytes in a buffer. |
| 311 | A buffer cannot contain more bytes than a 1-origin fixnum can represent, | 311 | A buffer cannot contain more bytes than a 1-origin fixnum can represent, |
| @@ -314,6 +314,16 @@ while (0) | |||
| 314 | #define BUF_BYTES_MAX \ | 314 | #define BUF_BYTES_MAX \ |
| 315 | (ptrdiff_t) min (MOST_POSITIVE_FIXNUM - 1, min (SIZE_MAX, PTRDIFF_MAX)) | 315 | (ptrdiff_t) min (MOST_POSITIVE_FIXNUM - 1, min (SIZE_MAX, PTRDIFF_MAX)) |
| 316 | 316 | ||
| 317 | /* Maximum gap size after compact_buffer, in bytes. Also | ||
| 318 | used in make_gap_larger to get some extra reserved space. */ | ||
| 319 | |||
| 320 | #define GAP_BYTES_DFL 2000 | ||
| 321 | |||
| 322 | /* Minimum gap size after compact_buffer, in bytes. Also | ||
| 323 | used in make_gap_smaller to avoid too small gap size. */ | ||
| 324 | |||
| 325 | #define GAP_BYTES_MIN 20 | ||
| 326 | |||
| 317 | /* Return the address of byte position N in current buffer. */ | 327 | /* Return the address of byte position N in current buffer. */ |
| 318 | 328 | ||
| 319 | #define BYTE_POS_ADDR(n) \ | 329 | #define BYTE_POS_ADDR(n) \ |
| @@ -355,28 +365,6 @@ while (0) | |||
| 355 | 365 | ||
| 356 | #define FETCH_BYTE(n) *(BYTE_POS_ADDR ((n))) | 366 | #define FETCH_BYTE(n) *(BYTE_POS_ADDR ((n))) |
| 357 | 367 | ||
| 358 | /* Variables used locally in FETCH_MULTIBYTE_CHAR. */ | ||
| 359 | extern unsigned char *_fetch_multibyte_char_p; | ||
| 360 | |||
| 361 | /* Return character code of multi-byte form at byte position POS. If POS | ||
| 362 | doesn't point the head of valid multi-byte form, only the byte at | ||
| 363 | POS is returned. No range checking. | ||
| 364 | |||
| 365 | WARNING: The character returned by this macro could be "unified" | ||
| 366 | inside STRING_CHAR, if the original character in the buffer belongs | ||
| 367 | to one of the Private Use Areas (PUAs) of codepoints that Emacs | ||
| 368 | uses to support non-unified CJK characters. If that happens, | ||
| 369 | CHAR_BYTES will return a value that is different from the length of | ||
| 370 | the original multibyte sequence stored in the buffer. Therefore, | ||
| 371 | do _not_ use FETCH_MULTIBYTE_CHAR if you need to advance through | ||
| 372 | the buffer to the next character after fetching this one. Instead, | ||
| 373 | use either FETCH_CHAR_ADVANCE or STRING_CHAR_AND_LENGTH. */ | ||
| 374 | |||
| 375 | #define FETCH_MULTIBYTE_CHAR(pos) \ | ||
| 376 | (_fetch_multibyte_char_p = (((pos) >= GPT_BYTE ? GAP_SIZE : 0) \ | ||
| 377 | + (pos) + BEG_ADDR - BEG_BYTE), \ | ||
| 378 | STRING_CHAR (_fetch_multibyte_char_p)) | ||
| 379 | |||
| 380 | /* Return character at byte position POS. If the current buffer is unibyte | 368 | /* Return character at byte position POS. If the current buffer is unibyte |
| 381 | and the character is not ASCII, make the returning character | 369 | and the character is not ASCII, make the returning character |
| 382 | multibyte. */ | 370 | multibyte. */ |
| @@ -425,16 +413,6 @@ extern unsigned char *_fetch_multibyte_char_p; | |||
| 425 | 413 | ||
| 426 | #define BUF_FETCH_BYTE(buf, n) \ | 414 | #define BUF_FETCH_BYTE(buf, n) \ |
| 427 | *(BUF_BYTE_ADDRESS ((buf), (n))) | 415 | *(BUF_BYTE_ADDRESS ((buf), (n))) |
| 428 | |||
| 429 | /* Return character code of multi-byte form at byte position POS in BUF. | ||
| 430 | If POS doesn't point the head of valid multi-byte form, only the byte at | ||
| 431 | POS is returned. No range checking. */ | ||
| 432 | |||
| 433 | #define BUF_FETCH_MULTIBYTE_CHAR(buf, pos) \ | ||
| 434 | (_fetch_multibyte_char_p \ | ||
| 435 | = (((pos) >= BUF_GPT_BYTE (buf) ? BUF_GAP_SIZE (buf) : 0) \ | ||
| 436 | + (pos) + BUF_BEG_ADDR (buf) - BEG_BYTE), \ | ||
| 437 | STRING_CHAR (_fetch_multibyte_char_p)) | ||
| 438 | 416 | ||
| 439 | /* Define the actual buffer data structures. */ | 417 | /* Define the actual buffer data structures. */ |
| 440 | 418 | ||
| @@ -467,6 +445,9 @@ struct buffer_text | |||
| 467 | 445 | ||
| 468 | EMACS_INT overlay_modiff; /* Counts modifications to overlays. */ | 446 | EMACS_INT overlay_modiff; /* Counts modifications to overlays. */ |
| 469 | 447 | ||
| 448 | EMACS_INT compact; /* Set to modiff each time when compact_buffer | ||
| 449 | is called for this buffer. */ | ||
| 450 | |||
| 470 | /* Minimum value of GPT - BEG since last redisplay that finished. */ | 451 | /* Minimum value of GPT - BEG since last redisplay that finished. */ |
| 471 | ptrdiff_t beg_unchanged; | 452 | ptrdiff_t beg_unchanged; |
| 472 | 453 | ||
| @@ -497,267 +478,164 @@ struct buffer_text | |||
| 497 | /* Usually 0. Temporarily set to 1 in decode_coding_gap to | 478 | /* Usually 0. Temporarily set to 1 in decode_coding_gap to |
| 498 | prevent Fgarbage_collect from shrinking the gap and losing | 479 | prevent Fgarbage_collect from shrinking the gap and losing |
| 499 | not-yet-decoded bytes. */ | 480 | not-yet-decoded bytes. */ |
| 500 | int inhibit_shrinking; | 481 | bool inhibit_shrinking; |
| 501 | }; | 482 | }; |
| 502 | 483 | ||
| 503 | /* Lisp fields in struct buffer are hidden from most code and accessed | 484 | /* Most code should use this macro to access Lisp fields in struct buffer. */ |
| 504 | via the BVAR macro, below. Only select pieces of code, like the GC, | ||
| 505 | are allowed to use BUFFER_INTERNAL_FIELD. */ | ||
| 506 | #define BUFFER_INTERNAL_FIELD(field) field ## _ | ||
| 507 | 485 | ||
| 508 | /* Most code should use this macro to access Lisp fields in struct | 486 | #define BVAR(buf, field) ((buf)->INTERNAL_FIELD (field)) |
| 509 | buffer. */ | ||
| 510 | #define BVAR(buf, field) ((buf)->BUFFER_INTERNAL_FIELD (field)) | ||
| 511 | 487 | ||
| 512 | /* This is the structure that the buffer Lisp object points to. */ | 488 | /* This is the structure that the buffer Lisp object points to. */ |
| 513 | 489 | ||
| 514 | struct buffer | 490 | struct buffer |
| 515 | { | 491 | { |
| 516 | /* Everything before the `name' slot must be of a non-Lisp_Object type, | ||
| 517 | and every slot after `name' must be a Lisp_Object. | ||
| 518 | |||
| 519 | Check out mark_buffer (alloc.c) to see why. */ | ||
| 520 | |||
| 521 | /* HEADER.NEXT is the next buffer, in chain of all buffers, | ||
| 522 | including killed buffers. | ||
| 523 | This chain is used only for garbage collection, in order to | ||
| 524 | collect killed buffers properly. | ||
| 525 | Note that vectors and most pseudovectors are all on one chain, | ||
| 526 | but buffers are on a separate chain of their own. */ | ||
| 527 | struct vectorlike_header header; | 492 | struct vectorlike_header header; |
| 528 | 493 | ||
| 529 | /* This structure holds the coordinates of the buffer contents | 494 | /* The name of this buffer. */ |
| 530 | in ordinary buffers. In indirect buffers, this is not used. */ | 495 | Lisp_Object INTERNAL_FIELD (name); |
| 531 | struct buffer_text own_text; | ||
| 532 | |||
| 533 | /* This points to the `struct buffer_text' that used for this buffer. | ||
| 534 | In an ordinary buffer, this is the own_text field above. | ||
| 535 | In an indirect buffer, this is the own_text field of another buffer. */ | ||
| 536 | struct buffer_text *text; | ||
| 537 | |||
| 538 | /* Char position of point in buffer. */ | ||
| 539 | ptrdiff_t pt; | ||
| 540 | /* Byte position of point in buffer. */ | ||
| 541 | ptrdiff_t pt_byte; | ||
| 542 | /* Char position of beginning of accessible range. */ | ||
| 543 | ptrdiff_t begv; | ||
| 544 | /* Byte position of beginning of accessible range. */ | ||
| 545 | ptrdiff_t begv_byte; | ||
| 546 | /* Char position of end of accessible range. */ | ||
| 547 | ptrdiff_t zv; | ||
| 548 | /* Byte position of end of accessible range. */ | ||
| 549 | ptrdiff_t zv_byte; | ||
| 550 | |||
| 551 | /* In an indirect buffer, this points to the base buffer. | ||
| 552 | In an ordinary buffer, it is 0. */ | ||
| 553 | struct buffer *base_buffer; | ||
| 554 | |||
| 555 | /* A non-zero value in slot IDX means that per-buffer variable | ||
| 556 | with index IDX has a local value in this buffer. The index IDX | ||
| 557 | for a buffer-local variable is stored in that variable's slot | ||
| 558 | in buffer_local_flags as a Lisp integer. If the index is -1, | ||
| 559 | this means the variable is always local in all buffers. */ | ||
| 560 | #define MAX_PER_BUFFER_VARS 50 | ||
| 561 | char local_flags[MAX_PER_BUFFER_VARS]; | ||
| 562 | |||
| 563 | /* Set to the modtime of the visited file when read or written. | ||
| 564 | -1 means visited file was nonexistent. | ||
| 565 | 0 means visited file modtime unknown; in no case complain | ||
| 566 | about any mismatch on next save attempt. */ | ||
| 567 | time_t modtime; | ||
| 568 | /* Size of the file when modtime was set. This is used to detect the | ||
| 569 | case where the file grew while we were reading it, so the modtime | ||
| 570 | is still the same (since it's rounded up to seconds) but we're actually | ||
| 571 | not up-to-date. -1 means the size is unknown. Only meaningful if | ||
| 572 | modtime is actually set. */ | ||
| 573 | off_t modtime_size; | ||
| 574 | /* The value of text->modiff at the last auto-save. */ | ||
| 575 | EMACS_INT auto_save_modified; | ||
| 576 | /* The value of text->modiff at the last display error. | ||
| 577 | Redisplay of this buffer is inhibited until it changes again. */ | ||
| 578 | EMACS_INT display_error_modiff; | ||
| 579 | /* The time at which we detected a failure to auto-save, | ||
| 580 | Or 0 if we didn't have a failure. */ | ||
| 581 | time_t auto_save_failure_time; | ||
| 582 | /* Position in buffer at which display started | ||
| 583 | the last time this buffer was displayed. */ | ||
| 584 | ptrdiff_t last_window_start; | ||
| 585 | |||
| 586 | /* Set nonzero whenever the narrowing is changed in this buffer. */ | ||
| 587 | int clip_changed; | ||
| 588 | |||
| 589 | /* If the long line scan cache is enabled (i.e. the buffer-local | ||
| 590 | variable cache-long-line-scans is non-nil), newline_cache | ||
| 591 | points to the newline cache, and width_run_cache points to the | ||
| 592 | width run cache. | ||
| 593 | |||
| 594 | The newline cache records which stretches of the buffer are | ||
| 595 | known *not* to contain newlines, so that they can be skipped | ||
| 596 | quickly when we search for newlines. | ||
| 597 | |||
| 598 | The width run cache records which stretches of the buffer are | ||
| 599 | known to contain characters whose widths are all the same. If | ||
| 600 | the width run cache maps a character to a value > 0, that value is | ||
| 601 | the character's width; if it maps a character to zero, we don't | ||
| 602 | know what its width is. This allows compute_motion to process | ||
| 603 | such regions very quickly, using algebra instead of inspecting | ||
| 604 | each character. See also width_table, below. */ | ||
| 605 | struct region_cache *newline_cache; | ||
| 606 | struct region_cache *width_run_cache; | ||
| 607 | |||
| 608 | /* Non-zero means don't use redisplay optimizations for | ||
| 609 | displaying this buffer. */ | ||
| 610 | unsigned prevent_redisplay_optimizations_p : 1; | ||
| 611 | |||
| 612 | /* List of overlays that end at or before the current center, | ||
| 613 | in order of end-position. */ | ||
| 614 | struct Lisp_Overlay *overlays_before; | ||
| 615 | |||
| 616 | /* List of overlays that end after the current center, | ||
| 617 | in order of start-position. */ | ||
| 618 | struct Lisp_Overlay *overlays_after; | ||
| 619 | |||
| 620 | /* Position where the overlay lists are centered. */ | ||
| 621 | ptrdiff_t overlay_center; | ||
| 622 | 496 | ||
| 623 | /* Everything from here down must be a Lisp_Object. */ | 497 | /* The name of the file visited in this buffer, or nil. */ |
| 624 | /* buffer-local Lisp variables start at `undo_list', | 498 | Lisp_Object INTERNAL_FIELD (filename); |
| 625 | tho only the ones from `name' on are GC'd normally. */ | ||
| 626 | #define FIRST_FIELD_PER_BUFFER undo_list | ||
| 627 | 499 | ||
| 628 | /* Changes in the buffer are recorded here for undo. | 500 | /* Directory for expanding relative file names. */ |
| 629 | t means don't record anything. | 501 | Lisp_Object INTERNAL_FIELD (directory); |
| 630 | This information belongs to the base buffer of an indirect buffer, | ||
| 631 | But we can't store it in the struct buffer_text | ||
| 632 | because local variables have to be right in the struct buffer. | ||
| 633 | So we copy it around in set_buffer_internal. | ||
| 634 | This comes before `name' because it is marked in a special way. */ | ||
| 635 | Lisp_Object BUFFER_INTERNAL_FIELD (undo_list); | ||
| 636 | 502 | ||
| 637 | /* The name of this buffer. */ | 503 | /* True if this buffer has been backed up (if you write to the visited |
| 638 | Lisp_Object BUFFER_INTERNAL_FIELD (name); | 504 | file and it hasn't been backed up, then a backup will be made). */ |
| 505 | Lisp_Object INTERNAL_FIELD (backed_up); | ||
| 639 | 506 | ||
| 640 | /* The name of the file visited in this buffer, or nil. */ | ||
| 641 | Lisp_Object BUFFER_INTERNAL_FIELD (filename); | ||
| 642 | /* Dir for expanding relative file names. */ | ||
| 643 | Lisp_Object BUFFER_INTERNAL_FIELD (directory); | ||
| 644 | /* True if this buffer has been backed up (if you write to the | ||
| 645 | visited file and it hasn't been backed up, then a backup will | ||
| 646 | be made). */ | ||
| 647 | /* This isn't really used by the C code, so could be deleted. */ | ||
| 648 | Lisp_Object BUFFER_INTERNAL_FIELD (backed_up); | ||
| 649 | /* Length of file when last read or saved. | 507 | /* Length of file when last read or saved. |
| 650 | -1 means auto saving turned off because buffer shrank a lot. | 508 | -1 means auto saving turned off because buffer shrank a lot. |
| 651 | -2 means don't turn off auto saving if buffer shrinks. | 509 | -2 means don't turn off auto saving if buffer shrinks. |
| 652 | (That value is used with buffer-swap-text.) | 510 | (That value is used with buffer-swap-text.) |
| 653 | This is not in the struct buffer_text | 511 | This is not in the struct buffer_text |
| 654 | because it's not used in indirect buffers at all. */ | 512 | because it's not used in indirect buffers at all. */ |
| 655 | Lisp_Object BUFFER_INTERNAL_FIELD (save_length); | 513 | Lisp_Object INTERNAL_FIELD (save_length); |
| 514 | |||
| 656 | /* File name used for auto-saving this buffer. | 515 | /* File name used for auto-saving this buffer. |
| 657 | This is not in the struct buffer_text | 516 | This is not in the struct buffer_text |
| 658 | because it's not used in indirect buffers at all. */ | 517 | because it's not used in indirect buffers at all. */ |
| 659 | Lisp_Object BUFFER_INTERNAL_FIELD (auto_save_file_name); | 518 | Lisp_Object INTERNAL_FIELD (auto_save_file_name); |
| 660 | 519 | ||
| 661 | /* Non-nil if buffer read-only. */ | 520 | /* Non-nil if buffer read-only. */ |
| 662 | Lisp_Object BUFFER_INTERNAL_FIELD (read_only); | 521 | Lisp_Object INTERNAL_FIELD (read_only); |
| 522 | |||
| 663 | /* "The mark". This is a marker which may | 523 | /* "The mark". This is a marker which may |
| 664 | point into this buffer or may point nowhere. */ | 524 | point into this buffer or may point nowhere. */ |
| 665 | Lisp_Object BUFFER_INTERNAL_FIELD (mark); | 525 | Lisp_Object INTERNAL_FIELD (mark); |
| 666 | 526 | ||
| 667 | /* Alist of elements (SYMBOL . VALUE-IN-THIS-BUFFER) for all | 527 | /* Alist of elements (SYMBOL . VALUE-IN-THIS-BUFFER) for all |
| 668 | per-buffer variables of this buffer. For locally unbound | 528 | per-buffer variables of this buffer. For locally unbound |
| 669 | symbols, just the symbol appears as the element. */ | 529 | symbols, just the symbol appears as the element. */ |
| 670 | Lisp_Object BUFFER_INTERNAL_FIELD (local_var_alist); | 530 | Lisp_Object INTERNAL_FIELD (local_var_alist); |
| 531 | |||
| 532 | /* Symbol naming major mode (e.g., lisp-mode). */ | ||
| 533 | Lisp_Object INTERNAL_FIELD (major_mode); | ||
| 534 | |||
| 535 | /* Pretty name of major mode (e.g., "Lisp"). */ | ||
| 536 | Lisp_Object INTERNAL_FIELD (mode_name); | ||
| 671 | 537 | ||
| 672 | /* Symbol naming major mode (eg, lisp-mode). */ | ||
| 673 | Lisp_Object BUFFER_INTERNAL_FIELD (major_mode); | ||
| 674 | /* Pretty name of major mode (eg, "Lisp"). */ | ||
| 675 | Lisp_Object BUFFER_INTERNAL_FIELD (mode_name); | ||
| 676 | /* Mode line element that controls format of mode line. */ | 538 | /* Mode line element that controls format of mode line. */ |
| 677 | Lisp_Object BUFFER_INTERNAL_FIELD (mode_line_format); | 539 | Lisp_Object INTERNAL_FIELD (mode_line_format); |
| 678 | 540 | ||
| 679 | /* Analogous to mode_line_format for the line displayed at the top | 541 | /* Analogous to mode_line_format for the line displayed at the top |
| 680 | of windows. Nil means don't display that line. */ | 542 | of windows. Nil means don't display that line. */ |
| 681 | Lisp_Object BUFFER_INTERNAL_FIELD (header_line_format); | 543 | Lisp_Object INTERNAL_FIELD (header_line_format); |
| 682 | 544 | ||
| 683 | /* Keys that are bound local to this buffer. */ | 545 | /* Keys that are bound local to this buffer. */ |
| 684 | Lisp_Object BUFFER_INTERNAL_FIELD (keymap); | 546 | Lisp_Object INTERNAL_FIELD (keymap); |
| 547 | |||
| 685 | /* This buffer's local abbrev table. */ | 548 | /* This buffer's local abbrev table. */ |
| 686 | Lisp_Object BUFFER_INTERNAL_FIELD (abbrev_table); | 549 | Lisp_Object INTERNAL_FIELD (abbrev_table); |
| 550 | |||
| 687 | /* This buffer's syntax table. */ | 551 | /* This buffer's syntax table. */ |
| 688 | Lisp_Object BUFFER_INTERNAL_FIELD (syntax_table); | 552 | Lisp_Object INTERNAL_FIELD (syntax_table); |
| 553 | |||
| 689 | /* This buffer's category table. */ | 554 | /* This buffer's category table. */ |
| 690 | Lisp_Object BUFFER_INTERNAL_FIELD (category_table); | 555 | Lisp_Object INTERNAL_FIELD (category_table); |
| 691 | 556 | ||
| 692 | /* Values of several buffer-local variables. */ | 557 | /* Values of several buffer-local variables. */ |
| 693 | /* tab-width is buffer-local so that redisplay can find it | 558 | /* tab-width is buffer-local so that redisplay can find it |
| 694 | in buffers that are not current. */ | 559 | in buffers that are not current. */ |
| 695 | Lisp_Object BUFFER_INTERNAL_FIELD (case_fold_search); | 560 | Lisp_Object INTERNAL_FIELD (case_fold_search); |
| 696 | Lisp_Object BUFFER_INTERNAL_FIELD (tab_width); | 561 | Lisp_Object INTERNAL_FIELD (tab_width); |
| 697 | Lisp_Object BUFFER_INTERNAL_FIELD (fill_column); | 562 | Lisp_Object INTERNAL_FIELD (fill_column); |
| 698 | Lisp_Object BUFFER_INTERNAL_FIELD (left_margin); | 563 | Lisp_Object INTERNAL_FIELD (left_margin); |
| 564 | |||
| 699 | /* Function to call when insert space past fill column. */ | 565 | /* Function to call when insert space past fill column. */ |
| 700 | Lisp_Object BUFFER_INTERNAL_FIELD (auto_fill_function); | 566 | Lisp_Object INTERNAL_FIELD (auto_fill_function); |
| 701 | 567 | ||
| 702 | /* Case table for case-conversion in this buffer. | 568 | /* Case table for case-conversion in this buffer. |
| 703 | This char-table maps each char into its lower-case version. */ | 569 | This char-table maps each char into its lower-case version. */ |
| 704 | Lisp_Object BUFFER_INTERNAL_FIELD (downcase_table); | 570 | Lisp_Object INTERNAL_FIELD (downcase_table); |
| 571 | |||
| 705 | /* Char-table mapping each char to its upper-case version. */ | 572 | /* Char-table mapping each char to its upper-case version. */ |
| 706 | Lisp_Object BUFFER_INTERNAL_FIELD (upcase_table); | 573 | Lisp_Object INTERNAL_FIELD (upcase_table); |
| 574 | |||
| 707 | /* Char-table for conversion for case-folding search. */ | 575 | /* Char-table for conversion for case-folding search. */ |
| 708 | Lisp_Object BUFFER_INTERNAL_FIELD (case_canon_table); | 576 | Lisp_Object INTERNAL_FIELD (case_canon_table); |
| 577 | |||
| 709 | /* Char-table of equivalences for case-folding search. */ | 578 | /* Char-table of equivalences for case-folding search. */ |
| 710 | Lisp_Object BUFFER_INTERNAL_FIELD (case_eqv_table); | 579 | Lisp_Object INTERNAL_FIELD (case_eqv_table); |
| 711 | 580 | ||
| 712 | /* Non-nil means do not display continuation lines. */ | 581 | /* Non-nil means do not display continuation lines. */ |
| 713 | Lisp_Object BUFFER_INTERNAL_FIELD (truncate_lines); | 582 | Lisp_Object INTERNAL_FIELD (truncate_lines); |
| 583 | |||
| 714 | /* Non-nil means to use word wrapping when displaying continuation lines. */ | 584 | /* Non-nil means to use word wrapping when displaying continuation lines. */ |
| 715 | Lisp_Object BUFFER_INTERNAL_FIELD (word_wrap); | 585 | Lisp_Object INTERNAL_FIELD (word_wrap); |
| 586 | |||
| 716 | /* Non-nil means display ctl chars with uparrow. */ | 587 | /* Non-nil means display ctl chars with uparrow. */ |
| 717 | Lisp_Object BUFFER_INTERNAL_FIELD (ctl_arrow); | 588 | Lisp_Object INTERNAL_FIELD (ctl_arrow); |
| 589 | |||
| 718 | /* Non-nil means reorder bidirectional text for display in the | 590 | /* Non-nil means reorder bidirectional text for display in the |
| 719 | visual order. */ | 591 | visual order. */ |
| 720 | Lisp_Object BUFFER_INTERNAL_FIELD (bidi_display_reordering); | 592 | Lisp_Object INTERNAL_FIELD (bidi_display_reordering); |
| 593 | |||
| 721 | /* If non-nil, specifies which direction of text to force in all the | 594 | /* If non-nil, specifies which direction of text to force in all the |
| 722 | paragraphs of the buffer. Nil means determine paragraph | 595 | paragraphs of the buffer. Nil means determine paragraph |
| 723 | direction dynamically for each paragraph. */ | 596 | direction dynamically for each paragraph. */ |
| 724 | Lisp_Object BUFFER_INTERNAL_FIELD (bidi_paragraph_direction); | 597 | Lisp_Object INTERNAL_FIELD (bidi_paragraph_direction); |
| 598 | |||
| 725 | /* Non-nil means do selective display; | 599 | /* Non-nil means do selective display; |
| 726 | see doc string in syms_of_buffer (buffer.c) for details. */ | 600 | see doc string in syms_of_buffer (buffer.c) for details. */ |
| 727 | Lisp_Object BUFFER_INTERNAL_FIELD (selective_display); | 601 | Lisp_Object INTERNAL_FIELD (selective_display); |
| 728 | #ifndef old | 602 | |
| 729 | /* Non-nil means show ... at end of line followed by invisible lines. */ | 603 | /* Non-nil means show ... at end of line followed by invisible lines. */ |
| 730 | Lisp_Object BUFFER_INTERNAL_FIELD (selective_display_ellipses); | 604 | Lisp_Object INTERNAL_FIELD (selective_display_ellipses); |
| 731 | #endif | 605 | |
| 732 | /* Alist of (FUNCTION . STRING) for each minor mode enabled in buffer. */ | 606 | /* Alist of (FUNCTION . STRING) for each minor mode enabled in buffer. */ |
| 733 | Lisp_Object BUFFER_INTERNAL_FIELD (minor_modes); | 607 | Lisp_Object INTERNAL_FIELD (minor_modes); |
| 608 | |||
| 734 | /* t if "self-insertion" should overwrite; `binary' if it should also | 609 | /* t if "self-insertion" should overwrite; `binary' if it should also |
| 735 | overwrite newlines and tabs - for editing executables and the like. */ | 610 | overwrite newlines and tabs - for editing executables and the like. */ |
| 736 | Lisp_Object BUFFER_INTERNAL_FIELD (overwrite_mode); | 611 | Lisp_Object INTERNAL_FIELD (overwrite_mode); |
| 737 | /* non-nil means abbrev mode is on. Expand abbrevs automatically. */ | 612 | |
| 738 | Lisp_Object BUFFER_INTERNAL_FIELD (abbrev_mode); | 613 | /* Non-nil means abbrev mode is on. Expand abbrevs automatically. */ |
| 614 | Lisp_Object INTERNAL_FIELD (abbrev_mode); | ||
| 615 | |||
| 739 | /* Display table to use for text in this buffer. */ | 616 | /* Display table to use for text in this buffer. */ |
| 740 | Lisp_Object BUFFER_INTERNAL_FIELD (display_table); | 617 | Lisp_Object INTERNAL_FIELD (display_table); |
| 618 | |||
| 741 | /* t means the mark and region are currently active. */ | 619 | /* t means the mark and region are currently active. */ |
| 742 | Lisp_Object BUFFER_INTERNAL_FIELD (mark_active); | 620 | Lisp_Object INTERNAL_FIELD (mark_active); |
| 743 | 621 | ||
| 744 | /* Non-nil means the buffer contents are regarded as multi-byte | 622 | /* Non-nil means the buffer contents are regarded as multi-byte |
| 745 | form of characters, not a binary code. */ | 623 | form of characters, not a binary code. */ |
| 746 | Lisp_Object BUFFER_INTERNAL_FIELD (enable_multibyte_characters); | 624 | Lisp_Object INTERNAL_FIELD (enable_multibyte_characters); |
| 747 | 625 | ||
| 748 | /* Coding system to be used for encoding the buffer contents on | 626 | /* Coding system to be used for encoding the buffer contents on |
| 749 | saving. */ | 627 | saving. */ |
| 750 | Lisp_Object BUFFER_INTERNAL_FIELD (buffer_file_coding_system); | 628 | Lisp_Object INTERNAL_FIELD (buffer_file_coding_system); |
| 751 | 629 | ||
| 752 | /* List of symbols naming the file format used for visited file. */ | 630 | /* List of symbols naming the file format used for visited file. */ |
| 753 | Lisp_Object BUFFER_INTERNAL_FIELD (file_format); | 631 | Lisp_Object INTERNAL_FIELD (file_format); |
| 754 | 632 | ||
| 755 | /* List of symbols naming the file format used for auto-save file. */ | 633 | /* List of symbols naming the file format used for auto-save file. */ |
| 756 | Lisp_Object BUFFER_INTERNAL_FIELD (auto_save_file_format); | 634 | Lisp_Object INTERNAL_FIELD (auto_save_file_format); |
| 757 | 635 | ||
| 758 | /* True if the newline position cache and width run cache are | 636 | /* True if the newline position cache, width run cache and BIDI paragraph |
| 759 | enabled. See search.c and indent.c. */ | 637 | cache are enabled. See search.c, indent.c and bidi.c for details. */ |
| 760 | Lisp_Object BUFFER_INTERNAL_FIELD (cache_long_line_scans); | 638 | Lisp_Object INTERNAL_FIELD (cache_long_scans); |
| 761 | 639 | ||
| 762 | /* If the width run cache is enabled, this table contains the | 640 | /* If the width run cache is enabled, this table contains the |
| 763 | character widths width_run_cache (see above) assumes. When we | 641 | character widths width_run_cache (see above) assumes. When we |
| @@ -765,105 +643,389 @@ struct buffer | |||
| 765 | current display table to see whether the display table has | 643 | current display table to see whether the display table has |
| 766 | affected the widths of any characters. If it has, we | 644 | affected the widths of any characters. If it has, we |
| 767 | invalidate the width run cache, and re-initialize width_table. */ | 645 | invalidate the width run cache, and re-initialize width_table. */ |
| 768 | Lisp_Object BUFFER_INTERNAL_FIELD (width_table); | 646 | Lisp_Object INTERNAL_FIELD (width_table); |
| 769 | 647 | ||
| 770 | /* In an indirect buffer, or a buffer that is the base of an | 648 | /* In an indirect buffer, or a buffer that is the base of an |
| 771 | indirect buffer, this holds a marker that records | 649 | indirect buffer, this holds a marker that records |
| 772 | PT for this buffer when the buffer is not current. */ | 650 | PT for this buffer when the buffer is not current. */ |
| 773 | Lisp_Object BUFFER_INTERNAL_FIELD (pt_marker); | 651 | Lisp_Object INTERNAL_FIELD (pt_marker); |
| 774 | 652 | ||
| 775 | /* In an indirect buffer, or a buffer that is the base of an | 653 | /* In an indirect buffer, or a buffer that is the base of an |
| 776 | indirect buffer, this holds a marker that records | 654 | indirect buffer, this holds a marker that records |
| 777 | BEGV for this buffer when the buffer is not current. */ | 655 | BEGV for this buffer when the buffer is not current. */ |
| 778 | Lisp_Object BUFFER_INTERNAL_FIELD (begv_marker); | 656 | Lisp_Object INTERNAL_FIELD (begv_marker); |
| 779 | 657 | ||
| 780 | /* In an indirect buffer, or a buffer that is the base of an | 658 | /* In an indirect buffer, or a buffer that is the base of an |
| 781 | indirect buffer, this holds a marker that records | 659 | indirect buffer, this holds a marker that records |
| 782 | ZV for this buffer when the buffer is not current. */ | 660 | ZV for this buffer when the buffer is not current. */ |
| 783 | Lisp_Object BUFFER_INTERNAL_FIELD (zv_marker); | 661 | Lisp_Object INTERNAL_FIELD (zv_marker); |
| 784 | 662 | ||
| 785 | /* This holds the point value before the last scroll operation. | 663 | /* This holds the point value before the last scroll operation. |
| 786 | Explicitly setting point sets this to nil. */ | 664 | Explicitly setting point sets this to nil. */ |
| 787 | Lisp_Object BUFFER_INTERNAL_FIELD (point_before_scroll); | 665 | Lisp_Object INTERNAL_FIELD (point_before_scroll); |
| 788 | 666 | ||
| 789 | /* Truename of the visited file, or nil. */ | 667 | /* Truename of the visited file, or nil. */ |
| 790 | Lisp_Object BUFFER_INTERNAL_FIELD (file_truename); | 668 | Lisp_Object INTERNAL_FIELD (file_truename); |
| 791 | 669 | ||
| 792 | /* Invisibility spec of this buffer. | 670 | /* Invisibility spec of this buffer. |
| 793 | t => any non-nil `invisible' property means invisible. | 671 | t => any non-nil `invisible' property means invisible. |
| 794 | A list => `invisible' property means invisible | 672 | A list => `invisible' property means invisible |
| 795 | if it is memq in that list. */ | 673 | if it is memq in that list. */ |
| 796 | Lisp_Object BUFFER_INTERNAL_FIELD (invisibility_spec); | 674 | Lisp_Object INTERNAL_FIELD (invisibility_spec); |
| 797 | 675 | ||
| 798 | /* This is the last window that was selected with this buffer in it, | 676 | /* This is the last window that was selected with this buffer in it, |
| 799 | or nil if that window no longer displays this buffer. */ | 677 | or nil if that window no longer displays this buffer. */ |
| 800 | Lisp_Object BUFFER_INTERNAL_FIELD (last_selected_window); | 678 | Lisp_Object INTERNAL_FIELD (last_selected_window); |
| 801 | 679 | ||
| 802 | /* Incremented each time the buffer is displayed in a window. */ | 680 | /* Incremented each time the buffer is displayed in a window. */ |
| 803 | Lisp_Object BUFFER_INTERNAL_FIELD (display_count); | 681 | Lisp_Object INTERNAL_FIELD (display_count); |
| 804 | 682 | ||
| 805 | /* Widths of left and right marginal areas for windows displaying | 683 | /* Widths of left and right marginal areas for windows displaying |
| 806 | this buffer. */ | 684 | this buffer. */ |
| 807 | Lisp_Object BUFFER_INTERNAL_FIELD (left_margin_cols), BUFFER_INTERNAL_FIELD (right_margin_cols); | 685 | Lisp_Object INTERNAL_FIELD (left_margin_cols); |
| 686 | Lisp_Object INTERNAL_FIELD (right_margin_cols); | ||
| 808 | 687 | ||
| 809 | /* Widths of left and right fringe areas for windows displaying | 688 | /* Widths of left and right fringe areas for windows displaying |
| 810 | this buffer. */ | 689 | this buffer. */ |
| 811 | Lisp_Object BUFFER_INTERNAL_FIELD (left_fringe_width), BUFFER_INTERNAL_FIELD (right_fringe_width); | 690 | Lisp_Object INTERNAL_FIELD (left_fringe_width); |
| 691 | Lisp_Object INTERNAL_FIELD (right_fringe_width); | ||
| 812 | 692 | ||
| 813 | /* Non-nil means fringes are drawn outside display margins; | 693 | /* Non-nil means fringes are drawn outside display margins; |
| 814 | othersize draw them between margin areas and text. */ | 694 | othersize draw them between margin areas and text. */ |
| 815 | Lisp_Object BUFFER_INTERNAL_FIELD (fringes_outside_margins); | 695 | Lisp_Object INTERNAL_FIELD (fringes_outside_margins); |
| 816 | 696 | ||
| 817 | /* Width and type of scroll bar areas for windows displaying | 697 | /* Width and type of scroll bar areas for windows displaying |
| 818 | this buffer. */ | 698 | this buffer. */ |
| 819 | Lisp_Object BUFFER_INTERNAL_FIELD (scroll_bar_width), BUFFER_INTERNAL_FIELD (vertical_scroll_bar_type); | 699 | Lisp_Object INTERNAL_FIELD (scroll_bar_width); |
| 700 | Lisp_Object INTERNAL_FIELD (vertical_scroll_bar_type); | ||
| 820 | 701 | ||
| 821 | /* Non-nil means indicate lines not displaying text (in a style | 702 | /* Non-nil means indicate lines not displaying text (in a style |
| 822 | like vi). */ | 703 | like vi). */ |
| 823 | Lisp_Object BUFFER_INTERNAL_FIELD (indicate_empty_lines); | 704 | Lisp_Object INTERNAL_FIELD (indicate_empty_lines); |
| 824 | 705 | ||
| 825 | /* Non-nil means indicate buffer boundaries and scrolling. */ | 706 | /* Non-nil means indicate buffer boundaries and scrolling. */ |
| 826 | Lisp_Object BUFFER_INTERNAL_FIELD (indicate_buffer_boundaries); | 707 | Lisp_Object INTERNAL_FIELD (indicate_buffer_boundaries); |
| 827 | 708 | ||
| 828 | /* Logical to physical fringe bitmap mappings. */ | 709 | /* Logical to physical fringe bitmap mappings. */ |
| 829 | Lisp_Object BUFFER_INTERNAL_FIELD (fringe_indicator_alist); | 710 | Lisp_Object INTERNAL_FIELD (fringe_indicator_alist); |
| 830 | 711 | ||
| 831 | /* Logical to physical cursor bitmap mappings. */ | 712 | /* Logical to physical cursor bitmap mappings. */ |
| 832 | Lisp_Object BUFFER_INTERNAL_FIELD (fringe_cursor_alist); | 713 | Lisp_Object INTERNAL_FIELD (fringe_cursor_alist); |
| 833 | 714 | ||
| 834 | /* Time stamp updated each time this buffer is displayed in a window. */ | 715 | /* Time stamp updated each time this buffer is displayed in a window. */ |
| 835 | Lisp_Object BUFFER_INTERNAL_FIELD (display_time); | 716 | Lisp_Object INTERNAL_FIELD (display_time); |
| 836 | 717 | ||
| 837 | /* If scrolling the display because point is below the bottom of a | 718 | /* If scrolling the display because point is below the bottom of a |
| 838 | window showing this buffer, try to choose a window start so | 719 | window showing this buffer, try to choose a window start so |
| 839 | that point ends up this number of lines from the top of the | 720 | that point ends up this number of lines from the top of the |
| 840 | window. Nil means that scrolling method isn't used. */ | 721 | window. Nil means that scrolling method isn't used. */ |
| 841 | Lisp_Object BUFFER_INTERNAL_FIELD (scroll_up_aggressively); | 722 | Lisp_Object INTERNAL_FIELD (scroll_up_aggressively); |
| 842 | 723 | ||
| 843 | /* If scrolling the display because point is above the top of a | 724 | /* If scrolling the display because point is above the top of a |
| 844 | window showing this buffer, try to choose a window start so | 725 | window showing this buffer, try to choose a window start so |
| 845 | that point ends up this number of lines from the bottom of the | 726 | that point ends up this number of lines from the bottom of the |
| 846 | window. Nil means that scrolling method isn't used. */ | 727 | window. Nil means that scrolling method isn't used. */ |
| 847 | Lisp_Object BUFFER_INTERNAL_FIELD (scroll_down_aggressively); | 728 | Lisp_Object INTERNAL_FIELD (scroll_down_aggressively); |
| 848 | 729 | ||
| 849 | /* Desired cursor type in this buffer. See the doc string of | 730 | /* Desired cursor type in this buffer. See the doc string of |
| 850 | per-buffer variable `cursor-type'. */ | 731 | per-buffer variable `cursor-type'. */ |
| 851 | Lisp_Object BUFFER_INTERNAL_FIELD (cursor_type); | 732 | Lisp_Object INTERNAL_FIELD (cursor_type); |
| 852 | 733 | ||
| 853 | /* An integer > 0 means put that number of pixels below text lines | 734 | /* An integer > 0 means put that number of pixels below text lines |
| 854 | in the display of this buffer. */ | 735 | in the display of this buffer. */ |
| 855 | Lisp_Object BUFFER_INTERNAL_FIELD (extra_line_spacing); | 736 | Lisp_Object INTERNAL_FIELD (extra_line_spacing); |
| 856 | 737 | ||
| 857 | /* *Cursor type to display in non-selected windows. | 738 | /* Cursor type to display in non-selected windows. |
| 858 | t means to use hollow box cursor. | 739 | t means to use hollow box cursor. |
| 859 | See `cursor-type' for other values. */ | 740 | See `cursor-type' for other values. */ |
| 860 | Lisp_Object BUFFER_INTERNAL_FIELD (cursor_in_non_selected_windows); | 741 | Lisp_Object INTERNAL_FIELD (cursor_in_non_selected_windows); |
| 742 | |||
| 743 | /* No more Lisp_Object beyond this point. Except undo_list, | ||
| 744 | which is handled specially in Fgarbage_collect . */ | ||
| 745 | |||
| 746 | /* This structure holds the coordinates of the buffer contents | ||
| 747 | in ordinary buffers. In indirect buffers, this is not used. */ | ||
| 748 | struct buffer_text own_text; | ||
| 749 | |||
| 750 | /* This points to the `struct buffer_text' that used for this buffer. | ||
| 751 | In an ordinary buffer, this is the own_text field above. | ||
| 752 | In an indirect buffer, this is the own_text field of another buffer. */ | ||
| 753 | struct buffer_text *text; | ||
| 754 | |||
| 755 | /* Next buffer, in chain of all buffers, including killed ones. */ | ||
| 756 | struct buffer *next; | ||
| 757 | |||
| 758 | /* Char position of point in buffer. */ | ||
| 759 | ptrdiff_t pt; | ||
| 861 | 760 | ||
| 862 | /* This must be the last field in the above list. */ | 761 | /* Byte position of point in buffer. */ |
| 863 | #define LAST_FIELD_PER_BUFFER cursor_in_non_selected_windows | 762 | ptrdiff_t pt_byte; |
| 763 | |||
| 764 | /* Char position of beginning of accessible range. */ | ||
| 765 | ptrdiff_t begv; | ||
| 766 | |||
| 767 | /* Byte position of beginning of accessible range. */ | ||
| 768 | ptrdiff_t begv_byte; | ||
| 769 | |||
| 770 | /* Char position of end of accessible range. */ | ||
| 771 | ptrdiff_t zv; | ||
| 772 | |||
| 773 | /* Byte position of end of accessible range. */ | ||
| 774 | ptrdiff_t zv_byte; | ||
| 775 | |||
| 776 | /* In an indirect buffer, this points to the base buffer. | ||
| 777 | In an ordinary buffer, it is 0. */ | ||
| 778 | struct buffer *base_buffer; | ||
| 779 | |||
| 780 | /* In an indirect buffer, this is -1. In an ordinary buffer, | ||
| 781 | it's the number of indirect buffers that share our text; | ||
| 782 | zero means that we're the only owner of this text. */ | ||
| 783 | int indirections; | ||
| 784 | |||
| 785 | /* Number of windows showing this buffer. Always -1 for | ||
| 786 | an indirect buffer since it counts as its base buffer. */ | ||
| 787 | int window_count; | ||
| 788 | |||
| 789 | /* A non-zero value in slot IDX means that per-buffer variable | ||
| 790 | with index IDX has a local value in this buffer. The index IDX | ||
| 791 | for a buffer-local variable is stored in that variable's slot | ||
| 792 | in buffer_local_flags as a Lisp integer. If the index is -1, | ||
| 793 | this means the variable is always local in all buffers. */ | ||
| 794 | #define MAX_PER_BUFFER_VARS 50 | ||
| 795 | char local_flags[MAX_PER_BUFFER_VARS]; | ||
| 796 | |||
| 797 | /* Set to the modtime of the visited file when read or written. | ||
| 798 | modtime.tv_nsec == NONEXISTENT_MODTIME_NSECS means | ||
| 799 | visited file was nonexistent. modtime.tv_nsec == | ||
| 800 | UNKNOWN_MODTIME_NSECS means visited file modtime unknown; | ||
| 801 | in no case complain about any mismatch on next save attempt. */ | ||
| 802 | #define NONEXISTENT_MODTIME_NSECS (-1) | ||
| 803 | #define UNKNOWN_MODTIME_NSECS (-2) | ||
| 804 | struct timespec modtime; | ||
| 805 | |||
| 806 | /* Size of the file when modtime was set. This is used to detect the | ||
| 807 | case where the file grew while we were reading it, so the modtime | ||
| 808 | is still the same (since it's rounded up to seconds) but we're actually | ||
| 809 | not up-to-date. -1 means the size is unknown. Only meaningful if | ||
| 810 | modtime is actually set. */ | ||
| 811 | off_t modtime_size; | ||
| 812 | |||
| 813 | /* The value of text->modiff at the last auto-save. */ | ||
| 814 | EMACS_INT auto_save_modified; | ||
| 815 | |||
| 816 | /* The value of text->modiff at the last display error. | ||
| 817 | Redisplay of this buffer is inhibited until it changes again. */ | ||
| 818 | EMACS_INT display_error_modiff; | ||
| 819 | |||
| 820 | /* The time at which we detected a failure to auto-save, | ||
| 821 | Or 0 if we didn't have a failure. */ | ||
| 822 | time_t auto_save_failure_time; | ||
| 823 | |||
| 824 | /* Position in buffer at which display started | ||
| 825 | the last time this buffer was displayed. */ | ||
| 826 | ptrdiff_t last_window_start; | ||
| 827 | |||
| 828 | /* If the long line scan cache is enabled (i.e. the buffer-local | ||
| 829 | variable cache-long-line-scans is non-nil), newline_cache | ||
| 830 | points to the newline cache, and width_run_cache points to the | ||
| 831 | width run cache. | ||
| 832 | |||
| 833 | The newline cache records which stretches of the buffer are | ||
| 834 | known *not* to contain newlines, so that they can be skipped | ||
| 835 | quickly when we search for newlines. | ||
| 836 | |||
| 837 | The width run cache records which stretches of the buffer are | ||
| 838 | known to contain characters whose widths are all the same. If | ||
| 839 | the width run cache maps a character to a value > 0, that value is | ||
| 840 | the character's width; if it maps a character to zero, we don't | ||
| 841 | know what its width is. This allows compute_motion to process | ||
| 842 | such regions very quickly, using algebra instead of inspecting | ||
| 843 | each character. See also width_table, below. | ||
| 844 | |||
| 845 | The latter cache is used to speedup bidi_find_paragraph_start. */ | ||
| 846 | struct region_cache *newline_cache; | ||
| 847 | struct region_cache *width_run_cache; | ||
| 848 | struct region_cache *bidi_paragraph_cache; | ||
| 849 | |||
| 850 | /* Non-zero means don't use redisplay optimizations for | ||
| 851 | displaying this buffer. */ | ||
| 852 | unsigned prevent_redisplay_optimizations_p : 1; | ||
| 853 | |||
| 854 | /* Non-zero whenever the narrowing is changed in this buffer. */ | ||
| 855 | unsigned clip_changed : 1; | ||
| 856 | |||
| 857 | /* List of overlays that end at or before the current center, | ||
| 858 | in order of end-position. */ | ||
| 859 | struct Lisp_Overlay *overlays_before; | ||
| 860 | |||
| 861 | /* List of overlays that end after the current center, | ||
| 862 | in order of start-position. */ | ||
| 863 | struct Lisp_Overlay *overlays_after; | ||
| 864 | |||
| 865 | /* Position where the overlay lists are centered. */ | ||
| 866 | ptrdiff_t overlay_center; | ||
| 867 | |||
| 868 | /* Changes in the buffer are recorded here for undo, and t means | ||
| 869 | don't record anything. This information belongs to the base | ||
| 870 | buffer of an indirect buffer. But we can't store it in the | ||
| 871 | struct buffer_text because local variables have to be right in | ||
| 872 | the struct buffer. So we copy it around in set_buffer_internal. */ | ||
| 873 | Lisp_Object INTERNAL_FIELD (undo_list); | ||
| 864 | }; | 874 | }; |
| 865 | 875 | ||
| 866 | 876 | /* Most code should use these functions to set Lisp fields in struct | |
| 877 | buffer. */ | ||
| 878 | BUFFER_INLINE void | ||
| 879 | bset_bidi_paragraph_direction (struct buffer *b, Lisp_Object val) | ||
| 880 | { | ||
| 881 | b->INTERNAL_FIELD (bidi_paragraph_direction) = val; | ||
| 882 | } | ||
| 883 | BUFFER_INLINE void | ||
| 884 | bset_case_canon_table (struct buffer *b, Lisp_Object val) | ||
| 885 | { | ||
| 886 | b->INTERNAL_FIELD (case_canon_table) = val; | ||
| 887 | } | ||
| 888 | BUFFER_INLINE void | ||
| 889 | bset_case_eqv_table (struct buffer *b, Lisp_Object val) | ||
| 890 | { | ||
| 891 | b->INTERNAL_FIELD (case_eqv_table) = val; | ||
| 892 | } | ||
| 893 | BUFFER_INLINE void | ||
| 894 | bset_directory (struct buffer *b, Lisp_Object val) | ||
| 895 | { | ||
| 896 | b->INTERNAL_FIELD (directory) = val; | ||
| 897 | } | ||
| 898 | BUFFER_INLINE void | ||
| 899 | bset_display_count (struct buffer *b, Lisp_Object val) | ||
| 900 | { | ||
| 901 | b->INTERNAL_FIELD (display_count) = val; | ||
| 902 | } | ||
| 903 | BUFFER_INLINE void | ||
| 904 | bset_display_time (struct buffer *b, Lisp_Object val) | ||
| 905 | { | ||
| 906 | b->INTERNAL_FIELD (display_time) = val; | ||
| 907 | } | ||
| 908 | BUFFER_INLINE void | ||
| 909 | bset_downcase_table (struct buffer *b, Lisp_Object val) | ||
| 910 | { | ||
| 911 | b->INTERNAL_FIELD (downcase_table) = val; | ||
| 912 | } | ||
| 913 | BUFFER_INLINE void | ||
| 914 | bset_enable_multibyte_characters (struct buffer *b, Lisp_Object val) | ||
| 915 | { | ||
| 916 | b->INTERNAL_FIELD (enable_multibyte_characters) = val; | ||
| 917 | } | ||
| 918 | BUFFER_INLINE void | ||
| 919 | bset_filename (struct buffer *b, Lisp_Object val) | ||
| 920 | { | ||
| 921 | b->INTERNAL_FIELD (filename) = val; | ||
| 922 | } | ||
| 923 | BUFFER_INLINE void | ||
| 924 | bset_keymap (struct buffer *b, Lisp_Object val) | ||
| 925 | { | ||
| 926 | b->INTERNAL_FIELD (keymap) = val; | ||
| 927 | } | ||
| 928 | BUFFER_INLINE void | ||
| 929 | bset_last_selected_window (struct buffer *b, Lisp_Object val) | ||
| 930 | { | ||
| 931 | b->INTERNAL_FIELD (last_selected_window) = val; | ||
| 932 | } | ||
| 933 | BUFFER_INLINE void | ||
| 934 | bset_local_var_alist (struct buffer *b, Lisp_Object val) | ||
| 935 | { | ||
| 936 | b->INTERNAL_FIELD (local_var_alist) = val; | ||
| 937 | } | ||
| 938 | BUFFER_INLINE void | ||
| 939 | bset_mark_active (struct buffer *b, Lisp_Object val) | ||
| 940 | { | ||
| 941 | b->INTERNAL_FIELD (mark_active) = val; | ||
| 942 | } | ||
| 943 | BUFFER_INLINE void | ||
| 944 | bset_point_before_scroll (struct buffer *b, Lisp_Object val) | ||
| 945 | { | ||
| 946 | b->INTERNAL_FIELD (point_before_scroll) = val; | ||
| 947 | } | ||
| 948 | BUFFER_INLINE void | ||
| 949 | bset_read_only (struct buffer *b, Lisp_Object val) | ||
| 950 | { | ||
| 951 | b->INTERNAL_FIELD (read_only) = val; | ||
| 952 | } | ||
| 953 | BUFFER_INLINE void | ||
| 954 | bset_truncate_lines (struct buffer *b, Lisp_Object val) | ||
| 955 | { | ||
| 956 | b->INTERNAL_FIELD (truncate_lines) = val; | ||
| 957 | } | ||
| 958 | BUFFER_INLINE void | ||
| 959 | bset_undo_list (struct buffer *b, Lisp_Object val) | ||
| 960 | { | ||
| 961 | b->INTERNAL_FIELD (undo_list) = val; | ||
| 962 | } | ||
| 963 | BUFFER_INLINE void | ||
| 964 | bset_upcase_table (struct buffer *b, Lisp_Object val) | ||
| 965 | { | ||
| 966 | b->INTERNAL_FIELD (upcase_table) = val; | ||
| 967 | } | ||
| 968 | BUFFER_INLINE void | ||
| 969 | bset_width_table (struct buffer *b, Lisp_Object val) | ||
| 970 | { | ||
| 971 | b->INTERNAL_FIELD (width_table) = val; | ||
| 972 | } | ||
| 973 | |||
| 974 | /* Number of Lisp_Objects at the beginning of struct buffer. | ||
| 975 | If you add, remove, or reorder Lisp_Objects within buffer | ||
| 976 | structure, make sure that this is still correct. */ | ||
| 977 | |||
| 978 | #define BUFFER_LISP_SIZE \ | ||
| 979 | ((offsetof (struct buffer, own_text) - header_size) / word_size) | ||
| 980 | |||
| 981 | /* Size of the struct buffer part beyond leading Lisp_Objects, in word_size | ||
| 982 | units. Rounding is needed for --with-wide-int configuration. */ | ||
| 983 | |||
| 984 | #define BUFFER_REST_SIZE \ | ||
| 985 | ((((sizeof (struct buffer) - offsetof (struct buffer, own_text)) \ | ||
| 986 | + (word_size - 1)) & ~(word_size - 1)) / word_size) | ||
| 987 | |||
| 988 | /* Initialize the pseudovector header of buffer object. BUFFER_LISP_SIZE | ||
| 989 | is required for GC, but BUFFER_REST_SIZE is set up just to be consistent | ||
| 990 | with other pseudovectors. */ | ||
| 991 | |||
| 992 | #define BUFFER_PVEC_INIT(b) \ | ||
| 993 | XSETPVECTYPESIZE (b, PVEC_BUFFER, BUFFER_LISP_SIZE, BUFFER_REST_SIZE) | ||
| 994 | |||
| 995 | /* Convenient check whether buffer B is live. */ | ||
| 996 | |||
| 997 | #define BUFFER_LIVE_P(b) (!NILP (BVAR (b, name))) | ||
| 998 | |||
| 999 | /* Convenient check whether buffer B is hidden (i.e. its name | ||
| 1000 | starts with a space). Caller must ensure that B is live. */ | ||
| 1001 | |||
| 1002 | #define BUFFER_HIDDEN_P(b) (SREF (BVAR (b, name), 0) == ' ') | ||
| 1003 | |||
| 1004 | /* Verify indirection counters. */ | ||
| 1005 | |||
| 1006 | #define BUFFER_CHECK_INDIRECTION(b) \ | ||
| 1007 | do { \ | ||
| 1008 | if (BUFFER_LIVE_P (b)) \ | ||
| 1009 | { \ | ||
| 1010 | if (b->base_buffer) \ | ||
| 1011 | { \ | ||
| 1012 | eassert (b->indirections == -1); \ | ||
| 1013 | eassert (b->base_buffer->indirections > 0); \ | ||
| 1014 | } \ | ||
| 1015 | else \ | ||
| 1016 | eassert (b->indirections >= 0); \ | ||
| 1017 | } \ | ||
| 1018 | } while (0) | ||
| 1019 | |||
| 1020 | /* Chain of all buffers, including killed ones. */ | ||
| 1021 | |||
| 1022 | extern struct buffer *all_buffers; | ||
| 1023 | |||
| 1024 | /* Used to iterate over the chain above. */ | ||
| 1025 | |||
| 1026 | #define FOR_EACH_BUFFER(b) \ | ||
| 1027 | for ((b) = all_buffers; (b); (b) = (b)->next) | ||
| 1028 | |||
| 867 | /* This points to the current buffer. */ | 1029 | /* This points to the current buffer. */ |
| 868 | 1030 | ||
| 869 | extern struct buffer *current_buffer; | 1031 | extern struct buffer *current_buffer; |
| @@ -901,21 +1063,47 @@ extern struct buffer buffer_local_symbols; | |||
| 901 | 1063 | ||
| 902 | extern void delete_all_overlays (struct buffer *); | 1064 | extern void delete_all_overlays (struct buffer *); |
| 903 | extern void reset_buffer (struct buffer *); | 1065 | extern void reset_buffer (struct buffer *); |
| 1066 | extern void compact_buffer (struct buffer *); | ||
| 904 | extern void evaporate_overlays (ptrdiff_t); | 1067 | extern void evaporate_overlays (ptrdiff_t); |
| 905 | extern ptrdiff_t overlays_at (EMACS_INT pos, int extend, Lisp_Object **vec_ptr, | 1068 | extern ptrdiff_t overlays_at (EMACS_INT, bool, Lisp_Object **, |
| 906 | ptrdiff_t *len_ptr, ptrdiff_t *next_ptr, | 1069 | ptrdiff_t *, ptrdiff_t *, ptrdiff_t *, bool); |
| 907 | ptrdiff_t *prev_ptr, int change_req); | ||
| 908 | extern ptrdiff_t sort_overlays (Lisp_Object *, ptrdiff_t, struct window *); | 1070 | extern ptrdiff_t sort_overlays (Lisp_Object *, ptrdiff_t, struct window *); |
| 909 | extern void recenter_overlay_lists (struct buffer *, ptrdiff_t); | 1071 | extern void recenter_overlay_lists (struct buffer *, ptrdiff_t); |
| 910 | extern ptrdiff_t overlay_strings (ptrdiff_t, struct window *, unsigned char **); | 1072 | extern ptrdiff_t overlay_strings (ptrdiff_t, struct window *, unsigned char **); |
| 911 | extern void validate_region (Lisp_Object *, Lisp_Object *); | 1073 | extern void validate_region (Lisp_Object *, Lisp_Object *); |
| 912 | extern void set_buffer_internal (struct buffer *); | ||
| 913 | extern void set_buffer_internal_1 (struct buffer *); | 1074 | extern void set_buffer_internal_1 (struct buffer *); |
| 914 | extern void set_buffer_temp (struct buffer *); | 1075 | extern void set_buffer_temp (struct buffer *); |
| 1076 | extern Lisp_Object buffer_local_value_1 (Lisp_Object, Lisp_Object); | ||
| 915 | extern void record_buffer (Lisp_Object); | 1077 | extern void record_buffer (Lisp_Object); |
| 916 | extern void buffer_slot_type_mismatch (Lisp_Object, int) NO_RETURN; | ||
| 917 | extern void fix_overlays_before (struct buffer *, ptrdiff_t, ptrdiff_t); | 1078 | extern void fix_overlays_before (struct buffer *, ptrdiff_t, ptrdiff_t); |
| 918 | extern void mmap_set_vars (int); | 1079 | extern void mmap_set_vars (bool); |
| 1080 | extern void restore_buffer (Lisp_Object); | ||
| 1081 | extern void set_buffer_if_live (Lisp_Object); | ||
| 1082 | |||
| 1083 | /* Set the current buffer to B. | ||
| 1084 | |||
| 1085 | We previously set windows_or_buffers_changed here to invalidate | ||
| 1086 | global unchanged information in beg_unchanged and end_unchanged. | ||
| 1087 | This is no longer necessary because we now compute unchanged | ||
| 1088 | information on a buffer-basis. Every action affecting other | ||
| 1089 | windows than the selected one requires a select_window at some | ||
| 1090 | time, and that increments windows_or_buffers_changed. */ | ||
| 1091 | |||
| 1092 | BUFFER_INLINE void | ||
| 1093 | set_buffer_internal (struct buffer *b) | ||
| 1094 | { | ||
| 1095 | if (current_buffer != b) | ||
| 1096 | set_buffer_internal_1 (b); | ||
| 1097 | } | ||
| 1098 | |||
| 1099 | /* Arrange to go back to the original buffer after the next | ||
| 1100 | call to unbind_to if the original buffer is still alive. */ | ||
| 1101 | |||
| 1102 | BUFFER_INLINE void | ||
| 1103 | record_unwind_current_buffer (void) | ||
| 1104 | { | ||
| 1105 | record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ()); | ||
| 1106 | } | ||
| 919 | 1107 | ||
| 920 | /* Get overlays at POSN into array OVERLAYS with NOVERLAYS elements. | 1108 | /* Get overlays at POSN into array OVERLAYS with NOVERLAYS elements. |
| 921 | If NEXTP is non-NULL, return next overlay there. | 1109 | If NEXTP is non-NULL, return next overlay there. |
| @@ -923,52 +1111,122 @@ extern void mmap_set_vars (int); | |||
| 923 | 1111 | ||
| 924 | #define GET_OVERLAYS_AT(posn, overlays, noverlays, nextp, chrq) \ | 1112 | #define GET_OVERLAYS_AT(posn, overlays, noverlays, nextp, chrq) \ |
| 925 | do { \ | 1113 | do { \ |
| 926 | ptrdiff_t maxlen = 40; \ | 1114 | ptrdiff_t maxlen = 40; \ |
| 927 | overlays = (Lisp_Object *) alloca (maxlen * sizeof (Lisp_Object)); \ | 1115 | overlays = alloca (maxlen * sizeof *overlays); \ |
| 928 | noverlays = overlays_at (posn, 0, &overlays, &maxlen, \ | 1116 | noverlays = overlays_at (posn, 0, &overlays, &maxlen, \ |
| 929 | nextp, NULL, chrq); \ | 1117 | nextp, NULL, chrq); \ |
| 930 | if (noverlays > maxlen) \ | 1118 | if (noverlays > maxlen) \ |
| 931 | { \ | 1119 | { \ |
| 932 | maxlen = noverlays; \ | 1120 | maxlen = noverlays; \ |
| 933 | overlays = (Lisp_Object *) alloca (maxlen * sizeof (Lisp_Object)); \ | 1121 | overlays = alloca (maxlen * sizeof *overlays); \ |
| 934 | noverlays = overlays_at (posn, 0, &overlays, &maxlen, \ | 1122 | noverlays = overlays_at (posn, 0, &overlays, &maxlen, \ |
| 935 | nextp, NULL, chrq); \ | 1123 | nextp, NULL, chrq); \ |
| 936 | } \ | 1124 | } \ |
| 937 | } while (0) | 1125 | } while (0) |
| 938 | 1126 | ||
| 939 | EXFUN (Fbuffer_live_p, 1); | 1127 | extern Lisp_Object Vbuffer_alist; |
| 940 | EXFUN (Fbuffer_name, 1); | ||
| 941 | EXFUN (Fnext_overlay_change, 1); | ||
| 942 | EXFUN (Fbuffer_local_value, 2); | ||
| 943 | |||
| 944 | extern Lisp_Object Qbefore_change_functions; | 1128 | extern Lisp_Object Qbefore_change_functions; |
| 945 | extern Lisp_Object Qafter_change_functions; | 1129 | extern Lisp_Object Qafter_change_functions; |
| 946 | extern Lisp_Object Qfirst_change_hook; | 1130 | extern Lisp_Object Qfirst_change_hook; |
| 1131 | extern Lisp_Object Qpriority, Qbefore_string, Qafter_string; | ||
| 947 | 1132 | ||
| 948 | 1133 | /* FOR_EACH_LIVE_BUFFER (LIST_VAR, BUF_VAR) followed by a statement is | |
| 949 | /* Overlays */ | 1134 | a `for' loop which iterates over the buffers from Vbuffer_alist. */ |
| 1135 | |||
| 1136 | #define FOR_EACH_LIVE_BUFFER(list_var, buf_var) \ | ||
| 1137 | FOR_EACH_ALIST_VALUE (Vbuffer_alist, list_var, buf_var) | ||
| 1138 | |||
| 1139 | /* Get text properties of B. */ | ||
| 1140 | |||
| 1141 | BUFFER_INLINE INTERVAL | ||
| 1142 | buffer_intervals (struct buffer *b) | ||
| 1143 | { | ||
| 1144 | eassert (b->text != NULL); | ||
| 1145 | return b->text->intervals; | ||
| 1146 | } | ||
| 1147 | |||
| 1148 | /* Set text properties of B to I. */ | ||
| 1149 | |||
| 1150 | BUFFER_INLINE void | ||
| 1151 | set_buffer_intervals (struct buffer *b, INTERVAL i) | ||
| 1152 | { | ||
| 1153 | eassert (b->text != NULL); | ||
| 1154 | b->text->intervals = i; | ||
| 1155 | } | ||
| 1156 | |||
| 1157 | /* Non-zero if current buffer has overlays. */ | ||
| 950 | 1158 | ||
| 951 | /* 1 if the OV is an overlay object. */ | 1159 | BUFFER_INLINE bool |
| 1160 | buffer_has_overlays (void) | ||
| 1161 | { | ||
| 1162 | return current_buffer->overlays_before || current_buffer->overlays_after; | ||
| 1163 | } | ||
| 1164 | |||
| 1165 | /* Return character code of multi-byte form at byte position POS. If POS | ||
| 1166 | doesn't point the head of valid multi-byte form, only the byte at | ||
| 1167 | POS is returned. No range checking. | ||
| 1168 | |||
| 1169 | WARNING: The character returned by this macro could be "unified" | ||
| 1170 | inside STRING_CHAR, if the original character in the buffer belongs | ||
| 1171 | to one of the Private Use Areas (PUAs) of codepoints that Emacs | ||
| 1172 | uses to support non-unified CJK characters. If that happens, | ||
| 1173 | CHAR_BYTES will return a value that is different from the length of | ||
| 1174 | the original multibyte sequence stored in the buffer. Therefore, | ||
| 1175 | do _not_ use FETCH_MULTIBYTE_CHAR if you need to advance through | ||
| 1176 | the buffer to the next character after fetching this one. Instead, | ||
| 1177 | use either FETCH_CHAR_ADVANCE or STRING_CHAR_AND_LENGTH. */ | ||
| 1178 | |||
| 1179 | BUFFER_INLINE int | ||
| 1180 | FETCH_MULTIBYTE_CHAR (ptrdiff_t pos) | ||
| 1181 | { | ||
| 1182 | unsigned char *p = ((pos >= GPT_BYTE ? GAP_SIZE : 0) | ||
| 1183 | + pos + BEG_ADDR - BEG_BYTE); | ||
| 1184 | return STRING_CHAR (p); | ||
| 1185 | } | ||
| 1186 | |||
| 1187 | /* Return character code of multi-byte form at byte position POS in BUF. | ||
| 1188 | If POS doesn't point the head of valid multi-byte form, only the byte at | ||
| 1189 | POS is returned. No range checking. */ | ||
| 1190 | |||
| 1191 | BUFFER_INLINE int | ||
| 1192 | BUF_FETCH_MULTIBYTE_CHAR (struct buffer *buf, ptrdiff_t pos) | ||
| 1193 | { | ||
| 1194 | unsigned char *p | ||
| 1195 | = ((pos >= BUF_GPT_BYTE (buf) ? BUF_GAP_SIZE (buf) : 0) | ||
| 1196 | + pos + BUF_BEG_ADDR (buf) - BEG_BYTE); | ||
| 1197 | return STRING_CHAR (p); | ||
| 1198 | } | ||
| 1199 | |||
| 1200 | /* Return number of windows showing B. */ | ||
| 1201 | |||
| 1202 | BUFFER_INLINE int | ||
| 1203 | buffer_window_count (struct buffer *b) | ||
| 1204 | { | ||
| 1205 | if (b->base_buffer) | ||
| 1206 | b = b->base_buffer; | ||
| 1207 | eassert (b->window_count >= 0); | ||
| 1208 | return b->window_count; | ||
| 1209 | } | ||
| 952 | 1210 | ||
| 953 | #define OVERLAY_VALID(OV) (OVERLAYP (OV)) | 1211 | /* Overlays */ |
| 954 | 1212 | ||
| 955 | /* Return the marker that stands for where OV starts in the buffer. */ | 1213 | /* Return the marker that stands for where OV starts in the buffer. */ |
| 956 | 1214 | ||
| 957 | #define OVERLAY_START(OV) (XOVERLAY (OV)->start) | 1215 | #define OVERLAY_START(OV) XOVERLAY (OV)->start |
| 958 | 1216 | ||
| 959 | /* Return the marker that stands for where OV ends in the buffer. */ | 1217 | /* Return the marker that stands for where OV ends in the buffer. */ |
| 960 | 1218 | ||
| 961 | #define OVERLAY_END(OV) (XOVERLAY (OV)->end) | 1219 | #define OVERLAY_END(OV) XOVERLAY (OV)->end |
| 962 | 1220 | ||
| 963 | /* Return the plist of overlay OV. */ | 1221 | /* Return the plist of overlay OV. */ |
| 964 | 1222 | ||
| 965 | #define OVERLAY_PLIST(OV) XOVERLAY ((OV))->plist | 1223 | #define OVERLAY_PLIST(OV) XOVERLAY (OV)->plist |
| 966 | 1224 | ||
| 967 | /* Return the actual buffer position for the marker P. | 1225 | /* Return the actual buffer position for the marker P. |
| 968 | We assume you know which buffer it's pointing into. */ | 1226 | We assume you know which buffer it's pointing into. */ |
| 969 | 1227 | ||
| 970 | #define OVERLAY_POSITION(P) \ | 1228 | #define OVERLAY_POSITION(P) \ |
| 971 | (MARKERP (P) ? marker_position (P) : (abort (), 0)) | 1229 | (MARKERP (P) ? marker_position (P) : (emacs_abort (), 0)) |
| 972 | 1230 | ||
| 973 | 1231 | ||
| 974 | /*********************************************************************** | 1232 | /*********************************************************************** |
| @@ -983,7 +1241,16 @@ extern int last_per_buffer_idx; | |||
| 983 | from the start of a buffer structure. */ | 1241 | from the start of a buffer structure. */ |
| 984 | 1242 | ||
| 985 | #define PER_BUFFER_VAR_OFFSET(VAR) \ | 1243 | #define PER_BUFFER_VAR_OFFSET(VAR) \ |
| 986 | offsetof (struct buffer, BUFFER_INTERNAL_FIELD (VAR)) | 1244 | offsetof (struct buffer, INTERNAL_FIELD (VAR)) |
| 1245 | |||
| 1246 | /* Used to iterate over normal Lisp_Object fields of struct buffer (all | ||
| 1247 | Lisp_Objects except undo_list). If you add, remove, or reorder | ||
| 1248 | Lisp_Objects in a struct buffer, make sure that this is still correct. */ | ||
| 1249 | |||
| 1250 | #define FOR_EACH_PER_BUFFER_OBJECT_AT(offset) \ | ||
| 1251 | for (offset = PER_BUFFER_VAR_OFFSET (name); \ | ||
| 1252 | offset <= PER_BUFFER_VAR_OFFSET (cursor_in_non_selected_windows); \ | ||
| 1253 | offset += word_size) | ||
| 987 | 1254 | ||
| 988 | /* Return the index of buffer-local variable VAR. Each per-buffer | 1255 | /* Return the index of buffer-local variable VAR. Each per-buffer |
| 989 | variable has an index > 0 associated with it, except when it always | 1256 | variable has an index > 0 associated with it, except when it always |
| @@ -999,7 +1266,7 @@ extern int last_per_buffer_idx; | |||
| 999 | 1266 | ||
| 1000 | #define PER_BUFFER_VALUE_P(B, IDX) \ | 1267 | #define PER_BUFFER_VALUE_P(B, IDX) \ |
| 1001 | (((IDX) < 0 || IDX >= last_per_buffer_idx) \ | 1268 | (((IDX) < 0 || IDX >= last_per_buffer_idx) \ |
| 1002 | ? (abort (), 0) \ | 1269 | ? (emacs_abort (), 0) \ |
| 1003 | : ((B)->local_flags[IDX] != 0)) | 1270 | : ((B)->local_flags[IDX] != 0)) |
| 1004 | 1271 | ||
| 1005 | /* Set whether per-buffer variable with index IDX has a buffer-local | 1272 | /* Set whether per-buffer variable with index IDX has a buffer-local |
| @@ -1008,7 +1275,7 @@ extern int last_per_buffer_idx; | |||
| 1008 | #define SET_PER_BUFFER_VALUE_P(B, IDX, VAL) \ | 1275 | #define SET_PER_BUFFER_VALUE_P(B, IDX, VAL) \ |
| 1009 | do { \ | 1276 | do { \ |
| 1010 | if ((IDX) < 0 || (IDX) >= last_per_buffer_idx) \ | 1277 | if ((IDX) < 0 || (IDX) >= last_per_buffer_idx) \ |
| 1011 | abort (); \ | 1278 | emacs_abort (); \ |
| 1012 | (B)->local_flags[IDX] = (VAL); \ | 1279 | (B)->local_flags[IDX] = (VAL); \ |
| 1013 | } while (0) | 1280 | } while (0) |
| 1014 | 1281 | ||
| @@ -1036,20 +1303,38 @@ extern int last_per_buffer_idx; | |||
| 1036 | #define PER_BUFFER_IDX(OFFSET) \ | 1303 | #define PER_BUFFER_IDX(OFFSET) \ |
| 1037 | XINT (*(Lisp_Object *)((OFFSET) + (char *) &buffer_local_flags)) | 1304 | XINT (*(Lisp_Object *)((OFFSET) + (char *) &buffer_local_flags)) |
| 1038 | 1305 | ||
| 1039 | /* Return the default value of the per-buffer variable at offset | 1306 | /* Functions to get and set default value of the per-buffer |
| 1040 | OFFSET in the buffer structure. */ | 1307 | variable at offset OFFSET in the buffer structure. */ |
| 1308 | |||
| 1309 | BUFFER_INLINE Lisp_Object | ||
| 1310 | per_buffer_default (int offset) | ||
| 1311 | { | ||
| 1312 | return *(Lisp_Object *)(offset + (char *) &buffer_defaults); | ||
| 1313 | } | ||
| 1314 | |||
| 1315 | BUFFER_INLINE void | ||
| 1316 | set_per_buffer_default (int offset, Lisp_Object value) | ||
| 1317 | { | ||
| 1318 | *(Lisp_Object *)(offset + (char *) &buffer_defaults) = value; | ||
| 1319 | } | ||
| 1041 | 1320 | ||
| 1042 | #define PER_BUFFER_DEFAULT(OFFSET) \ | 1321 | /* Functions to get and set buffer-local value of the per-buffer |
| 1043 | (*(Lisp_Object *)((OFFSET) + (char *) &buffer_defaults)) | 1322 | variable at offset OFFSET in the buffer structure. */ |
| 1044 | 1323 | ||
| 1045 | /* Return the buffer-local value of the per-buffer variable at offset | 1324 | BUFFER_INLINE Lisp_Object |
| 1046 | OFFSET in the buffer structure. */ | 1325 | per_buffer_value (struct buffer *b, int offset) |
| 1326 | { | ||
| 1327 | return *(Lisp_Object *)(offset + (char *) b); | ||
| 1328 | } | ||
| 1329 | |||
| 1330 | BUFFER_INLINE void | ||
| 1331 | set_per_buffer_value (struct buffer *b, int offset, Lisp_Object value) | ||
| 1332 | { | ||
| 1333 | *(Lisp_Object *)(offset + (char *) b) = value; | ||
| 1334 | } | ||
| 1047 | 1335 | ||
| 1048 | #define PER_BUFFER_VALUE(BUFFER, OFFSET) \ | ||
| 1049 | (*(Lisp_Object *)((OFFSET) + (char *) (BUFFER))) | ||
| 1050 | |||
| 1051 | /* Downcase a character C, or make no change if that cannot be done. */ | 1336 | /* Downcase a character C, or make no change if that cannot be done. */ |
| 1052 | static inline int | 1337 | BUFFER_INLINE int |
| 1053 | downcase (int c) | 1338 | downcase (int c) |
| 1054 | { | 1339 | { |
| 1055 | Lisp_Object downcase_table = BVAR (current_buffer, downcase_table); | 1340 | Lisp_Object downcase_table = BVAR (current_buffer, downcase_table); |
| @@ -1058,10 +1343,10 @@ downcase (int c) | |||
| 1058 | } | 1343 | } |
| 1059 | 1344 | ||
| 1060 | /* 1 if C is upper case. */ | 1345 | /* 1 if C is upper case. */ |
| 1061 | static inline int uppercasep (int c) { return downcase (c) != c; } | 1346 | BUFFER_INLINE bool uppercasep (int c) { return downcase (c) != c; } |
| 1062 | 1347 | ||
| 1063 | /* Upcase a character C known to be not upper case. */ | 1348 | /* Upcase a character C known to be not upper case. */ |
| 1064 | static inline int | 1349 | BUFFER_INLINE int |
| 1065 | upcase1 (int c) | 1350 | upcase1 (int c) |
| 1066 | { | 1351 | { |
| 1067 | Lisp_Object upcase_table = BVAR (current_buffer, upcase_table); | 1352 | Lisp_Object upcase_table = BVAR (current_buffer, upcase_table); |
| @@ -1070,8 +1355,13 @@ upcase1 (int c) | |||
| 1070 | } | 1355 | } |
| 1071 | 1356 | ||
| 1072 | /* 1 if C is lower case. */ | 1357 | /* 1 if C is lower case. */ |
| 1073 | static inline int lowercasep (int c) | 1358 | BUFFER_INLINE bool |
| 1074 | { return !uppercasep (c) && upcase1 (c) != c; } | 1359 | lowercasep (int c) |
| 1360 | { | ||
| 1361 | return !uppercasep (c) && upcase1 (c) != c; | ||
| 1362 | } | ||
| 1075 | 1363 | ||
| 1076 | /* Upcase a character C, or make no change if that cannot be done. */ | 1364 | /* Upcase a character C, or make no change if that cannot be done. */ |
| 1077 | static inline int upcase (int c) { return uppercasep (c) ? c : upcase1 (c); } | 1365 | BUFFER_INLINE int upcase (int c) { return uppercasep (c) ? c : upcase1 (c); } |
| 1366 | |||
| 1367 | INLINE_HEADER_END | ||