aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c55
1 files changed, 25 insertions, 30 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 4e121ca4cab..d8842a6d770 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -51,11 +51,6 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
51#include "w32heap.h" /* for mmap_* */ 51#include "w32heap.h" /* for mmap_* */
52#endif 52#endif
53 53
54/* First buffer in chain of all buffers (in reverse order of creation).
55 Threaded through ->header.next.buffer. */
56
57struct buffer *all_buffers;
58
59/* This structure holds the default values of the buffer-local variables 54/* This structure holds the default values of the buffer-local variables
60 defined with DEFVAR_PER_BUFFER, that have special slots in each buffer. 55 defined with DEFVAR_PER_BUFFER, that have special slots in each buffer.
61 The default value occupies the same slot in this structure 56 The default value occupies the same slot in this structure
@@ -1786,15 +1781,11 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1786 ask questions or their hooks get errors. */ 1781 ask questions or their hooks get errors. */
1787 if (!b->base_buffer && b->indirections > 0) 1782 if (!b->base_buffer && b->indirections > 0)
1788 { 1783 {
1789 struct buffer *other; 1784 Lisp_Object tail, other;
1790 1785
1791 FOR_EACH_BUFFER (other) 1786 FOR_EACH_LIVE_BUFFER (tail, other)
1792 if (other->base_buffer == b) 1787 if (XBUFFER (other)->base_buffer == b)
1793 { 1788 Fkill_buffer (other);
1794 Lisp_Object buf;
1795 XSETBUFFER (buf, other);
1796 Fkill_buffer (buf);
1797 }
1798 1789
1799 /* Exit if we now have killed the base buffer (Bug#11665). */ 1790 /* Exit if we now have killed the base buffer (Bug#11665). */
1800 if (!BUFFER_LIVE_P (b)) 1791 if (!BUFFER_LIVE_P (b))
@@ -1849,6 +1840,9 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1849 1840
1850 tem = Vinhibit_quit; 1841 tem = Vinhibit_quit;
1851 Vinhibit_quit = Qt; 1842 Vinhibit_quit = Qt;
1843 /* Once the buffer is removed from Vbuffer_alist, its undo_list field is
1844 not traced by the GC in the same way. So set it to nil early. */
1845 bset_undo_list (b, Qnil);
1852 /* Remove the buffer from the list of all buffers. */ 1846 /* Remove the buffer from the list of all buffers. */
1853 Vbuffer_alist = Fdelq (Frassq (buffer, Vbuffer_alist), Vbuffer_alist); 1847 Vbuffer_alist = Fdelq (Frassq (buffer, Vbuffer_alist), Vbuffer_alist);
1854 /* If replace_buffer_in_windows didn't do its job fix that now. */ 1848 /* If replace_buffer_in_windows didn't do its job fix that now. */
@@ -1963,7 +1957,6 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1963 } 1957 }
1964 bset_width_table (b, Qnil); 1958 bset_width_table (b, Qnil);
1965 unblock_input (); 1959 unblock_input ();
1966 bset_undo_list (b, Qnil);
1967 1960
1968 /* Run buffer-list-update-hook. */ 1961 /* Run buffer-list-update-hook. */
1969 if (!NILP (Vrun_hooks) && !b->inhibit_buffer_hooks) 1962 if (!NILP (Vrun_hooks) && !b->inhibit_buffer_hooks)
@@ -2351,10 +2344,10 @@ results, see Info node `(elisp)Swapping Text'. */)
2351 error ("Cannot swap indirect buffers's text"); 2344 error ("Cannot swap indirect buffers's text");
2352 2345
2353 { /* This is probably harder to make work. */ 2346 { /* This is probably harder to make work. */
2354 struct buffer *other; 2347 Lisp_Object tail, other;
2355 FOR_EACH_BUFFER (other) 2348 FOR_EACH_LIVE_BUFFER (tail, other)
2356 if (other->base_buffer == other_buffer 2349 if (XBUFFER (other)->base_buffer == other_buffer
2357 || other->base_buffer == current_buffer) 2350 || XBUFFER (other)->base_buffer == current_buffer)
2358 error ("One of the buffers to swap has indirect buffers"); 2351 error ("One of the buffers to swap has indirect buffers");
2359 } 2352 }
2360 2353
@@ -2502,7 +2495,7 @@ current buffer is cleared. */)
2502 (Lisp_Object flag) 2495 (Lisp_Object flag)
2503{ 2496{
2504 struct Lisp_Marker *tail, *markers; 2497 struct Lisp_Marker *tail, *markers;
2505 struct buffer *other; 2498 Lisp_Object btail, other;
2506 ptrdiff_t begv, zv; 2499 ptrdiff_t begv, zv;
2507 bool narrowed = (BEG != BEGV || Z != ZV); 2500 bool narrowed = (BEG != BEGV || Z != ZV);
2508 bool modified_p = !NILP (Fbuffer_modified_p (Qnil)); 2501 bool modified_p = !NILP (Fbuffer_modified_p (Qnil));
@@ -2755,13 +2748,16 @@ current buffer is cleared. */)
2755 2748
2756 /* Copy this buffer's new multibyte status 2749 /* Copy this buffer's new multibyte status
2757 into all of its indirect buffers. */ 2750 into all of its indirect buffers. */
2758 FOR_EACH_BUFFER (other) 2751 FOR_EACH_LIVE_BUFFER (btail, other)
2759 if (other->base_buffer == current_buffer && BUFFER_LIVE_P (other)) 2752 {
2760 { 2753 struct buffer *o = XBUFFER (other);
2761 BVAR (other, enable_multibyte_characters) 2754 if (o->base_buffer == current_buffer && BUFFER_LIVE_P (o))
2762 = BVAR (current_buffer, enable_multibyte_characters); 2755 {
2763 other->prevent_redisplay_optimizations_p = 1; 2756 BVAR (o, enable_multibyte_characters)
2764 } 2757 = BVAR (current_buffer, enable_multibyte_characters);
2758 o->prevent_redisplay_optimizations_p = true;
2759 }
2760 }
2765 2761
2766 /* Restore the modifiedness of the buffer. */ 2762 /* Restore the modifiedness of the buffer. */
2767 if (!modified_p && !NILP (Fbuffer_modified_p (Qnil))) 2763 if (!modified_p && !NILP (Fbuffer_modified_p (Qnil)))
@@ -5327,8 +5323,6 @@ init_buffer_once (void)
5327 Vbuffer_alist = Qnil; 5323 Vbuffer_alist = Qnil;
5328 current_buffer = 0; 5324 current_buffer = 0;
5329 pdumper_remember_lv_ptr_raw (&current_buffer, Lisp_Vectorlike); 5325 pdumper_remember_lv_ptr_raw (&current_buffer, Lisp_Vectorlike);
5330 all_buffers = 0;
5331 pdumper_remember_lv_ptr_raw (&all_buffers, Lisp_Vectorlike);
5332 5326
5333 QSFundamental = build_pure_c_string ("Fundamental"); 5327 QSFundamental = build_pure_c_string ("Fundamental");
5334 5328
@@ -5359,7 +5353,7 @@ init_buffer (void)
5359#ifdef USE_MMAP_FOR_BUFFERS 5353#ifdef USE_MMAP_FOR_BUFFERS
5360 if (dumped_with_unexec_p ()) 5354 if (dumped_with_unexec_p ())
5361 { 5355 {
5362 struct buffer *b; 5356 Lisp_Object tail, buffer;
5363 5357
5364#ifndef WINDOWSNT 5358#ifndef WINDOWSNT
5365 /* These must be reset in the dumped Emacs, to avoid stale 5359 /* These must be reset in the dumped Emacs, to avoid stale
@@ -5381,8 +5375,9 @@ init_buffer (void)
5381 " *code-conversion-work*". They are created by 5375 " *code-conversion-work*". They are created by
5382 init_buffer_once and init_window_once (which are not called 5376 init_buffer_once and init_window_once (which are not called
5383 in the dumped Emacs), and by the first call to coding.c routines. */ 5377 in the dumped Emacs), and by the first call to coding.c routines. */
5384 FOR_EACH_BUFFER (b) 5378 FOR_EACH_LIVE_BUFFER (tail, buffer)
5385 { 5379 {
5380 struct buffer *b = XBUFFER (buffer);
5386 b->text->beg = NULL; 5381 b->text->beg = NULL;
5387 enlarge_buffer_text (b, 0); 5382 enlarge_buffer_text (b, 0);
5388 } 5383 }