comparison src/buffer.c @ 5118:e0db3c197671 ben-lisp-object

merge up to latest default branch, doesn't compile yet
author Ben Wing <ben@xemacs.org>
date Sat, 26 Dec 2009 21:18:49 -0600
parents 3742ea8250b5 b604d235f028
children d1247f3cc363
comparison
equal deleted inserted replaced
5117:3742ea8250b5 5118:e0db3c197671
231 static const struct memory_description buffer_text_description_1 [] = { 231 static const struct memory_description buffer_text_description_1 [] = {
232 { XD_LISP_OBJECT, offsetof (struct buffer_text, line_number_cache) }, 232 { XD_LISP_OBJECT, offsetof (struct buffer_text, line_number_cache) },
233 { XD_END } 233 { XD_END }
234 }; 234 };
235 235
236 #ifdef NEW_GC
237 DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT ("buffer-text", buffer_text,
238 0, buffer_text_description_1,
239 Lisp_Buffer_Text);
240 #endif /* NEW_GC */
241
236 static const struct sized_memory_description buffer_text_description = { 242 static const struct sized_memory_description buffer_text_description = {
237 sizeof (struct buffer_text), 243 sizeof (struct buffer_text),
238 buffer_text_description_1 244 buffer_text_description_1
239 }; 245 };
240 246
242 #define MARKED_SLOT(x) { XD_LISP_OBJECT, offsetof (struct buffer, x) }, 248 #define MARKED_SLOT(x) { XD_LISP_OBJECT, offsetof (struct buffer, x) },
243 #include "bufslots.h" 249 #include "bufslots.h"
244 250
245 { XD_LISP_OBJECT, offsetof (struct buffer, extent_info) }, 251 { XD_LISP_OBJECT, offsetof (struct buffer, extent_info) },
246 252
253 #ifdef NEW_GC
254 { XD_BLOCK_PTR, offsetof (struct buffer, text),
255 1, { &buffer_text_description } },
256 { XD_LISP_OBJECT, offsetof (struct buffer, syntax_cache) },
257 #else /* not NEW_GC */
247 { XD_BLOCK_PTR, offsetof (struct buffer, text), 258 { XD_BLOCK_PTR, offsetof (struct buffer, text),
248 1, { &buffer_text_description } }, 259 1, { &buffer_text_description } },
249 { XD_BLOCK_PTR, offsetof (struct buffer, syntax_cache), 260 { XD_BLOCK_PTR, offsetof (struct buffer, syntax_cache),
250 1, { &syntax_cache_description } }, 261 1, { &syntax_cache_description } },
262 #endif /* not NEW_GC */
251 263
252 { XD_LISP_OBJECT, offsetof (struct buffer, indirect_children) }, 264 { XD_LISP_OBJECT, offsetof (struct buffer, indirect_children) },
253 { XD_LISP_OBJECT, offsetof (struct buffer, base_buffer) }, 265 { XD_LISP_OBJECT, offsetof (struct buffer, base_buffer) },
254 { XD_END } 266 { XD_END }
255 }; 267 };
317 } 329 }
318 330
319 /* We do not need a finalize method to handle a buffer's children list 331 /* We do not need a finalize method to handle a buffer's children list
320 because all buffers have `kill-buffer' applied to them before 332 because all buffers have `kill-buffer' applied to them before
321 they disappear, and the children removal happens then. */ 333 they disappear, and the children removal happens then. */
322 DEFINE_NONDUMPABLE_LISP_OBJECT ("buffer", buffer, mark_buffer, 334 DEFINE_NODUMP_LISP_OBJECT ("buffer", buffer, mark_buffer,
323 print_buffer, 0, 0, 0, 335 print_buffer, 0, 0, 0,
324 buffer_description, 336 buffer_description,
325 struct buffer); 337 struct buffer);
326 338
327 DEFUN ("bufferp", Fbufferp, 1, 1, 0, /* 339 DEFUN ("bufferp", Fbufferp, 1, 1, 0, /*
1496 current_buffer = b; 1508 current_buffer = b;
1497 invalidate_current_column (); /* invalidate indentation cache */ 1509 invalidate_current_column (); /* invalidate indentation cache */
1498 1510
1499 if (old_buf) 1511 if (old_buf)
1500 { 1512 {
1513 /* synchronize window point */
1514 Lisp_Object current_window = Fselected_window (Qnil);
1515 if (!NILP (current_window)
1516 && EQ(Fwindow_buffer (current_window), wrap_buffer (old_buf)))
1517 Fset_window_point (current_window, make_int (BUF_PT (old_buf)));
1518
1501 /* Put the undo list back in the base buffer, so that it appears 1519 /* Put the undo list back in the base buffer, so that it appears
1502 that an indirect buffer shares the undo list of its base. */ 1520 that an indirect buffer shares the undo list of its base. */
1503 if (old_buf->base_buffer) 1521 if (old_buf->base_buffer)
1504 old_buf->base_buffer->undo_list = old_buf->undo_list; 1522 old_buf->base_buffer->undo_list = old_buf->undo_list;
1505 } 1523 }
1694 1712
1695 DEFUN ("kill-all-local-variables", Fkill_all_local_variables, 0, 0, 0, /* 1713 DEFUN ("kill-all-local-variables", Fkill_all_local_variables, 0, 0, 0, /*
1696 Switch to Fundamental mode by killing current buffer's local variables. 1714 Switch to Fundamental mode by killing current buffer's local variables.
1697 Most local variable bindings are eliminated so that the default values 1715 Most local variable bindings are eliminated so that the default values
1698 become effective once more. Also, the syntax table is set from 1716 become effective once more. Also, the syntax table is set from
1699 `standard-syntax-table', the category table is set from 1717 the standard syntax table, the category table is set from the
1700 `standard-category-table' (if support for Mule exists), local keymap is set 1718 standard category table (if support for Mule exists), local keymap is set
1701 to nil, the abbrev table is set from `fundamental-mode-abbrev-table', 1719 to nil, the abbrev table is set from `fundamental-mode-abbrev-table',
1702 and all specifier specifications whose locale is the current buffer 1720 and all specifier specifications whose locale is the current buffer
1703 are removed. This function also forces redisplay of the modeline. 1721 are removed. This function also forces redisplay of the modeline.
1704 1722
1705 Every function to select a new major mode starts by 1723 Every function to select a new major mode starts by
1887 1905
1888 void 1906 void
1889 syms_of_buffer (void) 1907 syms_of_buffer (void)
1890 { 1908 {
1891 INIT_LISP_OBJECT (buffer); 1909 INIT_LISP_OBJECT (buffer);
1910 #ifdef NEW_GC
1911 INIT_LISP_OBJECT (buffer_text);
1912 #endif /* NEW_GC */
1892 1913
1893 DEFSYMBOL (Qbuffer_live_p); 1914 DEFSYMBOL (Qbuffer_live_p);
1894 DEFSYMBOL (Qbuffer_or_string_p); 1915 DEFSYMBOL (Qbuffer_or_string_p);
1895 DEFSYMBOL (Qmode_class); 1916 DEFSYMBOL (Qmode_class);
1896 DEFSYMBOL (Qrename_auto_save_file); 1917 DEFSYMBOL (Qrename_auto_save_file);
2111 delete_auto_save_files = 1; 2132 delete_auto_save_files = 1;
2112 } 2133 }
2113 2134
2114 /* The docstrings for DEFVAR_* are recorded externally by make-docfile. */ 2135 /* The docstrings for DEFVAR_* are recorded externally by make-docfile. */
2115 2136
2116 #ifdef MC_ALLOC 2137 #ifdef NEW_GC
2117 #define DEFVAR_BUFFER_LOCAL_1(lname, field_name, forward_type, magic_fun) \ 2138 #define DEFVAR_BUFFER_LOCAL_1(lname, field_name, forward_type, magic_fun) \
2118 do \ 2139 do \
2119 { \ 2140 { \
2120 struct symbol_value_forward *I_hate_C = \ 2141 struct symbol_value_forward *I_hate_C = \
2121 alloc_lrecord_type (struct symbol_value_forward, \ 2142 alloc_lrecord_type (struct symbol_value_forward, \
2136 *((Lisp_Object *)(offset + (char *)XBUFFER (Vbuffer_local_symbols))) \ 2157 *((Lisp_Object *)(offset + (char *)XBUFFER (Vbuffer_local_symbols))) \
2137 = intern (lname); \ 2158 = intern (lname); \
2138 } \ 2159 } \
2139 } while (0) 2160 } while (0)
2140 2161
2141 #else /* not MC_ALLOC */ 2162 #else /* not NEW_GC */
2142 /* Renamed from DEFVAR_PER_BUFFER because FSFmacs D_P_B takes 2163 /* Renamed from DEFVAR_PER_BUFFER because FSFmacs D_P_B takes
2143 a bogus extra arg, which confuses an otherwise identical make-docfile.c */ 2164 a bogus extra arg, which confuses an otherwise identical make-docfile.c */
2144 #define DEFVAR_BUFFER_LOCAL_1(lname, field_name, forward_type, magicfun) \ 2165 #define DEFVAR_BUFFER_LOCAL_1(lname, field_name, forward_type, magicfun) \
2145 do { \ 2166 do { \
2146 static const struct symbol_value_forward I_hate_C = \ 2167 static const struct symbol_value_forward I_hate_C = \
2170 \ 2191 \
2171 *((Lisp_Object *)(offset + (char *)XBUFFER (Vbuffer_local_symbols))) \ 2192 *((Lisp_Object *)(offset + (char *)XBUFFER (Vbuffer_local_symbols))) \
2172 = intern (lname); \ 2193 = intern (lname); \
2173 } \ 2194 } \
2174 } while (0) 2195 } while (0)
2175 #endif /* not MC_ALLOC */ 2196 #endif /* not NEW_GC */
2176 2197
2177 #define DEFVAR_BUFFER_LOCAL_MAGIC(lname, field_name, magicfun) \ 2198 #define DEFVAR_BUFFER_LOCAL_MAGIC(lname, field_name, magicfun) \
2178 DEFVAR_BUFFER_LOCAL_1 (lname, field_name, \ 2199 DEFVAR_BUFFER_LOCAL_1 (lname, field_name, \
2179 SYMVAL_CURRENT_BUFFER_FORWARD, magicfun) 2200 SYMVAL_CURRENT_BUFFER_FORWARD, magicfun)
2180 #define DEFVAR_BUFFER_LOCAL(lname, field_name) \ 2201 #define DEFVAR_BUFFER_LOCAL(lname, field_name) \
2618 */ ); 2639 */ );
2619 2640
2620 DEFVAR_BUFFER_LOCAL ("buffer-file-name", filename /* 2641 DEFVAR_BUFFER_LOCAL ("buffer-file-name", filename /*
2621 Name of file visited in current buffer, or nil if not visiting a file. 2642 Name of file visited in current buffer, or nil if not visiting a file.
2622 Each buffer has its own value of this variable. 2643 Each buffer has its own value of this variable.
2644 Code that changes this variable must maintain the invariant
2645 `(equal buffer-file-truename (file-truename buffer-file-name))'.
2623 */ ); 2646 */ );
2624 2647
2625 #if 0 /* FSFmacs */ 2648 #if 0 /* FSFmacs */
2626 /* 2649 /*
2627 Abbreviated truename of file visited in current buffer, or nil if none. 2650 Abbreviated truename of file visited in current buffer, or nil if none.
2630 Each buffer has its own value of this variable. 2653 Each buffer has its own value of this variable.
2631 */ 2654 */
2632 #endif /* FSFmacs */ 2655 #endif /* FSFmacs */
2633 2656
2634 DEFVAR_BUFFER_LOCAL ("buffer-file-truename", file_truename /* 2657 DEFVAR_BUFFER_LOCAL ("buffer-file-truename", file_truename /*
2635 The real name of the file visited in the current buffer, 2658 The real name of the file visited in the current buffer, or nil if not
2636 or nil if not visiting a file. This is the result of passing 2659 visiting a file. This is the result of passing `buffer-file-name' to the
2637 buffer-file-name to the `file-truename' function. Every buffer has 2660 `file-truename' function. Every buffer has its own value of this variable.
2638 its own value of this variable. This variable is automatically 2661 Code that changes the file name associated with a buffer maintains the
2639 maintained by the functions that change the file name associated 2662 invariant `(equal buffer-file-truename (file-truename buffer-file-name))'.
2640 with a buffer.
2641 */ ); 2663 */ );
2642 2664
2643 DEFVAR_BUFFER_LOCAL ("buffer-auto-save-file-name", auto_save_file_name /* 2665 DEFVAR_BUFFER_LOCAL ("buffer-auto-save-file-name", auto_save_file_name /*
2644 Name of file for auto-saving current buffer, 2666 Name of file for auto-saving current buffer,
2645 or nil if buffer should not be auto-saved. 2667 or nil if buffer should not be auto-saved.
2908 #endif 2930 #endif
2909 if ((initial_directory = qxe_allocating_getcwd ()) == NULL) 2931 if ((initial_directory = qxe_allocating_getcwd ()) == NULL)
2910 { 2932 {
2911 Ibyte *errmess; 2933 Ibyte *errmess;
2912 GET_STRERROR (errmess, errno); 2934 GET_STRERROR (errmess, errno);
2913 fatal ("`getcwd' failed: %s\n", errmess); 2935 stderr_out ("`getcwd' failed: %s: changing default directory to %s\n",
2936 errmess, DEFAULT_DIRECTORY_FALLBACK);
2937
2938 if (qxe_chdir ((Ibyte *)DEFAULT_DIRECTORY_FALLBACK) < 0)
2939 {
2940 GET_STRERROR (errmess, errno);
2941
2942 fatal ("could not `chdir' to `%s': %s\n",
2943 DEFAULT_DIRECTORY_FALLBACK, errmess);
2944 }
2945
2946 initial_directory = qxe_allocating_getcwd();
2947 assert (initial_directory != NULL);
2914 } 2948 }
2915 2949
2916 /* Make sure pwd is DIRECTORY_SEP-terminated. 2950 /* Make sure pwd is DIRECTORY_SEP-terminated.
2917 Maybe this should really use some standard subroutine 2951 Maybe this should really use some standard subroutine
2918 whose definition is filename syntax dependent. */ 2952 whose definition is filename syntax dependent. */