diff options
| author | YAMAMOTO Mitsuharu | 2019-04-27 18:33:39 +0900 |
|---|---|---|
| committer | YAMAMOTO Mitsuharu | 2019-04-27 18:33:39 +0900 |
| commit | 886bedb36c7b959b7e6fc8ce8e0c04e144b0ae28 (patch) | |
| tree | b5770d9fc10a704ad8aeb3474c6940121252c770 /src/buffer.c | |
| parent | 015a6e1df2772bd43680df5cbeaffccf98a881da (diff) | |
| parent | 8dc00b2f1e6523c634df3e24379afbe712a32b27 (diff) | |
| download | emacs-886bedb36c7b959b7e6fc8ce8e0c04e144b0ae28.tar.gz emacs-886bedb36c7b959b7e6fc8ce8e0c04e144b0ae28.zip | |
Merge branch 'master' into harfbuzz
Diffstat (limited to 'src/buffer.c')
| -rw-r--r-- | src/buffer.c | 145 |
1 files changed, 98 insertions, 47 deletions
diff --git a/src/buffer.c b/src/buffer.c index a71bd77de9f..ab477481912 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* Buffer manipulation primitives for GNU Emacs. | 1 | /* Buffer manipulation primitives for GNU Emacs. |
| 2 | 2 | ||
| 3 | Copyright (C) 1985-1989, 1993-1995, 1997-2018 Free Software Foundation, | 3 | Copyright (C) 1985-1989, 1993-1995, 1997-2019 Free Software Foundation, |
| 4 | Inc. | 4 | Inc. |
| 5 | 5 | ||
| 6 | This file is part of GNU Emacs. | 6 | This file is part of GNU Emacs. |
| @@ -37,6 +37,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 37 | #include "window.h" | 37 | #include "window.h" |
| 38 | #include "commands.h" | 38 | #include "commands.h" |
| 39 | #include "character.h" | 39 | #include "character.h" |
| 40 | #include "coding.h" | ||
| 40 | #include "buffer.h" | 41 | #include "buffer.h" |
| 41 | #include "region-cache.h" | 42 | #include "region-cache.h" |
| 42 | #include "indent.h" | 43 | #include "indent.h" |
| @@ -44,6 +45,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 44 | #include "keymap.h" | 45 | #include "keymap.h" |
| 45 | #include "frame.h" | 46 | #include "frame.h" |
| 46 | #include "xwidget.h" | 47 | #include "xwidget.h" |
| 48 | #include "pdumper.h" | ||
| 47 | 49 | ||
| 48 | #ifdef WINDOWSNT | 50 | #ifdef WINDOWSNT |
| 49 | #include "w32heap.h" /* for mmap_* */ | 51 | #include "w32heap.h" /* for mmap_* */ |
| @@ -466,7 +468,7 @@ See also `find-buffer-visiting'. */) | |||
| 466 | filename = Fexpand_file_name (filename, Qnil); | 468 | filename = Fexpand_file_name (filename, Qnil); |
| 467 | 469 | ||
| 468 | /* If the file name has special constructs in it, | 470 | /* If the file name has special constructs in it, |
| 469 | call the corresponding file handler. */ | 471 | call the corresponding file name handler. */ |
| 470 | handler = Ffind_file_name_handler (filename, Qget_file_buffer); | 472 | handler = Ffind_file_name_handler (filename, Qget_file_buffer); |
| 471 | if (!NILP (handler)) | 473 | if (!NILP (handler)) |
| 472 | { | 474 | { |
| @@ -529,6 +531,8 @@ even if it is dead. The return value is never nil. */) | |||
| 529 | /* No one shows us now. */ | 531 | /* No one shows us now. */ |
| 530 | b->window_count = 0; | 532 | b->window_count = 0; |
| 531 | 533 | ||
| 534 | memset (&b->local_flags, 0, sizeof (b->local_flags)); | ||
| 535 | |||
| 532 | BUF_GAP_SIZE (b) = 20; | 536 | BUF_GAP_SIZE (b) = 20; |
| 533 | block_input (); | 537 | block_input (); |
| 534 | /* We allocate extra 1-byte at the tail and keep it always '\0' for | 538 | /* We allocate extra 1-byte at the tail and keep it always '\0' for |
| @@ -580,6 +584,11 @@ even if it is dead. The return value is never nil. */) | |||
| 580 | set_string_intervals (name, NULL); | 584 | set_string_intervals (name, NULL); |
| 581 | bset_name (b, name); | 585 | bset_name (b, name); |
| 582 | 586 | ||
| 587 | b->inhibit_buffer_hooks | ||
| 588 | = (STRINGP (Vcode_conversion_workbuf_name) | ||
| 589 | && strncmp (SSDATA (name), SSDATA (Vcode_conversion_workbuf_name), | ||
| 590 | SBYTES (Vcode_conversion_workbuf_name)) == 0); | ||
| 591 | |||
| 583 | bset_undo_list (b, SREF (name, 0) != ' ' ? Qnil : Qt); | 592 | bset_undo_list (b, SREF (name, 0) != ' ' ? Qnil : Qt); |
| 584 | 593 | ||
| 585 | reset_buffer (b); | 594 | reset_buffer (b); |
| @@ -592,7 +601,7 @@ even if it is dead. The return value is never nil. */) | |||
| 592 | XSETBUFFER (buffer, b); | 601 | XSETBUFFER (buffer, b); |
| 593 | Vbuffer_alist = nconc2 (Vbuffer_alist, list1 (Fcons (name, buffer))); | 602 | Vbuffer_alist = nconc2 (Vbuffer_alist, list1 (Fcons (name, buffer))); |
| 594 | /* And run buffer-list-update-hook. */ | 603 | /* And run buffer-list-update-hook. */ |
| 595 | if (!NILP (Vrun_hooks)) | 604 | if (!NILP (Vrun_hooks) && !b->inhibit_buffer_hooks) |
| 596 | call1 (Vrun_hooks, Qbuffer_list_update_hook); | 605 | call1 (Vrun_hooks, Qbuffer_list_update_hook); |
| 597 | 606 | ||
| 598 | return buffer; | 607 | return buffer; |
| @@ -781,6 +790,8 @@ CLONE nil means the indirect buffer's state is reset to default values. */) | |||
| 781 | /* Always -1 for an indirect buffer. */ | 790 | /* Always -1 for an indirect buffer. */ |
| 782 | b->window_count = -1; | 791 | b->window_count = -1; |
| 783 | 792 | ||
| 793 | memset (&b->local_flags, 0, sizeof (b->local_flags)); | ||
| 794 | |||
| 784 | b->pt = b->base_buffer->pt; | 795 | b->pt = b->base_buffer->pt; |
| 785 | b->begv = b->base_buffer->begv; | 796 | b->begv = b->base_buffer->begv; |
| 786 | b->zv = b->base_buffer->zv; | 797 | b->zv = b->base_buffer->zv; |
| @@ -1196,7 +1207,7 @@ buffer_local_value (Lisp_Object variable, Lisp_Object buffer) | |||
| 1196 | result = Fassoc (variable, BVAR (buf, local_var_alist), Qnil); | 1207 | result = Fassoc (variable, BVAR (buf, local_var_alist), Qnil); |
| 1197 | if (!NILP (result)) | 1208 | if (!NILP (result)) |
| 1198 | { | 1209 | { |
| 1199 | if (blv->fwd) | 1210 | if (blv->fwd.fwdptr) |
| 1200 | { /* What binding is loaded right now? */ | 1211 | { /* What binding is loaded right now? */ |
| 1201 | Lisp_Object current_alist_element = blv->valcell; | 1212 | Lisp_Object current_alist_element = blv->valcell; |
| 1202 | 1213 | ||
| @@ -1217,7 +1228,7 @@ buffer_local_value (Lisp_Object variable, Lisp_Object buffer) | |||
| 1217 | } | 1228 | } |
| 1218 | case SYMBOL_FORWARDED: | 1229 | case SYMBOL_FORWARDED: |
| 1219 | { | 1230 | { |
| 1220 | union Lisp_Fwd *fwd = SYMBOL_FWD (sym); | 1231 | lispfwd fwd = SYMBOL_FWD (sym); |
| 1221 | if (BUFFER_OBJFWDP (fwd)) | 1232 | if (BUFFER_OBJFWDP (fwd)) |
| 1222 | result = per_buffer_value (buf, XBUFFER_OBJFWD (fwd)->offset); | 1233 | result = per_buffer_value (buf, XBUFFER_OBJFWD (fwd)->offset); |
| 1223 | else | 1234 | else |
| @@ -1408,7 +1419,7 @@ state of the current buffer. Use with care. */) | |||
| 1408 | /* If SAVE_MODIFF == auto_save_modified == MODIFF, | 1419 | /* If SAVE_MODIFF == auto_save_modified == MODIFF, |
| 1409 | we can either decrease SAVE_MODIFF and auto_save_modified | 1420 | we can either decrease SAVE_MODIFF and auto_save_modified |
| 1410 | or increase MODIFF. */ | 1421 | or increase MODIFF. */ |
| 1411 | : MODIFF++); | 1422 | : modiff_incr (&MODIFF)); |
| 1412 | 1423 | ||
| 1413 | return flag; | 1424 | return flag; |
| 1414 | } | 1425 | } |
| @@ -1417,11 +1428,11 @@ DEFUN ("buffer-modified-tick", Fbuffer_modified_tick, Sbuffer_modified_tick, | |||
| 1417 | 0, 1, 0, | 1428 | 0, 1, 0, |
| 1418 | doc: /* Return BUFFER's tick counter, incremented for each change in text. | 1429 | doc: /* Return BUFFER's tick counter, incremented for each change in text. |
| 1419 | Each buffer has a tick counter which is incremented each time the | 1430 | Each buffer has a tick counter which is incremented each time the |
| 1420 | text in that buffer is changed. It wraps around occasionally. | 1431 | text in that buffer is changed. No argument or nil as argument means |
| 1421 | No argument or nil as argument means use current buffer as BUFFER. */) | 1432 | use current buffer as BUFFER. */) |
| 1422 | (register Lisp_Object buffer) | 1433 | (Lisp_Object buffer) |
| 1423 | { | 1434 | { |
| 1424 | return make_fixnum (BUF_MODIFF (decode_buffer (buffer))); | 1435 | return modiff_to_integer (BUF_MODIFF (decode_buffer (buffer))); |
| 1425 | } | 1436 | } |
| 1426 | 1437 | ||
| 1427 | DEFUN ("buffer-chars-modified-tick", Fbuffer_chars_modified_tick, | 1438 | DEFUN ("buffer-chars-modified-tick", Fbuffer_chars_modified_tick, |
| @@ -1434,9 +1445,9 @@ values returned by two individual calls of `buffer-chars-modified-tick', | |||
| 1434 | you can tell whether a character change occurred in that buffer in | 1445 | you can tell whether a character change occurred in that buffer in |
| 1435 | between these calls. No argument or nil as argument means use current | 1446 | between these calls. No argument or nil as argument means use current |
| 1436 | buffer as BUFFER. */) | 1447 | buffer as BUFFER. */) |
| 1437 | (register Lisp_Object buffer) | 1448 | (Lisp_Object buffer) |
| 1438 | { | 1449 | { |
| 1439 | return make_fixnum (BUF_CHARS_MODIFF (decode_buffer (buffer))); | 1450 | return modiff_to_integer (BUF_CHARS_MODIFF (decode_buffer (buffer))); |
| 1440 | } | 1451 | } |
| 1441 | 1452 | ||
| 1442 | DEFUN ("rename-buffer", Frename_buffer, Srename_buffer, 1, 2, | 1453 | DEFUN ("rename-buffer", Frename_buffer, Srename_buffer, 1, 2, |
| @@ -1488,7 +1499,7 @@ This does not change the name of the visited file (if any). */) | |||
| 1488 | call0 (intern ("rename-auto-save-file")); | 1499 | call0 (intern ("rename-auto-save-file")); |
| 1489 | 1500 | ||
| 1490 | /* Run buffer-list-update-hook. */ | 1501 | /* Run buffer-list-update-hook. */ |
| 1491 | if (!NILP (Vrun_hooks)) | 1502 | if (!NILP (Vrun_hooks) && !current_buffer->inhibit_buffer_hooks) |
| 1492 | call1 (Vrun_hooks, Qbuffer_list_update_hook); | 1503 | call1 (Vrun_hooks, Qbuffer_list_update_hook); |
| 1493 | 1504 | ||
| 1494 | /* Refetch since that last call may have done GC. */ | 1505 | /* Refetch since that last call may have done GC. */ |
| @@ -1701,10 +1712,13 @@ cleaning up all windows currently displaying the buffer to be killed. */) | |||
| 1701 | 1712 | ||
| 1702 | /* First run the query functions; if any query is answered no, | 1713 | /* First run the query functions; if any query is answered no, |
| 1703 | don't kill the buffer. */ | 1714 | don't kill the buffer. */ |
| 1704 | tem = CALLN (Frun_hook_with_args_until_failure, | 1715 | if (!b->inhibit_buffer_hooks) |
| 1705 | Qkill_buffer_query_functions); | 1716 | { |
| 1706 | if (NILP (tem)) | 1717 | tem = CALLN (Frun_hook_with_args_until_failure, |
| 1707 | return unbind_to (count, Qnil); | 1718 | Qkill_buffer_query_functions); |
| 1719 | if (NILP (tem)) | ||
| 1720 | return unbind_to (count, Qnil); | ||
| 1721 | } | ||
| 1708 | 1722 | ||
| 1709 | /* Query if the buffer is still modified. */ | 1723 | /* Query if the buffer is still modified. */ |
| 1710 | if (INTERACTIVE && !NILP (BVAR (b, filename)) | 1724 | if (INTERACTIVE && !NILP (BVAR (b, filename)) |
| @@ -1721,7 +1735,8 @@ cleaning up all windows currently displaying the buffer to be killed. */) | |||
| 1721 | return unbind_to (count, Qt); | 1735 | return unbind_to (count, Qt); |
| 1722 | 1736 | ||
| 1723 | /* Then run the hooks. */ | 1737 | /* Then run the hooks. */ |
| 1724 | run_hook (Qkill_buffer_hook); | 1738 | if (!b->inhibit_buffer_hooks) |
| 1739 | run_hook (Qkill_buffer_hook); | ||
| 1725 | unbind_to (count, Qnil); | 1740 | unbind_to (count, Qnil); |
| 1726 | } | 1741 | } |
| 1727 | 1742 | ||
| @@ -1923,7 +1938,7 @@ cleaning up all windows currently displaying the buffer to be killed. */) | |||
| 1923 | bset_undo_list (b, Qnil); | 1938 | bset_undo_list (b, Qnil); |
| 1924 | 1939 | ||
| 1925 | /* Run buffer-list-update-hook. */ | 1940 | /* Run buffer-list-update-hook. */ |
| 1926 | if (!NILP (Vrun_hooks)) | 1941 | if (!NILP (Vrun_hooks) && !b->inhibit_buffer_hooks) |
| 1927 | call1 (Vrun_hooks, Qbuffer_list_update_hook); | 1942 | call1 (Vrun_hooks, Qbuffer_list_update_hook); |
| 1928 | 1943 | ||
| 1929 | return Qt; | 1944 | return Qt; |
| @@ -1965,7 +1980,7 @@ record_buffer (Lisp_Object buffer) | |||
| 1965 | fset_buried_buffer_list (f, Fdelq (buffer, f->buried_buffer_list)); | 1980 | fset_buried_buffer_list (f, Fdelq (buffer, f->buried_buffer_list)); |
| 1966 | 1981 | ||
| 1967 | /* Run buffer-list-update-hook. */ | 1982 | /* Run buffer-list-update-hook. */ |
| 1968 | if (!NILP (Vrun_hooks)) | 1983 | if (!NILP (Vrun_hooks) && !XBUFFER (buffer)->inhibit_buffer_hooks) |
| 1969 | call1 (Vrun_hooks, Qbuffer_list_update_hook); | 1984 | call1 (Vrun_hooks, Qbuffer_list_update_hook); |
| 1970 | } | 1985 | } |
| 1971 | 1986 | ||
| @@ -2004,7 +2019,7 @@ DEFUN ("bury-buffer-internal", Fbury_buffer_internal, Sbury_buffer_internal, | |||
| 2004 | (f, Fcons (buffer, Fdelq (buffer, f->buried_buffer_list))); | 2019 | (f, Fcons (buffer, Fdelq (buffer, f->buried_buffer_list))); |
| 2005 | 2020 | ||
| 2006 | /* Run buffer-list-update-hook. */ | 2021 | /* Run buffer-list-update-hook. */ |
| 2007 | if (!NILP (Vrun_hooks)) | 2022 | if (!NILP (Vrun_hooks) && !XBUFFER (buffer)->inhibit_buffer_hooks) |
| 2008 | call1 (Vrun_hooks, Qbuffer_list_update_hook); | 2023 | call1 (Vrun_hooks, Qbuffer_list_update_hook); |
| 2009 | 2024 | ||
| 2010 | return Qnil; | 2025 | return Qnil; |
| @@ -2125,7 +2140,7 @@ void set_buffer_internal_2 (register struct buffer *b) | |||
| 2125 | Lisp_Object var = XCAR (XCAR (tail)); | 2140 | Lisp_Object var = XCAR (XCAR (tail)); |
| 2126 | struct Lisp_Symbol *sym = XSYMBOL (var); | 2141 | struct Lisp_Symbol *sym = XSYMBOL (var); |
| 2127 | if (sym->u.s.redirect == SYMBOL_LOCALIZED /* Just to be sure. */ | 2142 | if (sym->u.s.redirect == SYMBOL_LOCALIZED /* Just to be sure. */ |
| 2128 | && SYMBOL_BLV (sym)->fwd) | 2143 | && SYMBOL_BLV (sym)->fwd.fwdptr) |
| 2129 | /* Just reference the variable | 2144 | /* Just reference the variable |
| 2130 | to cause it to become set for this buffer. */ | 2145 | to cause it to become set for this buffer. */ |
| 2131 | Fsymbol_value (var); | 2146 | Fsymbol_value (var); |
| @@ -2370,9 +2385,12 @@ results, see Info node `(elisp)Swapping Text'. */) | |||
| 2370 | bset_point_before_scroll (current_buffer, Qnil); | 2385 | bset_point_before_scroll (current_buffer, Qnil); |
| 2371 | bset_point_before_scroll (other_buffer, Qnil); | 2386 | bset_point_before_scroll (other_buffer, Qnil); |
| 2372 | 2387 | ||
| 2373 | current_buffer->text->modiff++; other_buffer->text->modiff++; | 2388 | modiff_incr (¤t_buffer->text->modiff); |
| 2374 | current_buffer->text->chars_modiff++; other_buffer->text->chars_modiff++; | 2389 | modiff_incr (&other_buffer->text->modiff); |
| 2375 | current_buffer->text->overlay_modiff++; other_buffer->text->overlay_modiff++; | 2390 | modiff_incr (¤t_buffer->text->chars_modiff); |
| 2391 | modiff_incr (&other_buffer->text->chars_modiff); | ||
| 2392 | modiff_incr (¤t_buffer->text->overlay_modiff); | ||
| 2393 | modiff_incr (&other_buffer->text->overlay_modiff); | ||
| 2376 | current_buffer->text->beg_unchanged = current_buffer->text->gpt; | 2394 | current_buffer->text->beg_unchanged = current_buffer->text->gpt; |
| 2377 | current_buffer->text->end_unchanged = current_buffer->text->gpt; | 2395 | current_buffer->text->end_unchanged = current_buffer->text->gpt; |
| 2378 | other_buffer->text->beg_unchanged = other_buffer->text->gpt; | 2396 | other_buffer->text->beg_unchanged = other_buffer->text->gpt; |
| @@ -3908,7 +3926,7 @@ modify_overlay (struct buffer *buf, ptrdiff_t start, ptrdiff_t end) | |||
| 3908 | 3926 | ||
| 3909 | bset_redisplay (buf); | 3927 | bset_redisplay (buf); |
| 3910 | 3928 | ||
| 3911 | ++BUF_OVERLAY_MODIFF (buf); | 3929 | modiff_incr (&BUF_OVERLAY_MODIFF (buf)); |
| 3912 | } | 3930 | } |
| 3913 | 3931 | ||
| 3914 | /* Remove OVERLAY from LIST. */ | 3932 | /* Remove OVERLAY from LIST. */ |
| @@ -5001,24 +5019,37 @@ alloc_buffer_text (struct buffer *b, ptrdiff_t nbytes) | |||
| 5001 | void | 5019 | void |
| 5002 | enlarge_buffer_text (struct buffer *b, ptrdiff_t delta) | 5020 | enlarge_buffer_text (struct buffer *b, ptrdiff_t delta) |
| 5003 | { | 5021 | { |
| 5004 | void *p; | ||
| 5005 | ptrdiff_t nbytes = (BUF_Z_BYTE (b) - BUF_BEG_BYTE (b) + BUF_GAP_SIZE (b) + 1 | ||
| 5006 | + delta); | ||
| 5007 | block_input (); | 5022 | block_input (); |
| 5023 | void *p; | ||
| 5024 | unsigned char *old_beg = b->text->beg; | ||
| 5025 | ptrdiff_t old_nbytes = | ||
| 5026 | BUF_Z_BYTE (b) - BUF_BEG_BYTE (b) + BUF_GAP_SIZE (b) + 1; | ||
| 5027 | ptrdiff_t new_nbytes = old_nbytes + delta; | ||
| 5028 | |||
| 5029 | if (pdumper_object_p (old_beg)) | ||
| 5030 | b->text->beg = NULL; | ||
| 5031 | else | ||
| 5032 | old_beg = NULL; | ||
| 5033 | |||
| 5008 | #if defined USE_MMAP_FOR_BUFFERS | 5034 | #if defined USE_MMAP_FOR_BUFFERS |
| 5009 | p = mmap_realloc ((void **) &b->text->beg, nbytes); | 5035 | p = mmap_realloc ((void **) &b->text->beg, new_nbytes); |
| 5010 | #elif defined REL_ALLOC | 5036 | #elif defined REL_ALLOC |
| 5011 | p = r_re_alloc ((void **) &b->text->beg, nbytes); | 5037 | p = r_re_alloc ((void **) &b->text->beg, new_nbytes); |
| 5012 | #else | 5038 | #else |
| 5013 | p = xrealloc (b->text->beg, nbytes); | 5039 | p = xrealloc (b->text->beg, new_nbytes); |
| 5014 | #endif | 5040 | #endif |
| 5015 | 5041 | ||
| 5016 | if (p == NULL) | 5042 | if (p == NULL) |
| 5017 | { | 5043 | { |
| 5044 | if (old_beg) | ||
| 5045 | b->text->beg = old_beg; | ||
| 5018 | unblock_input (); | 5046 | unblock_input (); |
| 5019 | memory_full (nbytes); | 5047 | memory_full (new_nbytes); |
| 5020 | } | 5048 | } |
| 5021 | 5049 | ||
| 5050 | if (old_beg) | ||
| 5051 | memcpy (p, old_beg, min (old_nbytes, new_nbytes)); | ||
| 5052 | |||
| 5022 | BUF_BEG_ADDR (b) = p; | 5053 | BUF_BEG_ADDR (b) = p; |
| 5023 | unblock_input (); | 5054 | unblock_input (); |
| 5024 | } | 5055 | } |
| @@ -5031,13 +5062,16 @@ free_buffer_text (struct buffer *b) | |||
| 5031 | { | 5062 | { |
| 5032 | block_input (); | 5063 | block_input (); |
| 5033 | 5064 | ||
| 5065 | if (!pdumper_object_p (b->text->beg)) | ||
| 5066 | { | ||
| 5034 | #if defined USE_MMAP_FOR_BUFFERS | 5067 | #if defined USE_MMAP_FOR_BUFFERS |
| 5035 | mmap_free ((void **) &b->text->beg); | 5068 | mmap_free ((void **) &b->text->beg); |
| 5036 | #elif defined REL_ALLOC | 5069 | #elif defined REL_ALLOC |
| 5037 | r_alloc_free ((void **) &b->text->beg); | 5070 | r_alloc_free ((void **) &b->text->beg); |
| 5038 | #else | 5071 | #else |
| 5039 | xfree (b->text->beg); | 5072 | xfree (b->text->beg); |
| 5040 | #endif | 5073 | #endif |
| 5074 | } | ||
| 5041 | 5075 | ||
| 5042 | BUF_BEG_ADDR (b) = NULL; | 5076 | BUF_BEG_ADDR (b) = NULL; |
| 5043 | unblock_input (); | 5077 | unblock_input (); |
| @@ -5048,14 +5082,25 @@ free_buffer_text (struct buffer *b) | |||
| 5048 | /*********************************************************************** | 5082 | /*********************************************************************** |
| 5049 | Initialization | 5083 | Initialization |
| 5050 | ***********************************************************************/ | 5084 | ***********************************************************************/ |
| 5051 | |||
| 5052 | void | 5085 | void |
| 5053 | init_buffer_once (void) | 5086 | init_buffer_once (void) |
| 5054 | { | 5087 | { |
| 5088 | /* TODO: clean up the buffer-local machinery. Right now, | ||
| 5089 | we have: | ||
| 5090 | |||
| 5091 | buffer_defaults: default values of buffer-locals | ||
| 5092 | buffer_local_flags: metadata | ||
| 5093 | buffer_permanent_local_flags: metadata | ||
| 5094 | buffer_local_symbols: metadata | ||
| 5095 | |||
| 5096 | There must be a simpler way to store the metadata. | ||
| 5097 | */ | ||
| 5098 | |||
| 5055 | int idx; | 5099 | int idx; |
| 5056 | 5100 | ||
| 5057 | /* Items flagged permanent get an explicit permanent-local property | 5101 | /* Items flagged permanent get an explicit permanent-local property |
| 5058 | added in bindings.el, for clarity. */ | 5102 | added in bindings.el, for clarity. */ |
| 5103 | PDUMPER_REMEMBER_SCALAR (buffer_permanent_local_flags); | ||
| 5059 | memset (buffer_permanent_local_flags, 0, sizeof buffer_permanent_local_flags); | 5104 | memset (buffer_permanent_local_flags, 0, sizeof buffer_permanent_local_flags); |
| 5060 | 5105 | ||
| 5061 | /* 0 means not a lisp var, -1 means always local, else mask. */ | 5106 | /* 0 means not a lisp var, -1 means always local, else mask. */ |
| @@ -5144,10 +5189,15 @@ init_buffer_once (void) | |||
| 5144 | XSETFASTINT (BVAR (&buffer_local_flags, extra_line_spacing), idx); ++idx; | 5189 | XSETFASTINT (BVAR (&buffer_local_flags, extra_line_spacing), idx); ++idx; |
| 5145 | XSETFASTINT (BVAR (&buffer_local_flags, cursor_in_non_selected_windows), idx); ++idx; | 5190 | XSETFASTINT (BVAR (&buffer_local_flags, cursor_in_non_selected_windows), idx); ++idx; |
| 5146 | 5191 | ||
| 5192 | /* buffer_local_flags contains no pointers, so it's safe to treat it | ||
| 5193 | as a blob for pdumper. */ | ||
| 5194 | PDUMPER_REMEMBER_SCALAR (buffer_local_flags); | ||
| 5195 | |||
| 5147 | /* Need more room? */ | 5196 | /* Need more room? */ |
| 5148 | if (idx >= MAX_PER_BUFFER_VARS) | 5197 | if (idx >= MAX_PER_BUFFER_VARS) |
| 5149 | emacs_abort (); | 5198 | emacs_abort (); |
| 5150 | last_per_buffer_idx = idx; | 5199 | last_per_buffer_idx = idx; |
| 5200 | PDUMPER_REMEMBER_SCALAR (last_per_buffer_idx); | ||
| 5151 | 5201 | ||
| 5152 | /* Make sure all markable slots in buffer_defaults | 5202 | /* Make sure all markable slots in buffer_defaults |
| 5153 | are initialized reasonably, so mark_buffer won't choke. */ | 5203 | are initialized reasonably, so mark_buffer won't choke. */ |
| @@ -5242,7 +5292,9 @@ init_buffer_once (void) | |||
| 5242 | 5292 | ||
| 5243 | Vbuffer_alist = Qnil; | 5293 | Vbuffer_alist = Qnil; |
| 5244 | current_buffer = 0; | 5294 | current_buffer = 0; |
| 5295 | pdumper_remember_lv_ptr_raw (¤t_buffer, Lisp_Vectorlike); | ||
| 5245 | all_buffers = 0; | 5296 | all_buffers = 0; |
| 5297 | pdumper_remember_lv_ptr_raw (&all_buffers, Lisp_Vectorlike); | ||
| 5246 | 5298 | ||
| 5247 | QSFundamental = build_pure_c_string ("Fundamental"); | 5299 | QSFundamental = build_pure_c_string ("Fundamental"); |
| 5248 | 5300 | ||
| @@ -5266,12 +5318,12 @@ init_buffer_once (void) | |||
| 5266 | } | 5318 | } |
| 5267 | 5319 | ||
| 5268 | void | 5320 | void |
| 5269 | init_buffer (int initialized) | 5321 | init_buffer (void) |
| 5270 | { | 5322 | { |
| 5271 | Lisp_Object temp; | 5323 | Lisp_Object temp; |
| 5272 | 5324 | ||
| 5273 | #ifdef USE_MMAP_FOR_BUFFERS | 5325 | #ifdef USE_MMAP_FOR_BUFFERS |
| 5274 | if (initialized) | 5326 | if (dumped_with_unexec_p ()) |
| 5275 | { | 5327 | { |
| 5276 | struct buffer *b; | 5328 | struct buffer *b; |
| 5277 | 5329 | ||
| @@ -5312,9 +5364,6 @@ init_buffer (int initialized) | |||
| 5312 | eassert (b->text->beg != NULL); | 5364 | eassert (b->text->beg != NULL); |
| 5313 | } | 5365 | } |
| 5314 | } | 5366 | } |
| 5315 | #else /* not USE_MMAP_FOR_BUFFERS */ | ||
| 5316 | /* Avoid compiler warnings. */ | ||
| 5317 | (void) initialized; | ||
| 5318 | #endif /* USE_MMAP_FOR_BUFFERS */ | 5367 | #endif /* USE_MMAP_FOR_BUFFERS */ |
| 5319 | 5368 | ||
| 5320 | AUTO_STRING (scratch, "*scratch*"); | 5369 | AUTO_STRING (scratch, "*scratch*"); |
| @@ -5395,7 +5444,7 @@ defvar_per_buffer (struct Lisp_Buffer_Objfwd *bo_fwd, const char *namestring, | |||
| 5395 | bo_fwd->predicate = predicate; | 5444 | bo_fwd->predicate = predicate; |
| 5396 | sym->u.s.declared_special = true; | 5445 | sym->u.s.declared_special = true; |
| 5397 | sym->u.s.redirect = SYMBOL_FORWARDED; | 5446 | sym->u.s.redirect = SYMBOL_FORWARDED; |
| 5398 | SET_SYMBOL_FWD (sym, (union Lisp_Fwd *) bo_fwd); | 5447 | SET_SYMBOL_FWD (sym, bo_fwd); |
| 5399 | XSETSYMBOL (PER_BUFFER_SYMBOL (offset), sym); | 5448 | XSETSYMBOL (PER_BUFFER_SYMBOL (offset), sym); |
| 5400 | 5449 | ||
| 5401 | if (PER_BUFFER_IDX (offset) == 0) | 5450 | if (PER_BUFFER_IDX (offset) == 0) |
| @@ -5448,7 +5497,7 @@ syms_of_buffer (void) | |||
| 5448 | Qoverwrite_mode_binary)); | 5497 | Qoverwrite_mode_binary)); |
| 5449 | 5498 | ||
| 5450 | Fput (Qprotected_field, Qerror_conditions, | 5499 | Fput (Qprotected_field, Qerror_conditions, |
| 5451 | listn (CONSTYPE_PURE, 2, Qprotected_field, Qerror)); | 5500 | pure_list (Qprotected_field, Qerror)); |
| 5452 | Fput (Qprotected_field, Qerror_message, | 5501 | Fput (Qprotected_field, Qerror_message, |
| 5453 | build_pure_c_string ("Attempt to modify a protected field")); | 5502 | build_pure_c_string ("Attempt to modify a protected field")); |
| 5454 | 5503 | ||
| @@ -6217,9 +6266,11 @@ The function `kill-all-local-variables' runs this before doing anything else. * | |||
| 6217 | 6266 | ||
| 6218 | DEFVAR_LISP ("buffer-list-update-hook", Vbuffer_list_update_hook, | 6267 | DEFVAR_LISP ("buffer-list-update-hook", Vbuffer_list_update_hook, |
| 6219 | doc: /* Hook run when the buffer list changes. | 6268 | doc: /* Hook run when the buffer list changes. |
| 6220 | Functions running this hook are, `get-buffer-create', | 6269 | Functions (implicitly) running this hook are `get-buffer-create', |
| 6221 | `make-indirect-buffer', `rename-buffer', `kill-buffer', | 6270 | `make-indirect-buffer', `rename-buffer', `kill-buffer', `bury-buffer' |
| 6222 | `bury-buffer-internal' and `select-window'. */); | 6271 | and `select-window'. Functions run by this hook should avoid calling |
| 6272 | `select-window' with a nil NORECORD argument or `with-temp-buffer' | ||
| 6273 | since either may lead to infinite recursion. */); | ||
| 6223 | Vbuffer_list_update_hook = Qnil; | 6274 | Vbuffer_list_update_hook = Qnil; |
| 6224 | DEFSYM (Qbuffer_list_update_hook, "buffer-list-update-hook"); | 6275 | DEFSYM (Qbuffer_list_update_hook, "buffer-list-update-hook"); |
| 6225 | 6276 | ||