aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
authorJim Blandy1992-08-19 06:18:37 +0000
committerJim Blandy1992-08-19 06:18:37 +0000
commit0fa3ba92d87d3825d75109ea2b7f2bb2bab18d74 (patch)
tree7b334a50b28fcdb0a0badf037357dcecc9029e9d /src/buffer.c
parent64aeaceb937fb1d4a39deb5ae5519ed8c94dd934 (diff)
downloademacs-0fa3ba92d87d3825d75109ea2b7f2bb2bab18d74.tar.gz
emacs-0fa3ba92d87d3825d75109ea2b7f2bb2bab18d74.zip
* 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.
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c67
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 */
86static Lisp_Object Vbuffer_local_symbols; 86static 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. */
94struct 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
90int check_protected_fields; 98int 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. */
1214void
1215buffer_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
1204init_buffer_once () 1240init_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\
1379This is the same as (default-value 'case-fold-search)."); 1415This is the same as (default-value 'case-fold-search).");
1380 1416
1381 DEFVAR_PER_BUFFER ("mode-line-format", &current_buffer->mode_line_format, 0); 1417 DEFVAR_PER_BUFFER ("mode-line-format", &current_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.");
1415nil here means use current buffer's major mode."); 1452nil here means use current buffer's major mode.");
1416 1453
1417 DEFVAR_PER_BUFFER ("major-mode", &current_buffer->major_mode, 1454 DEFVAR_PER_BUFFER ("major-mode", &current_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", &current_buffer->mode_name, 1458 DEFVAR_PER_BUFFER ("mode-name", &current_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", &current_buffer->abbrev_mode, 1462 DEFVAR_PER_BUFFER ("abbrev-mode", &current_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\
1425Automatically becomes buffer-local when set in any fashion."); 1464Automatically becomes buffer-local when set in any fashion.");
1426 1465
1427 DEFVAR_PER_BUFFER ("case-fold-search", &current_buffer->case_fold_search, 1466 DEFVAR_PER_BUFFER ("case-fold-search", &current_buffer->case_fold_search,
1467 Qnil,
1428 "*Non-nil if searches should ignore case.\n\ 1468 "*Non-nil if searches should ignore case.\n\
1429Automatically becomes buffer-local when set in any fashion."); 1469Automatically becomes buffer-local when set in any fashion.");
1430 1470
1431 DEFVAR_PER_BUFFER ("fill-column", &current_buffer->fill_column, 1471 DEFVAR_PER_BUFFER ("fill-column", &current_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\
1433Automatically becomes buffer-local when set in any fashion."); 1474Automatically becomes buffer-local when set in any fashion.");
1434 1475
1435 DEFVAR_PER_BUFFER ("left-margin", &current_buffer->left_margin, 1476 DEFVAR_PER_BUFFER ("left-margin", &current_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\
1437Linefeed indents to this column in Fundamental mode.\n\ 1479Linefeed indents to this column in Fundamental mode.\n\
1438Automatically becomes buffer-local when set in any fashion."); 1480Automatically becomes buffer-local when set in any fashion.");
1439 1481
1440 DEFVAR_PER_BUFFER ("tab-width", &current_buffer->tab_width, 1482 DEFVAR_PER_BUFFER ("tab-width", &current_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\
1442Automatically becomes buffer-local when set in any fashion."); 1485Automatically becomes buffer-local when set in any fashion.");
1443 1486
1444 DEFVAR_PER_BUFFER ("ctl-arrow", &current_buffer->ctl_arrow, 1487 DEFVAR_PER_BUFFER ("ctl-arrow", &current_buffer->ctl_arrow, Qnil,
1445 "*Non-nil means display control chars with uparrow.\n\ 1488 "*Non-nil means display control chars with uparrow.\n\
1446Nil means use backslash and octal digits.\n\ 1489Nil means use backslash and octal digits.\n\
1447Automatically becomes buffer-local when set in any fashion.\n\ 1490Automatically becomes buffer-local when set in any fashion.\n\
1448This variable does not apply to characters whose display is specified\n\ 1491This variable does not apply to characters whose display is specified\n\
1449in the current display table (if there is one)."); 1492in the current display table (if there is one).");
1450 1493
1451 DEFVAR_PER_BUFFER ("truncate-lines", &current_buffer->truncate_lines, 1494 DEFVAR_PER_BUFFER ("truncate-lines", &current_buffer->truncate_lines, Qnil,
1452 "*Non-nil means do not display continuation lines;\n\ 1495 "*Non-nil means do not display continuation lines;\n\
1453give each line of text one screen line.\n\ 1496give each line of text one screen line.\n\
1454Automatically becomes buffer-local when set in any fashion.\n\ 1497Automatically becomes buffer-local when set in any fashion.\n\
@@ -1458,10 +1501,12 @@ Note that this is overridden by the variable\n\
1458and this buffer is not full-frame width."); 1501and this buffer is not full-frame width.");
1459 1502
1460 DEFVAR_PER_BUFFER ("default-directory", &current_buffer->directory, 1503 DEFVAR_PER_BUFFER ("default-directory", &current_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\
1462Each buffer has its own value of this variable."); 1506Each buffer has its own value of this variable.");
1463 1507
1464 DEFVAR_PER_BUFFER ("auto-fill-function", &current_buffer->auto_fill_function, 1508 DEFVAR_PER_BUFFER ("auto-fill-function", &current_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\
1466It is called after self-inserting a space at a column beyond `fill-column'.\n\ 1511It is called after self-inserting a space at a column beyond `fill-column'.\n\
1467Each buffer has its own value of this variable.\n\ 1512Each buffer has its own value of this variable.\n\
@@ -1469,30 +1514,34 @@ NOTE: This variable is not an ordinary hook;\n\
1469It may not be a list of functions."); 1514It may not be a list of functions.");
1470 1515
1471 DEFVAR_PER_BUFFER ("buffer-file-name", &current_buffer->filename, 1516 DEFVAR_PER_BUFFER ("buffer-file-name", &current_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\
1473Each buffer has its own value of this variable."); 1519Each 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 &current_buffer->auto_save_file_name, 1522 &current_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\
1478or nil if buffer should not be auto-saved.\n\ 1525or nil if buffer should not be auto-saved.\n\
1479Each buffer has its own value of this variable."); 1526Each buffer has its own value of this variable.");
1480 1527
1481 DEFVAR_PER_BUFFER ("buffer-read-only", &current_buffer->read_only, 1528 DEFVAR_PER_BUFFER ("buffer-read-only", &current_buffer->read_only, Qnil,
1482 "Non-nil if this buffer is read-only.\n\ 1529 "Non-nil if this buffer is read-only.\n\
1483Each buffer has its own value of this variable."); 1530Each buffer has its own value of this variable.");
1484 1531
1485 DEFVAR_PER_BUFFER ("buffer-backed-up", &current_buffer->backed_up, 1532 DEFVAR_PER_BUFFER ("buffer-backed-up", &current_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\
1487Backing up is done before the first time the file is saved.\n\ 1534Backing up is done before the first time the file is saved.\n\
1488Each buffer has its own value of this variable."); 1535Each buffer has its own value of this variable.");
1489 1536
1490 DEFVAR_PER_BUFFER ("buffer-saved-size", &current_buffer->save_length, 1537 DEFVAR_PER_BUFFER ("buffer-saved-size", &current_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\
14920 initially.\n\ 15400 initially.\n\
1493Each buffer has its own value of this variable."); 1541Each buffer has its own value of this variable.");
1494 1542
1495 DEFVAR_PER_BUFFER ("selective-display", &current_buffer->selective_display, 1543 DEFVAR_PER_BUFFER ("selective-display", &current_buffer->selective_display,
1544 Qnil,
1496 "Non-nil enables selective display:\n\ 1545 "Non-nil enables selective display:\n\
1497Integer N as value means display only lines\n\ 1546Integer 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 &current_buffer->selective_display_ellipses, 1554 &current_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\
1507Automatically becomes buffer-local when set in any fashion."); 1557Automatically becomes buffer-local when set in any fashion.");
1508#endif 1558#endif
1509 1559
1510 DEFVAR_PER_BUFFER ("overwrite-mode", &current_buffer->overwrite_mode, 1560 DEFVAR_PER_BUFFER ("overwrite-mode", &current_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\
1512Automatically becomes buffer-local when set in any fashion."); 1562Automatically becomes buffer-local when set in any fashion.");
1513 1563
1514 DEFVAR_PER_BUFFER ("buffer-display-table", &current_buffer->display_table, 1564 DEFVAR_PER_BUFFER ("buffer-display-table", &current_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\
1516Automatically becomes buffer-local when set in any fashion.\n\ 1567Automatically becomes buffer-local when set in any fashion.\n\
1517The display table is a vector created with `make-display-table'.\n\ 1568The 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\
1528Each window can have its own, overriding display table."); 1579Each window can have its own, overriding display table.");
1529 1580
1530 DEFVAR_PER_BUFFER ("buffer-field-list", &current_buffer->fieldlist, 1581 DEFVAR_PER_BUFFER ("buffer-field-list", &current_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", &current_buffer->undo_list, 1623 DEFVAR_PER_BUFFER ("buffer-undo-list", &current_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\
1573Recent changes come first; older changes follow newer.\n\ 1626Recent changes come first; older changes follow newer.\n\
1574\n\ 1627\n\