comparison src/buffer.c @ 51669:f3dc77591fe2

(set_buffer_internal_1): Test CONSP for lists. (Fget_buffer_create, Fkill_buffer, Fset_buffer_multibyte): Update to new types.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Thu, 26 Jun 2003 23:16:44 +0000
parents 5fc6a7035dd3
children 3b58843e8f3f
comparison
equal deleted inserted replaced
51668:0f333fd92a1d 51669:f3dc77591fe2
411 411
412 reset_buffer (b); 412 reset_buffer (b);
413 reset_buffer_local_variables (b, 1); 413 reset_buffer_local_variables (b, 1);
414 414
415 b->mark = Fmake_marker (); 415 b->mark = Fmake_marker ();
416 BUF_MARKERS (b) = Qnil; 416 BUF_MARKERS (b) = NULL;
417 b->name = name; 417 b->name = name;
418 418
419 /* Put this in the alist of all live buffers. */ 419 /* Put this in the alist of all live buffers. */
420 XSETBUFFER (buf, b); 420 XSETBUFFER (buf, b);
421 Vbuffer_alist = nconc2 (Vbuffer_alist, Fcons (Fcons (name, buf), Qnil)); 421 Vbuffer_alist = nconc2 (Vbuffer_alist, Fcons (Fcons (name, buf), Qnil));
1406 if (b->base_buffer) 1406 if (b->base_buffer)
1407 { 1407 {
1408 /* Unchain all markers that belong to this indirect buffer. 1408 /* Unchain all markers that belong to this indirect buffer.
1409 Don't unchain the markers that belong to the base buffer 1409 Don't unchain the markers that belong to the base buffer
1410 or its other indirect buffers. */ 1410 or its other indirect buffers. */
1411 for (tem = BUF_MARKERS (b); !NILP (tem); ) 1411 for (m = BUF_MARKERS (b); m; )
1412 { 1412 {
1413 Lisp_Object next; 1413 struct Lisp_Marker *next = m->next;
1414 m = XMARKER (tem);
1415 next = m->chain;
1416 if (m->buffer == b) 1414 if (m->buffer == b)
1417 unchain_marker (tem); 1415 unchain_marker (m);
1418 tem = next; 1416 m = next;
1419 } 1417 }
1420 } 1418 }
1421 else 1419 else
1422 { 1420 {
1423 /* Unchain all markers of this buffer and its indirect buffers. 1421 /* Unchain all markers of this buffer and its indirect buffers.
1424 and leave them pointing nowhere. */ 1422 and leave them pointing nowhere. */
1425 for (tem = BUF_MARKERS (b); !NILP (tem); ) 1423 for (m = BUF_MARKERS (b); m; )
1426 { 1424 {
1427 m = XMARKER (tem); 1425 struct Lisp_Marker *next = m->next;
1428 m->buffer = 0; 1426 m->buffer = 0;
1429 tem = m->chain; 1427 m->next = NULL;
1430 m->chain = Qnil; 1428 m = next;
1431 } 1429 }
1432 BUF_MARKERS (b) = Qnil; 1430 BUF_MARKERS (b) = NULL;
1433 BUF_INTERVALS (b) = NULL_INTERVAL; 1431 BUF_INTERVALS (b) = NULL_INTERVAL;
1434 1432
1435 /* Perhaps we should explicitly free the interval tree here... */ 1433 /* Perhaps we should explicitly free the interval tree here... */
1436 } 1434 }
1437 1435
1771 } 1769 }
1772 1770
1773 /* Look down buffer's list of local Lisp variables 1771 /* Look down buffer's list of local Lisp variables
1774 to find and update any that forward into C variables. */ 1772 to find and update any that forward into C variables. */
1775 1773
1776 for (tail = b->local_var_alist; !NILP (tail); tail = XCDR (tail)) 1774 for (tail = b->local_var_alist; CONSP (tail); tail = XCDR (tail))
1777 { 1775 {
1778 valcontents = SYMBOL_VALUE (XCAR (XCAR (tail))); 1776 valcontents = SYMBOL_VALUE (XCAR (XCAR (tail)));
1779 if ((BUFFER_LOCAL_VALUEP (valcontents) 1777 if ((BUFFER_LOCAL_VALUEP (valcontents)
1780 || SOME_BUFFER_LOCAL_VALUEP (valcontents)) 1778 || SOME_BUFFER_LOCAL_VALUEP (valcontents))
1781 && (tem = XBUFFER_LOCAL_VALUE (valcontents)->realvalue, 1779 && (tem = XBUFFER_LOCAL_VALUE (valcontents)->realvalue,
1786 } 1784 }
1787 1785
1788 /* Do the same with any others that were local to the previous buffer */ 1786 /* Do the same with any others that were local to the previous buffer */
1789 1787
1790 if (old_buf) 1788 if (old_buf)
1791 for (tail = old_buf->local_var_alist; !NILP (tail); tail = XCDR (tail)) 1789 for (tail = old_buf->local_var_alist; CONSP (tail); tail = XCDR (tail))
1792 { 1790 {
1793 valcontents = SYMBOL_VALUE (XCAR (XCAR (tail))); 1791 valcontents = SYMBOL_VALUE (XCAR (XCAR (tail)));
1794 if ((BUFFER_LOCAL_VALUEP (valcontents) 1792 if ((BUFFER_LOCAL_VALUEP (valcontents)
1795 || SOME_BUFFER_LOCAL_VALUEP (valcontents)) 1793 || SOME_BUFFER_LOCAL_VALUEP (valcontents))
1796 && (tem = XBUFFER_LOCAL_VALUE (valcontents)->realvalue, 1794 && (tem = XBUFFER_LOCAL_VALUE (valcontents)->realvalue,
2044 The buffer contents remain unchanged as a sequence of bytes 2042 The buffer contents remain unchanged as a sequence of bytes
2045 but the contents viewed as characters do change. */) 2043 but the contents viewed as characters do change. */)
2046 (flag) 2044 (flag)
2047 Lisp_Object flag; 2045 Lisp_Object flag;
2048 { 2046 {
2049 Lisp_Object tail, markers; 2047 struct Lisp_Marker *tail, *markers;
2050 struct buffer *other; 2048 struct buffer *other;
2051 int undo_enabled_p = !EQ (current_buffer->undo_list, Qt); 2049 int undo_enabled_p = !EQ (current_buffer->undo_list, Qt);
2052 int begv, zv; 2050 int begv, zv;
2053 int narrowed = (BEG != BEGV || Z != ZV); 2051 int narrowed = (BEG != BEGV || Z != ZV);
2054 int modified_p = !NILP (Fbuffer_modified_p (Qnil)); 2052 int modified_p = !NILP (Fbuffer_modified_p (Qnil));
2091 BEGV = BEGV_BYTE; 2089 BEGV = BEGV_BYTE;
2092 ZV = ZV_BYTE; 2090 ZV = ZV_BYTE;
2093 GPT = GPT_BYTE; 2091 GPT = GPT_BYTE;
2094 TEMP_SET_PT_BOTH (PT_BYTE, PT_BYTE); 2092 TEMP_SET_PT_BOTH (PT_BYTE, PT_BYTE);
2095 2093
2096 tail = BUF_MARKERS (current_buffer); 2094
2097 while (! NILP (tail)) 2095 for (tail = BUF_MARKERS (current_buffer); tail; tail = tail->next)
2098 { 2096 tail->charpos = tail->bytepos;
2099 XMARKER (tail)->charpos = XMARKER (tail)->bytepos;
2100 tail = XMARKER (tail)->chain;
2101 }
2102 2097
2103 /* Convert multibyte form of 8-bit characters to unibyte. */ 2098 /* Convert multibyte form of 8-bit characters to unibyte. */
2104 pos = BEG; 2099 pos = BEG;
2105 stop = GPT; 2100 stop = GPT;
2106 p = BEG_ADDR; 2101 p = BEG_ADDR;
2244 tail = markers = BUF_MARKERS (current_buffer); 2239 tail = markers = BUF_MARKERS (current_buffer);
2245 2240
2246 /* This prevents BYTE_TO_CHAR (that is, buf_bytepos_to_charpos) from 2241 /* This prevents BYTE_TO_CHAR (that is, buf_bytepos_to_charpos) from
2247 getting confused by the markers that have not yet been updated. 2242 getting confused by the markers that have not yet been updated.
2248 It is also a signal that it should never create a marker. */ 2243 It is also a signal that it should never create a marker. */
2249 BUF_MARKERS (current_buffer) = Qnil; 2244 BUF_MARKERS (current_buffer) = NULL;
2250 2245
2251 while (! NILP (tail)) 2246 for (; tail; tail = tail->next)
2252 { 2247 {
2253 XMARKER (tail)->bytepos 2248 tail->bytepos = advance_to_char_boundary (tail->bytepos);
2254 = advance_to_char_boundary (XMARKER (tail)->bytepos); 2249 tail->charpos = BYTE_TO_CHAR (tail->bytepos);
2255 XMARKER (tail)->charpos = BYTE_TO_CHAR (XMARKER (tail)->bytepos);
2256
2257 tail = XMARKER (tail)->chain;
2258 } 2250 }
2259 2251
2260 /* Make sure no markers were put on the chain 2252 /* Make sure no markers were put on the chain
2261 while the chain value was incorrect. */ 2253 while the chain value was incorrect. */
2262 if (! EQ (BUF_MARKERS (current_buffer), Qnil)) 2254 if (BUF_MARKERS (current_buffer))
2263 abort (); 2255 abort ();
2264 2256
2265 BUF_MARKERS (current_buffer) = markers; 2257 BUF_MARKERS (current_buffer) = markers;
2266 2258
2267 /* Do this last, so it can calculate the new correspondences 2259 /* Do this last, so it can calculate the new correspondences