aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
authorEli Zaretskii2013-03-28 20:13:59 +0200
committerEli Zaretskii2013-03-28 20:13:59 +0200
commitd76bf86f438d4f5f9fe493ab76f02ffc78f3ae2e (patch)
tree04fa8bc7bd2058a316a7ee30f8741d25bfd0b060 /src/buffer.c
parent2ef26ceb192c7683754cf0b4aa3087f501254332 (diff)
parente74aeda863cd6896e06e92586f87b45d63d67d15 (diff)
downloademacs-d76bf86f438d4f5f9fe493ab76f02ffc78f3ae2e.tar.gz
emacs-d76bf86f438d4f5f9fe493ab76f02ffc78f3ae2e.zip
Merge from trunk and resolve conflicts.
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c229
1 files changed, 113 insertions, 116 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 619a729a859..8728b418812 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1,6 +1,7 @@
1/* Buffer manipulation primitives for GNU Emacs. 1/* Buffer manipulation primitives for GNU Emacs.
2 2
3Copyright (C) 1985-1989, 1993-1995, 1997-2012 Free Software Foundation, Inc. 3Copyright (C) 1985-1989, 1993-1995, 1997-2013 Free Software Foundation,
4Inc.
4 5
5This file is part of GNU Emacs. 6This file is part of GNU Emacs.
6 7
@@ -371,9 +372,6 @@ bset_zv_marker (struct buffer *b, Lisp_Object val)
371 b->INTERNAL_FIELD (zv_marker) = val; 372 b->INTERNAL_FIELD (zv_marker) = val;
372} 373}
373 374
374/* For debugging; temporary. See set_buffer_internal. */
375/* Lisp_Object Qlisp_mode, Vcheck_symbol; */
376
377void 375void
378nsberror (Lisp_Object spec) 376nsberror (Lisp_Object spec)
379{ 377{
@@ -547,6 +545,8 @@ even if it is dead. The return value is never nil. */)
547 b->base_buffer = NULL; 545 b->base_buffer = NULL;
548 /* No one shares the text with us now. */ 546 /* No one shares the text with us now. */
549 b->indirections = 0; 547 b->indirections = 0;
548 /* No one shows us now. */
549 b->window_count = 0;
550 550
551 BUF_GAP_SIZE (b) = 20; 551 BUF_GAP_SIZE (b) = 20;
552 block_input (); 552 block_input ();
@@ -573,6 +573,7 @@ even if it is dead. The return value is never nil. */)
573 BUF_CHARS_MODIFF (b) = 1; 573 BUF_CHARS_MODIFF (b) = 1;
574 BUF_OVERLAY_MODIFF (b) = 1; 574 BUF_OVERLAY_MODIFF (b) = 1;
575 BUF_SAVE_MODIFF (b) = 1; 575 BUF_SAVE_MODIFF (b) = 1;
576 BUF_COMPACT (b) = 1;
576 set_buffer_intervals (b, NULL); 577 set_buffer_intervals (b, NULL);
577 BUF_UNCHANGED_MODIFIED (b) = 1; 578 BUF_UNCHANGED_MODIFIED (b) = 1;
578 BUF_OVERLAY_UNCHANGED_MODIFIED (b) = 1; 579 BUF_OVERLAY_UNCHANGED_MODIFIED (b) = 1;
@@ -794,6 +795,8 @@ CLONE nil means the indirect buffer's state is reset to default values. */)
794 b->indirections = -1; 795 b->indirections = -1;
795 /* Notify base buffer that we share the text now. */ 796 /* Notify base buffer that we share the text now. */
796 b->base_buffer->indirections++; 797 b->base_buffer->indirections++;
798 /* Always -1 for an indirect buffer. */
799 b->window_count = -1;
797 800
798 b->pt = b->base_buffer->pt; 801 b->pt = b->base_buffer->pt;
799 b->begv = b->base_buffer->begv; 802 b->begv = b->base_buffer->begv;
@@ -1336,7 +1339,7 @@ DEFUN ("set-buffer-modified-p", Fset_buffer_modified_p, Sset_buffer_modified_p,
1336A non-nil FLAG means mark the buffer modified. */) 1339A non-nil FLAG means mark the buffer modified. */)
1337 (Lisp_Object flag) 1340 (Lisp_Object flag)
1338{ 1341{
1339 Lisp_Object fn, buffer, window; 1342 Lisp_Object fn;
1340 1343
1341#ifdef CLASH_DETECTION 1344#ifdef CLASH_DETECTION
1342 /* If buffer becoming modified, lock the file. 1345 /* If buffer becoming modified, lock the file.
@@ -1389,9 +1392,7 @@ A non-nil FLAG means mark the buffer modified. */)
1389 Ideally, I think there should be another mechanism for fontifying 1392 Ideally, I think there should be another mechanism for fontifying
1390 buffers without "modifying" buffers, or redisplay should be 1393 buffers without "modifying" buffers, or redisplay should be
1391 smarter about updating the `*' in mode lines. --gerd */ 1394 smarter about updating the `*' in mode lines. --gerd */
1392 XSETBUFFER (buffer, current_buffer); 1395 if (buffer_window_count (current_buffer))
1393 window = Fget_buffer_window (buffer, Qt);
1394 if (WINDOWP (window))
1395 { 1396 {
1396 ++update_mode_lines; 1397 ++update_mode_lines;
1397 current_buffer->prevent_redisplay_optimizations_p = 1; 1398 current_buffer->prevent_redisplay_optimizations_p = 1;
@@ -1529,6 +1530,16 @@ This does not change the name of the visited file (if any). */)
1529 return BVAR (current_buffer, name); 1530 return BVAR (current_buffer, name);
1530} 1531}
1531 1532
1533/* True if B can be used as 'other-than-BUFFER' buffer. */
1534
1535static bool
1536candidate_buffer (Lisp_Object b, Lisp_Object buffer)
1537{
1538 return (BUFFERP (b) && !EQ (b, buffer)
1539 && BUFFER_LIVE_P (XBUFFER (b))
1540 && !BUFFER_HIDDEN_P (XBUFFER (b)));
1541}
1542
1532DEFUN ("other-buffer", Fother_buffer, Sother_buffer, 0, 3, 0, 1543DEFUN ("other-buffer", Fother_buffer, Sother_buffer, 0, 3, 0,
1533 doc: /* Return most recently selected buffer other than BUFFER. 1544 doc: /* Return most recently selected buffer other than BUFFER.
1534Buffers not visible in windows are preferred to visible buffers, unless 1545Buffers not visible in windows are preferred to visible buffers, unless
@@ -1550,9 +1561,7 @@ exists, return the buffer `*scratch*' (creating it if necessary). */)
1550 for (; CONSP (tail); tail = XCDR (tail)) 1561 for (; CONSP (tail); tail = XCDR (tail))
1551 { 1562 {
1552 buf = XCAR (tail); 1563 buf = XCAR (tail);
1553 if (BUFFERP (buf) && !EQ (buf, buffer) 1564 if (candidate_buffer (buf, buffer)
1554 && BUFFER_LIVE_P (XBUFFER (buf))
1555 && (SREF (BVAR (XBUFFER (buf), name), 0) != ' ')
1556 /* If the frame has a buffer_predicate, disregard buffers that 1565 /* If the frame has a buffer_predicate, disregard buffers that
1557 don't fit the predicate. */ 1566 don't fit the predicate. */
1558 && (NILP (pred) || !NILP (call1 (pred, buf)))) 1567 && (NILP (pred) || !NILP (call1 (pred, buf))))
@@ -1570,9 +1579,7 @@ exists, return the buffer `*scratch*' (creating it if necessary). */)
1570 for (; CONSP (tail); tail = XCDR (tail)) 1579 for (; CONSP (tail); tail = XCDR (tail))
1571 { 1580 {
1572 buf = Fcdr (XCAR (tail)); 1581 buf = Fcdr (XCAR (tail));
1573 if (BUFFERP (buf) && !EQ (buf, buffer) 1582 if (candidate_buffer (buf, buffer)
1574 && BUFFER_LIVE_P (XBUFFER (buf))
1575 && (SREF (BVAR (XBUFFER (buf), name), 0) != ' ')
1576 /* If the frame has a buffer_predicate, disregard buffers that 1583 /* If the frame has a buffer_predicate, disregard buffers that
1577 don't fit the predicate. */ 1584 don't fit the predicate. */
1578 && (NILP (pred) || !NILP (call1 (pred, buf)))) 1585 && (NILP (pred) || !NILP (call1 (pred, buf))))
@@ -1608,13 +1615,10 @@ other_buffer_safely (Lisp_Object buffer)
1608{ 1615{
1609 Lisp_Object tail, buf; 1616 Lisp_Object tail, buf;
1610 1617
1611 tail = Vbuffer_alist; 1618 for (tail = Vbuffer_alist; CONSP (tail); tail = XCDR (tail))
1612 for (; CONSP (tail); tail = XCDR (tail))
1613 { 1619 {
1614 buf = Fcdr (XCAR (tail)); 1620 buf = Fcdr (XCAR (tail));
1615 if (BUFFERP (buf) && !EQ (buf, buffer) 1621 if (candidate_buffer (buf, buffer))
1616 && BUFFER_LIVE_P (XBUFFER (buf))
1617 && (SREF (BVAR (XBUFFER (buf), name), 0) != ' '))
1618 return buf; 1622 return buf;
1619 } 1623 }
1620 1624
@@ -1662,7 +1666,7 @@ compact_buffer (struct buffer *buffer)
1662 which aren't changed since last compaction. */ 1666 which aren't changed since last compaction. */
1663 if (BUFFER_LIVE_P (buffer) 1667 if (BUFFER_LIVE_P (buffer)
1664 && (buffer->base_buffer == NULL) 1668 && (buffer->base_buffer == NULL)
1665 && (buffer->text->compact != buffer->text->modiff)) 1669 && (BUF_COMPACT (buffer) != BUF_MODIFF (buffer)))
1666 { 1670 {
1667 /* If a buffer's undo list is Qt, that means that undo is 1671 /* If a buffer's undo list is Qt, that means that undo is
1668 turned off in that buffer. Calling truncate_undo_list on 1672 turned off in that buffer. Calling truncate_undo_list on
@@ -1675,19 +1679,15 @@ compact_buffer (struct buffer *buffer)
1675 if (!buffer->text->inhibit_shrinking) 1679 if (!buffer->text->inhibit_shrinking)
1676 { 1680 {
1677 /* If a buffer's gap size is more than 10% of the buffer 1681 /* If a buffer's gap size is more than 10% of the buffer
1678 size, or larger than 2000 bytes, then shrink it 1682 size, or larger than GAP_BYTES_DFL bytes, then shrink it
1679 accordingly. Keep a minimum size of 20 bytes. */ 1683 accordingly. Keep a minimum size of GAP_BYTES_MIN bytes. */
1680 int size = min (2000, max (20, (buffer->text->z_byte / 10))); 1684 ptrdiff_t size = clip_to_bounds (GAP_BYTES_MIN,
1681 1685 BUF_Z_BYTE (buffer) / 10,
1682 if (buffer->text->gap_size > size) 1686 GAP_BYTES_DFL);
1683 { 1687 if (BUF_GAP_SIZE (buffer) > size)
1684 struct buffer *save_current = current_buffer; 1688 make_gap_1 (buffer, -(BUF_GAP_SIZE (buffer) - size));
1685 current_buffer = buffer;
1686 make_gap (-(buffer->text->gap_size - size));
1687 current_buffer = save_current;
1688 }
1689 } 1689 }
1690 buffer->text->compact = buffer->text->modiff; 1690 BUF_COMPACT (buffer) = BUF_MODIFF (buffer);
1691 } 1691 }
1692} 1692}
1693 1693
@@ -1769,7 +1769,7 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1769 since anything can happen within do_yes_or_no_p. */ 1769 since anything can happen within do_yes_or_no_p. */
1770 1770
1771 /* Don't kill the minibuffer now current. */ 1771 /* Don't kill the minibuffer now current. */
1772 if (EQ (buffer, XWINDOW (minibuf_window)->buffer)) 1772 if (EQ (buffer, XWINDOW (minibuf_window)->contents))
1773 return Qnil; 1773 return Qnil;
1774 1774
1775 /* When we kill an ordinary buffer which shares it's buffer text 1775 /* When we kill an ordinary buffer which shares it's buffer text
@@ -1820,7 +1820,7 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1820 /* If the buffer now current is shown in the minibuffer and our buffer 1820 /* If the buffer now current is shown in the minibuffer and our buffer
1821 is the sole other buffer give up. */ 1821 is the sole other buffer give up. */
1822 XSETBUFFER (tem, current_buffer); 1822 XSETBUFFER (tem, current_buffer);
1823 if (EQ (tem, XWINDOW (minibuf_window)->buffer) 1823 if (EQ (tem, XWINDOW (minibuf_window)->contents)
1824 && EQ (buffer, Fother_buffer (buffer, Qnil, Qnil))) 1824 && EQ (buffer, Fother_buffer (buffer, Qnil, Qnil)))
1825 return Qnil; 1825 return Qnil;
1826 1826
@@ -1926,10 +1926,16 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1926 eassert (b->indirections == -1); 1926 eassert (b->indirections == -1);
1927 b->base_buffer->indirections--; 1927 b->base_buffer->indirections--;
1928 eassert (b->base_buffer->indirections >= 0); 1928 eassert (b->base_buffer->indirections >= 0);
1929 /* Make sure that we wasn't confused. */
1930 eassert (b->window_count == -1);
1929 } 1931 }
1930 else 1932 else
1931 /* No one shares our buffer text, can free it. */ 1933 {
1932 free_buffer_text (b); 1934 /* Make sure that no one shows us. */
1935 eassert (b->window_count == 0);
1936 /* No one shares our buffer text, can free it. */
1937 free_buffer_text (b);
1938 }
1933 1939
1934 if (b->newline_cache) 1940 if (b->newline_cache)
1935 { 1941 {
@@ -2036,7 +2042,7 @@ DEFUN ("bury-buffer-internal", Fbury_buffer_internal, Sbury_buffer_internal,
2036DEFUN ("set-buffer-major-mode", Fset_buffer_major_mode, Sset_buffer_major_mode, 1, 1, 0, 2042DEFUN ("set-buffer-major-mode", Fset_buffer_major_mode, Sset_buffer_major_mode, 1, 1, 0,
2037 doc: /* Set an appropriate major mode for BUFFER. 2043 doc: /* Set an appropriate major mode for BUFFER.
2038For the *scratch* buffer, use `initial-major-mode', otherwise choose a mode 2044For the *scratch* buffer, use `initial-major-mode', otherwise choose a mode
2039according to `default-major-mode'. 2045according to the default value of `major-mode'.
2040Use this function before selecting the buffer, since it may need to inspect 2046Use this function before selecting the buffer, since it may need to inspect
2041the current buffer's major mode. */) 2047the current buffer's major mode. */)
2042 (Lisp_Object buffer) 2048 (Lisp_Object buffer)
@@ -2388,8 +2394,9 @@ DEFUN ("buffer-swap-text", Fbuffer_swap_text, Sbuffer_swap_text,
2388 BUF_MARKERS(buf) should either be for `buf' or dead. */ 2394 BUF_MARKERS(buf) should either be for `buf' or dead. */
2389 eassert (!m->buffer); 2395 eassert (!m->buffer);
2390 } 2396 }
2391 { /* Some of the C code expects that w->buffer == w->pointm->buffer. 2397 { /* Some of the C code expects that both window markers of a
2392 So since we just swapped the markers between the two buffers, we need 2398 live window points to that window's buffer. So since we
2399 just swapped the markers between the two buffers, we need
2393 to undo the effect of this swap for window markers. */ 2400 to undo the effect of this swap for window markers. */
2394 Lisp_Object w = Fselected_window (), ws = Qnil; 2401 Lisp_Object w = Fselected_window (), ws = Qnil;
2395 Lisp_Object buf1, buf2; 2402 Lisp_Object buf1, buf2;
@@ -2399,12 +2406,19 @@ DEFUN ("buffer-swap-text", Fbuffer_swap_text, Sbuffer_swap_text,
2399 { 2406 {
2400 ws = Fcons (w, ws); 2407 ws = Fcons (w, ws);
2401 if (MARKERP (XWINDOW (w)->pointm) 2408 if (MARKERP (XWINDOW (w)->pointm)
2402 && (EQ (XWINDOW (w)->buffer, buf1) 2409 && (EQ (XWINDOW (w)->contents, buf1)
2403 || EQ (XWINDOW (w)->buffer, buf2))) 2410 || EQ (XWINDOW (w)->contents, buf2)))
2404 Fset_marker (XWINDOW (w)->pointm, 2411 Fset_marker (XWINDOW (w)->pointm,
2405 make_number 2412 make_number
2406 (BUF_BEGV (XBUFFER (XWINDOW (w)->buffer))), 2413 (BUF_BEGV (XBUFFER (XWINDOW (w)->contents))),
2407 XWINDOW (w)->buffer); 2414 XWINDOW (w)->contents);
2415 if (MARKERP (XWINDOW (w)->start)
2416 && (EQ (XWINDOW (w)->contents, buf1)
2417 || EQ (XWINDOW (w)->contents, buf2)))
2418 Fset_marker (XWINDOW (w)->start,
2419 make_number
2420 (XBUFFER (XWINDOW (w)->contents)->last_window_start),
2421 XWINDOW (w)->contents);
2408 w = Fnext_window (w, Qt, Qt); 2422 w = Fnext_window (w, Qt, Qt);
2409 } 2423 }
2410 } 2424 }
@@ -2678,10 +2692,11 @@ current buffer is cleared. */)
2678 2692
2679 UNGCPRO; 2693 UNGCPRO;
2680 2694
2681 /* Changing the multibyteness of a buffer means that all windows
2682 showing that buffer must be updated thoroughly. */
2683 current_buffer->prevent_redisplay_optimizations_p = 1; 2695 current_buffer->prevent_redisplay_optimizations_p = 1;
2684 ++windows_or_buffers_changed; 2696
2697 /* If buffer is shown in a window, let redisplay consider other windows. */
2698 if (buffer_window_count (current_buffer))
2699 ++windows_or_buffers_changed;
2685 2700
2686 /* Copy this buffer's new multibyte status 2701 /* Copy this buffer's new multibyte status
2687 into all of its indirect buffers. */ 2702 into all of its indirect buffers. */
@@ -3144,7 +3159,10 @@ ptrdiff_t
3144sort_overlays (Lisp_Object *overlay_vec, ptrdiff_t noverlays, struct window *w) 3159sort_overlays (Lisp_Object *overlay_vec, ptrdiff_t noverlays, struct window *w)
3145{ 3160{
3146 ptrdiff_t i, j; 3161 ptrdiff_t i, j;
3147 struct sortvec *sortvec = alloca (noverlays * sizeof *sortvec); 3162 USE_SAFE_ALLOCA;
3163 struct sortvec *sortvec;
3164
3165 SAFE_NALLOCA (sortvec, 1, noverlays);
3148 3166
3149 /* Put the valid and relevant overlays into sortvec. */ 3167 /* Put the valid and relevant overlays into sortvec. */
3150 3168
@@ -3190,6 +3208,8 @@ sort_overlays (Lisp_Object *overlay_vec, ptrdiff_t noverlays, struct window *w)
3190 3208
3191 for (i = 0; i < noverlays; i++) 3209 for (i = 0; i < noverlays; i++)
3192 overlay_vec[i] = sortvec[i].overlay; 3210 overlay_vec[i] = sortvec[i].overlay;
3211
3212 SAFE_FREE ();
3193 return (noverlays); 3213 return (noverlays);
3194} 3214}
3195 3215
@@ -3877,17 +3897,17 @@ modify_overlay (struct buffer *buf, ptrdiff_t start, ptrdiff_t end)
3877 3897
3878 BUF_COMPUTE_UNCHANGED (buf, start, end); 3898 BUF_COMPUTE_UNCHANGED (buf, start, end);
3879 3899
3880 /* If this is a buffer not in the selected window, 3900 /* If BUF is visible, consider updating the display if ... */
3881 we must do other windows. */ 3901 if (buffer_window_count (buf) > 0)
3882 if (buf != XBUFFER (XWINDOW (selected_window)->buffer)) 3902 {
3883 windows_or_buffers_changed = 1; 3903 /* ... it's visible in other window than selected, */
3884 /* If multiple windows show this buffer, we must do other windows. */ 3904 if (buf != XBUFFER (XWINDOW (selected_window)->contents))
3885 else if (buffer_shared > 1) 3905 windows_or_buffers_changed = 1;
3886 windows_or_buffers_changed = 1; 3906 /* ... or if we modify an overlay at the end of the buffer
3887 /* If we modify an overlay at the end of the buffer, we cannot 3907 and so we cannot be sure that window end is still valid. */
3888 be sure that window end is still valid. */ 3908 else if (end >= ZV && start <= ZV)
3889 else if (end >= ZV && start <= ZV) 3909 windows_or_buffers_changed = 1;
3890 windows_or_buffers_changed = 1; 3910 }
3891 3911
3892 ++BUF_OVERLAY_MODIFF (buf); 3912 ++BUF_OVERLAY_MODIFF (buf);
3893} 3913}
@@ -4566,27 +4586,7 @@ evaporate_overlays (ptrdiff_t pos)
4566 for (; CONSP (hit_list); hit_list = XCDR (hit_list)) 4586 for (; CONSP (hit_list); hit_list = XCDR (hit_list))
4567 Fdelete_overlay (XCAR (hit_list)); 4587 Fdelete_overlay (XCAR (hit_list));
4568} 4588}
4569
4570/* Somebody has tried to store a value with an unacceptable type
4571 in the slot with offset OFFSET. */
4572
4573void
4574buffer_slot_type_mismatch (Lisp_Object newval, int type)
4575{
4576 Lisp_Object predicate;
4577 4589
4578 switch (type)
4579 {
4580 case_Lisp_Int: predicate = Qintegerp; break;
4581 case Lisp_String: predicate = Qstringp; break;
4582 case Lisp_Symbol: predicate = Qsymbolp; break;
4583 default: emacs_abort ();
4584 }
4585
4586 wrong_type_argument (predicate, newval);
4587}
4588
4589
4590/*********************************************************************** 4590/***********************************************************************
4591 Allocation with mmap 4591 Allocation with mmap
4592 ***********************************************************************/ 4592 ***********************************************************************/
@@ -5122,6 +5122,9 @@ init_buffer_once (void)
5122 /* No one will share the text with these buffers, but let's play it safe. */ 5122 /* No one will share the text with these buffers, but let's play it safe. */
5123 buffer_defaults.indirections = 0; 5123 buffer_defaults.indirections = 0;
5124 buffer_local_symbols.indirections = 0; 5124 buffer_local_symbols.indirections = 0;
5125 /* Likewise no one will display them. */
5126 buffer_defaults.window_count = 0;
5127 buffer_local_symbols.window_count = 0;
5125 set_buffer_intervals (&buffer_defaults, NULL); 5128 set_buffer_intervals (&buffer_defaults, NULL);
5126 set_buffer_intervals (&buffer_local_symbols, NULL); 5129 set_buffer_intervals (&buffer_local_symbols, NULL);
5127 /* This is not strictly necessary, but let's make them initialized. */ 5130 /* This is not strictly necessary, but let's make them initialized. */
@@ -5357,25 +5360,23 @@ init_buffer (void)
5357 free (pwd); 5360 free (pwd);
5358} 5361}
5359 5362
5360/* Similar to defvar_lisp but define a variable whose value is the Lisp 5363/* Similar to defvar_lisp but define a variable whose value is the
5361 Object stored in the current buffer. address is the address of the slot 5364 Lisp_Object stored in the current buffer. LNAME is the Lisp-level
5362 in the buffer that is current now. */ 5365 variable name. VNAME is the name of the buffer slot. PREDICATE
5363 5366 is nil for a general Lisp variable. If PREDICATE is non-nil, then
5364/* TYPE is nil for a general Lisp variable. 5367 only Lisp values that satisfies the PREDICATE are allowed (except
5365 An integer specifies a type; then only Lisp values 5368 that nil is allowed too). DOC is a dummy where you write the doc
5366 with that type code are allowed (except that nil is allowed too). 5369 string as a comment. */
5367 LNAME is the Lisp-level variable name. 5370
5368 VNAME is the name of the buffer slot. 5371#define DEFVAR_PER_BUFFER(lname, vname, predicate, doc) \
5369 DOC is a dummy where you write the doc string as a comment. */ 5372 do { \
5370#define DEFVAR_PER_BUFFER(lname, vname, type, doc) \ 5373 static struct Lisp_Buffer_Objfwd bo_fwd; \
5371 do { \ 5374 defvar_per_buffer (&bo_fwd, lname, vname, predicate); \
5372 static struct Lisp_Buffer_Objfwd bo_fwd; \
5373 defvar_per_buffer (&bo_fwd, lname, vname, type); \
5374 } while (0) 5375 } while (0)
5375 5376
5376static void 5377static void
5377defvar_per_buffer (struct Lisp_Buffer_Objfwd *bo_fwd, const char *namestring, 5378defvar_per_buffer (struct Lisp_Buffer_Objfwd *bo_fwd, const char *namestring,
5378 Lisp_Object *address, Lisp_Object type) 5379 Lisp_Object *address, Lisp_Object predicate)
5379{ 5380{
5380 struct Lisp_Symbol *sym; 5381 struct Lisp_Symbol *sym;
5381 int offset; 5382 int offset;
@@ -5385,7 +5386,7 @@ defvar_per_buffer (struct Lisp_Buffer_Objfwd *bo_fwd, const char *namestring,
5385 5386
5386 bo_fwd->type = Lisp_Fwd_Buffer_Obj; 5387 bo_fwd->type = Lisp_Fwd_Buffer_Obj;
5387 bo_fwd->offset = offset; 5388 bo_fwd->offset = offset;
5388 bo_fwd->slottype = type; 5389 bo_fwd->predicate = predicate;
5389 sym->declared_special = 1; 5390 sym->declared_special = 1;
5390 sym->redirect = SYMBOL_FORWARDED; 5391 sym->redirect = SYMBOL_FORWARDED;
5391 { 5392 {
@@ -5648,7 +5649,7 @@ Decimal digits after the % specify field width to which to pad. */);
5648 doc: /* Value of `major-mode' for new buffers. */); 5649 doc: /* Value of `major-mode' for new buffers. */);
5649 5650
5650 DEFVAR_PER_BUFFER ("major-mode", &BVAR (current_buffer, major_mode), 5651 DEFVAR_PER_BUFFER ("major-mode", &BVAR (current_buffer, major_mode),
5651 make_number (Lisp_Symbol), 5652 Qsymbolp,
5652 doc: /* Symbol for current buffer's major mode. 5653 doc: /* Symbol for current buffer's major mode.
5653The default value (normally `fundamental-mode') affects new buffers. 5654The default value (normally `fundamental-mode') affects new buffers.
5654A value of nil means to use the current buffer's major mode, provided 5655A value of nil means to use the current buffer's major mode, provided
@@ -5679,17 +5680,17 @@ Use the command `abbrev-mode' to change this variable. */);
5679 doc: /* Non-nil if searches and matches should ignore case. */); 5680 doc: /* Non-nil if searches and matches should ignore case. */);
5680 5681
5681 DEFVAR_PER_BUFFER ("fill-column", &BVAR (current_buffer, fill_column), 5682 DEFVAR_PER_BUFFER ("fill-column", &BVAR (current_buffer, fill_column),
5682 make_number (Lisp_Int0), 5683 Qintegerp,
5683 doc: /* Column beyond which automatic line-wrapping should happen. 5684 doc: /* Column beyond which automatic line-wrapping should happen.
5684Interactively, you can set the buffer local value using \\[set-fill-column]. */); 5685Interactively, you can set the buffer local value using \\[set-fill-column]. */);
5685 5686
5686 DEFVAR_PER_BUFFER ("left-margin", &BVAR (current_buffer, left_margin), 5687 DEFVAR_PER_BUFFER ("left-margin", &BVAR (current_buffer, left_margin),
5687 make_number (Lisp_Int0), 5688 Qintegerp,
5688 doc: /* Column for the default `indent-line-function' to indent to. 5689 doc: /* Column for the default `indent-line-function' to indent to.
5689Linefeed indents to this column in Fundamental mode. */); 5690Linefeed indents to this column in Fundamental mode. */);
5690 5691
5691 DEFVAR_PER_BUFFER ("tab-width", &BVAR (current_buffer, tab_width), 5692 DEFVAR_PER_BUFFER ("tab-width", &BVAR (current_buffer, tab_width),
5692 make_number (Lisp_Int0), 5693 Qintegerp,
5693 doc: /* Distance between tab stops (for display of tab characters), in columns. 5694 doc: /* Distance between tab stops (for display of tab characters), in columns.
5694This should be an integer greater than zero. */); 5695This should be an integer greater than zero. */);
5695 5696
@@ -5774,7 +5775,7 @@ visual lines rather than logical lines. See the documentation of
5774`visual-line-mode'. */); 5775`visual-line-mode'. */);
5775 5776
5776 DEFVAR_PER_BUFFER ("default-directory", &BVAR (current_buffer, directory), 5777 DEFVAR_PER_BUFFER ("default-directory", &BVAR (current_buffer, directory),
5777 make_number (Lisp_String), 5778 Qstringp,
5778 doc: /* Name of default directory of current buffer. Should end with slash. 5779 doc: /* Name of default directory of current buffer. Should end with slash.
5779To interactively change the default directory, use command `cd'. */); 5780To interactively change the default directory, use command `cd'. */);
5780 5781
@@ -5787,18 +5788,18 @@ NOTE: This variable is not a hook;
5787its value may not be a list of functions. */); 5788its value may not be a list of functions. */);
5788 5789
5789 DEFVAR_PER_BUFFER ("buffer-file-name", &BVAR (current_buffer, filename), 5790 DEFVAR_PER_BUFFER ("buffer-file-name", &BVAR (current_buffer, filename),
5790 make_number (Lisp_String), 5791 Qstringp,
5791 doc: /* Name of file visited in current buffer, or nil if not visiting a file. */); 5792 doc: /* Name of file visited in current buffer, or nil if not visiting a file. */);
5792 5793
5793 DEFVAR_PER_BUFFER ("buffer-file-truename", &BVAR (current_buffer, file_truename), 5794 DEFVAR_PER_BUFFER ("buffer-file-truename", &BVAR (current_buffer, file_truename),
5794 make_number (Lisp_String), 5795 Qstringp,
5795 doc: /* Abbreviated truename of file visited in current buffer, or nil if none. 5796 doc: /* Abbreviated truename of file visited in current buffer, or nil if none.
5796The truename of a file is calculated by `file-truename' 5797The truename of a file is calculated by `file-truename'
5797and then abbreviated with `abbreviate-file-name'. */); 5798and then abbreviated with `abbreviate-file-name'. */);
5798 5799
5799 DEFVAR_PER_BUFFER ("buffer-auto-save-file-name", 5800 DEFVAR_PER_BUFFER ("buffer-auto-save-file-name",
5800 &BVAR (current_buffer, auto_save_file_name), 5801 &BVAR (current_buffer, auto_save_file_name),
5801 make_number (Lisp_String), 5802 Qstringp,
5802 doc: /* Name of file for auto-saving current buffer. 5803 doc: /* Name of file for auto-saving current buffer.
5803If it is nil, that means don't auto-save this buffer. */); 5804If it is nil, that means don't auto-save this buffer. */);
5804 5805
@@ -5810,7 +5811,7 @@ If it is nil, that means don't auto-save this buffer. */);
5810Backing up is done before the first time the file is saved. */); 5811Backing up is done before the first time the file is saved. */);
5811 5812
5812 DEFVAR_PER_BUFFER ("buffer-saved-size", &BVAR (current_buffer, save_length), 5813 DEFVAR_PER_BUFFER ("buffer-saved-size", &BVAR (current_buffer, save_length),
5813 make_number (Lisp_Int0), 5814 Qintegerp,
5814 doc: /* Length of current buffer when last read in, saved or auto-saved. 5815 doc: /* Length of current buffer when last read in, saved or auto-saved.
58150 initially. 58160 initially.
5816-1 means auto-saving turned off until next real save. 5817-1 means auto-saving turned off until next real save.
@@ -5880,23 +5881,23 @@ In addition, a char-table has six extra slots to control the display of:
5880See also the functions `display-table-slot' and `set-display-table-slot'. */); 5881See also the functions `display-table-slot' and `set-display-table-slot'. */);
5881 5882
5882 DEFVAR_PER_BUFFER ("left-margin-width", &BVAR (current_buffer, left_margin_cols), 5883 DEFVAR_PER_BUFFER ("left-margin-width", &BVAR (current_buffer, left_margin_cols),
5883 Qnil, 5884 Qintegerp,
5884 doc: /* Width of left marginal area for display of a buffer. 5885 doc: /* Width of left marginal area for display of a buffer.
5885A value of nil means no marginal area. */); 5886A value of nil means no marginal area. */);
5886 5887
5887 DEFVAR_PER_BUFFER ("right-margin-width", &BVAR (current_buffer, right_margin_cols), 5888 DEFVAR_PER_BUFFER ("right-margin-width", &BVAR (current_buffer, right_margin_cols),
5888 Qnil, 5889 Qintegerp,
5889 doc: /* Width of right marginal area for display of a buffer. 5890 doc: /* Width of right marginal area for display of a buffer.
5890A value of nil means no marginal area. */); 5891A value of nil means no marginal area. */);
5891 5892
5892 DEFVAR_PER_BUFFER ("left-fringe-width", &BVAR (current_buffer, left_fringe_width), 5893 DEFVAR_PER_BUFFER ("left-fringe-width", &BVAR (current_buffer, left_fringe_width),
5893 Qnil, 5894 Qintegerp,
5894 doc: /* Width of this buffer's left fringe (in pixels). 5895 doc: /* Width of this buffer's left fringe (in pixels).
5895A value of 0 means no left fringe is shown in this buffer's window. 5896A value of 0 means no left fringe is shown in this buffer's window.
5896A value of nil means to use the left fringe width from the window's frame. */); 5897A value of nil means to use the left fringe width from the window's frame. */);
5897 5898
5898 DEFVAR_PER_BUFFER ("right-fringe-width", &BVAR (current_buffer, right_fringe_width), 5899 DEFVAR_PER_BUFFER ("right-fringe-width", &BVAR (current_buffer, right_fringe_width),
5899 Qnil, 5900 Qintegerp,
5900 doc: /* Width of this buffer's right fringe (in pixels). 5901 doc: /* Width of this buffer's right fringe (in pixels).
5901A value of 0 means no right fringe is shown in this buffer's window. 5902A value of 0 means no right fringe is shown in this buffer's window.
5902A value of nil means to use the right fringe width from the window's frame. */); 5903A value of nil means to use the right fringe width from the window's frame. */);
@@ -5907,7 +5908,7 @@ A value of nil means to use the right fringe width from the window's frame. */)
5907A value of nil means to display fringes between margins and buffer text. */); 5908A value of nil means to display fringes between margins and buffer text. */);
5908 5909
5909 DEFVAR_PER_BUFFER ("scroll-bar-width", &BVAR (current_buffer, scroll_bar_width), 5910 DEFVAR_PER_BUFFER ("scroll-bar-width", &BVAR (current_buffer, scroll_bar_width),
5910 Qnil, 5911 Qintegerp,
5911 doc: /* Width of this buffer's scroll bars in pixels. 5912 doc: /* Width of this buffer's scroll bars in pixels.
5912A value of nil means to use the scroll bar width from the window's frame. */); 5913A value of nil means to use the scroll bar width from the window's frame. */);
5913 5914
@@ -5987,7 +5988,7 @@ BITMAP is the corresponding fringe bitmap shown for the logical
5987cursor type. */); 5988cursor type. */);
5988 5989
5989 DEFVAR_PER_BUFFER ("scroll-up-aggressively", 5990 DEFVAR_PER_BUFFER ("scroll-up-aggressively",
5990 &BVAR (current_buffer, scroll_up_aggressively), Qnil, 5991 &BVAR (current_buffer, scroll_up_aggressively), Qfloatp,
5991 doc: /* How far to scroll windows upward. 5992 doc: /* How far to scroll windows upward.
5992If you move point off the bottom, the window scrolls automatically. 5993If you move point off the bottom, the window scrolls automatically.
5993This variable controls how far it scrolls. The value nil, the default, 5994This variable controls how far it scrolls. The value nil, the default,
@@ -6000,7 +6001,7 @@ window scrolls by a full window height. Meaningful values are
6000between 0.0 and 1.0, inclusive. */); 6001between 0.0 and 1.0, inclusive. */);
6001 6002
6002 DEFVAR_PER_BUFFER ("scroll-down-aggressively", 6003 DEFVAR_PER_BUFFER ("scroll-down-aggressively",
6003 &BVAR (current_buffer, scroll_down_aggressively), Qnil, 6004 &BVAR (current_buffer, scroll_down_aggressively), Qfloatp,
6004 doc: /* How far to scroll windows downward. 6005 doc: /* How far to scroll windows downward.
6005If you move point off the top, the window scrolls automatically. 6006If you move point off the top, the window scrolls automatically.
6006This variable controls how far it scrolls. The value nil, the default, 6007This variable controls how far it scrolls. The value nil, the default,
@@ -6012,10 +6013,6 @@ simple case that you moved off with C-b means scrolling just one line.
6012window scrolls by a full window height. Meaningful values are 6013window scrolls by a full window height. Meaningful values are
6013between 0.0 and 1.0, inclusive. */); 6014between 0.0 and 1.0, inclusive. */);
6014 6015
6015/*DEFVAR_LISP ("debug-check-symbol", &Vcheck_symbol,
6016 "Don't ask.");
6017*/
6018
6019 DEFVAR_LISP ("before-change-functions", Vbefore_change_functions, 6016 DEFVAR_LISP ("before-change-functions", Vbefore_change_functions,
6020 doc: /* List of functions to call before each text change. 6017 doc: /* List of functions to call before each text change.
6021Two arguments are passed to each function: the positions of 6018Two arguments are passed to each function: the positions of
@@ -6154,7 +6151,7 @@ then characters with property value PROP are invisible,
6154and they have an ellipsis as well if ELLIPSIS is non-nil. */); 6151and they have an ellipsis as well if ELLIPSIS is non-nil. */);
6155 6152
6156 DEFVAR_PER_BUFFER ("buffer-display-count", 6153 DEFVAR_PER_BUFFER ("buffer-display-count",
6157 &BVAR (current_buffer, display_count), Qnil, 6154 &BVAR (current_buffer, display_count), Qintegerp,
6158 doc: /* A number incremented each time this buffer is displayed in a window. 6155 doc: /* A number incremented each time this buffer is displayed in a window.
6159The function `set-window-buffer' increments it. */); 6156The function `set-window-buffer' increments it. */);
6160 6157
@@ -6213,7 +6210,7 @@ cursor's appearance is instead controlled by the variable
6213`cursor-in-non-selected-windows'. */); 6210`cursor-in-non-selected-windows'. */);
6214 6211
6215 DEFVAR_PER_BUFFER ("line-spacing", 6212 DEFVAR_PER_BUFFER ("line-spacing",
6216 &BVAR (current_buffer, extra_line_spacing), Qnil, 6213 &BVAR (current_buffer, extra_line_spacing), Qnumberp,
6217 doc: /* Additional space to put between lines when displaying a buffer. 6214 doc: /* Additional space to put between lines when displaying a buffer.
6218The space is measured in pixels, and put below lines on graphic displays, 6215The space is measured in pixels, and put below lines on graphic displays,
6219see `display-graphic-p'. 6216see `display-graphic-p'.