aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 425d05ca790..0b3dde27968 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -897,6 +897,8 @@ delete_all_overlays (struct buffer *b)
897{ 897{
898 struct Lisp_Overlay *ov, *next; 898 struct Lisp_Overlay *ov, *next;
899 899
900 /* FIXME: Since each drop_overlay will scan BUF_MARKERS to unlink its
901 markers, we have an unneeded O(N^2) behavior here. */
900 for (ov = b->overlays_before; ov; ov = next) 902 for (ov = b->overlays_before; ov; ov = next)
901 { 903 {
902 drop_overlay (b, ov); 904 drop_overlay (b, ov);
@@ -1661,18 +1663,11 @@ No argument or nil as argument means do this for the current buffer. */)
1661void 1663void
1662compact_buffer (struct buffer *buffer) 1664compact_buffer (struct buffer *buffer)
1663{ 1665{
1664 /* Verify indirection counters. */ 1666 BUFFER_CHECK_INDIRECTION (buffer);
1665 if (buffer->base_buffer)
1666 {
1667 eassert (buffer->indirections == -1);
1668 eassert (buffer->base_buffer->indirections > 0);
1669 }
1670 else
1671 eassert (buffer->indirections >= 0);
1672 1667
1673 /* Skip dead buffers, indirect buffers and buffers 1668 /* Skip dead buffers, indirect buffers and buffers
1674 which aren't changed since last compaction. */ 1669 which aren't changed since last compaction. */
1675 if (!NILP (buffer->INTERNAL_FIELD (name)) 1670 if (BUFFER_LIVE_P (buffer)
1676 && (buffer->base_buffer == NULL) 1671 && (buffer->base_buffer == NULL)
1677 && (buffer->text->compact != buffer->text->modiff)) 1672 && (buffer->text->compact != buffer->text->modiff))
1678 { 1673 {
@@ -1889,12 +1884,16 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1889 /* Unchain all markers that belong to this indirect buffer. 1884 /* Unchain all markers that belong to this indirect buffer.
1890 Don't unchain the markers that belong to the base buffer 1885 Don't unchain the markers that belong to the base buffer
1891 or its other indirect buffers. */ 1886 or its other indirect buffers. */
1892 for (m = BUF_MARKERS (b); m; ) 1887 struct Lisp_Marker **mp = &BUF_MARKERS (b);
1888 while ((m = *mp))
1893 { 1889 {
1894 struct Lisp_Marker *next = m->next;
1895 if (m->buffer == b) 1890 if (m->buffer == b)
1896 unchain_marker (m); 1891 {
1897 m = next; 1892 m->buffer = NULL;
1893 *mp = m->next;
1894 }
1895 else
1896 mp = &m->next;
1898 } 1897 }
1899 } 1898 }
1900 else 1899 else
@@ -1911,8 +1910,12 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1911 BUF_MARKERS (b) = NULL; 1910 BUF_MARKERS (b) = NULL;
1912 set_buffer_intervals (b, NULL); 1911 set_buffer_intervals (b, NULL);
1913 1912
1914 /* Perhaps we should explicitly free the interval tree here... */ 1913 /* Perhaps we should explicitly free the interval tree here... */
1915 } 1914 }
1915 /* Since we've unlinked the markers, the overlays can't be here any more
1916 either. */
1917 b->overlays_before = NULL;
1918 b->overlays_after = NULL;
1916 1919
1917 /* Reset the local variables, so that this buffer's local values 1920 /* Reset the local variables, so that this buffer's local values
1918 won't be protected from GC. They would be protected 1921 won't be protected from GC. They would be protected
@@ -2105,6 +2108,8 @@ set_buffer_internal_1 (register struct buffer *b)
2105 if (current_buffer == b) 2108 if (current_buffer == b)
2106 return; 2109 return;
2107 2110
2111 BUFFER_CHECK_INDIRECTION (b);
2112
2108 old_buf = current_buffer; 2113 old_buf = current_buffer;
2109 current_buffer = b; 2114 current_buffer = b;
2110 last_known_column_point = -1; /* invalidate indentation cache */ 2115 last_known_column_point = -1; /* invalidate indentation cache */
@@ -2176,7 +2181,7 @@ set_buffer_temp (struct buffer *b)
2176DEFUN ("set-buffer", Fset_buffer, Sset_buffer, 1, 1, 0, 2181DEFUN ("set-buffer", Fset_buffer, Sset_buffer, 1, 1, 0,
2177 doc: /* Make buffer BUFFER-OR-NAME current for editing operations. 2182 doc: /* Make buffer BUFFER-OR-NAME current for editing operations.
2178BUFFER-OR-NAME may be a buffer or the name of an existing buffer. See 2183BUFFER-OR-NAME may be a buffer or the name of an existing buffer. See
2179also `save-excursion' when you want to make a buffer current 2184also `with-current-buffer' when you want to make a buffer current
2180temporarily. This function does not display the buffer, so its effect 2185temporarily. This function does not display the buffer, so its effect
2181ends when the current command terminates. Use `switch-to-buffer' or 2186ends when the current command terminates. Use `switch-to-buffer' or
2182`pop-to-buffer' to switch buffers permanently. */) 2187`pop-to-buffer' to switch buffers permanently. */)