Mercurial > hg > xemacs-beta
comparison src/buffer.c @ 5495:1f0b15040456
Merge.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Sun, 01 May 2011 18:44:03 +0100 |
parents | 4dee0387b9de |
children | 56144c8593a8 |
comparison
equal
deleted
inserted
replaced
5494:861f2601a38b | 5495:1f0b15040456 |
---|---|
1 /* Buffer manipulation primitives for XEmacs. | 1 /* Buffer manipulation primitives for XEmacs. |
2 Copyright (C) 1985-1989, 1992-1995 Free Software Foundation, Inc. | 2 Copyright (C) 1985-1989, 1992-1995 Free Software Foundation, Inc. |
3 Copyright (C) 1995 Sun Microsystems, Inc. | 3 Copyright (C) 1995 Sun Microsystems, Inc. |
4 Copyright (C) 1995, 1996, 2000, 2001, 2002, 2004 Ben Wing. | 4 Copyright (C) 1995, 1996, 2000, 2001, 2002, 2004, 2010 Ben Wing. |
5 | 5 |
6 This file is part of XEmacs. | 6 This file is part of XEmacs. |
7 | 7 |
8 XEmacs is free software; you can redistribute it and/or modify it | 8 XEmacs is free software: you can redistribute it and/or modify it |
9 under the terms of the GNU General Public License as published by the | 9 under the terms of the GNU General Public License as published by the |
10 Free Software Foundation; either version 2, or (at your option) any | 10 Free Software Foundation, either version 3 of the License, or (at your |
11 later version. | 11 option) any later version. |
12 | 12 |
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT | 13 XEmacs is distributed in the hope that it will be useful, but WITHOUT |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | 14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | 15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
16 for more details. | 16 for more details. |
17 | 17 |
18 You should have received a copy of the GNU General Public License | 18 You should have received a copy of the GNU General Public License |
19 along with XEmacs; see the file COPYING. If not, write to | 19 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */ |
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
21 Boston, MA 02111-1307, USA. */ | |
22 | 20 |
23 /* Synched up with: Mule 2.0, FSF 19.30. */ | 21 /* Synched up with: Mule 2.0, FSF 19.30. */ |
24 | 22 |
25 /* Authorship: | 23 /* Authorship: |
26 | 24 |
28 Some changes by Jamie Zawinski, c. 1991-1994 (e.g. separate buffer | 26 Some changes by Jamie Zawinski, c. 1991-1994 (e.g. separate buffer |
29 list per frame, buffer slots). | 27 list per frame, buffer slots). |
30 A few changes for buffer-local vars by Richard Mlynarik for | 28 A few changes for buffer-local vars by Richard Mlynarik for |
31 19.8 or 19.9, c. 1993. | 29 19.8 or 19.9, c. 1993. |
32 Many changes by Ben Wing: changes and cleanups for Mule, esp. the | 30 Many changes by Ben Wing: changes and cleanups for Mule, esp. the |
33 macros in buffer.h and the intial version of the coding-system | 31 macros in buffer.h and the initial version of the coding-system |
34 conversion macros (in buffer.h) and associated fns. (in this file), | 32 conversion macros (in buffer.h) and associated fns. (in this file), |
35 19.12 (c. 1995); synch. to FSF 19.30 c. 1994; memory usage stats | 33 19.12 (c. 1995); synch. to FSF 19.30 c. 1994; memory usage stats |
36 c. 1996; generated-modeline-string c. 1996 for mousable modeline in | 34 c. 1996; generated-modeline-string c. 1996 for mousable modeline in |
37 19.14. | 35 19.14. |
38 Indirect buffer code by Hrvoje Niksic, c. 1997? | 36 Indirect buffer code by Hrvoje Niksic, c. 1997? |
232 { XD_LISP_OBJECT, offsetof (struct buffer_text, line_number_cache) }, | 230 { XD_LISP_OBJECT, offsetof (struct buffer_text, line_number_cache) }, |
233 { XD_END } | 231 { XD_END } |
234 }; | 232 }; |
235 | 233 |
236 #ifdef NEW_GC | 234 #ifdef NEW_GC |
237 DEFINE_LRECORD_IMPLEMENTATION ("buffer-text", buffer_text, | 235 DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT ("buffer-text", buffer_text, |
238 1, /*dumpable-flag*/ | 236 0, buffer_text_description_1, |
239 0, 0, 0, 0, 0, | 237 Lisp_Buffer_Text); |
240 buffer_text_description_1, | |
241 Lisp_Buffer_Text); | |
242 #endif /* NEW_GC */ | 238 #endif /* NEW_GC */ |
243 | 239 |
244 static const struct sized_memory_description buffer_text_description = { | 240 static const struct sized_memory_description buffer_text_description = { |
245 sizeof (struct buffer_text), | 241 sizeof (struct buffer_text), |
246 buffer_text_description_1 | 242 buffer_text_description_1 |
302 struct buffer *b = XBUFFER (obj); | 298 struct buffer *b = XBUFFER (obj); |
303 | 299 |
304 if (print_readably) | 300 if (print_readably) |
305 { | 301 { |
306 if (!BUFFER_LIVE_P (b)) | 302 if (!BUFFER_LIVE_P (b)) |
307 printing_unreadable_object ("#<killed buffer>"); | 303 printing_unreadable_object_fmt ("#<killed buffer>"); |
308 else | 304 else |
309 printing_unreadable_object ("#<buffer %s>", XSTRING_DATA (b->name)); | 305 printing_unreadable_object_fmt ("#<buffer %s>", XSTRING_DATA (b->name)); |
310 } | 306 } |
311 else if (!BUFFER_LIVE_P (b)) | 307 else if (!BUFFER_LIVE_P (b)) |
312 write_ascstring (printcharfun, "#<killed buffer>"); | 308 write_ascstring (printcharfun, "#<killed buffer>"); |
313 else if (escapeflag) | 309 else if (escapeflag) |
314 write_fmt_string_lisp (printcharfun, "#<buffer %S>", 1, b->name); | 310 write_fmt_string_lisp (printcharfun, "#<buffer %S>", 1, b->name); |
331 } | 327 } |
332 | 328 |
333 /* We do not need a finalize method to handle a buffer's children list | 329 /* We do not need a finalize method to handle a buffer's children list |
334 because all buffers have `kill-buffer' applied to them before | 330 because all buffers have `kill-buffer' applied to them before |
335 they disappear, and the children removal happens then. */ | 331 they disappear, and the children removal happens then. */ |
336 DEFINE_LRECORD_IMPLEMENTATION ("buffer", buffer, | 332 DEFINE_NODUMP_LISP_OBJECT ("buffer", buffer, mark_buffer, |
337 0, /*dumpable-flag*/ | 333 print_buffer, 0, 0, 0, |
338 mark_buffer, print_buffer, 0, 0, 0, | 334 buffer_description, |
339 buffer_description, | 335 struct buffer); |
340 struct buffer); | |
341 | 336 |
342 DEFUN ("bufferp", Fbufferp, 1, 1, 0, /* | 337 DEFUN ("bufferp", Fbufferp, 1, 1, 0, /* |
343 Return t if OBJECT is an editor buffer. | 338 Return t if OBJECT is an editor buffer. |
344 */ | 339 */ |
345 (object)) | 340 (object)) |
601 } | 596 } |
602 | 597 |
603 static struct buffer * | 598 static struct buffer * |
604 allocate_buffer (void) | 599 allocate_buffer (void) |
605 { | 600 { |
606 struct buffer *b = ALLOC_LCRECORD_TYPE (struct buffer, &lrecord_buffer); | 601 Lisp_Object obj = ALLOC_NORMAL_LISP_OBJECT (buffer); |
607 | 602 |
608 COPY_LCRECORD (b, XBUFFER (Vbuffer_defaults)); | 603 copy_lisp_object (obj, Vbuffer_defaults); |
609 | 604 |
610 return b; | 605 return XBUFFER (obj); |
611 } | 606 } |
612 | 607 |
613 static Lisp_Object | 608 static Lisp_Object |
614 finish_init_buffer (struct buffer *b, Lisp_Object name) | 609 finish_init_buffer (struct buffer *b, Lisp_Object name) |
615 { | 610 { |
641 init_buffer_markers (b); | 636 init_buffer_markers (b); |
642 init_buffer_syntax_cache (b); | 637 init_buffer_syntax_cache (b); |
643 | 638 |
644 b->generated_modeline_string = Fmake_string (make_int (84), make_int (' ')); | 639 b->generated_modeline_string = Fmake_string (make_int (84), make_int (' ')); |
645 b->modeline_extent_table = make_lisp_hash_table (20, HASH_TABLE_KEY_WEAK, | 640 b->modeline_extent_table = make_lisp_hash_table (20, HASH_TABLE_KEY_WEAK, |
646 HASH_TABLE_EQ); | 641 Qeq); |
647 | 642 |
648 | 643 |
649 return buf; | 644 return buf; |
650 } | 645 } |
651 | 646 |
1753 | 1748 |
1754 #ifdef MEMORY_USAGE_STATS | 1749 #ifdef MEMORY_USAGE_STATS |
1755 | 1750 |
1756 struct buffer_stats | 1751 struct buffer_stats |
1757 { | 1752 { |
1758 int text; | 1753 struct usage_stats u; |
1759 int markers; | 1754 Bytecount text; |
1760 int extents; | 1755 /* Ancillary Lisp */ |
1761 int other; | 1756 Bytecount markers; |
1757 Bytecount extents; | |
1762 }; | 1758 }; |
1763 | 1759 |
1764 static Bytecount | 1760 static Bytecount |
1765 compute_buffer_text_usage (struct buffer *b, struct overhead_stats *ovstats) | 1761 compute_buffer_text_usage (struct buffer *b, struct usage_stats *ustats) |
1766 { | 1762 { |
1767 int was_requested = b->text->z - 1; | 1763 Bytecount was_requested, gap, malloc_use; |
1768 Bytecount gap = b->text->gap_size + b->text->end_gap_size; | 1764 |
1769 Bytecount malloc_use = malloced_storage_size (b->text->beg, was_requested + gap, 0); | 1765 /* Killed buffer? */ |
1770 | 1766 if (!b->text) |
1771 ovstats->gap_overhead += gap; | 1767 return 0; |
1772 ovstats->was_requested += was_requested; | 1768 |
1773 ovstats->malloc_overhead += malloc_use - (was_requested + gap); | 1769 /* Indirect buffer shares its text with someone else, so don't double- |
1770 count the text */ | |
1771 if (b->base_buffer) | |
1772 return 0; | |
1773 | |
1774 was_requested = b->text->z - 1; | |
1775 gap = b->text->gap_size + b->text->end_gap_size; | |
1776 malloc_use = malloced_storage_size (b->text->beg, was_requested + gap, 0); | |
1777 | |
1778 ustats->gap_overhead += gap; | |
1779 ustats->was_requested += was_requested; | |
1780 ustats->malloc_overhead += malloc_use - (was_requested + gap); | |
1774 return malloc_use; | 1781 return malloc_use; |
1775 } | 1782 } |
1776 | 1783 |
1777 static void | 1784 static void |
1778 compute_buffer_usage (struct buffer *b, struct buffer_stats *stats, | 1785 compute_buffer_usage (struct buffer *b, struct buffer_stats *stats, |
1779 struct overhead_stats *ovstats) | 1786 struct usage_stats *ustats) |
1780 { | 1787 { |
1781 xzero (*stats); | 1788 stats->text += compute_buffer_text_usage (b, ustats); |
1782 stats->other += LISPOBJ_STORAGE_SIZE (b, sizeof (*b), ovstats); | 1789 stats->markers += compute_buffer_marker_usage (b); |
1783 stats->text += compute_buffer_text_usage (b, ovstats); | 1790 stats->extents += compute_buffer_extent_usage (b); |
1784 stats->markers += compute_buffer_marker_usage (b, ovstats); | 1791 } |
1785 stats->extents += compute_buffer_extent_usage (b, ovstats); | 1792 |
1786 } | 1793 static void |
1787 | 1794 buffer_memory_usage (Lisp_Object buffer, struct generic_usage_stats *gustats) |
1788 DEFUN ("buffer-memory-usage", Fbuffer_memory_usage, 1, 1, 0, /* | 1795 { |
1789 Return stats about the memory usage of buffer BUFFER. | 1796 struct buffer_stats *stats = (struct buffer_stats *) gustats; |
1790 The values returned are in the form of an alist of usage types and byte | 1797 |
1791 counts. The byte counts attempt to encompass all the memory used | 1798 compute_buffer_usage (XBUFFER (buffer), stats, &stats->u); |
1792 by the buffer (separate from the memory logically associated with a | |
1793 buffer or frame), including internal structures and any malloc() | |
1794 overhead associated with them. In practice, the byte counts are | |
1795 underestimated because certain memory usage is very hard to determine | |
1796 \(e.g. the amount of memory used inside the Xt library or inside the | |
1797 X server) and because there is other stuff that might logically | |
1798 be associated with a window, buffer, or frame (e.g. window configurations, | |
1799 glyphs) but should not obviously be included in the usage counts. | |
1800 | |
1801 Multiple slices of the total memory usage may be returned, separated | |
1802 by a nil. Each slice represents a particular view of the memory, a | |
1803 particular way of partitioning it into groups. Within a slice, there | |
1804 is no overlap between the groups of memory, and each slice collectively | |
1805 represents all the memory concerned. | |
1806 */ | |
1807 (buffer)) | |
1808 { | |
1809 struct buffer_stats stats; | |
1810 struct overhead_stats ovstats; | |
1811 Lisp_Object val = Qnil; | |
1812 | |
1813 CHECK_BUFFER (buffer); /* dead buffers should be allowed, no? */ | |
1814 xzero (ovstats); | |
1815 compute_buffer_usage (XBUFFER (buffer), &stats, &ovstats); | |
1816 | |
1817 val = acons (Qtext, make_int (stats.text), val); | |
1818 val = acons (Qmarkers, make_int (stats.markers), val); | |
1819 val = acons (Qextents, make_int (stats.extents), val); | |
1820 val = acons (Qother, make_int (stats.other), val); | |
1821 val = Fcons (Qnil, val); | |
1822 val = acons (Qactually_requested, make_int (ovstats.was_requested), val); | |
1823 val = acons (Qmalloc_overhead, make_int (ovstats.malloc_overhead), val); | |
1824 val = acons (Qgap_overhead, make_int (ovstats.gap_overhead), val); | |
1825 val = acons (Qdynarr_overhead, make_int (ovstats.dynarr_overhead), val); | |
1826 | |
1827 return Fnreverse (val); | |
1828 } | 1799 } |
1829 | 1800 |
1830 #endif /* MEMORY_USAGE_STATS */ | 1801 #endif /* MEMORY_USAGE_STATS */ |
1831 | 1802 |
1832 #if defined (DEBUG_XEMACS) && defined (MULE) | 1803 #if defined (DEBUG_XEMACS) && defined (MULE) |
1844 CHECK_BUFFER (buffer); /* dead buffers should be allowed, no? */ | 1815 CHECK_BUFFER (buffer); /* dead buffers should be allowed, no? */ |
1845 b = XBUFFER (buffer); | 1816 b = XBUFFER (buffer); |
1846 | 1817 |
1847 #define ADD_INT(field) \ | 1818 #define ADD_INT(field) \ |
1848 plist = cons3 (make_int (b->text->field), \ | 1819 plist = cons3 (make_int (b->text->field), \ |
1849 intern_converting_underscores_to_dashes (#field), plist) | 1820 intern_massaging_name (#field), plist) |
1850 #define ADD_BOOL(field) \ | 1821 #define ADD_BOOL(field) \ |
1851 plist = cons3 (b->text->field ? Qt : Qnil, \ | 1822 plist = cons3 (b->text->field ? Qt : Qnil, \ |
1852 intern_converting_underscores_to_dashes (#field), plist) | 1823 intern_massaging_name (#field), plist) |
1853 ADD_INT (bufz); | 1824 ADD_INT (bufz); |
1854 ADD_INT (z); | 1825 ADD_INT (z); |
1855 #ifdef OLD_BYTE_CHAR | 1826 #ifdef OLD_BYTE_CHAR |
1856 ADD_INT (mule_bufmin); | 1827 ADD_INT (mule_bufmin); |
1857 ADD_INT (mule_bufmax); | 1828 ADD_INT (mule_bufmax); |
1906 #endif /* defined (DEBUG_XEMACS) && defined (MULE) */ | 1877 #endif /* defined (DEBUG_XEMACS) && defined (MULE) */ |
1907 | 1878 |
1908 | 1879 |
1909 | 1880 |
1910 void | 1881 void |
1882 buffer_objects_create (void) | |
1883 { | |
1884 #ifdef MEMORY_USAGE_STATS | |
1885 OBJECT_HAS_METHOD (buffer, memory_usage); | |
1886 #endif | |
1887 } | |
1888 | |
1889 void | |
1911 syms_of_buffer (void) | 1890 syms_of_buffer (void) |
1912 { | 1891 { |
1913 INIT_LRECORD_IMPLEMENTATION (buffer); | 1892 INIT_LISP_OBJECT (buffer); |
1914 #ifdef NEW_GC | 1893 #ifdef NEW_GC |
1915 INIT_LRECORD_IMPLEMENTATION (buffer_text); | 1894 INIT_LISP_OBJECT (buffer_text); |
1916 #endif /* NEW_GC */ | 1895 #endif /* NEW_GC */ |
1917 | 1896 |
1918 DEFSYMBOL (Qbuffer_live_p); | 1897 DEFSYMBOL (Qbuffer_live_p); |
1919 DEFSYMBOL (Qbuffer_or_string_p); | 1898 DEFSYMBOL (Qbuffer_or_string_p); |
1920 DEFSYMBOL (Qmode_class); | 1899 DEFSYMBOL (Qmode_class); |
1970 DEFSUBR (Fcurrent_buffer); | 1949 DEFSUBR (Fcurrent_buffer); |
1971 DEFSUBR (Fset_buffer); | 1950 DEFSUBR (Fset_buffer); |
1972 DEFSUBR (Fbarf_if_buffer_read_only); | 1951 DEFSUBR (Fbarf_if_buffer_read_only); |
1973 DEFSUBR (Fbury_buffer); | 1952 DEFSUBR (Fbury_buffer); |
1974 DEFSUBR (Fkill_all_local_variables); | 1953 DEFSUBR (Fkill_all_local_variables); |
1975 #ifdef MEMORY_USAGE_STATS | |
1976 DEFSUBR (Fbuffer_memory_usage); | |
1977 #endif | |
1978 #if defined (DEBUG_XEMACS) && defined (MULE) | 1954 #if defined (DEBUG_XEMACS) && defined (MULE) |
1979 DEFSUBR (Fbuffer_char_byte_converion_info); | 1955 DEFSUBR (Fbuffer_char_byte_converion_info); |
1980 DEFSUBR (Fstring_char_byte_converion_info); | 1956 DEFSUBR (Fstring_char_byte_converion_info); |
1981 #endif | 1957 #endif |
1982 | 1958 |
1995 /* initialize the buffer routines */ | 1971 /* initialize the buffer routines */ |
1996 void | 1972 void |
1997 vars_of_buffer (void) | 1973 vars_of_buffer (void) |
1998 { | 1974 { |
1999 /* This function can GC */ | 1975 /* This function can GC */ |
1976 #ifdef MEMORY_USAGE_STATS | |
1977 OBJECT_HAS_PROPERTY | |
1978 (buffer, memusage_stats_list, list4 (Qtext, Qt, Qmarkers, Qextents)); | |
1979 #endif /* MEMORY_USAGE_STATS */ | |
1980 | |
2000 staticpro (&QSFundamental); | 1981 staticpro (&QSFundamental); |
2001 staticpro (&QSscratch); | 1982 staticpro (&QSscratch); |
2002 | 1983 |
2003 QSFundamental = build_ascstring ("Fundamental"); | 1984 QSFundamental = build_ascstring ("Fundamental"); |
2004 QSscratch = build_ascstring ("*scratch*"); | 1985 QSscratch = build_ascstring ("*scratch*"); |
2141 #ifdef NEW_GC | 2122 #ifdef NEW_GC |
2142 #define DEFVAR_BUFFER_LOCAL_1(lname, field_name, forward_type, magic_fun) \ | 2123 #define DEFVAR_BUFFER_LOCAL_1(lname, field_name, forward_type, magic_fun) \ |
2143 do \ | 2124 do \ |
2144 { \ | 2125 { \ |
2145 struct symbol_value_forward *I_hate_C = \ | 2126 struct symbol_value_forward *I_hate_C = \ |
2146 alloc_lrecord_type (struct symbol_value_forward, \ | 2127 XSYMBOL_VALUE_FORWARD (ALLOC_NORMAL_LISP_OBJECT (symbol_value_forward)); \ |
2147 &lrecord_symbol_value_forward); \ | 2128 /*mcpro ((Lisp_Object) I_hate_C);*/ \ |
2148 /*mcpro ((Lisp_Object) I_hate_C);*/ \ | |
2149 \ | 2129 \ |
2150 I_hate_C->magic.value = &(buffer_local_flags.field_name); \ | 2130 I_hate_C->magic.value = &(buffer_local_flags.field_name); \ |
2151 I_hate_C->magic.type = forward_type; \ | 2131 I_hate_C->magic.type = forward_type; \ |
2152 I_hate_C->magicfun = magic_fun; \ | 2132 I_hate_C->magicfun = magic_fun; \ |
2153 \ | 2133 \ |
2177 1, /* mark bit */ \ | 2157 1, /* mark bit */ \ |
2178 1, /* c_readonly bit */ \ | 2158 1, /* c_readonly bit */ \ |
2179 1 /* lisp_readonly bit */ \ | 2159 1 /* lisp_readonly bit */ \ |
2180 }, \ | 2160 }, \ |
2181 0, /* next */ \ | 2161 0, /* next */ \ |
2182 0, /* uid */ \ | |
2183 0 /* free */ \ | |
2184 }, \ | 2162 }, \ |
2185 &(buffer_local_flags.field_name), \ | 2163 &(buffer_local_flags.field_name), \ |
2186 forward_type \ | 2164 forward_type \ |
2187 }, \ | 2165 }, \ |
2188 magicfun \ | 2166 magicfun \ |
2217 DEFVAR_BUFFER_DEFAULTS_MAGIC (lname, field_name, 0) | 2195 DEFVAR_BUFFER_DEFAULTS_MAGIC (lname, field_name, 0) |
2218 | 2196 |
2219 static void | 2197 static void |
2220 nuke_all_buffer_slots (struct buffer *b, Lisp_Object zap) | 2198 nuke_all_buffer_slots (struct buffer *b, Lisp_Object zap) |
2221 { | 2199 { |
2222 ZERO_LCRECORD (b); | 2200 zero_nonsized_lisp_object (wrap_buffer (b)); |
2223 | 2201 |
2224 b->extent_info = Qnil; | 2202 b->extent_info = Qnil; |
2225 b->indirect_children = Qnil; | 2203 b->indirect_children = Qnil; |
2226 b->own_text.line_number_cache = Qnil; | 2204 b->own_text.line_number_cache = Qnil; |
2227 | 2205 |
2232 static void | 2210 static void |
2233 common_init_complex_vars_of_buffer (void) | 2211 common_init_complex_vars_of_buffer (void) |
2234 { | 2212 { |
2235 /* Make sure all markable slots in buffer_defaults | 2213 /* Make sure all markable slots in buffer_defaults |
2236 are initialized reasonably, so mark_buffer won't choke. */ | 2214 are initialized reasonably, so mark_buffer won't choke. */ |
2237 struct buffer *defs = ALLOC_LCRECORD_TYPE (struct buffer, &lrecord_buffer); | 2215 Lisp_Object defobj = ALLOC_NORMAL_LISP_OBJECT (buffer); |
2238 struct buffer *syms = ALLOC_LCRECORD_TYPE (struct buffer, &lrecord_buffer); | 2216 struct buffer *defs = XBUFFER (defobj); |
2217 Lisp_Object symobj = ALLOC_NORMAL_LISP_OBJECT (buffer); | |
2218 struct buffer *syms = XBUFFER (symobj); | |
2239 | 2219 |
2240 staticpro_nodump (&Vbuffer_defaults); | 2220 staticpro_nodump (&Vbuffer_defaults); |
2241 staticpro_nodump (&Vbuffer_local_symbols); | 2221 staticpro_nodump (&Vbuffer_local_symbols); |
2242 Vbuffer_defaults = wrap_buffer (defs); | 2222 Vbuffer_defaults = defobj; |
2243 Vbuffer_local_symbols = wrap_buffer (syms); | 2223 Vbuffer_local_symbols = symobj; |
2244 | 2224 |
2245 nuke_all_buffer_slots (syms, Qnil); | 2225 nuke_all_buffer_slots (syms, Qnil); |
2246 nuke_all_buffer_slots (defs, Qnil); | 2226 nuke_all_buffer_slots (defs, Qnil); |
2247 defs->text = &defs->own_text; | 2227 defs->text = &defs->own_text; |
2248 syms->text = &syms->own_text; | 2228 syms->text = &syms->own_text; |
2295 The local flag is a bit that is used in the buffer | 2275 The local flag is a bit that is used in the buffer |
2296 to say that it has its own local value for the slot. | 2276 to say that it has its own local value for the slot. |
2297 The local flag bits are in the local_var_flags slot of the | 2277 The local flag bits are in the local_var_flags slot of the |
2298 buffer. */ | 2278 buffer. */ |
2299 | 2279 |
2280 set_lheader_implementation ((struct lrecord_header *) | |
2281 &buffer_local_flags, &lrecord_buffer); | |
2300 nuke_all_buffer_slots (&buffer_local_flags, make_int (-2)); | 2282 nuke_all_buffer_slots (&buffer_local_flags, make_int (-2)); |
2301 buffer_local_flags.filename = always_local_no_default; | 2283 buffer_local_flags.filename = always_local_no_default; |
2302 buffer_local_flags.directory = always_local_no_default; | 2284 buffer_local_flags.directory = always_local_no_default; |
2303 buffer_local_flags.backed_up = always_local_no_default; | 2285 buffer_local_flags.backed_up = always_local_no_default; |
2304 buffer_local_flags.saved_size = always_local_no_default; | 2286 buffer_local_flags.saved_size = always_local_no_default; |
2321 buffer_local_flags.case_table = resettable; | 2303 buffer_local_flags.case_table = resettable; |
2322 buffer_local_flags.syntax_table = resettable; | 2304 buffer_local_flags.syntax_table = resettable; |
2323 #ifdef MULE | 2305 #ifdef MULE |
2324 buffer_local_flags.category_table = resettable; | 2306 buffer_local_flags.category_table = resettable; |
2325 #endif | 2307 #endif |
2308 buffer_local_flags.display_time = always_local_no_default; | |
2309 buffer_local_flags.display_count = make_int (0); | |
2326 | 2310 |
2327 buffer_local_flags.modeline_format = make_int (1<<0); | 2311 buffer_local_flags.modeline_format = make_int (1<<0); |
2328 buffer_local_flags.abbrev_mode = make_int (1<<1); | 2312 buffer_local_flags.abbrev_mode = make_int (1<<1); |
2329 buffer_local_flags.overwrite_mode = make_int (1<<2); | 2313 buffer_local_flags.overwrite_mode = make_int (1<<2); |
2330 buffer_local_flags.case_fold_search = make_int (1<<3); | 2314 buffer_local_flags.case_fold_search = make_int (1<<3); |
2814 List of formats to use when saving this buffer. | 2798 List of formats to use when saving this buffer. |
2815 Formats are defined by `format-alist'. This variable is | 2799 Formats are defined by `format-alist'. This variable is |
2816 set when a file is visited. Automatically local in all buffers. | 2800 set when a file is visited. Automatically local in all buffers. |
2817 */ ); | 2801 */ ); |
2818 | 2802 |
2803 DEFVAR_BUFFER_LOCAL ("buffer-display-count", display_count /* | |
2804 A number incremented each time this buffer is displayed in a window. | |
2805 The function `set-window-buffer' updates it. | |
2806 */ ); | |
2807 | |
2808 DEFVAR_BUFFER_LOCAL ("buffer-display-time", display_time /* | |
2809 Time stamp updated each time this buffer is displayed in a window. | |
2810 The function `set-window-buffer' updates this variable | |
2811 to the value obtained by calling `current-time'. | |
2812 If the buffer has never been shown in a window, the value is nil. | |
2813 */); | |
2814 | |
2819 DEFVAR_BUFFER_LOCAL_MAGIC ("buffer-invisibility-spec", invisibility_spec /* | 2815 DEFVAR_BUFFER_LOCAL_MAGIC ("buffer-invisibility-spec", invisibility_spec /* |
2820 Invisibility spec of this buffer. | 2816 Invisibility spec of this buffer. |
2821 The default is t, which means that text is invisible | 2817 The default is t, which means that text is invisible |
2822 if it has (or is covered by an extent with) a non-nil `invisible' property. | 2818 if it has (or is covered by an extent with) a non-nil `invisible' property. |
2823 If the value is a list, a text character is invisible if its `invisible' | 2819 If the value is a list, a text character is invisible if its `invisible' |
2869 | 2865 |
2870 /* Check for DEFVAR_BUFFER_LOCAL without initializing the corresponding | 2866 /* Check for DEFVAR_BUFFER_LOCAL without initializing the corresponding |
2871 slot of buffer_local_flags and vice-versa. Must be done after all | 2867 slot of buffer_local_flags and vice-versa. Must be done after all |
2872 DEFVAR_BUFFER_LOCAL() calls. */ | 2868 DEFVAR_BUFFER_LOCAL() calls. */ |
2873 #define MARKED_SLOT(slot) \ | 2869 #define MARKED_SLOT(slot) \ |
2874 if ((XINT (buffer_local_flags.slot) != -2 && \ | 2870 assert ((XINT (buffer_local_flags.slot) != -2 && \ |
2875 XINT (buffer_local_flags.slot) != -3) \ | 2871 XINT (buffer_local_flags.slot) != -3) \ |
2876 != !(NILP (XBUFFER (Vbuffer_local_symbols)->slot))) \ | 2872 == !(NILP (XBUFFER (Vbuffer_local_symbols)->slot))); |
2877 ABORT (); | |
2878 #include "bufslots.h" | 2873 #include "bufslots.h" |
2879 | 2874 |
2880 { | 2875 { |
2881 Lisp_Object scratch = Fget_buffer_create (QSscratch); | 2876 Lisp_Object scratch = Fget_buffer_create (QSscratch); |
2882 Fset_buffer (scratch); | 2877 Fset_buffer (scratch); |