diff options
Diffstat (limited to 'src/buffer.c')
| -rw-r--r-- | src/buffer.c | 67 |
1 files changed, 60 insertions, 7 deletions
diff --git a/src/buffer.c b/src/buffer.c index 2bd7cc52e05..15da8404157 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -85,6 +85,14 @@ 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 | 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; | ||
| 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; |
| @@ -1201,6 +1209,34 @@ if any protected fields overlap this portion.") | |||
| 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; |
| @@ -1378,7 +1414,8 @@ This is the same as (default-value 'tab-width)."); | |||
| 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! |
| @@ -1415,40 +1452,46 @@ Decimal digits after the % specify field width to which to pad."); | |||
| 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\ |
| @@ -1458,10 +1501,12 @@ Note that this is overridden by the variable\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\ |
| @@ -1469,30 +1514,34 @@ 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\ |
| @@ -1503,15 +1552,17 @@ Automatically becomes buffer-local when set in any fashion."); | |||
| 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\ |
| @@ -1528,6 +1579,7 @@ 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, |
| @@ -1569,6 +1621,7 @@ 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\ |