diff options
| author | Kenichi Handa | 2012-08-16 21:25:17 +0900 |
|---|---|---|
| committer | Kenichi Handa | 2012-08-16 21:25:17 +0900 |
| commit | d75ffb4ed0b2e72a9361a07d16a5c884a9459728 (patch) | |
| tree | 8ac5a6a8ae033fef7fbc7fb7b09a703ef4b0ed5b /src/buffer.c | |
| parent | 69c41c4070c86baac11a627e9c3d366420aeb7cc (diff) | |
| parent | 250c8ab9b8f6322959fa3122db83944c30c3894b (diff) | |
| download | emacs-d75ffb4ed0b2e72a9361a07d16a5c884a9459728.tar.gz emacs-d75ffb4ed0b2e72a9361a07d16a5c884a9459728.zip | |
merge trunk
Diffstat (limited to 'src/buffer.c')
| -rw-r--r-- | src/buffer.c | 605 |
1 files changed, 315 insertions, 290 deletions
diff --git a/src/buffer.c b/src/buffer.c index b8c81a10d54..56d6231f5f8 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -19,6 +19,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 19 | 19 | ||
| 20 | #include <config.h> | 20 | #include <config.h> |
| 21 | 21 | ||
| 22 | #define BUFFER_INLINE EXTERN_INLINE | ||
| 23 | |||
| 22 | #include <sys/types.h> | 24 | #include <sys/types.h> |
| 23 | #include <sys/stat.h> | 25 | #include <sys/stat.h> |
| 24 | #include <sys/param.h> | 26 | #include <sys/param.h> |
| @@ -56,7 +58,7 @@ struct buffer *all_buffers; | |||
| 56 | Setting the default value also goes through the alist of buffers | 58 | Setting the default value also goes through the alist of buffers |
| 57 | and stores into each buffer that does not say it has a local value. */ | 59 | and stores into each buffer that does not say it has a local value. */ |
| 58 | 60 | ||
| 59 | DECL_ALIGN (struct buffer, buffer_defaults); | 61 | struct buffer alignas (GCALIGNMENT) buffer_defaults; |
| 60 | 62 | ||
| 61 | /* A Lisp_Object pointer to the above, used for staticpro */ | 63 | /* A Lisp_Object pointer to the above, used for staticpro */ |
| 62 | 64 | ||
| @@ -83,7 +85,7 @@ struct buffer buffer_local_flags; | |||
| 83 | /* This structure holds the names of symbols whose values may be | 85 | /* This structure holds the names of symbols whose values may be |
| 84 | buffer-local. It is indexed and accessed in the same way as the above. */ | 86 | buffer-local. It is indexed and accessed in the same way as the above. */ |
| 85 | 87 | ||
| 86 | DECL_ALIGN (struct buffer, buffer_local_symbols); | 88 | struct buffer alignas (GCALIGNMENT) buffer_local_symbols; |
| 87 | 89 | ||
| 88 | /* A Lisp_Object pointer to the above, used for staticpro */ | 90 | /* A Lisp_Object pointer to the above, used for staticpro */ |
| 89 | static Lisp_Object Vbuffer_local_symbols; | 91 | static Lisp_Object Vbuffer_local_symbols; |
| @@ -97,7 +99,7 @@ static Lisp_Object Vbuffer_local_symbols; | |||
| 97 | /* Maximum length of an overlay vector. */ | 99 | /* Maximum length of an overlay vector. */ |
| 98 | #define OVERLAY_COUNT_MAX \ | 100 | #define OVERLAY_COUNT_MAX \ |
| 99 | ((ptrdiff_t) min (MOST_POSITIVE_FIXNUM, \ | 101 | ((ptrdiff_t) min (MOST_POSITIVE_FIXNUM, \ |
| 100 | min (PTRDIFF_MAX, SIZE_MAX) / sizeof (Lisp_Object))) | 102 | min (PTRDIFF_MAX, SIZE_MAX) / word_size)) |
| 101 | 103 | ||
| 102 | /* Flags indicating which built-in buffer-local variables | 104 | /* Flags indicating which built-in buffer-local variables |
| 103 | are permanent locals. */ | 105 | are permanent locals. */ |
| @@ -153,7 +155,7 @@ static void alloc_buffer_text (struct buffer *, ptrdiff_t); | |||
| 153 | static void free_buffer_text (struct buffer *b); | 155 | static void free_buffer_text (struct buffer *b); |
| 154 | static struct Lisp_Overlay * copy_overlays (struct buffer *, struct Lisp_Overlay *); | 156 | static struct Lisp_Overlay * copy_overlays (struct buffer *, struct Lisp_Overlay *); |
| 155 | static void modify_overlay (struct buffer *, ptrdiff_t, ptrdiff_t); | 157 | static void modify_overlay (struct buffer *, ptrdiff_t, ptrdiff_t); |
| 156 | static Lisp_Object buffer_lisp_local_variables (struct buffer *); | 158 | static Lisp_Object buffer_lisp_local_variables (struct buffer *, int); |
| 157 | 159 | ||
| 158 | /* For debugging; temporary. See set_buffer_internal. */ | 160 | /* For debugging; temporary. See set_buffer_internal. */ |
| 159 | /* Lisp_Object Qlisp_mode, Vcheck_symbol; */ | 161 | /* Lisp_Object Qlisp_mode, Vcheck_symbol; */ |
| @@ -329,7 +331,9 @@ even if it is dead. The return value is never nil. */) | |||
| 329 | 331 | ||
| 330 | /* An ordinary buffer uses its own struct buffer_text. */ | 332 | /* An ordinary buffer uses its own struct buffer_text. */ |
| 331 | b->text = &b->own_text; | 333 | b->text = &b->own_text; |
| 332 | b->base_buffer = 0; | 334 | b->base_buffer = NULL; |
| 335 | /* No one shares the text with us now. */ | ||
| 336 | b->indirections = 0; | ||
| 333 | 337 | ||
| 334 | BUF_GAP_SIZE (b) = 20; | 338 | BUF_GAP_SIZE (b) = 20; |
| 335 | BLOCK_INPUT; | 339 | BLOCK_INPUT; |
| @@ -356,7 +360,7 @@ even if it is dead. The return value is never nil. */) | |||
| 356 | BUF_CHARS_MODIFF (b) = 1; | 360 | BUF_CHARS_MODIFF (b) = 1; |
| 357 | BUF_OVERLAY_MODIFF (b) = 1; | 361 | BUF_OVERLAY_MODIFF (b) = 1; |
| 358 | BUF_SAVE_MODIFF (b) = 1; | 362 | BUF_SAVE_MODIFF (b) = 1; |
| 359 | BUF_INTERVALS (b) = 0; | 363 | buffer_set_intervals (b, NULL); |
| 360 | BUF_UNCHANGED_MODIFIED (b) = 1; | 364 | BUF_UNCHANGED_MODIFIED (b) = 1; |
| 361 | BUF_OVERLAY_UNCHANGED_MODIFIED (b) = 1; | 365 | BUF_OVERLAY_UNCHANGED_MODIFIED (b) = 1; |
| 362 | BUF_END_UNCHANGED (b) = 0; | 366 | BUF_END_UNCHANGED (b) = 0; |
| @@ -366,7 +370,7 @@ even if it is dead. The return value is never nil. */) | |||
| 366 | 370 | ||
| 367 | b->newline_cache = 0; | 371 | b->newline_cache = 0; |
| 368 | b->width_run_cache = 0; | 372 | b->width_run_cache = 0; |
| 369 | BVAR (b, width_table) = Qnil; | 373 | BSET (b, width_table, Qnil); |
| 370 | b->prevent_redisplay_optimizations_p = 1; | 374 | b->prevent_redisplay_optimizations_p = 1; |
| 371 | 375 | ||
| 372 | /* Put this on the chain of all buffers including killed ones. */ | 376 | /* Put this on the chain of all buffers including killed ones. */ |
| @@ -375,20 +379,20 @@ even if it is dead. The return value is never nil. */) | |||
| 375 | 379 | ||
| 376 | /* An ordinary buffer normally doesn't need markers | 380 | /* An ordinary buffer normally doesn't need markers |
| 377 | to handle BEGV and ZV. */ | 381 | to handle BEGV and ZV. */ |
| 378 | BVAR (b, pt_marker) = Qnil; | 382 | BSET (b, pt_marker, Qnil); |
| 379 | BVAR (b, begv_marker) = Qnil; | 383 | BSET (b, begv_marker, Qnil); |
| 380 | BVAR (b, zv_marker) = Qnil; | 384 | BSET (b, zv_marker, Qnil); |
| 381 | 385 | ||
| 382 | name = Fcopy_sequence (buffer_or_name); | 386 | name = Fcopy_sequence (buffer_or_name); |
| 383 | STRING_SET_INTERVALS (name, NULL_INTERVAL); | 387 | string_set_intervals (name, NULL); |
| 384 | BVAR (b, name) = name; | 388 | BSET (b, name, name); |
| 385 | 389 | ||
| 386 | BVAR (b, undo_list) = (SREF (name, 0) != ' ') ? Qnil : Qt; | 390 | BSET (b, undo_list, (SREF (name, 0) != ' ') ? Qnil : Qt); |
| 387 | 391 | ||
| 388 | reset_buffer (b); | 392 | reset_buffer (b); |
| 389 | reset_buffer_local_variables (b, 1); | 393 | reset_buffer_local_variables (b, 1); |
| 390 | 394 | ||
| 391 | BVAR (b, mark) = Fmake_marker (); | 395 | BSET (b, mark, Fmake_marker ()); |
| 392 | BUF_MARKERS (b) = NULL; | 396 | BUF_MARKERS (b) = NULL; |
| 393 | 397 | ||
| 394 | /* Put this in the alist of all live buffers. */ | 398 | /* Put this in the alist of all live buffers. */ |
| @@ -408,36 +412,24 @@ even if it is dead. The return value is never nil. */) | |||
| 408 | static struct Lisp_Overlay * | 412 | static struct Lisp_Overlay * |
| 409 | copy_overlays (struct buffer *b, struct Lisp_Overlay *list) | 413 | copy_overlays (struct buffer *b, struct Lisp_Overlay *list) |
| 410 | { | 414 | { |
| 411 | Lisp_Object buffer; | ||
| 412 | struct Lisp_Overlay *result = NULL, *tail = NULL; | 415 | struct Lisp_Overlay *result = NULL, *tail = NULL; |
| 413 | 416 | ||
| 414 | XSETBUFFER (buffer, b); | ||
| 415 | |||
| 416 | for (; list; list = list->next) | 417 | for (; list; list = list->next) |
| 417 | { | 418 | { |
| 418 | Lisp_Object overlay, start, end, old_overlay; | 419 | Lisp_Object overlay, start, end; |
| 419 | ptrdiff_t charpos; | 420 | struct Lisp_Marker *m; |
| 420 | |||
| 421 | XSETMISC (old_overlay, list); | ||
| 422 | charpos = marker_position (OVERLAY_START (old_overlay)); | ||
| 423 | start = Fmake_marker (); | ||
| 424 | Fset_marker (start, make_number (charpos), buffer); | ||
| 425 | XMARKER (start)->insertion_type | ||
| 426 | = XMARKER (OVERLAY_START (old_overlay))->insertion_type; | ||
| 427 | |||
| 428 | charpos = marker_position (OVERLAY_END (old_overlay)); | ||
| 429 | end = Fmake_marker (); | ||
| 430 | Fset_marker (end, make_number (charpos), buffer); | ||
| 431 | XMARKER (end)->insertion_type | ||
| 432 | = XMARKER (OVERLAY_END (old_overlay))->insertion_type; | ||
| 433 | |||
| 434 | overlay = allocate_misc (); | ||
| 435 | XMISCTYPE (overlay) = Lisp_Misc_Overlay; | ||
| 436 | OVERLAY_START (overlay) = start; | ||
| 437 | OVERLAY_END (overlay) = end; | ||
| 438 | OVERLAY_PLIST (overlay) = Fcopy_sequence (OVERLAY_PLIST (old_overlay)); | ||
| 439 | XOVERLAY (overlay)->next = NULL; | ||
| 440 | 421 | ||
| 422 | eassert (MARKERP (list->start)); | ||
| 423 | m = XMARKER (list->start); | ||
| 424 | start = build_marker (b, m->charpos, m->bytepos); | ||
| 425 | XMARKER (start)->insertion_type = m->insertion_type; | ||
| 426 | |||
| 427 | eassert (MARKERP (list->end)); | ||
| 428 | m = XMARKER (list->end); | ||
| 429 | end = build_marker (b, m->charpos, m->bytepos); | ||
| 430 | XMARKER (end)->insertion_type = m->insertion_type; | ||
| 431 | |||
| 432 | overlay = build_overlay (start, end, Fcopy_sequence (list->plist)); | ||
| 441 | if (tail) | 433 | if (tail) |
| 442 | tail = tail->next = XOVERLAY (overlay); | 434 | tail = tail->next = XOVERLAY (overlay); |
| 443 | else | 435 | else |
| @@ -460,7 +452,7 @@ clone_per_buffer_values (struct buffer *from, struct buffer *to) | |||
| 460 | { | 452 | { |
| 461 | int offset; | 453 | int offset; |
| 462 | 454 | ||
| 463 | for_each_per_buffer_object_at (offset) | 455 | FOR_EACH_PER_BUFFER_OBJECT_AT (offset) |
| 464 | { | 456 | { |
| 465 | Lisp_Object obj; | 457 | Lisp_Object obj; |
| 466 | 458 | ||
| @@ -482,12 +474,12 @@ clone_per_buffer_values (struct buffer *from, struct buffer *to) | |||
| 482 | 474 | ||
| 483 | memcpy (to->local_flags, from->local_flags, sizeof to->local_flags); | 475 | memcpy (to->local_flags, from->local_flags, sizeof to->local_flags); |
| 484 | 476 | ||
| 485 | to->overlays_before = copy_overlays (to, from->overlays_before); | 477 | buffer_set_overlays_before (to, copy_overlays (to, from->overlays_before)); |
| 486 | to->overlays_after = copy_overlays (to, from->overlays_after); | 478 | buffer_set_overlays_after (to, copy_overlays (to, from->overlays_after)); |
| 487 | 479 | ||
| 488 | /* Get (a copy of) the alist of Lisp-level local variables of FROM | 480 | /* Get (a copy of) the alist of Lisp-level local variables of FROM |
| 489 | and install that in TO. */ | 481 | and install that in TO. */ |
| 490 | BVAR (to, local_var_alist) = buffer_lisp_local_variables (from); | 482 | BSET (to, local_var_alist, buffer_lisp_local_variables (from, 1)); |
| 491 | } | 483 | } |
| 492 | 484 | ||
| 493 | 485 | ||
| @@ -568,12 +560,18 @@ CLONE nil means the indirect buffer's state is reset to default values. */) | |||
| 568 | 560 | ||
| 569 | b = allocate_buffer (); | 561 | b = allocate_buffer (); |
| 570 | 562 | ||
| 563 | /* No double indirection - if base buffer is indirect, | ||
| 564 | new buffer becomes an indirect to base's base. */ | ||
| 571 | b->base_buffer = (XBUFFER (base_buffer)->base_buffer | 565 | b->base_buffer = (XBUFFER (base_buffer)->base_buffer |
| 572 | ? XBUFFER (base_buffer)->base_buffer | 566 | ? XBUFFER (base_buffer)->base_buffer |
| 573 | : XBUFFER (base_buffer)); | 567 | : XBUFFER (base_buffer)); |
| 574 | 568 | ||
| 575 | /* Use the base buffer's text object. */ | 569 | /* Use the base buffer's text object. */ |
| 576 | b->text = b->base_buffer->text; | 570 | b->text = b->base_buffer->text; |
| 571 | /* We have no own text. */ | ||
| 572 | b->indirections = -1; | ||
| 573 | /* Notify base buffer that we share the text now. */ | ||
| 574 | b->base_buffer->indirections++; | ||
| 577 | 575 | ||
| 578 | b->pt = b->base_buffer->pt; | 576 | b->pt = b->base_buffer->pt; |
| 579 | b->begv = b->base_buffer->begv; | 577 | b->begv = b->base_buffer->begv; |
| @@ -584,15 +582,15 @@ CLONE nil means the indirect buffer's state is reset to default values. */) | |||
| 584 | 582 | ||
| 585 | b->newline_cache = 0; | 583 | b->newline_cache = 0; |
| 586 | b->width_run_cache = 0; | 584 | b->width_run_cache = 0; |
| 587 | BVAR (b, width_table) = Qnil; | 585 | BSET (b, width_table, Qnil); |
| 588 | 586 | ||
| 589 | /* Put this on the chain of all buffers including killed ones. */ | 587 | /* Put this on the chain of all buffers including killed ones. */ |
| 590 | b->header.next.buffer = all_buffers; | 588 | b->header.next.buffer = all_buffers; |
| 591 | all_buffers = b; | 589 | all_buffers = b; |
| 592 | 590 | ||
| 593 | name = Fcopy_sequence (name); | 591 | name = Fcopy_sequence (name); |
| 594 | STRING_SET_INTERVALS (name, NULL_INTERVAL); | 592 | string_set_intervals (name, NULL); |
| 595 | BVAR (b, name) = name; | 593 | BSET (b, name, name); |
| 596 | 594 | ||
| 597 | reset_buffer (b); | 595 | reset_buffer (b); |
| 598 | reset_buffer_local_variables (b, 1); | 596 | reset_buffer_local_variables (b, 1); |
| @@ -601,10 +599,10 @@ CLONE nil means the indirect buffer's state is reset to default values. */) | |||
| 601 | XSETBUFFER (buf, b); | 599 | XSETBUFFER (buf, b); |
| 602 | Vbuffer_alist = nconc2 (Vbuffer_alist, Fcons (Fcons (name, buf), Qnil)); | 600 | Vbuffer_alist = nconc2 (Vbuffer_alist, Fcons (Fcons (name, buf), Qnil)); |
| 603 | 601 | ||
| 604 | BVAR (b, mark) = Fmake_marker (); | 602 | BSET (b, mark, Fmake_marker ()); |
| 605 | 603 | ||
| 606 | /* The multibyte status belongs to the base buffer. */ | 604 | /* The multibyte status belongs to the base buffer. */ |
| 607 | BVAR (b, enable_multibyte_characters) = BVAR (b->base_buffer, enable_multibyte_characters); | 605 | BSET (b, enable_multibyte_characters, BVAR (b->base_buffer, enable_multibyte_characters)); |
| 608 | 606 | ||
| 609 | /* Make sure the base buffer has markers for its narrowing. */ | 607 | /* Make sure the base buffer has markers for its narrowing. */ |
| 610 | if (NILP (BVAR (b->base_buffer, pt_marker))) | 608 | if (NILP (BVAR (b->base_buffer, pt_marker))) |
| @@ -612,14 +610,14 @@ CLONE nil means the indirect buffer's state is reset to default values. */) | |||
| 612 | eassert (NILP (BVAR (b->base_buffer, begv_marker))); | 610 | eassert (NILP (BVAR (b->base_buffer, begv_marker))); |
| 613 | eassert (NILP (BVAR (b->base_buffer, zv_marker))); | 611 | eassert (NILP (BVAR (b->base_buffer, zv_marker))); |
| 614 | 612 | ||
| 615 | BVAR (b->base_buffer, pt_marker) | 613 | BSET (b->base_buffer, pt_marker, |
| 616 | = build_marker (b->base_buffer, b->base_buffer->pt, b->base_buffer->pt_byte); | 614 | build_marker (b->base_buffer, b->base_buffer->pt, b->base_buffer->pt_byte)); |
| 617 | 615 | ||
| 618 | BVAR (b->base_buffer, begv_marker) | 616 | BSET (b->base_buffer, begv_marker, |
| 619 | = build_marker (b->base_buffer, b->base_buffer->begv, b->base_buffer->begv_byte); | 617 | build_marker (b->base_buffer, b->base_buffer->begv, b->base_buffer->begv_byte)); |
| 620 | 618 | ||
| 621 | BVAR (b->base_buffer, zv_marker) | 619 | BSET (b->base_buffer, zv_marker, |
| 622 | = build_marker (b->base_buffer, b->base_buffer->zv, b->base_buffer->zv_byte); | 620 | build_marker (b->base_buffer, b->base_buffer->zv, b->base_buffer->zv_byte)); |
| 623 | 621 | ||
| 624 | XMARKER (BVAR (b->base_buffer, zv_marker))->insertion_type = 1; | 622 | XMARKER (BVAR (b->base_buffer, zv_marker))->insertion_type = 1; |
| 625 | } | 623 | } |
| @@ -627,9 +625,9 @@ CLONE nil means the indirect buffer's state is reset to default values. */) | |||
| 627 | if (NILP (clone)) | 625 | if (NILP (clone)) |
| 628 | { | 626 | { |
| 629 | /* Give the indirect buffer markers for its narrowing. */ | 627 | /* Give the indirect buffer markers for its narrowing. */ |
| 630 | BVAR (b, pt_marker) = build_marker (b, b->pt, b->pt_byte); | 628 | BSET (b, pt_marker, build_marker (b, b->pt, b->pt_byte)); |
| 631 | BVAR (b, begv_marker) = build_marker (b, b->begv, b->begv_byte); | 629 | BSET (b, begv_marker, build_marker (b, b->begv, b->begv_byte)); |
| 632 | BVAR (b, zv_marker) = build_marker (b, b->zv, b->zv_byte); | 630 | BSET (b, zv_marker, build_marker (b, b->zv, b->zv_byte)); |
| 633 | XMARKER (BVAR (b, zv_marker))->insertion_type = 1; | 631 | XMARKER (BVAR (b, zv_marker))->insertion_type = 1; |
| 634 | } | 632 | } |
| 635 | else | 633 | else |
| @@ -637,11 +635,11 @@ CLONE nil means the indirect buffer's state is reset to default values. */) | |||
| 637 | struct buffer *old_b = current_buffer; | 635 | struct buffer *old_b = current_buffer; |
| 638 | 636 | ||
| 639 | clone_per_buffer_values (b->base_buffer, b); | 637 | clone_per_buffer_values (b->base_buffer, b); |
| 640 | BVAR (b, filename) = Qnil; | 638 | BSET (b, filename, Qnil); |
| 641 | BVAR (b, file_truename) = Qnil; | 639 | BSET (b, file_truename, Qnil); |
| 642 | BVAR (b, display_count) = make_number (0); | 640 | BSET (b, display_count, make_number (0)); |
| 643 | BVAR (b, backed_up) = Qnil; | 641 | BSET (b, backed_up, Qnil); |
| 644 | BVAR (b, auto_save_file_name) = Qnil; | 642 | BSET (b, auto_save_file_name, Qnil); |
| 645 | set_buffer_internal_1 (b); | 643 | set_buffer_internal_1 (b); |
| 646 | Fset (intern ("buffer-save-without-query"), Qnil); | 644 | Fset (intern ("buffer-save-without-query"), Qnil); |
| 647 | Fset (intern ("buffer-file-number"), Qnil); | 645 | Fset (intern ("buffer-file-number"), Qnil); |
| @@ -662,7 +660,8 @@ static void | |||
| 662 | drop_overlay (struct buffer *b, struct Lisp_Overlay *ov) | 660 | drop_overlay (struct buffer *b, struct Lisp_Overlay *ov) |
| 663 | { | 661 | { |
| 664 | eassert (b == XBUFFER (Fmarker_buffer (ov->start))); | 662 | eassert (b == XBUFFER (Fmarker_buffer (ov->start))); |
| 665 | modify_overlay (b, marker_position (ov->start), marker_position (ov->end)); | 663 | modify_overlay (b, marker_position (ov->start), |
| 664 | marker_position (ov->end)); | ||
| 666 | Fset_marker (ov->start, Qnil, Qnil); | 665 | Fset_marker (ov->start, Qnil, Qnil); |
| 667 | Fset_marker (ov->end, Qnil, Qnil); | 666 | Fset_marker (ov->end, Qnil, Qnil); |
| 668 | 667 | ||
| @@ -689,7 +688,8 @@ delete_all_overlays (struct buffer *b) | |||
| 689 | ov->next = NULL; | 688 | ov->next = NULL; |
| 690 | } | 689 | } |
| 691 | 690 | ||
| 692 | b->overlays_before = b->overlays_after = NULL; | 691 | buffer_set_overlays_before (b, NULL); |
| 692 | buffer_set_overlays_after (b, NULL); | ||
| 693 | } | 693 | } |
| 694 | 694 | ||
| 695 | /* Reinitialize everything about a buffer except its name and contents | 695 | /* Reinitialize everything about a buffer except its name and contents |
| @@ -702,9 +702,10 @@ delete_all_overlays (struct buffer *b) | |||
| 702 | void | 702 | void |
| 703 | reset_buffer (register struct buffer *b) | 703 | reset_buffer (register struct buffer *b) |
| 704 | { | 704 | { |
| 705 | BVAR (b, filename) = Qnil; | 705 | BSET (b, filename, Qnil); |
| 706 | BVAR (b, file_truename) = Qnil; | 706 | BSET (b, file_truename, Qnil); |
| 707 | BVAR (b, directory) = (current_buffer) ? BVAR (current_buffer, directory) : Qnil; | 707 | BSET (b, directory, |
| 708 | (current_buffer) ? BVAR (current_buffer, directory) : Qnil); | ||
| 708 | b->modtime = make_emacs_time (0, UNKNOWN_MODTIME_NSECS); | 709 | b->modtime = make_emacs_time (0, UNKNOWN_MODTIME_NSECS); |
| 709 | b->modtime_size = -1; | 710 | b->modtime_size = -1; |
| 710 | XSETFASTINT (BVAR (b, save_length), 0); | 711 | XSETFASTINT (BVAR (b, save_length), 0); |
| @@ -712,24 +713,25 @@ reset_buffer (register struct buffer *b) | |||
| 712 | /* It is more conservative to start out "changed" than "unchanged". */ | 713 | /* It is more conservative to start out "changed" than "unchanged". */ |
| 713 | b->clip_changed = 0; | 714 | b->clip_changed = 0; |
| 714 | b->prevent_redisplay_optimizations_p = 1; | 715 | b->prevent_redisplay_optimizations_p = 1; |
| 715 | BVAR (b, backed_up) = Qnil; | 716 | BSET (b, backed_up, Qnil); |
| 716 | BUF_AUTOSAVE_MODIFF (b) = 0; | 717 | BUF_AUTOSAVE_MODIFF (b) = 0; |
| 717 | b->auto_save_failure_time = 0; | 718 | b->auto_save_failure_time = 0; |
| 718 | BVAR (b, auto_save_file_name) = Qnil; | 719 | BSET (b, auto_save_file_name, Qnil); |
| 719 | BVAR (b, read_only) = Qnil; | 720 | BSET (b, read_only, Qnil); |
| 720 | b->overlays_before = NULL; | 721 | buffer_set_overlays_before (b, NULL); |
| 721 | b->overlays_after = NULL; | 722 | buffer_set_overlays_after (b, NULL); |
| 722 | b->overlay_center = BEG; | 723 | b->overlay_center = BEG; |
| 723 | BVAR (b, mark_active) = Qnil; | 724 | BSET (b, mark_active, Qnil); |
| 724 | BVAR (b, point_before_scroll) = Qnil; | 725 | BSET (b, point_before_scroll, Qnil); |
| 725 | BVAR (b, file_format) = Qnil; | 726 | BSET (b, file_format, Qnil); |
| 726 | BVAR (b, auto_save_file_format) = Qt; | 727 | BSET (b, auto_save_file_format, Qt); |
| 727 | BVAR (b, last_selected_window) = Qnil; | 728 | BSET (b, last_selected_window, Qnil); |
| 728 | XSETINT (BVAR (b, display_count), 0); | 729 | BSET (b, display_count, make_number (0)); |
| 729 | BVAR (b, display_time) = Qnil; | 730 | BSET (b, display_time, Qnil); |
| 730 | BVAR (b, enable_multibyte_characters) = BVAR (&buffer_defaults, enable_multibyte_characters); | 731 | BSET (b, enable_multibyte_characters, |
| 731 | BVAR (b, cursor_type) = BVAR (&buffer_defaults, cursor_type); | 732 | BVAR (&buffer_defaults, enable_multibyte_characters)); |
| 732 | BVAR (b, extra_line_spacing) = BVAR (&buffer_defaults, extra_line_spacing); | 733 | BSET (b, cursor_type, BVAR (&buffer_defaults, cursor_type)); |
| 734 | BSET (b, extra_line_spacing, BVAR (&buffer_defaults, extra_line_spacing)); | ||
| 733 | 735 | ||
| 734 | b->display_error_modiff = 0; | 736 | b->display_error_modiff = 0; |
| 735 | } | 737 | } |
| @@ -753,10 +755,10 @@ reset_buffer_local_variables (register struct buffer *b, int permanent_too) | |||
| 753 | things that depend on the major mode. | 755 | things that depend on the major mode. |
| 754 | default-major-mode is handled at a higher level. | 756 | default-major-mode is handled at a higher level. |
| 755 | We ignore it here. */ | 757 | We ignore it here. */ |
| 756 | BVAR (b, major_mode) = Qfundamental_mode; | 758 | BSET (b, major_mode, Qfundamental_mode); |
| 757 | BVAR (b, keymap) = Qnil; | 759 | BSET (b, keymap, Qnil); |
| 758 | BVAR (b, mode_name) = QSFundamental; | 760 | BSET (b, mode_name, QSFundamental); |
| 759 | BVAR (b, minor_modes) = Qnil; | 761 | BSET (b, minor_modes, Qnil); |
| 760 | 762 | ||
| 761 | /* If the standard case table has been altered and invalidated, | 763 | /* If the standard case table has been altered and invalidated, |
| 762 | fix up its insides first. */ | 764 | fix up its insides first. */ |
| @@ -765,15 +767,15 @@ reset_buffer_local_variables (register struct buffer *b, int permanent_too) | |||
| 765 | && CHAR_TABLE_P (XCHAR_TABLE (Vascii_downcase_table)->extras[2]))) | 767 | && CHAR_TABLE_P (XCHAR_TABLE (Vascii_downcase_table)->extras[2]))) |
| 766 | Fset_standard_case_table (Vascii_downcase_table); | 768 | Fset_standard_case_table (Vascii_downcase_table); |
| 767 | 769 | ||
| 768 | BVAR (b, downcase_table) = Vascii_downcase_table; | 770 | BSET (b, downcase_table, Vascii_downcase_table); |
| 769 | BVAR (b, upcase_table) = XCHAR_TABLE (Vascii_downcase_table)->extras[0]; | 771 | BSET (b, upcase_table, XCHAR_TABLE (Vascii_downcase_table)->extras[0]); |
| 770 | BVAR (b, case_canon_table) = XCHAR_TABLE (Vascii_downcase_table)->extras[1]; | 772 | BSET (b, case_canon_table, XCHAR_TABLE (Vascii_downcase_table)->extras[1]); |
| 771 | BVAR (b, case_eqv_table) = XCHAR_TABLE (Vascii_downcase_table)->extras[2]; | 773 | BSET (b, case_eqv_table, XCHAR_TABLE (Vascii_downcase_table)->extras[2]); |
| 772 | BVAR (b, invisibility_spec) = Qt; | 774 | BSET (b, invisibility_spec, Qt); |
| 773 | 775 | ||
| 774 | /* Reset all (or most) per-buffer variables to their defaults. */ | 776 | /* Reset all (or most) per-buffer variables to their defaults. */ |
| 775 | if (permanent_too) | 777 | if (permanent_too) |
| 776 | BVAR (b, local_var_alist) = Qnil; | 778 | BSET (b, local_var_alist, Qnil); |
| 777 | else | 779 | else |
| 778 | { | 780 | { |
| 779 | Lisp_Object tmp, prop, last = Qnil; | 781 | Lisp_Object tmp, prop, last = Qnil; |
| @@ -807,7 +809,7 @@ reset_buffer_local_variables (register struct buffer *b, int permanent_too) | |||
| 807 | } | 809 | } |
| 808 | /* Delete this local variable. */ | 810 | /* Delete this local variable. */ |
| 809 | else if (NILP (last)) | 811 | else if (NILP (last)) |
| 810 | BVAR (b, local_var_alist) = XCDR (tmp); | 812 | BSET (b, local_var_alist, XCDR (tmp)); |
| 811 | else | 813 | else |
| 812 | XSETCDR (last, XCDR (tmp)); | 814 | XSETCDR (last, XCDR (tmp)); |
| 813 | } | 815 | } |
| @@ -817,7 +819,7 @@ reset_buffer_local_variables (register struct buffer *b, int permanent_too) | |||
| 817 | SET_PER_BUFFER_VALUE_P (b, i, 0); | 819 | SET_PER_BUFFER_VALUE_P (b, i, 0); |
| 818 | 820 | ||
| 819 | /* For each slot that has a default value, copy that into the slot. */ | 821 | /* For each slot that has a default value, copy that into the slot. */ |
| 820 | for_each_per_buffer_object_at (offset) | 822 | FOR_EACH_PER_BUFFER_OBJECT_AT (offset) |
| 821 | { | 823 | { |
| 822 | int idx = PER_BUFFER_IDX (offset); | 824 | int idx = PER_BUFFER_IDX (offset); |
| 823 | if ((idx > 0 | 825 | if ((idx > 0 |
| @@ -862,7 +864,7 @@ is first appended to NAME, to speed up finding a non-existent buffer. */) | |||
| 862 | { | 864 | { |
| 863 | /* Note fileio.c:make_temp_name does random differently. */ | 865 | /* Note fileio.c:make_temp_name does random differently. */ |
| 864 | tem2 = concat2 (name, make_formatted_string | 866 | tem2 = concat2 (name, make_formatted_string |
| 865 | (number, "-%"pI"d", | 867 | (number, "-%"pI"d", |
| 866 | XFASTINT (Frandom (make_number (999999))))); | 868 | XFASTINT (Frandom (make_number (999999))))); |
| 867 | tem = Fget_buffer (tem2); | 869 | tem = Fget_buffer (tem2); |
| 868 | if (NILP (tem)) | 870 | if (NILP (tem)) |
| @@ -1012,10 +1014,12 @@ buffer_local_value_1 (Lisp_Object variable, Lisp_Object buffer) | |||
| 1012 | 1014 | ||
| 1013 | /* Return an alist of the Lisp-level buffer-local bindings of | 1015 | /* Return an alist of the Lisp-level buffer-local bindings of |
| 1014 | buffer BUF. That is, don't include the variables maintained | 1016 | buffer BUF. That is, don't include the variables maintained |
| 1015 | in special slots in the buffer object. */ | 1017 | in special slots in the buffer object. |
| 1018 | If CLONE is zero elements of the form (VAR . unbound) are replaced | ||
| 1019 | by VAR. */ | ||
| 1016 | 1020 | ||
| 1017 | static Lisp_Object | 1021 | static Lisp_Object |
| 1018 | buffer_lisp_local_variables (struct buffer *buf) | 1022 | buffer_lisp_local_variables (struct buffer *buf, int clone) |
| 1019 | { | 1023 | { |
| 1020 | Lisp_Object result = Qnil; | 1024 | Lisp_Object result = Qnil; |
| 1021 | register Lisp_Object tail; | 1025 | register Lisp_Object tail; |
| @@ -1035,7 +1039,7 @@ buffer_lisp_local_variables (struct buffer *buf) | |||
| 1035 | if (buf != current_buffer) | 1039 | if (buf != current_buffer) |
| 1036 | val = XCDR (elt); | 1040 | val = XCDR (elt); |
| 1037 | 1041 | ||
| 1038 | result = Fcons (EQ (val, Qunbound) | 1042 | result = Fcons (!clone && EQ (val, Qunbound) |
| 1039 | ? XCAR (elt) | 1043 | ? XCAR (elt) |
| 1040 | : Fcons (XCAR (elt), val), | 1044 | : Fcons (XCAR (elt), val), |
| 1041 | result); | 1045 | result); |
| @@ -1064,13 +1068,13 @@ No argument or nil as argument means use current buffer as BUFFER. */) | |||
| 1064 | buf = XBUFFER (buffer); | 1068 | buf = XBUFFER (buffer); |
| 1065 | } | 1069 | } |
| 1066 | 1070 | ||
| 1067 | result = buffer_lisp_local_variables (buf); | 1071 | result = buffer_lisp_local_variables (buf, 0); |
| 1068 | 1072 | ||
| 1069 | /* Add on all the variables stored in special slots. */ | 1073 | /* Add on all the variables stored in special slots. */ |
| 1070 | { | 1074 | { |
| 1071 | int offset, idx; | 1075 | int offset, idx; |
| 1072 | 1076 | ||
| 1073 | for_each_per_buffer_object_at (offset) | 1077 | FOR_EACH_PER_BUFFER_OBJECT_AT (offset) |
| 1074 | { | 1078 | { |
| 1075 | idx = PER_BUFFER_IDX (offset); | 1079 | idx = PER_BUFFER_IDX (offset); |
| 1076 | if ((idx == -1 || PER_BUFFER_VALUE_P (buf, idx)) | 1080 | if ((idx == -1 || PER_BUFFER_VALUE_P (buf, idx)) |
| @@ -1282,7 +1286,7 @@ This does not change the name of the visited file (if any). */) | |||
| 1282 | error ("Buffer name `%s' is in use", SDATA (newname)); | 1286 | error ("Buffer name `%s' is in use", SDATA (newname)); |
| 1283 | } | 1287 | } |
| 1284 | 1288 | ||
| 1285 | BVAR (current_buffer, name) = newname; | 1289 | BSET (current_buffer, name, newname); |
| 1286 | 1290 | ||
| 1287 | /* Catch redisplay's attention. Unless we do this, the mode lines for | 1291 | /* Catch redisplay's attention. Unless we do this, the mode lines for |
| 1288 | any windows displaying current_buffer will stay unchanged. */ | 1292 | any windows displaying current_buffer will stay unchanged. */ |
| @@ -1427,19 +1431,60 @@ No argument or nil as argument means do this for the current buffer. */) | |||
| 1427 | } | 1431 | } |
| 1428 | 1432 | ||
| 1429 | if (EQ (BVAR (XBUFFER (real_buffer), undo_list), Qt)) | 1433 | if (EQ (BVAR (XBUFFER (real_buffer), undo_list), Qt)) |
| 1430 | BVAR (XBUFFER (real_buffer), undo_list) = Qnil; | 1434 | BSET (XBUFFER (real_buffer), undo_list, Qnil); |
| 1431 | 1435 | ||
| 1432 | return Qnil; | 1436 | return Qnil; |
| 1433 | } | 1437 | } |
| 1434 | 1438 | ||
| 1435 | /* | 1439 | /* Truncate undo list and shrink the gap of BUFFER. */ |
| 1436 | DEFVAR_LISP ("kill-buffer-hook", ..., "\ | 1440 | |
| 1437 | Hook to be run (by `run-hooks', which see) when a buffer is killed.\n\ | 1441 | int |
| 1438 | The buffer being killed will be current while the hook is running.\n\ | 1442 | compact_buffer (struct buffer *buffer) |
| 1443 | { | ||
| 1444 | /* Verify indirection counters. */ | ||
| 1445 | if (buffer->base_buffer) | ||
| 1446 | { | ||
| 1447 | eassert (buffer->indirections == -1); | ||
| 1448 | eassert (buffer->base_buffer->indirections > 0); | ||
| 1449 | } | ||
| 1450 | else | ||
| 1451 | eassert (buffer->indirections >= 0); | ||
| 1452 | |||
| 1453 | /* Skip dead buffers, indirect buffers and buffers | ||
| 1454 | which aren't changed since last compaction. */ | ||
| 1455 | if (!NILP (buffer->INTERNAL_FIELD (name)) | ||
| 1456 | && (buffer->base_buffer == NULL) | ||
| 1457 | && (buffer->text->compact != buffer->text->modiff)) | ||
| 1458 | { | ||
| 1459 | /* If a buffer's undo list is Qt, that means that undo is | ||
| 1460 | turned off in that buffer. Calling truncate_undo_list on | ||
| 1461 | Qt tends to return NULL, which effectively turns undo back on. | ||
| 1462 | So don't call truncate_undo_list if undo_list is Qt. */ | ||
| 1463 | if (!EQ (buffer->INTERNAL_FIELD (undo_list), Qt)) | ||
| 1464 | truncate_undo_list (buffer); | ||
| 1465 | |||
| 1466 | /* Shrink buffer gaps. */ | ||
| 1467 | if (!buffer->text->inhibit_shrinking) | ||
| 1468 | { | ||
| 1469 | /* If a buffer's gap size is more than 10% of the buffer | ||
| 1470 | size, or larger than 2000 bytes, then shrink it | ||
| 1471 | accordingly. Keep a minimum size of 20 bytes. */ | ||
| 1472 | int size = min (2000, max (20, (buffer->text->z_byte / 10))); | ||
| 1473 | |||
| 1474 | if (buffer->text->gap_size > size) | ||
| 1475 | { | ||
| 1476 | struct buffer *save_current = current_buffer; | ||
| 1477 | current_buffer = buffer; | ||
| 1478 | make_gap (-(buffer->text->gap_size - size)); | ||
| 1479 | current_buffer = save_current; | ||
| 1480 | } | ||
| 1481 | } | ||
| 1482 | buffer->text->compact = buffer->text->modiff; | ||
| 1483 | return 1; | ||
| 1484 | } | ||
| 1485 | return 0; | ||
| 1486 | } | ||
| 1439 | 1487 | ||
| 1440 | Functions run by this hook are supposed to not change the current | ||
| 1441 | buffer. See `kill-buffer'." | ||
| 1442 | */ | ||
| 1443 | DEFUN ("kill-buffer", Fkill_buffer, Skill_buffer, 0, 1, "bKill buffer: ", | 1488 | DEFUN ("kill-buffer", Fkill_buffer, Skill_buffer, 0, 1, "bKill buffer: ", |
| 1444 | doc: /* Kill the buffer specified by BUFFER-OR-NAME. | 1489 | doc: /* Kill the buffer specified by BUFFER-OR-NAME. |
| 1445 | The argument may be a buffer or the name of an existing buffer. | 1490 | The argument may be a buffer or the name of an existing buffer. |
| @@ -1521,19 +1566,18 @@ cleaning up all windows currently displaying the buffer to be killed. */) | |||
| 1521 | if (EQ (buffer, XWINDOW (minibuf_window)->buffer)) | 1566 | if (EQ (buffer, XWINDOW (minibuf_window)->buffer)) |
| 1522 | return Qnil; | 1567 | return Qnil; |
| 1523 | 1568 | ||
| 1524 | /* When we kill a base buffer, kill all its indirect buffers. | 1569 | /* When we kill an ordinary buffer which shares it's buffer text |
| 1570 | with indirect buffer(s), we must kill indirect buffer(s) too. | ||
| 1525 | We do it at this stage so nothing terrible happens if they | 1571 | We do it at this stage so nothing terrible happens if they |
| 1526 | ask questions or their hooks get errors. */ | 1572 | ask questions or their hooks get errors. */ |
| 1527 | if (! b->base_buffer) | 1573 | if (!b->base_buffer && b->indirections > 0) |
| 1528 | { | 1574 | { |
| 1529 | struct buffer *other; | 1575 | struct buffer *other; |
| 1530 | 1576 | ||
| 1531 | GCPRO1 (buffer); | 1577 | GCPRO1 (buffer); |
| 1532 | 1578 | ||
| 1533 | for (other = all_buffers; other; other = other->header.next.buffer) | 1579 | FOR_EACH_BUFFER (other) |
| 1534 | /* all_buffers contains dead buffers too; | 1580 | if (other->base_buffer == b) |
| 1535 | don't re-kill them. */ | ||
| 1536 | if (other->base_buffer == b && !NILP (BVAR (other, name))) | ||
| 1537 | { | 1581 | { |
| 1538 | Lisp_Object buf; | 1582 | Lisp_Object buf; |
| 1539 | XSETBUFFER (buf, other); | 1583 | XSETBUFFER (buf, other); |
| @@ -1647,7 +1691,7 @@ cleaning up all windows currently displaying the buffer to be killed. */) | |||
| 1647 | m = next; | 1691 | m = next; |
| 1648 | } | 1692 | } |
| 1649 | BUF_MARKERS (b) = NULL; | 1693 | BUF_MARKERS (b) = NULL; |
| 1650 | BUF_INTERVALS (b) = NULL_INTERVAL; | 1694 | buffer_set_intervals (b, NULL); |
| 1651 | 1695 | ||
| 1652 | /* Perhaps we should explicitly free the interval tree here... */ | 1696 | /* Perhaps we should explicitly free the interval tree here... */ |
| 1653 | } | 1697 | } |
| @@ -1659,10 +1703,18 @@ cleaning up all windows currently displaying the buffer to be killed. */) | |||
| 1659 | swap_out_buffer_local_variables (b); | 1703 | swap_out_buffer_local_variables (b); |
| 1660 | reset_buffer_local_variables (b, 1); | 1704 | reset_buffer_local_variables (b, 1); |
| 1661 | 1705 | ||
| 1662 | BVAR (b, name) = Qnil; | 1706 | BSET (b, name, Qnil); |
| 1663 | 1707 | ||
| 1664 | BLOCK_INPUT; | 1708 | BLOCK_INPUT; |
| 1665 | if (! b->base_buffer) | 1709 | if (b->base_buffer) |
| 1710 | { | ||
| 1711 | /* Notify our base buffer that we don't share the text anymore. */ | ||
| 1712 | eassert (b->indirections == -1); | ||
| 1713 | b->base_buffer->indirections--; | ||
| 1714 | eassert (b->base_buffer->indirections >= 0); | ||
| 1715 | } | ||
| 1716 | else | ||
| 1717 | /* No one shares our buffer text, can free it. */ | ||
| 1666 | free_buffer_text (b); | 1718 | free_buffer_text (b); |
| 1667 | 1719 | ||
| 1668 | if (b->newline_cache) | 1720 | if (b->newline_cache) |
| @@ -1675,9 +1727,9 @@ cleaning up all windows currently displaying the buffer to be killed. */) | |||
| 1675 | free_region_cache (b->width_run_cache); | 1727 | free_region_cache (b->width_run_cache); |
| 1676 | b->width_run_cache = 0; | 1728 | b->width_run_cache = 0; |
| 1677 | } | 1729 | } |
| 1678 | BVAR (b, width_table) = Qnil; | 1730 | BSET (b, width_table, Qnil); |
| 1679 | UNBLOCK_INPUT; | 1731 | UNBLOCK_INPUT; |
| 1680 | BVAR (b, undo_list) = Qnil; | 1732 | BSET (b, undo_list, Qnil); |
| 1681 | 1733 | ||
| 1682 | /* Run buffer-list-update-hook. */ | 1734 | /* Run buffer-list-update-hook. */ |
| 1683 | if (!NILP (Vrun_hooks)) | 1735 | if (!NILP (Vrun_hooks)) |
| @@ -1718,8 +1770,8 @@ record_buffer (Lisp_Object buffer) | |||
| 1718 | Vinhibit_quit = tem; | 1770 | Vinhibit_quit = tem; |
| 1719 | 1771 | ||
| 1720 | /* Update buffer list of selected frame. */ | 1772 | /* Update buffer list of selected frame. */ |
| 1721 | f->buffer_list = Fcons (buffer, Fdelq (buffer, f->buffer_list)); | 1773 | FSET (f, buffer_list, Fcons (buffer, Fdelq (buffer, f->buffer_list))); |
| 1722 | f->buried_buffer_list = Fdelq (buffer, f->buried_buffer_list); | 1774 | FSET (f, buried_buffer_list, Fdelq (buffer, f->buried_buffer_list)); |
| 1723 | 1775 | ||
| 1724 | /* Run buffer-list-update-hook. */ | 1776 | /* Run buffer-list-update-hook. */ |
| 1725 | if (!NILP (Vrun_hooks)) | 1777 | if (!NILP (Vrun_hooks)) |
| @@ -1756,8 +1808,9 @@ DEFUN ("bury-buffer-internal", Fbury_buffer_internal, Sbury_buffer_internal, | |||
| 1756 | Vinhibit_quit = tem; | 1808 | Vinhibit_quit = tem; |
| 1757 | 1809 | ||
| 1758 | /* Update buffer lists of selected frame. */ | 1810 | /* Update buffer lists of selected frame. */ |
| 1759 | f->buffer_list = Fdelq (buffer, f->buffer_list); | 1811 | FSET (f, buffer_list, Fdelq (buffer, f->buffer_list)); |
| 1760 | f->buried_buffer_list = Fcons (buffer, Fdelq (buffer, f->buried_buffer_list)); | 1812 | FSET (f, buried_buffer_list, |
| 1813 | Fcons (buffer, Fdelq (buffer, f->buried_buffer_list))); | ||
| 1761 | 1814 | ||
| 1762 | /* Run buffer-list-update-hook. */ | 1815 | /* Run buffer-list-update-hook. */ |
| 1763 | if (!NILP (Vrun_hooks)) | 1816 | if (!NILP (Vrun_hooks)) |
| @@ -1857,7 +1910,7 @@ set_buffer_internal_1 (register struct buffer *b) | |||
| 1857 | /* Put the undo list back in the base buffer, so that it appears | 1910 | /* Put the undo list back in the base buffer, so that it appears |
| 1858 | that an indirect buffer shares the undo list of its base. */ | 1911 | that an indirect buffer shares the undo list of its base. */ |
| 1859 | if (old_buf->base_buffer) | 1912 | if (old_buf->base_buffer) |
| 1860 | BVAR (old_buf->base_buffer, undo_list) = BVAR (old_buf, undo_list); | 1913 | BSET (old_buf->base_buffer, undo_list, BVAR (old_buf, undo_list)); |
| 1861 | 1914 | ||
| 1862 | /* If the old current buffer has markers to record PT, BEGV and ZV | 1915 | /* If the old current buffer has markers to record PT, BEGV and ZV |
| 1863 | when it is not current, update them now. */ | 1916 | when it is not current, update them now. */ |
| @@ -1867,7 +1920,7 @@ set_buffer_internal_1 (register struct buffer *b) | |||
| 1867 | /* Get the undo list from the base buffer, so that it appears | 1920 | /* Get the undo list from the base buffer, so that it appears |
| 1868 | that an indirect buffer shares the undo list of its base. */ | 1921 | that an indirect buffer shares the undo list of its base. */ |
| 1869 | if (b->base_buffer) | 1922 | if (b->base_buffer) |
| 1870 | BVAR (b, undo_list) = BVAR (b->base_buffer, undo_list); | 1923 | BSET (b, undo_list, BVAR (b->base_buffer, undo_list)); |
| 1871 | 1924 | ||
| 1872 | /* If the new current buffer has markers to record PT, BEGV and ZV | 1925 | /* If the new current buffer has markers to record PT, BEGV and ZV |
| 1873 | when it is not current, fetch them now. */ | 1926 | when it is not current, fetch them now. */ |
| @@ -2050,7 +2103,7 @@ DEFUN ("buffer-swap-text", Fbuffer_swap_text, Sbuffer_swap_text, | |||
| 2050 | 2103 | ||
| 2051 | { /* This is probably harder to make work. */ | 2104 | { /* This is probably harder to make work. */ |
| 2052 | struct buffer *other; | 2105 | struct buffer *other; |
| 2053 | for (other = all_buffers; other; other = other->header.next.buffer) | 2106 | FOR_EACH_BUFFER (other) |
| 2054 | if (other->base_buffer == other_buffer | 2107 | if (other->base_buffer == other_buffer |
| 2055 | || other->base_buffer == current_buffer) | 2108 | || other->base_buffer == current_buffer) |
| 2056 | error ("One of the buffers to swap has indirect buffers"); | 2109 | error ("One of the buffers to swap has indirect buffers"); |
| @@ -2065,8 +2118,8 @@ DEFUN ("buffer-swap-text", Fbuffer_swap_text, Sbuffer_swap_text, | |||
| 2065 | #define swapfield_(field, type) \ | 2118 | #define swapfield_(field, type) \ |
| 2066 | do { \ | 2119 | do { \ |
| 2067 | type tmp##field = BVAR (other_buffer, field); \ | 2120 | type tmp##field = BVAR (other_buffer, field); \ |
| 2068 | BVAR (other_buffer, field) = BVAR (current_buffer, field); \ | 2121 | BSET (other_buffer, field, BVAR (current_buffer, field)); \ |
| 2069 | BVAR (current_buffer, field) = tmp##field; \ | 2122 | BSET (current_buffer, field, tmp##field); \ |
| 2070 | } while (0) | 2123 | } while (0) |
| 2071 | 2124 | ||
| 2072 | swapfield (own_text, struct buffer_text); | 2125 | swapfield (own_text, struct buffer_text); |
| @@ -2087,6 +2140,7 @@ DEFUN ("buffer-swap-text", Fbuffer_swap_text, Sbuffer_swap_text, | |||
| 2087 | swapfield (zv_byte, ptrdiff_t); | 2140 | swapfield (zv_byte, ptrdiff_t); |
| 2088 | eassert (!current_buffer->base_buffer); | 2141 | eassert (!current_buffer->base_buffer); |
| 2089 | eassert (!other_buffer->base_buffer); | 2142 | eassert (!other_buffer->base_buffer); |
| 2143 | swapfield (indirections, ptrdiff_t); | ||
| 2090 | current_buffer->clip_changed = 1; other_buffer->clip_changed = 1; | 2144 | current_buffer->clip_changed = 1; other_buffer->clip_changed = 1; |
| 2091 | swapfield (newline_cache, struct region_cache *); | 2145 | swapfield (newline_cache, struct region_cache *); |
| 2092 | swapfield (width_run_cache, struct region_cache *); | 2146 | swapfield (width_run_cache, struct region_cache *); |
| @@ -2105,8 +2159,8 @@ DEFUN ("buffer-swap-text", Fbuffer_swap_text, Sbuffer_swap_text, | |||
| 2105 | swapfield_ (pt_marker, Lisp_Object); | 2159 | swapfield_ (pt_marker, Lisp_Object); |
| 2106 | swapfield_ (begv_marker, Lisp_Object); | 2160 | swapfield_ (begv_marker, Lisp_Object); |
| 2107 | swapfield_ (zv_marker, Lisp_Object); | 2161 | swapfield_ (zv_marker, Lisp_Object); |
| 2108 | BVAR (current_buffer, point_before_scroll) = Qnil; | 2162 | BSET (current_buffer, point_before_scroll, Qnil); |
| 2109 | BVAR (other_buffer, point_before_scroll) = Qnil; | 2163 | BSET (other_buffer, point_before_scroll, Qnil); |
| 2110 | 2164 | ||
| 2111 | current_buffer->text->modiff++; other_buffer->text->modiff++; | 2165 | current_buffer->text->modiff++; other_buffer->text->modiff++; |
| 2112 | current_buffer->text->chars_modiff++; other_buffer->text->chars_modiff++; | 2166 | current_buffer->text->chars_modiff++; other_buffer->text->chars_modiff++; |
| @@ -2146,7 +2200,8 @@ DEFUN ("buffer-swap-text", Fbuffer_swap_text, Sbuffer_swap_text, | |||
| 2146 | && (EQ (XWINDOW (w)->buffer, buf1) | 2200 | && (EQ (XWINDOW (w)->buffer, buf1) |
| 2147 | || EQ (XWINDOW (w)->buffer, buf2))) | 2201 | || EQ (XWINDOW (w)->buffer, buf2))) |
| 2148 | Fset_marker (XWINDOW (w)->pointm, | 2202 | Fset_marker (XWINDOW (w)->pointm, |
| 2149 | make_number (BUF_BEGV (XBUFFER (XWINDOW (w)->buffer))), | 2203 | make_number |
| 2204 | (BUF_BEGV (XBUFFER (XWINDOW (w)->buffer))), | ||
| 2150 | XWINDOW (w)->buffer); | 2205 | XWINDOW (w)->buffer); |
| 2151 | w = Fnext_window (w, Qt, Qt); | 2206 | w = Fnext_window (w, Qt, Qt); |
| 2152 | } | 2207 | } |
| @@ -2194,7 +2249,7 @@ current buffer is cleared. */) | |||
| 2194 | 2249 | ||
| 2195 | /* Don't record these buffer changes. We will put a special undo entry | 2250 | /* Don't record these buffer changes. We will put a special undo entry |
| 2196 | instead. */ | 2251 | instead. */ |
| 2197 | BVAR (current_buffer, undo_list) = Qt; | 2252 | BSET (current_buffer, undo_list, Qt); |
| 2198 | 2253 | ||
| 2199 | /* If the cached position is for this buffer, clear it out. */ | 2254 | /* If the cached position is for this buffer, clear it out. */ |
| 2200 | clear_charpos_cache (current_buffer); | 2255 | clear_charpos_cache (current_buffer); |
| @@ -2216,7 +2271,7 @@ current buffer is cleared. */) | |||
| 2216 | to calculate the old correspondences. */ | 2271 | to calculate the old correspondences. */ |
| 2217 | set_intervals_multibyte (0); | 2272 | set_intervals_multibyte (0); |
| 2218 | 2273 | ||
| 2219 | BVAR (current_buffer, enable_multibyte_characters) = Qnil; | 2274 | BSET (current_buffer, enable_multibyte_characters, Qnil); |
| 2220 | 2275 | ||
| 2221 | Z = Z_BYTE; | 2276 | Z = Z_BYTE; |
| 2222 | BEGV = BEGV_BYTE; | 2277 | BEGV = BEGV_BYTE; |
| @@ -2354,7 +2409,7 @@ current buffer is cleared. */) | |||
| 2354 | 2409 | ||
| 2355 | /* Do this first, so that chars_in_text asks the right question. | 2410 | /* Do this first, so that chars_in_text asks the right question. |
| 2356 | set_intervals_multibyte needs it too. */ | 2411 | set_intervals_multibyte needs it too. */ |
| 2357 | BVAR (current_buffer, enable_multibyte_characters) = Qt; | 2412 | BSET (current_buffer, enable_multibyte_characters, Qt); |
| 2358 | 2413 | ||
| 2359 | GPT_BYTE = advance_to_char_boundary (GPT_BYTE); | 2414 | GPT_BYTE = advance_to_char_boundary (GPT_BYTE); |
| 2360 | GPT = chars_in_text (BEG_ADDR, GPT_BYTE - BEG_BYTE) + BEG; | 2415 | GPT = chars_in_text (BEG_ADDR, GPT_BYTE - BEG_BYTE) + BEG; |
| @@ -2412,10 +2467,11 @@ current buffer is cleared. */) | |||
| 2412 | if (!EQ (old_undo, Qt)) | 2467 | if (!EQ (old_undo, Qt)) |
| 2413 | { | 2468 | { |
| 2414 | /* Represent all the above changes by a special undo entry. */ | 2469 | /* Represent all the above changes by a special undo entry. */ |
| 2415 | BVAR (current_buffer, undo_list) = Fcons (list3 (Qapply, | 2470 | BSET (current_buffer, undo_list, |
| 2416 | intern ("set-buffer-multibyte"), | 2471 | Fcons (list3 (Qapply, |
| 2417 | NILP (flag) ? Qt : Qnil), | 2472 | intern ("set-buffer-multibyte"), |
| 2418 | old_undo); | 2473 | NILP (flag) ? Qt : Qnil), |
| 2474 | old_undo)); | ||
| 2419 | } | 2475 | } |
| 2420 | 2476 | ||
| 2421 | UNGCPRO; | 2477 | UNGCPRO; |
| @@ -2427,7 +2483,7 @@ current buffer is cleared. */) | |||
| 2427 | 2483 | ||
| 2428 | /* Copy this buffer's new multibyte status | 2484 | /* Copy this buffer's new multibyte status |
| 2429 | into all of its indirect buffers. */ | 2485 | into all of its indirect buffers. */ |
| 2430 | for (other = all_buffers; other; other = other->header.next.buffer) | 2486 | FOR_EACH_BUFFER (other) |
| 2431 | if (other->base_buffer == current_buffer && !NILP (BVAR (other, name))) | 2487 | if (other->base_buffer == current_buffer && !NILP (BVAR (other, name))) |
| 2432 | { | 2488 | { |
| 2433 | BVAR (other, enable_multibyte_characters) | 2489 | BVAR (other, enable_multibyte_characters) |
| @@ -2827,8 +2883,7 @@ overlay_touches_p (ptrdiff_t pos) | |||
| 2827 | ptrdiff_t endpos; | 2883 | ptrdiff_t endpos; |
| 2828 | 2884 | ||
| 2829 | XSETMISC (overlay ,tail); | 2885 | XSETMISC (overlay ,tail); |
| 2830 | if (!OVERLAYP (overlay)) | 2886 | eassert (OVERLAYP (overlay)); |
| 2831 | abort (); | ||
| 2832 | 2887 | ||
| 2833 | endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); | 2888 | endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); |
| 2834 | if (endpos < pos) | 2889 | if (endpos < pos) |
| @@ -2842,8 +2897,7 @@ overlay_touches_p (ptrdiff_t pos) | |||
| 2842 | ptrdiff_t startpos; | 2897 | ptrdiff_t startpos; |
| 2843 | 2898 | ||
| 2844 | XSETMISC (overlay, tail); | 2899 | XSETMISC (overlay, tail); |
| 2845 | if (!OVERLAYP (overlay)) | 2900 | eassert (OVERLAYP (overlay)); |
| 2846 | abort (); | ||
| 2847 | 2901 | ||
| 2848 | startpos = OVERLAY_POSITION (OVERLAY_START (overlay)); | 2902 | startpos = OVERLAY_POSITION (OVERLAY_START (overlay)); |
| 2849 | if (pos < startpos) | 2903 | if (pos < startpos) |
| @@ -2898,7 +2952,7 @@ sort_overlays (Lisp_Object *overlay_vec, ptrdiff_t noverlays, struct window *w) | |||
| 2898 | Lisp_Object overlay; | 2952 | Lisp_Object overlay; |
| 2899 | 2953 | ||
| 2900 | overlay = overlay_vec[i]; | 2954 | overlay = overlay_vec[i]; |
| 2901 | if (OVERLAY_VALID (overlay) | 2955 | if (OVERLAYP (overlay) |
| 2902 | && OVERLAY_POSITION (OVERLAY_START (overlay)) > 0 | 2956 | && OVERLAY_POSITION (OVERLAY_START (overlay)) > 0 |
| 2903 | && OVERLAY_POSITION (OVERLAY_END (overlay)) > 0) | 2957 | && OVERLAY_POSITION (OVERLAY_END (overlay)) > 0) |
| 2904 | { | 2958 | { |
| @@ -3169,22 +3223,7 @@ recenter_overlay_lists (struct buffer *buf, ptrdiff_t pos) | |||
| 3169 | { | 3223 | { |
| 3170 | next = tail->next; | 3224 | next = tail->next; |
| 3171 | XSETMISC (overlay, tail); | 3225 | XSETMISC (overlay, tail); |
| 3172 | 3226 | eassert (OVERLAYP (overlay)); | |
| 3173 | /* If the overlay is not valid, get rid of it. */ | ||
| 3174 | if (!OVERLAY_VALID (overlay)) | ||
| 3175 | #if 1 | ||
| 3176 | abort (); | ||
| 3177 | #else | ||
| 3178 | { | ||
| 3179 | /* Splice the cons cell TAIL out of overlays_before. */ | ||
| 3180 | if (!NILP (prev)) | ||
| 3181 | XCDR (prev) = next; | ||
| 3182 | else | ||
| 3183 | buf->overlays_before = next; | ||
| 3184 | tail = prev; | ||
| 3185 | continue; | ||
| 3186 | } | ||
| 3187 | #endif | ||
| 3188 | 3227 | ||
| 3189 | beg = OVERLAY_START (overlay); | 3228 | beg = OVERLAY_START (overlay); |
| 3190 | end = OVERLAY_END (overlay); | 3229 | end = OVERLAY_END (overlay); |
| @@ -3199,7 +3238,7 @@ recenter_overlay_lists (struct buffer *buf, ptrdiff_t pos) | |||
| 3199 | if (prev) | 3238 | if (prev) |
| 3200 | prev->next = next; | 3239 | prev->next = next; |
| 3201 | else | 3240 | else |
| 3202 | buf->overlays_before = next; | 3241 | buffer_set_overlays_before (buf, next); |
| 3203 | 3242 | ||
| 3204 | /* Search thru overlays_after for where to put it. */ | 3243 | /* Search thru overlays_after for where to put it. */ |
| 3205 | other_prev = NULL; | 3244 | other_prev = NULL; |
| @@ -3209,7 +3248,7 @@ recenter_overlay_lists (struct buffer *buf, ptrdiff_t pos) | |||
| 3209 | Lisp_Object otherbeg, otheroverlay; | 3248 | Lisp_Object otherbeg, otheroverlay; |
| 3210 | 3249 | ||
| 3211 | XSETMISC (otheroverlay, other); | 3250 | XSETMISC (otheroverlay, other); |
| 3212 | eassert (OVERLAY_VALID (otheroverlay)); | 3251 | eassert (OVERLAYP (otheroverlay)); |
| 3213 | 3252 | ||
| 3214 | otherbeg = OVERLAY_START (otheroverlay); | 3253 | otherbeg = OVERLAY_START (otheroverlay); |
| 3215 | if (OVERLAY_POSITION (otherbeg) >= where) | 3254 | if (OVERLAY_POSITION (otherbeg) >= where) |
| @@ -3221,7 +3260,7 @@ recenter_overlay_lists (struct buffer *buf, ptrdiff_t pos) | |||
| 3221 | if (other_prev) | 3260 | if (other_prev) |
| 3222 | other_prev->next = tail; | 3261 | other_prev->next = tail; |
| 3223 | else | 3262 | else |
| 3224 | buf->overlays_after = tail; | 3263 | buffer_set_overlays_after (buf, tail); |
| 3225 | tail = prev; | 3264 | tail = prev; |
| 3226 | } | 3265 | } |
| 3227 | else | 3266 | else |
| @@ -3237,22 +3276,7 @@ recenter_overlay_lists (struct buffer *buf, ptrdiff_t pos) | |||
| 3237 | { | 3276 | { |
| 3238 | next = tail->next; | 3277 | next = tail->next; |
| 3239 | XSETMISC (overlay, tail); | 3278 | XSETMISC (overlay, tail); |
| 3240 | 3279 | eassert (OVERLAYP (overlay)); | |
| 3241 | /* If the overlay is not valid, get rid of it. */ | ||
| 3242 | if (!OVERLAY_VALID (overlay)) | ||
| 3243 | #if 1 | ||
| 3244 | abort (); | ||
| 3245 | #else | ||
| 3246 | { | ||
| 3247 | /* Splice the cons cell TAIL out of overlays_after. */ | ||
| 3248 | if (!NILP (prev)) | ||
| 3249 | XCDR (prev) = next; | ||
| 3250 | else | ||
| 3251 | buf->overlays_after = next; | ||
| 3252 | tail = prev; | ||
| 3253 | continue; | ||
| 3254 | } | ||
| 3255 | #endif | ||
| 3256 | 3280 | ||
| 3257 | beg = OVERLAY_START (overlay); | 3281 | beg = OVERLAY_START (overlay); |
| 3258 | end = OVERLAY_END (overlay); | 3282 | end = OVERLAY_END (overlay); |
| @@ -3272,7 +3296,7 @@ recenter_overlay_lists (struct buffer *buf, ptrdiff_t pos) | |||
| 3272 | if (prev) | 3296 | if (prev) |
| 3273 | prev->next = next; | 3297 | prev->next = next; |
| 3274 | else | 3298 | else |
| 3275 | buf->overlays_after = next; | 3299 | buffer_set_overlays_after (buf, next); |
| 3276 | 3300 | ||
| 3277 | /* Search thru overlays_before for where to put it. */ | 3301 | /* Search thru overlays_before for where to put it. */ |
| 3278 | other_prev = NULL; | 3302 | other_prev = NULL; |
| @@ -3282,7 +3306,7 @@ recenter_overlay_lists (struct buffer *buf, ptrdiff_t pos) | |||
| 3282 | Lisp_Object otherend, otheroverlay; | 3306 | Lisp_Object otherend, otheroverlay; |
| 3283 | 3307 | ||
| 3284 | XSETMISC (otheroverlay, other); | 3308 | XSETMISC (otheroverlay, other); |
| 3285 | eassert (OVERLAY_VALID (otheroverlay)); | 3309 | eassert (OVERLAYP (otheroverlay)); |
| 3286 | 3310 | ||
| 3287 | otherend = OVERLAY_END (otheroverlay); | 3311 | otherend = OVERLAY_END (otheroverlay); |
| 3288 | if (OVERLAY_POSITION (otherend) <= where) | 3312 | if (OVERLAY_POSITION (otherend) <= where) |
| @@ -3294,7 +3318,7 @@ recenter_overlay_lists (struct buffer *buf, ptrdiff_t pos) | |||
| 3294 | if (other_prev) | 3318 | if (other_prev) |
| 3295 | other_prev->next = tail; | 3319 | other_prev->next = tail; |
| 3296 | else | 3320 | else |
| 3297 | buf->overlays_before = tail; | 3321 | buffer_set_overlays_before (buf, tail); |
| 3298 | tail = prev; | 3322 | tail = prev; |
| 3299 | } | 3323 | } |
| 3300 | } | 3324 | } |
| @@ -3399,7 +3423,7 @@ fix_start_end_in_overlays (register ptrdiff_t start, register ptrdiff_t end) | |||
| 3399 | beforep = tail; | 3423 | beforep = tail; |
| 3400 | } | 3424 | } |
| 3401 | if (!parent) | 3425 | if (!parent) |
| 3402 | current_buffer->overlays_before = tail->next; | 3426 | buffer_set_overlays_before (current_buffer, tail->next); |
| 3403 | else | 3427 | else |
| 3404 | parent->next = tail->next; | 3428 | parent->next = tail->next; |
| 3405 | tail = tail->next; | 3429 | tail = tail->next; |
| @@ -3445,7 +3469,7 @@ fix_start_end_in_overlays (register ptrdiff_t start, register ptrdiff_t end) | |||
| 3445 | beforep = tail; | 3469 | beforep = tail; |
| 3446 | } | 3470 | } |
| 3447 | if (!parent) | 3471 | if (!parent) |
| 3448 | current_buffer->overlays_after = tail->next; | 3472 | buffer_set_overlays_after (current_buffer, tail->next); |
| 3449 | else | 3473 | else |
| 3450 | parent->next = tail->next; | 3474 | parent->next = tail->next; |
| 3451 | tail = tail->next; | 3475 | tail = tail->next; |
| @@ -3459,14 +3483,14 @@ fix_start_end_in_overlays (register ptrdiff_t start, register ptrdiff_t end) | |||
| 3459 | if (beforep) | 3483 | if (beforep) |
| 3460 | { | 3484 | { |
| 3461 | beforep->next = current_buffer->overlays_before; | 3485 | beforep->next = current_buffer->overlays_before; |
| 3462 | current_buffer->overlays_before = before_list; | 3486 | buffer_set_overlays_before (current_buffer, before_list); |
| 3463 | } | 3487 | } |
| 3464 | recenter_overlay_lists (current_buffer, current_buffer->overlay_center); | 3488 | recenter_overlay_lists (current_buffer, current_buffer->overlay_center); |
| 3465 | 3489 | ||
| 3466 | if (afterp) | 3490 | if (afterp) |
| 3467 | { | 3491 | { |
| 3468 | afterp->next = current_buffer->overlays_after; | 3492 | afterp->next = current_buffer->overlays_after; |
| 3469 | current_buffer->overlays_after = after_list; | 3493 | buffer_set_overlays_after (current_buffer, after_list); |
| 3470 | } | 3494 | } |
| 3471 | recenter_overlay_lists (current_buffer, current_buffer->overlay_center); | 3495 | recenter_overlay_lists (current_buffer, current_buffer->overlay_center); |
| 3472 | } | 3496 | } |
| @@ -3543,7 +3567,7 @@ fix_overlays_before (struct buffer *bp, ptrdiff_t prev, ptrdiff_t pos) | |||
| 3543 | if (!right_pair) | 3567 | if (!right_pair) |
| 3544 | { | 3568 | { |
| 3545 | found->next = bp->overlays_before; | 3569 | found->next = bp->overlays_before; |
| 3546 | bp->overlays_before = found; | 3570 | buffer_set_overlays_before (bp, found); |
| 3547 | } | 3571 | } |
| 3548 | else | 3572 | else |
| 3549 | { | 3573 | { |
| @@ -3613,12 +3637,7 @@ for the rear of the overlay advance when text is inserted there | |||
| 3613 | if (!NILP (rear_advance)) | 3637 | if (!NILP (rear_advance)) |
| 3614 | XMARKER (end)->insertion_type = 1; | 3638 | XMARKER (end)->insertion_type = 1; |
| 3615 | 3639 | ||
| 3616 | overlay = allocate_misc (); | 3640 | overlay = build_overlay (beg, end, Qnil); |
| 3617 | XMISCTYPE (overlay) = Lisp_Misc_Overlay; | ||
| 3618 | XOVERLAY (overlay)->start = beg; | ||
| 3619 | XOVERLAY (overlay)->end = end; | ||
| 3620 | XOVERLAY (overlay)->plist = Qnil; | ||
| 3621 | XOVERLAY (overlay)->next = NULL; | ||
| 3622 | 3641 | ||
| 3623 | /* Put the new overlay on the wrong list. */ | 3642 | /* Put the new overlay on the wrong list. */ |
| 3624 | end = OVERLAY_END (overlay); | 3643 | end = OVERLAY_END (overlay); |
| @@ -3626,13 +3645,13 @@ for the rear of the overlay advance when text is inserted there | |||
| 3626 | { | 3645 | { |
| 3627 | if (b->overlays_after) | 3646 | if (b->overlays_after) |
| 3628 | XOVERLAY (overlay)->next = b->overlays_after; | 3647 | XOVERLAY (overlay)->next = b->overlays_after; |
| 3629 | b->overlays_after = XOVERLAY (overlay); | 3648 | buffer_set_overlays_after (b, XOVERLAY (overlay)); |
| 3630 | } | 3649 | } |
| 3631 | else | 3650 | else |
| 3632 | { | 3651 | { |
| 3633 | if (b->overlays_before) | 3652 | if (b->overlays_before) |
| 3634 | XOVERLAY (overlay)->next = b->overlays_before; | 3653 | XOVERLAY (overlay)->next = b->overlays_before; |
| 3635 | b->overlays_before = XOVERLAY (overlay); | 3654 | buffer_set_overlays_before (b, XOVERLAY (overlay)); |
| 3636 | } | 3655 | } |
| 3637 | 3656 | ||
| 3638 | /* This puts it in the right list, and in the right order. */ | 3657 | /* This puts it in the right list, and in the right order. */ |
| @@ -3690,6 +3709,18 @@ unchain_overlay (struct Lisp_Overlay *list, struct Lisp_Overlay *overlay) | |||
| 3690 | return list; | 3709 | return list; |
| 3691 | } | 3710 | } |
| 3692 | 3711 | ||
| 3712 | /* Remove OVERLAY from both overlay lists of B. */ | ||
| 3713 | |||
| 3714 | static void | ||
| 3715 | unchain_both (struct buffer *b, Lisp_Object overlay) | ||
| 3716 | { | ||
| 3717 | struct Lisp_Overlay *ov = XOVERLAY (overlay); | ||
| 3718 | |||
| 3719 | buffer_set_overlays_before (b, unchain_overlay (b->overlays_before, ov)); | ||
| 3720 | buffer_set_overlays_after (b, unchain_overlay (b->overlays_after, ov)); | ||
| 3721 | eassert (XOVERLAY (overlay)->next == NULL); | ||
| 3722 | } | ||
| 3723 | |||
| 3693 | DEFUN ("move-overlay", Fmove_overlay, Smove_overlay, 3, 4, 0, | 3724 | DEFUN ("move-overlay", Fmove_overlay, Smove_overlay, 3, 4, 0, |
| 3694 | doc: /* Set the endpoints of OVERLAY to BEG and END in BUFFER. | 3725 | doc: /* Set the endpoints of OVERLAY to BEG and END in BUFFER. |
| 3695 | If BUFFER is omitted, leave OVERLAY in the same buffer it inhabits now. | 3726 | If BUFFER is omitted, leave OVERLAY in the same buffer it inhabits now. |
| @@ -3740,11 +3771,7 @@ buffer. */) | |||
| 3740 | o_beg = OVERLAY_POSITION (OVERLAY_START (overlay)); | 3771 | o_beg = OVERLAY_POSITION (OVERLAY_START (overlay)); |
| 3741 | o_end = OVERLAY_POSITION (OVERLAY_END (overlay)); | 3772 | o_end = OVERLAY_POSITION (OVERLAY_END (overlay)); |
| 3742 | 3773 | ||
| 3743 | ob->overlays_before = | 3774 | unchain_both (ob, overlay); |
| 3744 | unchain_overlay (ob->overlays_before, XOVERLAY (overlay)); | ||
| 3745 | ob->overlays_after = | ||
| 3746 | unchain_overlay (ob->overlays_after, XOVERLAY (overlay)); | ||
| 3747 | eassert (XOVERLAY (overlay)->next == NULL); | ||
| 3748 | } | 3775 | } |
| 3749 | 3776 | ||
| 3750 | /* Set the overlay boundaries, which may clip them. */ | 3777 | /* Set the overlay boundaries, which may clip them. */ |
| @@ -3785,12 +3812,12 @@ buffer. */) | |||
| 3785 | if (n_end < b->overlay_center) | 3812 | if (n_end < b->overlay_center) |
| 3786 | { | 3813 | { |
| 3787 | XOVERLAY (overlay)->next = b->overlays_after; | 3814 | XOVERLAY (overlay)->next = b->overlays_after; |
| 3788 | b->overlays_after = XOVERLAY (overlay); | 3815 | buffer_set_overlays_after (b, XOVERLAY (overlay)); |
| 3789 | } | 3816 | } |
| 3790 | else | 3817 | else |
| 3791 | { | 3818 | { |
| 3792 | XOVERLAY (overlay)->next = b->overlays_before; | 3819 | XOVERLAY (overlay)->next = b->overlays_before; |
| 3793 | b->overlays_before = XOVERLAY (overlay); | 3820 | buffer_set_overlays_before (b, XOVERLAY (overlay)); |
| 3794 | } | 3821 | } |
| 3795 | 3822 | ||
| 3796 | /* This puts it in the right list, and in the right order. */ | 3823 | /* This puts it in the right list, and in the right order. */ |
| @@ -3816,12 +3843,7 @@ DEFUN ("delete-overlay", Fdelete_overlay, Sdelete_overlay, 1, 1, 0, | |||
| 3816 | b = XBUFFER (buffer); | 3843 | b = XBUFFER (buffer); |
| 3817 | specbind (Qinhibit_quit, Qt); | 3844 | specbind (Qinhibit_quit, Qt); |
| 3818 | 3845 | ||
| 3819 | b->overlays_before | 3846 | unchain_both (b, overlay); |
| 3820 | = unchain_overlay (b->overlays_before, XOVERLAY (overlay)); | ||
| 3821 | b->overlays_after | ||
| 3822 | = unchain_overlay (b->overlays_after, XOVERLAY (overlay)); | ||
| 3823 | eassert (XOVERLAY (overlay)->next == NULL); | ||
| 3824 | |||
| 3825 | drop_overlay (b, XOVERLAY (overlay)); | 3847 | drop_overlay (b, XOVERLAY (overlay)); |
| 3826 | 3848 | ||
| 3827 | /* When deleting an overlay with before or after strings, turn off | 3849 | /* When deleting an overlay with before or after strings, turn off |
| @@ -4018,6 +4040,7 @@ However, the overlays you get are the real objects that the buffer uses. */) | |||
| 4018 | { | 4040 | { |
| 4019 | struct Lisp_Overlay *ol; | 4041 | struct Lisp_Overlay *ol; |
| 4020 | Lisp_Object before = Qnil, after = Qnil, tmp; | 4042 | Lisp_Object before = Qnil, after = Qnil, tmp; |
| 4043 | |||
| 4021 | for (ol = current_buffer->overlays_before; ol; ol = ol->next) | 4044 | for (ol = current_buffer->overlays_before; ol; ol = ol->next) |
| 4022 | { | 4045 | { |
| 4023 | XSETMISC (tmp, ol); | 4046 | XSETMISC (tmp, ol); |
| @@ -4028,6 +4051,7 @@ However, the overlays you get are the real objects that the buffer uses. */) | |||
| 4028 | XSETMISC (tmp, ol); | 4051 | XSETMISC (tmp, ol); |
| 4029 | after = Fcons (tmp, after); | 4052 | after = Fcons (tmp, after); |
| 4030 | } | 4053 | } |
| 4054 | |||
| 4031 | return Fcons (Fnreverse (before), Fnreverse (after)); | 4055 | return Fcons (Fnreverse (before), Fnreverse (after)); |
| 4032 | } | 4056 | } |
| 4033 | 4057 | ||
| @@ -4076,8 +4100,8 @@ VALUE will be returned.*/) | |||
| 4076 | } | 4100 | } |
| 4077 | /* It wasn't in the list, so add it to the front. */ | 4101 | /* It wasn't in the list, so add it to the front. */ |
| 4078 | changed = !NILP (value); | 4102 | changed = !NILP (value); |
| 4079 | XOVERLAY (overlay)->plist | 4103 | set_overlay_plist |
| 4080 | = Fcons (prop, Fcons (value, XOVERLAY (overlay)->plist)); | 4104 | (overlay, Fcons (prop, Fcons (value, XOVERLAY (overlay)->plist))); |
| 4081 | found: | 4105 | found: |
| 4082 | if (! NILP (buffer)) | 4106 | if (! NILP (buffer)) |
| 4083 | { | 4107 | { |
| @@ -4252,7 +4276,7 @@ report_overlay_modification (Lisp_Object start, Lisp_Object end, int after, | |||
| 4252 | ptrdiff_t i; | 4276 | ptrdiff_t i; |
| 4253 | 4277 | ||
| 4254 | memcpy (copy, XVECTOR (last_overlay_modification_hooks)->contents, | 4278 | memcpy (copy, XVECTOR (last_overlay_modification_hooks)->contents, |
| 4255 | size * sizeof (Lisp_Object)); | 4279 | size * word_size); |
| 4256 | gcpro1.var = copy; | 4280 | gcpro1.var = copy; |
| 4257 | gcpro1.nvars = size; | 4281 | gcpro1.nvars = size; |
| 4258 | 4282 | ||
| @@ -4871,8 +4895,7 @@ init_buffer_once (void) | |||
| 4871 | sure that this is still correct. Otherwise, mark_vectorlike may not | 4895 | sure that this is still correct. Otherwise, mark_vectorlike may not |
| 4872 | trace all Lisp_Objects in buffer_defaults and buffer_local_symbols. */ | 4896 | trace all Lisp_Objects in buffer_defaults and buffer_local_symbols. */ |
| 4873 | const int pvecsize | 4897 | const int pvecsize |
| 4874 | = (offsetof (struct buffer, own_text) - sizeof (struct vectorlike_header)) | 4898 | = (offsetof (struct buffer, own_text) - header_size) / word_size; |
| 4875 | / sizeof (Lisp_Object); | ||
| 4876 | 4899 | ||
| 4877 | memset (buffer_permanent_local_flags, 0, sizeof buffer_permanent_local_flags); | 4900 | memset (buffer_permanent_local_flags, 0, sizeof buffer_permanent_local_flags); |
| 4878 | 4901 | ||
| @@ -4887,8 +4910,11 @@ init_buffer_once (void) | |||
| 4887 | /* Prevent GC from getting confused. */ | 4910 | /* Prevent GC from getting confused. */ |
| 4888 | buffer_defaults.text = &buffer_defaults.own_text; | 4911 | buffer_defaults.text = &buffer_defaults.own_text; |
| 4889 | buffer_local_symbols.text = &buffer_local_symbols.own_text; | 4912 | buffer_local_symbols.text = &buffer_local_symbols.own_text; |
| 4890 | BUF_INTERVALS (&buffer_defaults) = 0; | 4913 | /* No one will share the text with these buffers, but let's play it safe. */ |
| 4891 | BUF_INTERVALS (&buffer_local_symbols) = 0; | 4914 | buffer_defaults.indirections = 0; |
| 4915 | buffer_local_symbols.indirections = 0; | ||
| 4916 | buffer_set_intervals (&buffer_defaults, NULL); | ||
| 4917 | buffer_set_intervals (&buffer_local_symbols, NULL); | ||
| 4892 | XSETPVECTYPESIZE (&buffer_defaults, PVEC_BUFFER, pvecsize); | 4918 | XSETPVECTYPESIZE (&buffer_defaults, PVEC_BUFFER, pvecsize); |
| 4893 | XSETBUFFER (Vbuffer_defaults, &buffer_defaults); | 4919 | XSETBUFFER (Vbuffer_defaults, &buffer_defaults); |
| 4894 | XSETPVECTYPESIZE (&buffer_local_symbols, PVEC_BUFFER, pvecsize); | 4920 | XSETPVECTYPESIZE (&buffer_local_symbols, PVEC_BUFFER, pvecsize); |
| @@ -4898,55 +4924,55 @@ init_buffer_once (void) | |||
| 4898 | /* Must do these before making the first buffer! */ | 4924 | /* Must do these before making the first buffer! */ |
| 4899 | 4925 | ||
| 4900 | /* real setup is done in bindings.el */ | 4926 | /* real setup is done in bindings.el */ |
| 4901 | BVAR (&buffer_defaults, mode_line_format) = build_pure_c_string ("%-"); | 4927 | BSET (&buffer_defaults, mode_line_format, build_pure_c_string ("%-")); |
| 4902 | BVAR (&buffer_defaults, header_line_format) = Qnil; | 4928 | BSET (&buffer_defaults, header_line_format, Qnil); |
| 4903 | BVAR (&buffer_defaults, abbrev_mode) = Qnil; | 4929 | BSET (&buffer_defaults, abbrev_mode, Qnil); |
| 4904 | BVAR (&buffer_defaults, overwrite_mode) = Qnil; | 4930 | BSET (&buffer_defaults, overwrite_mode, Qnil); |
| 4905 | BVAR (&buffer_defaults, case_fold_search) = Qt; | 4931 | BSET (&buffer_defaults, case_fold_search, Qt); |
| 4906 | BVAR (&buffer_defaults, auto_fill_function) = Qnil; | 4932 | BSET (&buffer_defaults, auto_fill_function, Qnil); |
| 4907 | BVAR (&buffer_defaults, selective_display) = Qnil; | 4933 | BSET (&buffer_defaults, selective_display, Qnil); |
| 4908 | BVAR (&buffer_defaults, selective_display_ellipses) = Qt; | 4934 | BSET (&buffer_defaults, selective_display_ellipses, Qt); |
| 4909 | BVAR (&buffer_defaults, abbrev_table) = Qnil; | 4935 | BSET (&buffer_defaults, abbrev_table, Qnil); |
| 4910 | BVAR (&buffer_defaults, display_table) = Qnil; | 4936 | BSET (&buffer_defaults, display_table, Qnil); |
| 4911 | BVAR (&buffer_defaults, undo_list) = Qnil; | 4937 | BSET (&buffer_defaults, undo_list, Qnil); |
| 4912 | BVAR (&buffer_defaults, mark_active) = Qnil; | 4938 | BSET (&buffer_defaults, mark_active, Qnil); |
| 4913 | BVAR (&buffer_defaults, file_format) = Qnil; | 4939 | BSET (&buffer_defaults, file_format, Qnil); |
| 4914 | BVAR (&buffer_defaults, auto_save_file_format) = Qt; | 4940 | BSET (&buffer_defaults, auto_save_file_format, Qt); |
| 4915 | buffer_defaults.overlays_before = NULL; | 4941 | buffer_set_overlays_before (&buffer_defaults, NULL); |
| 4916 | buffer_defaults.overlays_after = NULL; | 4942 | buffer_set_overlays_after (&buffer_defaults, NULL); |
| 4917 | buffer_defaults.overlay_center = BEG; | 4943 | buffer_defaults.overlay_center = BEG; |
| 4918 | 4944 | ||
| 4919 | XSETFASTINT (BVAR (&buffer_defaults, tab_width), 8); | 4945 | XSETFASTINT (BVAR (&buffer_defaults, tab_width), 8); |
| 4920 | BVAR (&buffer_defaults, truncate_lines) = Qnil; | 4946 | BSET (&buffer_defaults, truncate_lines, Qnil); |
| 4921 | BVAR (&buffer_defaults, word_wrap) = Qnil; | 4947 | BSET (&buffer_defaults, word_wrap, Qnil); |
| 4922 | BVAR (&buffer_defaults, ctl_arrow) = Qt; | 4948 | BSET (&buffer_defaults, ctl_arrow, Qt); |
| 4923 | BVAR (&buffer_defaults, bidi_display_reordering) = Qt; | 4949 | BSET (&buffer_defaults, bidi_display_reordering, Qt); |
| 4924 | BVAR (&buffer_defaults, bidi_paragraph_direction) = Qnil; | 4950 | BSET (&buffer_defaults, bidi_paragraph_direction, Qnil); |
| 4925 | BVAR (&buffer_defaults, cursor_type) = Qt; | 4951 | BSET (&buffer_defaults, cursor_type, Qt); |
| 4926 | BVAR (&buffer_defaults, extra_line_spacing) = Qnil; | 4952 | BSET (&buffer_defaults, extra_line_spacing, Qnil); |
| 4927 | BVAR (&buffer_defaults, cursor_in_non_selected_windows) = Qt; | 4953 | BSET (&buffer_defaults, cursor_in_non_selected_windows, Qt); |
| 4928 | 4954 | ||
| 4929 | BVAR (&buffer_defaults, enable_multibyte_characters) = Qt; | 4955 | BSET (&buffer_defaults, enable_multibyte_characters, Qt); |
| 4930 | BVAR (&buffer_defaults, buffer_file_coding_system) = Qnil; | 4956 | BSET (&buffer_defaults, buffer_file_coding_system, Qnil); |
| 4931 | XSETFASTINT (BVAR (&buffer_defaults, fill_column), 70); | 4957 | XSETFASTINT (BVAR (&buffer_defaults, fill_column), 70); |
| 4932 | XSETFASTINT (BVAR (&buffer_defaults, left_margin), 0); | 4958 | XSETFASTINT (BVAR (&buffer_defaults, left_margin), 0); |
| 4933 | BVAR (&buffer_defaults, cache_long_line_scans) = Qnil; | 4959 | BSET (&buffer_defaults, cache_long_line_scans, Qnil); |
| 4934 | BVAR (&buffer_defaults, file_truename) = Qnil; | 4960 | BSET (&buffer_defaults, file_truename, Qnil); |
| 4935 | XSETFASTINT (BVAR (&buffer_defaults, display_count), 0); | 4961 | XSETFASTINT (BVAR (&buffer_defaults, display_count), 0); |
| 4936 | XSETFASTINT (BVAR (&buffer_defaults, left_margin_cols), 0); | 4962 | XSETFASTINT (BVAR (&buffer_defaults, left_margin_cols), 0); |
| 4937 | XSETFASTINT (BVAR (&buffer_defaults, right_margin_cols), 0); | 4963 | XSETFASTINT (BVAR (&buffer_defaults, right_margin_cols), 0); |
| 4938 | BVAR (&buffer_defaults, left_fringe_width) = Qnil; | 4964 | BSET (&buffer_defaults, left_fringe_width, Qnil); |
| 4939 | BVAR (&buffer_defaults, right_fringe_width) = Qnil; | 4965 | BSET (&buffer_defaults, right_fringe_width, Qnil); |
| 4940 | BVAR (&buffer_defaults, fringes_outside_margins) = Qnil; | 4966 | BSET (&buffer_defaults, fringes_outside_margins, Qnil); |
| 4941 | BVAR (&buffer_defaults, scroll_bar_width) = Qnil; | 4967 | BSET (&buffer_defaults, scroll_bar_width, Qnil); |
| 4942 | BVAR (&buffer_defaults, vertical_scroll_bar_type) = Qt; | 4968 | BSET (&buffer_defaults, vertical_scroll_bar_type, Qt); |
| 4943 | BVAR (&buffer_defaults, indicate_empty_lines) = Qnil; | 4969 | BSET (&buffer_defaults, indicate_empty_lines, Qnil); |
| 4944 | BVAR (&buffer_defaults, indicate_buffer_boundaries) = Qnil; | 4970 | BSET (&buffer_defaults, indicate_buffer_boundaries, Qnil); |
| 4945 | BVAR (&buffer_defaults, fringe_indicator_alist) = Qnil; | 4971 | BSET (&buffer_defaults, fringe_indicator_alist, Qnil); |
| 4946 | BVAR (&buffer_defaults, fringe_cursor_alist) = Qnil; | 4972 | BSET (&buffer_defaults, fringe_cursor_alist, Qnil); |
| 4947 | BVAR (&buffer_defaults, scroll_up_aggressively) = Qnil; | 4973 | BSET (&buffer_defaults, scroll_up_aggressively, Qnil); |
| 4948 | BVAR (&buffer_defaults, scroll_down_aggressively) = Qnil; | 4974 | BSET (&buffer_defaults, scroll_down_aggressively, Qnil); |
| 4949 | BVAR (&buffer_defaults, display_time) = Qnil; | 4975 | BSET (&buffer_defaults, display_time, Qnil); |
| 4950 | 4976 | ||
| 4951 | /* Assign the local-flags to the slots that have default values. | 4977 | /* Assign the local-flags to the slots that have default values. |
| 4952 | The local flag is a bit that is used in the buffer | 4978 | The local flag is a bit that is used in the buffer |
| @@ -4954,28 +4980,28 @@ init_buffer_once (void) | |||
| 4954 | The local flag bits are in the local_var_flags slot of the buffer. */ | 4980 | The local flag bits are in the local_var_flags slot of the buffer. */ |
| 4955 | 4981 | ||
| 4956 | /* Nothing can work if this isn't true */ | 4982 | /* Nothing can work if this isn't true */ |
| 4957 | { verify (sizeof (EMACS_INT) == sizeof (Lisp_Object)); } | 4983 | { verify (sizeof (EMACS_INT) == word_size); } |
| 4958 | 4984 | ||
| 4959 | /* 0 means not a lisp var, -1 means always local, else mask */ | 4985 | /* 0 means not a lisp var, -1 means always local, else mask */ |
| 4960 | memset (&buffer_local_flags, 0, sizeof buffer_local_flags); | 4986 | memset (&buffer_local_flags, 0, sizeof buffer_local_flags); |
| 4961 | XSETINT (BVAR (&buffer_local_flags, filename), -1); | 4987 | BSET (&buffer_local_flags, filename, make_number (-1)); |
| 4962 | XSETINT (BVAR (&buffer_local_flags, directory), -1); | 4988 | BSET (&buffer_local_flags, directory, make_number (-1)); |
| 4963 | XSETINT (BVAR (&buffer_local_flags, backed_up), -1); | 4989 | BSET (&buffer_local_flags, backed_up, make_number (-1)); |
| 4964 | XSETINT (BVAR (&buffer_local_flags, save_length), -1); | 4990 | BSET (&buffer_local_flags, save_length, make_number (-1)); |
| 4965 | XSETINT (BVAR (&buffer_local_flags, auto_save_file_name), -1); | 4991 | BSET (&buffer_local_flags, auto_save_file_name, make_number (-1)); |
| 4966 | XSETINT (BVAR (&buffer_local_flags, read_only), -1); | 4992 | BSET (&buffer_local_flags, read_only, make_number (-1)); |
| 4967 | XSETINT (BVAR (&buffer_local_flags, major_mode), -1); | 4993 | BSET (&buffer_local_flags, major_mode, make_number (-1)); |
| 4968 | XSETINT (BVAR (&buffer_local_flags, mode_name), -1); | 4994 | BSET (&buffer_local_flags, mode_name, make_number (-1)); |
| 4969 | XSETINT (BVAR (&buffer_local_flags, undo_list), -1); | 4995 | BSET (&buffer_local_flags, undo_list, make_number (-1)); |
| 4970 | XSETINT (BVAR (&buffer_local_flags, mark_active), -1); | 4996 | BSET (&buffer_local_flags, mark_active, make_number (-1)); |
| 4971 | XSETINT (BVAR (&buffer_local_flags, point_before_scroll), -1); | 4997 | BSET (&buffer_local_flags, point_before_scroll, make_number (-1)); |
| 4972 | XSETINT (BVAR (&buffer_local_flags, file_truename), -1); | 4998 | BSET (&buffer_local_flags, file_truename, make_number (-1)); |
| 4973 | XSETINT (BVAR (&buffer_local_flags, invisibility_spec), -1); | 4999 | BSET (&buffer_local_flags, invisibility_spec, make_number (-1)); |
| 4974 | XSETINT (BVAR (&buffer_local_flags, file_format), -1); | 5000 | BSET (&buffer_local_flags, file_format, make_number (-1)); |
| 4975 | XSETINT (BVAR (&buffer_local_flags, auto_save_file_format), -1); | 5001 | BSET (&buffer_local_flags, auto_save_file_format, make_number (-1)); |
| 4976 | XSETINT (BVAR (&buffer_local_flags, display_count), -1); | 5002 | BSET (&buffer_local_flags, display_count, make_number (-1)); |
| 4977 | XSETINT (BVAR (&buffer_local_flags, display_time), -1); | 5003 | BSET (&buffer_local_flags, display_time, make_number (-1)); |
| 4978 | XSETINT (BVAR (&buffer_local_flags, enable_multibyte_characters), -1); | 5004 | BSET (&buffer_local_flags, enable_multibyte_characters, make_number (-1)); |
| 4979 | 5005 | ||
| 4980 | idx = 1; | 5006 | idx = 1; |
| 4981 | XSETFASTINT (BVAR (&buffer_local_flags, mode_line_format), idx); ++idx; | 5007 | XSETFASTINT (BVAR (&buffer_local_flags, mode_line_format), idx); ++idx; |
| @@ -5031,7 +5057,7 @@ init_buffer_once (void) | |||
| 5031 | QSFundamental = build_pure_c_string ("Fundamental"); | 5057 | QSFundamental = build_pure_c_string ("Fundamental"); |
| 5032 | 5058 | ||
| 5033 | Qfundamental_mode = intern_c_string ("fundamental-mode"); | 5059 | Qfundamental_mode = intern_c_string ("fundamental-mode"); |
| 5034 | BVAR (&buffer_defaults, major_mode) = Qfundamental_mode; | 5060 | BSET (&buffer_defaults, major_mode, Qfundamental_mode); |
| 5035 | 5061 | ||
| 5036 | Qmode_class = intern_c_string ("mode-class"); | 5062 | Qmode_class = intern_c_string ("mode-class"); |
| 5037 | 5063 | ||
| @@ -5065,7 +5091,7 @@ init_buffer (void) | |||
| 5065 | Map new memory. */ | 5091 | Map new memory. */ |
| 5066 | struct buffer *b; | 5092 | struct buffer *b; |
| 5067 | 5093 | ||
| 5068 | for (b = all_buffers; b; b = b->header.next.buffer) | 5094 | FOR_EACH_BUFFER (b) |
| 5069 | if (b->text->beg == NULL) | 5095 | if (b->text->beg == NULL) |
| 5070 | enlarge_buffer_text (b, 0); | 5096 | enlarge_buffer_text (b, 0); |
| 5071 | } | 5097 | } |
| @@ -5094,13 +5120,13 @@ init_buffer (void) | |||
| 5094 | len++; | 5120 | len++; |
| 5095 | } | 5121 | } |
| 5096 | 5122 | ||
| 5097 | BVAR (current_buffer, directory) = make_unibyte_string (pwd, len); | 5123 | BSET (current_buffer, directory, make_unibyte_string (pwd, len)); |
| 5098 | if (! NILP (BVAR (&buffer_defaults, enable_multibyte_characters))) | 5124 | if (! NILP (BVAR (&buffer_defaults, enable_multibyte_characters))) |
| 5099 | /* At this moment, we still don't know how to decode the | 5125 | /* At this moment, we still don't know how to decode the |
| 5100 | directory name. So, we keep the bytes in multibyte form so | 5126 | directory name. So, we keep the bytes in multibyte form so |
| 5101 | that ENCODE_FILE correctly gets the original bytes. */ | 5127 | that ENCODE_FILE correctly gets the original bytes. */ |
| 5102 | BVAR (current_buffer, directory) | 5128 | BSET (current_buffer, directory, |
| 5103 | = string_to_multibyte (BVAR (current_buffer, directory)); | 5129 | string_to_multibyte (BVAR (current_buffer, directory))); |
| 5104 | 5130 | ||
| 5105 | /* Add /: to the front of the name | 5131 | /* Add /: to the front of the name |
| 5106 | if it would otherwise be treated as magic. */ | 5132 | if it would otherwise be treated as magic. */ |
| @@ -5111,11 +5137,11 @@ init_buffer (void) | |||
| 5111 | However, it is not necessary to turn / into /:/. | 5137 | However, it is not necessary to turn / into /:/. |
| 5112 | So avoid doing that. */ | 5138 | So avoid doing that. */ |
| 5113 | && strcmp ("/", SSDATA (BVAR (current_buffer, directory)))) | 5139 | && strcmp ("/", SSDATA (BVAR (current_buffer, directory)))) |
| 5114 | BVAR (current_buffer, directory) | 5140 | BSET (current_buffer, directory, |
| 5115 | = concat2 (build_string ("/:"), BVAR (current_buffer, directory)); | 5141 | concat2 (build_string ("/:"), BVAR (current_buffer, directory))); |
| 5116 | 5142 | ||
| 5117 | temp = get_minibuffer (0); | 5143 | temp = get_minibuffer (0); |
| 5118 | BVAR (XBUFFER (temp), directory) = BVAR (current_buffer, directory); | 5144 | BSET (XBUFFER (temp), directory, BVAR (current_buffer, directory)); |
| 5119 | 5145 | ||
| 5120 | free (pwd); | 5146 | free (pwd); |
| 5121 | } | 5147 | } |
| @@ -5199,7 +5225,7 @@ syms_of_buffer (void) | |||
| 5199 | DEFSYM (Qkill_buffer_query_functions, "kill-buffer-query-functions"); | 5225 | DEFSYM (Qkill_buffer_query_functions, "kill-buffer-query-functions"); |
| 5200 | 5226 | ||
| 5201 | Fput (Qprotected_field, Qerror_conditions, | 5227 | Fput (Qprotected_field, Qerror_conditions, |
| 5202 | pure_cons (Qprotected_field, pure_cons (Qerror, Qnil))); | 5228 | listn (CONSTYPE_PURE, 2, Qprotected_field, Qerror)); |
| 5203 | Fput (Qprotected_field, Qerror_message, | 5229 | Fput (Qprotected_field, Qerror_message, |
| 5204 | build_pure_c_string ("Attempt to modify a protected field")); | 5230 | build_pure_c_string ("Attempt to modify a protected field")); |
| 5205 | 5231 | ||
| @@ -5444,17 +5470,17 @@ Use the command `abbrev-mode' to change this variable. */); | |||
| 5444 | doc: /* Non-nil if searches and matches should ignore case. */); | 5470 | doc: /* Non-nil if searches and matches should ignore case. */); |
| 5445 | 5471 | ||
| 5446 | DEFVAR_PER_BUFFER ("fill-column", &BVAR (current_buffer, fill_column), | 5472 | DEFVAR_PER_BUFFER ("fill-column", &BVAR (current_buffer, fill_column), |
| 5447 | make_number (LISP_INT_TAG), | 5473 | make_number (Lisp_Int0), |
| 5448 | doc: /* Column beyond which automatic line-wrapping should happen. | 5474 | doc: /* Column beyond which automatic line-wrapping should happen. |
| 5449 | Interactively, you can set the buffer local value using \\[set-fill-column]. */); | 5475 | Interactively, you can set the buffer local value using \\[set-fill-column]. */); |
| 5450 | 5476 | ||
| 5451 | DEFVAR_PER_BUFFER ("left-margin", &BVAR (current_buffer, left_margin), | 5477 | DEFVAR_PER_BUFFER ("left-margin", &BVAR (current_buffer, left_margin), |
| 5452 | make_number (LISP_INT_TAG), | 5478 | make_number (Lisp_Int0), |
| 5453 | doc: /* Column for the default `indent-line-function' to indent to. | 5479 | doc: /* Column for the default `indent-line-function' to indent to. |
| 5454 | Linefeed indents to this column in Fundamental mode. */); | 5480 | Linefeed indents to this column in Fundamental mode. */); |
| 5455 | 5481 | ||
| 5456 | DEFVAR_PER_BUFFER ("tab-width", &BVAR (current_buffer, tab_width), | 5482 | DEFVAR_PER_BUFFER ("tab-width", &BVAR (current_buffer, tab_width), |
| 5457 | make_number (LISP_INT_TAG), | 5483 | make_number (Lisp_Int0), |
| 5458 | doc: /* Distance between tab stops (for display of tab characters), in columns. | 5484 | doc: /* Distance between tab stops (for display of tab characters), in columns. |
| 5459 | This should be an integer greater than zero. */); | 5485 | This should be an integer greater than zero. */); |
| 5460 | 5486 | ||
| @@ -5575,7 +5601,7 @@ If it is nil, that means don't auto-save this buffer. */); | |||
| 5575 | Backing up is done before the first time the file is saved. */); | 5601 | Backing up is done before the first time the file is saved. */); |
| 5576 | 5602 | ||
| 5577 | DEFVAR_PER_BUFFER ("buffer-saved-size", &BVAR (current_buffer, save_length), | 5603 | DEFVAR_PER_BUFFER ("buffer-saved-size", &BVAR (current_buffer, save_length), |
| 5578 | make_number (LISP_INT_TAG), | 5604 | make_number (Lisp_Int0), |
| 5579 | doc: /* Length of current buffer when last read in, saved or auto-saved. | 5605 | doc: /* Length of current buffer when last read in, saved or auto-saved. |
| 5580 | 0 initially. | 5606 | 0 initially. |
| 5581 | -1 means auto-saving turned off until next real save. | 5607 | -1 means auto-saving turned off until next real save. |
| @@ -6024,7 +6050,6 @@ and `bury-buffer-internal'. */); | |||
| 6024 | defsubr (&Smake_indirect_buffer); | 6050 | defsubr (&Smake_indirect_buffer); |
| 6025 | defsubr (&Sgenerate_new_buffer_name); | 6051 | defsubr (&Sgenerate_new_buffer_name); |
| 6026 | defsubr (&Sbuffer_name); | 6052 | defsubr (&Sbuffer_name); |
| 6027 | /*defsubr (&Sbuffer_number);*/ | ||
| 6028 | defsubr (&Sbuffer_file_name); | 6053 | defsubr (&Sbuffer_file_name); |
| 6029 | defsubr (&Sbuffer_base_buffer); | 6054 | defsubr (&Sbuffer_base_buffer); |
| 6030 | defsubr (&Sbuffer_local_value); | 6055 | defsubr (&Sbuffer_local_value); |