Mercurial > emacs
comparison src/buffer.c @ 1001:c1ebe69206df
* buffer.c (syms_of_buffer): Call DEFVAR_PER_BUFFER with the new
TYPE argument.
* buffer.c (buffer_local_types): New variable.
(buffer_slot_type_mismatch): New function.
| author | Jim Blandy <jimb@redhat.com> |
|---|---|
| date | Wed, 19 Aug 1992 06:18:37 +0000 |
| parents | bb24f1180bb6 |
| children | 59fa7697bb14 |
comparison
equal
deleted
inserted
replaced
| 1000:67bfadf24043 | 1001:c1ebe69206df |
|---|---|
| 82 buffer-local. It is indexed and accessed in the same way as the above. */ | 82 buffer-local. It is indexed and accessed in the same way as the above. */ |
| 83 | 83 |
| 84 struct buffer buffer_local_symbols; | 84 struct buffer buffer_local_symbols; |
| 85 /* A Lisp_Object pointer to the above, used for staticpro */ | 85 /* A Lisp_Object pointer to the above, used for staticpro */ |
| 86 static Lisp_Object Vbuffer_local_symbols; | 86 static Lisp_Object Vbuffer_local_symbols; |
| 87 | |
| 88 /* This structure holds the required types for the values in the | |
| 89 buffer-local slots. If a slot contains Qnil, then the | |
| 90 corresponding buffer slot may contain a value of any type. If a | |
| 91 slot contains an integer, then prospective values' tags must be | |
| 92 equal to that integer. When a tag does not match, the function | |
| 93 buffer_slot_type_mismatch will signal an error. */ | |
| 94 struct buffer buffer_local_types; | |
| 87 | 95 |
| 88 /* Nonzero means don't allow modification of protected fields. */ | 96 /* Nonzero means don't allow modification of protected fields. */ |
| 89 | 97 |
| 90 int check_protected_fields; | 98 int check_protected_fields; |
| 91 | 99 |
| 1199 } | 1207 } |
| 1200 | 1208 |
| 1201 return collector; | 1209 return collector; |
| 1202 } | 1210 } |
| 1203 | 1211 |
| 1212 /* Somebody has tried to store NEWVAL into the buffer-local slot with | |
| 1213 offset XUINT (valcontents), and NEWVAL has an unacceptable type. */ | |
| 1214 void | |
| 1215 buffer_slot_type_mismatch (valcontents, newval) | |
| 1216 Lisp_Object valcontents, newval; | |
| 1217 { | |
| 1218 unsigned int offset = XUINT (valcontents); | |
| 1219 char *symbol_name = | |
| 1220 (XSYMBOL (*(Lisp_Object *)(offset + (char *)&buffer_local_symbols)) | |
| 1221 ->name->data); | |
| 1222 char *type_name; | |
| 1223 | |
| 1224 switch (XINT (*(Lisp_Object *)(offset + (char *)&buffer_local_types))) | |
| 1225 { | |
| 1226 case Lisp_Int: type_name = "integers"; break; | |
| 1227 case Lisp_String: type_name = "strings"; break; | |
| 1228 case Lisp_Marker: type_name = "markers"; break; | |
| 1229 case Lisp_Symbol: type_name = "symbols"; break; | |
| 1230 case Lisp_Cons: type_name = "lists"; break; | |
| 1231 case Lisp_Vector: type_name = "vector"; break; | |
| 1232 default: | |
| 1233 abort (); | |
| 1234 } | |
| 1235 | |
| 1236 error ("only %s should be stored in the buffer-local variable %s", | |
| 1237 type_name, symbol_name); | |
| 1238 } | |
| 1239 | |
| 1204 init_buffer_once () | 1240 init_buffer_once () |
| 1205 { | 1241 { |
| 1206 register Lisp_Object tem; | 1242 register Lisp_Object tem; |
| 1207 | 1243 |
| 1208 /* Make sure all markable slots in buffer_defaults | 1244 /* Make sure all markable slots in buffer_defaults |
| 1376 DEFVAR_LISP_NOPRO ("default-case-fold-search", | 1412 DEFVAR_LISP_NOPRO ("default-case-fold-search", |
| 1377 &buffer_defaults.case_fold_search, | 1413 &buffer_defaults.case_fold_search, |
| 1378 "Default value of `case-fold-search' for buffers that don't override it.\n\ | 1414 "Default value of `case-fold-search' for buffers that don't override it.\n\ |
| 1379 This is the same as (default-value 'case-fold-search)."); | 1415 This is the same as (default-value 'case-fold-search)."); |
| 1380 | 1416 |
| 1381 DEFVAR_PER_BUFFER ("mode-line-format", ¤t_buffer->mode_line_format, 0); | 1417 DEFVAR_PER_BUFFER ("mode-line-format", ¤t_buffer->mode_line_format, |
| 1418 Qnil, 0); | |
| 1382 | 1419 |
| 1383 /* This doc string is too long for cpp; cpp dies if it isn't in a comment. | 1420 /* This doc string is too long for cpp; cpp dies if it isn't in a comment. |
| 1384 But make-docfile finds it! | 1421 But make-docfile finds it! |
| 1385 DEFVAR_PER_BUFFER ("mode-line-format", ¤t_buffer->mode_line_format, | 1422 DEFVAR_PER_BUFFER ("mode-line-format", ¤t_buffer->mode_line_format, |
| 1386 "Template for displaying mode line for current buffer.\n\ | 1423 "Template for displaying mode line for current buffer.\n\ |
| 1413 DEFVAR_LISP_NOPRO ("default-major-mode", &buffer_defaults.major_mode, | 1450 DEFVAR_LISP_NOPRO ("default-major-mode", &buffer_defaults.major_mode, |
| 1414 "*Major mode for new buffers. Defaults to `fundamental-mode'.\n\ | 1451 "*Major mode for new buffers. Defaults to `fundamental-mode'.\n\ |
| 1415 nil here means use current buffer's major mode."); | 1452 nil here means use current buffer's major mode."); |
| 1416 | 1453 |
| 1417 DEFVAR_PER_BUFFER ("major-mode", ¤t_buffer->major_mode, | 1454 DEFVAR_PER_BUFFER ("major-mode", ¤t_buffer->major_mode, |
| 1455 make_number (Lisp_Symbol), | |
| 1418 "Symbol for current buffer's major mode."); | 1456 "Symbol for current buffer's major mode."); |
| 1419 | 1457 |
| 1420 DEFVAR_PER_BUFFER ("mode-name", ¤t_buffer->mode_name, | 1458 DEFVAR_PER_BUFFER ("mode-name", ¤t_buffer->mode_name, |
| 1459 make_number (Lisp_String), | |
| 1421 "Pretty name of current buffer's major mode (a string)."); | 1460 "Pretty name of current buffer's major mode (a string)."); |
| 1422 | 1461 |
| 1423 DEFVAR_PER_BUFFER ("abbrev-mode", ¤t_buffer->abbrev_mode, | 1462 DEFVAR_PER_BUFFER ("abbrev-mode", ¤t_buffer->abbrev_mode, Qnil, |
| 1424 "Non-nil turns on automatic expansion of abbrevs as they are inserted.\n\ | 1463 "Non-nil turns on automatic expansion of abbrevs as they are inserted.\n\ |
| 1425 Automatically becomes buffer-local when set in any fashion."); | 1464 Automatically becomes buffer-local when set in any fashion."); |
| 1426 | 1465 |
| 1427 DEFVAR_PER_BUFFER ("case-fold-search", ¤t_buffer->case_fold_search, | 1466 DEFVAR_PER_BUFFER ("case-fold-search", ¤t_buffer->case_fold_search, |
| 1467 Qnil, | |
| 1428 "*Non-nil if searches should ignore case.\n\ | 1468 "*Non-nil if searches should ignore case.\n\ |
| 1429 Automatically becomes buffer-local when set in any fashion."); | 1469 Automatically becomes buffer-local when set in any fashion."); |
| 1430 | 1470 |
| 1431 DEFVAR_PER_BUFFER ("fill-column", ¤t_buffer->fill_column, | 1471 DEFVAR_PER_BUFFER ("fill-column", ¤t_buffer->fill_column, |
| 1472 make_number (Lisp_Int), | |
| 1432 "*Column beyond which automatic line-wrapping should happen.\n\ | 1473 "*Column beyond which automatic line-wrapping should happen.\n\ |
| 1433 Automatically becomes buffer-local when set in any fashion."); | 1474 Automatically becomes buffer-local when set in any fashion."); |
| 1434 | 1475 |
| 1435 DEFVAR_PER_BUFFER ("left-margin", ¤t_buffer->left_margin, | 1476 DEFVAR_PER_BUFFER ("left-margin", ¤t_buffer->left_margin, |
| 1477 make_number (Lisp_Int), | |
| 1436 "*Column for the default indent-line-function to indent to.\n\ | 1478 "*Column for the default indent-line-function to indent to.\n\ |
| 1437 Linefeed indents to this column in Fundamental mode.\n\ | 1479 Linefeed indents to this column in Fundamental mode.\n\ |
| 1438 Automatically becomes buffer-local when set in any fashion."); | 1480 Automatically becomes buffer-local when set in any fashion."); |
| 1439 | 1481 |
| 1440 DEFVAR_PER_BUFFER ("tab-width", ¤t_buffer->tab_width, | 1482 DEFVAR_PER_BUFFER ("tab-width", ¤t_buffer->tab_width, |
| 1483 make_number (Lisp_Int), | |
| 1441 "*Distance between tab stops (for display of tab characters), in columns.\n\ | 1484 "*Distance between tab stops (for display of tab characters), in columns.\n\ |
| 1442 Automatically becomes buffer-local when set in any fashion."); | 1485 Automatically becomes buffer-local when set in any fashion."); |
| 1443 | 1486 |
| 1444 DEFVAR_PER_BUFFER ("ctl-arrow", ¤t_buffer->ctl_arrow, | 1487 DEFVAR_PER_BUFFER ("ctl-arrow", ¤t_buffer->ctl_arrow, Qnil, |
| 1445 "*Non-nil means display control chars with uparrow.\n\ | 1488 "*Non-nil means display control chars with uparrow.\n\ |
| 1446 Nil means use backslash and octal digits.\n\ | 1489 Nil means use backslash and octal digits.\n\ |
| 1447 Automatically becomes buffer-local when set in any fashion.\n\ | 1490 Automatically becomes buffer-local when set in any fashion.\n\ |
| 1448 This variable does not apply to characters whose display is specified\n\ | 1491 This variable does not apply to characters whose display is specified\n\ |
| 1449 in the current display table (if there is one)."); | 1492 in the current display table (if there is one)."); |
| 1450 | 1493 |
| 1451 DEFVAR_PER_BUFFER ("truncate-lines", ¤t_buffer->truncate_lines, | 1494 DEFVAR_PER_BUFFER ("truncate-lines", ¤t_buffer->truncate_lines, Qnil, |
| 1452 "*Non-nil means do not display continuation lines;\n\ | 1495 "*Non-nil means do not display continuation lines;\n\ |
| 1453 give each line of text one screen line.\n\ | 1496 give each line of text one screen line.\n\ |
| 1454 Automatically becomes buffer-local when set in any fashion.\n\ | 1497 Automatically becomes buffer-local when set in any fashion.\n\ |
| 1455 \n\ | 1498 \n\ |
| 1456 Note that this is overridden by the variable\n\ | 1499 Note that this is overridden by the variable\n\ |
| 1457 `truncate-partial-width-windows' if that variable is non-nil\n\ | 1500 `truncate-partial-width-windows' if that variable is non-nil\n\ |
| 1458 and this buffer is not full-frame width."); | 1501 and this buffer is not full-frame width."); |
| 1459 | 1502 |
| 1460 DEFVAR_PER_BUFFER ("default-directory", ¤t_buffer->directory, | 1503 DEFVAR_PER_BUFFER ("default-directory", ¤t_buffer->directory, |
| 1504 make_number (Lisp_String), | |
| 1461 "Name of default directory of current buffer. Should end with slash.\n\ | 1505 "Name of default directory of current buffer. Should end with slash.\n\ |
| 1462 Each buffer has its own value of this variable."); | 1506 Each buffer has its own value of this variable."); |
| 1463 | 1507 |
| 1464 DEFVAR_PER_BUFFER ("auto-fill-function", ¤t_buffer->auto_fill_function, | 1508 DEFVAR_PER_BUFFER ("auto-fill-function", ¤t_buffer->auto_fill_function, |
| 1509 Qnil, | |
| 1465 "Function called (if non-nil) to perform auto-fill.\n\ | 1510 "Function called (if non-nil) to perform auto-fill.\n\ |
| 1466 It is called after self-inserting a space at a column beyond `fill-column'.\n\ | 1511 It is called after self-inserting a space at a column beyond `fill-column'.\n\ |
| 1467 Each buffer has its own value of this variable.\n\ | 1512 Each buffer has its own value of this variable.\n\ |
| 1468 NOTE: This variable is not an ordinary hook;\n\ | 1513 NOTE: This variable is not an ordinary hook;\n\ |
| 1469 It may not be a list of functions."); | 1514 It may not be a list of functions."); |
| 1470 | 1515 |
| 1471 DEFVAR_PER_BUFFER ("buffer-file-name", ¤t_buffer->filename, | 1516 DEFVAR_PER_BUFFER ("buffer-file-name", ¤t_buffer->filename, |
| 1517 make_number (Lisp_String), | |
| 1472 "Name of file visited in current buffer, or nil if not visiting a file.\n\ | 1518 "Name of file visited in current buffer, or nil if not visiting a file.\n\ |
| 1473 Each buffer has its own value of this variable."); | 1519 Each buffer has its own value of this variable."); |
| 1474 | 1520 |
| 1475 DEFVAR_PER_BUFFER ("buffer-auto-save-file-name", | 1521 DEFVAR_PER_BUFFER ("buffer-auto-save-file-name", |
| 1476 ¤t_buffer->auto_save_file_name, | 1522 ¤t_buffer->auto_save_file_name, |
| 1523 make_number (Lisp_String), | |
| 1477 "Name of file for auto-saving current buffer,\n\ | 1524 "Name of file for auto-saving current buffer,\n\ |
| 1478 or nil if buffer should not be auto-saved.\n\ | 1525 or nil if buffer should not be auto-saved.\n\ |
| 1479 Each buffer has its own value of this variable."); | 1526 Each buffer has its own value of this variable."); |
| 1480 | 1527 |
| 1481 DEFVAR_PER_BUFFER ("buffer-read-only", ¤t_buffer->read_only, | 1528 DEFVAR_PER_BUFFER ("buffer-read-only", ¤t_buffer->read_only, Qnil, |
| 1482 "Non-nil if this buffer is read-only.\n\ | 1529 "Non-nil if this buffer is read-only.\n\ |
| 1483 Each buffer has its own value of this variable."); | 1530 Each buffer has its own value of this variable."); |
| 1484 | 1531 |
| 1485 DEFVAR_PER_BUFFER ("buffer-backed-up", ¤t_buffer->backed_up, | 1532 DEFVAR_PER_BUFFER ("buffer-backed-up", ¤t_buffer->backed_up, Qnil, |
| 1486 "Non-nil if this buffer's file has been backed up.\n\ | 1533 "Non-nil if this buffer's file has been backed up.\n\ |
| 1487 Backing up is done before the first time the file is saved.\n\ | 1534 Backing up is done before the first time the file is saved.\n\ |
| 1488 Each buffer has its own value of this variable."); | 1535 Each buffer has its own value of this variable."); |
| 1489 | 1536 |
| 1490 DEFVAR_PER_BUFFER ("buffer-saved-size", ¤t_buffer->save_length, | 1537 DEFVAR_PER_BUFFER ("buffer-saved-size", ¤t_buffer->save_length, |
| 1538 make_number (Lisp_Int), | |
| 1491 "Length of current buffer when last read in, saved or auto-saved.\n\ | 1539 "Length of current buffer when last read in, saved or auto-saved.\n\ |
| 1492 0 initially.\n\ | 1540 0 initially.\n\ |
| 1493 Each buffer has its own value of this variable."); | 1541 Each buffer has its own value of this variable."); |
| 1494 | 1542 |
| 1495 DEFVAR_PER_BUFFER ("selective-display", ¤t_buffer->selective_display, | 1543 DEFVAR_PER_BUFFER ("selective-display", ¤t_buffer->selective_display, |
| 1544 Qnil, | |
| 1496 "Non-nil enables selective display:\n\ | 1545 "Non-nil enables selective display:\n\ |
| 1497 Integer N as value means display only lines\n\ | 1546 Integer N as value means display only lines\n\ |
| 1498 that start with less than n columns of space.\n\ | 1547 that start with less than n columns of space.\n\ |
| 1499 A value of t means, after a ^M, all the rest of the line is invisible.\n\ | 1548 A value of t means, after a ^M, all the rest of the line is invisible.\n\ |
| 1500 Then ^M's in the file are written into files as newlines.\n\n\ | 1549 Then ^M's in the file are written into files as newlines.\n\n\ |
| 1501 Automatically becomes buffer-local when set in any fashion."); | 1550 Automatically becomes buffer-local when set in any fashion."); |
| 1502 | 1551 |
| 1503 #ifndef old | 1552 #ifndef old |
| 1504 DEFVAR_PER_BUFFER ("selective-display-ellipses", | 1553 DEFVAR_PER_BUFFER ("selective-display-ellipses", |
| 1505 ¤t_buffer->selective_display_ellipses, | 1554 ¤t_buffer->selective_display_ellipses, |
| 1555 Qnil, | |
| 1506 "t means display ... on previous line when a line is invisible.\n\ | 1556 "t means display ... on previous line when a line is invisible.\n\ |
| 1507 Automatically becomes buffer-local when set in any fashion."); | 1557 Automatically becomes buffer-local when set in any fashion."); |
| 1508 #endif | 1558 #endif |
| 1509 | 1559 |
| 1510 DEFVAR_PER_BUFFER ("overwrite-mode", ¤t_buffer->overwrite_mode, | 1560 DEFVAR_PER_BUFFER ("overwrite-mode", ¤t_buffer->overwrite_mode, Qnil, |
| 1511 "Non-nil if self-insertion should replace existing text.\n\ | 1561 "Non-nil if self-insertion should replace existing text.\n\ |
| 1512 Automatically becomes buffer-local when set in any fashion."); | 1562 Automatically becomes buffer-local when set in any fashion."); |
| 1513 | 1563 |
| 1514 DEFVAR_PER_BUFFER ("buffer-display-table", ¤t_buffer->display_table, | 1564 DEFVAR_PER_BUFFER ("buffer-display-table", ¤t_buffer->display_table, |
| 1565 make_number (Lisp_Vector), | |
| 1515 "Display table that controls display of the contents of current buffer.\n\ | 1566 "Display table that controls display of the contents of current buffer.\n\ |
| 1516 Automatically becomes buffer-local when set in any fashion.\n\ | 1567 Automatically becomes buffer-local when set in any fashion.\n\ |
| 1517 The display table is a vector created with `make-display-table'.\n\ | 1568 The display table is a vector created with `make-display-table'.\n\ |
| 1518 The first 256 elements control how to display each possible text character.\n\ | 1569 The first 256 elements control how to display each possible text character.\n\ |
| 1519 The value should be a \"rope\" (see `make-rope') or nil;\n\ | 1570 The value should be a \"rope\" (see `make-rope') or nil;\n\ |
| 1526 the decoration indicating the presence of invisible lines (element 260).\n\ | 1577 the decoration indicating the presence of invisible lines (element 260).\n\ |
| 1527 If this variable is nil, the value of `standard-display-table' is used.\n\ | 1578 If this variable is nil, the value of `standard-display-table' is used.\n\ |
| 1528 Each window can have its own, overriding display table."); | 1579 Each window can have its own, overriding display table."); |
| 1529 | 1580 |
| 1530 DEFVAR_PER_BUFFER ("buffer-field-list", ¤t_buffer->fieldlist, | 1581 DEFVAR_PER_BUFFER ("buffer-field-list", ¤t_buffer->fieldlist, |
| 1582 make_number (Lisp_Cons), | |
| 1531 "List of fields in the current buffer. See `add-field'."); | 1583 "List of fields in the current buffer. See `add-field'."); |
| 1532 | 1584 |
| 1533 DEFVAR_BOOL ("check-protected-fields", check_protected_fields, | 1585 DEFVAR_BOOL ("check-protected-fields", check_protected_fields, |
| 1534 "Non-nil means don't allow modification of a protected field.\n\ | 1586 "Non-nil means don't allow modification of a protected field.\n\ |
| 1535 See `add-field'."); | 1587 See `add-field'."); |
| 1567 "Function to call before changing a buffer which is unmodified.\n\ | 1619 "Function to call before changing a buffer which is unmodified.\n\ |
| 1568 The function is called, with no arguments, if it is non-nil."); | 1620 The function is called, with no arguments, if it is non-nil."); |
| 1569 Vfirst_change_function = Qnil; | 1621 Vfirst_change_function = Qnil; |
| 1570 | 1622 |
| 1571 DEFVAR_PER_BUFFER ("buffer-undo-list", ¤t_buffer->undo_list, | 1623 DEFVAR_PER_BUFFER ("buffer-undo-list", ¤t_buffer->undo_list, |
| 1624 make_number (Lisp_Cons), | |
| 1572 "List of undo entries in current buffer.\n\ | 1625 "List of undo entries in current buffer.\n\ |
| 1573 Recent changes come first; older changes follow newer.\n\ | 1626 Recent changes come first; older changes follow newer.\n\ |
| 1574 \n\ | 1627 \n\ |
| 1575 An entry (START . END) represents an insertion which begins at\n\ | 1628 An entry (START . END) represents an insertion which begins at\n\ |
| 1576 position START and ends at position END.\n\ | 1629 position START and ends at position END.\n\ |
