aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDmitry Antipov2014-07-16 12:45:22 +0400
committerDmitry Antipov2014-07-16 12:45:22 +0400
commite0b07ec3416d1ee7c77234e9dd0a7408b50da83c (patch)
tree430fc691f2cc593268fd1ada8defcec5b9c78ef4 /src
parent74660d84d923fd8252b166770ca2403f6025a7ac (diff)
downloademacs-e0b07ec3416d1ee7c77234e9dd0a7408b50da83c.tar.gz
emacs-e0b07ec3416d1ee7c77234e9dd0a7408b50da83c.zip
More precise control over values of some buffer-local variables.
* keyboard.c (Qvertical_scroll_bar): * frame.c (Qleft, Qright): Move to ... * buffer.c (Qleft, Qright, Qvertical_scroll_bar): ... here. * buffer.c (Qchoice, Qrange, Qoverwrite_mode, Qfraction): New symbols. (syms_of_buffer): DEFSYM all of the above, attach special properties. Use special symbols to DEFVAR_PER_BUFFER overwrite-mode, vertical-scroll-bar, scroll-up-aggressively and scroll-down-aggressively. * buffer.h (Qchoice, Qrange, Qleft, Qright, Qvertical_scroll_bar): Add declarations. * nsfns.m, frame.h (Qleft, Qright): * nsterm.m (Qleft): Remove declarations. * gtkutil.c (toplevel): Include buffer.h. * data.c (wrong_choice, wrong_range): New functions. (store_symval_forwarding): Handle special properties of buffer-local variables and use functions from the above to signal error, if any.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog20
-rw-r--r--src/buffer.c27
-rw-r--r--src/buffer.h1
-rw-r--r--src/data.c71
-rw-r--r--src/frame.c3
-rw-r--r--src/frame.h2
-rw-r--r--src/gtkutil.c1
-rw-r--r--src/keyboard.c2
-rw-r--r--src/nsfns.m2
-rw-r--r--src/nsterm.m2
10 files changed, 115 insertions, 16 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 4fb688aed16..3561cca4ac3 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,23 @@
12014-07-16 Dmitry Antipov <dmantipov@yandex.ru>
2
3 More precise control over values of some buffer-local variables.
4 * keyboard.c (Qvertical_scroll_bar):
5 * frame.c (Qleft, Qright): Move to ...
6 * buffer.c (Qleft, Qright, Qvertical_scroll_bar): ... here.
7 * buffer.c (Qchoice, Qrange, Qoverwrite_mode, Qfraction): New symbols.
8 (syms_of_buffer): DEFSYM all of the above, attach special properties.
9 Use special symbols to DEFVAR_PER_BUFFER overwrite-mode,
10 vertical-scroll-bar, scroll-up-aggressively
11 and scroll-down-aggressively.
12 * buffer.h (Qchoice, Qrange, Qleft, Qright, Qvertical_scroll_bar):
13 Add declarations.
14 * nsfns.m, frame.h (Qleft, Qright):
15 * nsterm.m (Qleft): Remove declarations.
16 * gtkutil.c (toplevel): Include buffer.h.
17 * data.c (wrong_choice, wrong_range): New functions.
18 (store_symval_forwarding): Handle special properties of buffer-local
19 variables and use functions from the above to signal error, if any.
20
12014-07-15 Daiki Ueno <ueno@gnu.org> 212014-07-15 Daiki Ueno <ueno@gnu.org>
2 22
3 * nsgui.h (XCHAR2B_BYTE1): Add missing parentheses around 23 * nsgui.h (XCHAR2B_BYTE1): Add missing parentheses around
diff --git a/src/buffer.c b/src/buffer.c
index d6f6b2c7703..53cc25e2c8f 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -145,6 +145,9 @@ Lisp_Object Qmodification_hooks;
145Lisp_Object Qinsert_in_front_hooks; 145Lisp_Object Qinsert_in_front_hooks;
146Lisp_Object Qinsert_behind_hooks; 146Lisp_Object Qinsert_behind_hooks;
147 147
148Lisp_Object Qchoice, Qrange, Qleft, Qright, Qvertical_scroll_bar;
149static Lisp_Object Qoverwrite_mode, Qfraction;
150
148static void alloc_buffer_text (struct buffer *, ptrdiff_t); 151static void alloc_buffer_text (struct buffer *, ptrdiff_t);
149static void free_buffer_text (struct buffer *b); 152static void free_buffer_text (struct buffer *b);
150static struct Lisp_Overlay * copy_overlays (struct buffer *, struct Lisp_Overlay *); 153static struct Lisp_Overlay * copy_overlays (struct buffer *, struct Lisp_Overlay *);
@@ -5422,6 +5425,10 @@ syms_of_buffer (void)
5422 staticpro (&Qpermanent_local); 5425 staticpro (&Qpermanent_local);
5423 staticpro (&Qkill_buffer_hook); 5426 staticpro (&Qkill_buffer_hook);
5424 5427
5428 DEFSYM (Qleft, "left");
5429 DEFSYM (Qright, "right");
5430 DEFSYM (Qrange, "range");
5431
5425 DEFSYM (Qpermanent_local_hook, "permanent-local-hook"); 5432 DEFSYM (Qpermanent_local_hook, "permanent-local-hook");
5426 DEFSYM (Qoverlayp, "overlayp"); 5433 DEFSYM (Qoverlayp, "overlayp");
5427 DEFSYM (Qevaporate, "evaporate"); 5434 DEFSYM (Qevaporate, "evaporate");
@@ -5437,6 +5444,17 @@ syms_of_buffer (void)
5437 DEFSYM (Qafter_change_functions, "after-change-functions"); 5444 DEFSYM (Qafter_change_functions, "after-change-functions");
5438 DEFSYM (Qkill_buffer_query_functions, "kill-buffer-query-functions"); 5445 DEFSYM (Qkill_buffer_query_functions, "kill-buffer-query-functions");
5439 5446
5447 DEFSYM (Qvertical_scroll_bar, "vertical-scroll-bar");
5448 Fput (Qvertical_scroll_bar, Qchoice, list4 (Qnil, Qt, Qleft, Qright));
5449
5450 DEFSYM (Qfraction, "fraction");
5451 Fput (Qfraction, Qrange, Fcons (make_float (0.0), make_float (1.0)));
5452
5453 DEFSYM (Qoverwrite_mode, "overwrite-mode");
5454 Fput (Qoverwrite_mode, Qchoice,
5455 list3 (Qnil, intern ("overwrite-mode-textual"),
5456 intern ("overwrite-mode-binary")));
5457
5440 Fput (Qprotected_field, Qerror_conditions, 5458 Fput (Qprotected_field, Qerror_conditions,
5441 listn (CONSTYPE_PURE, 2, Qprotected_field, Qerror)); 5459 listn (CONSTYPE_PURE, 2, Qprotected_field, Qerror));
5442 Fput (Qprotected_field, Qerror_message, 5460 Fput (Qprotected_field, Qerror_message,
@@ -5842,7 +5860,8 @@ in a file, save the ^M as a newline. */);
5842 Qnil, 5860 Qnil,
5843 doc: /* Non-nil means display ... on previous line when a line is invisible. */); 5861 doc: /* Non-nil means display ... on previous line when a line is invisible. */);
5844 5862
5845 DEFVAR_PER_BUFFER ("overwrite-mode", &BVAR (current_buffer, overwrite_mode), Qnil, 5863 DEFVAR_PER_BUFFER ("overwrite-mode", &BVAR (current_buffer, overwrite_mode),
5864 Qoverwrite_mode,
5846 doc: /* Non-nil if self-insertion should replace existing text. 5865 doc: /* Non-nil if self-insertion should replace existing text.
5847The value should be one of `overwrite-mode-textual', 5866The value should be one of `overwrite-mode-textual',
5848`overwrite-mode-binary', or nil. 5867`overwrite-mode-binary', or nil.
@@ -5936,7 +5955,7 @@ in a window. To make the change take effect, call `set-window-buffer'. */);
5936A value of nil means to use the scroll bar width from the window's frame. */); 5955A value of nil means to use the scroll bar width from the window's frame. */);
5937 5956
5938 DEFVAR_PER_BUFFER ("vertical-scroll-bar", &BVAR (current_buffer, vertical_scroll_bar_type), 5957 DEFVAR_PER_BUFFER ("vertical-scroll-bar", &BVAR (current_buffer, vertical_scroll_bar_type),
5939 Qnil, 5958 Qvertical_scroll_bar,
5940 doc: /* Position of this buffer's vertical scroll bar. 5959 doc: /* Position of this buffer's vertical scroll bar.
5941The value takes effect whenever you tell a window to display this buffer; 5960The value takes effect whenever you tell a window to display this buffer;
5942for instance, with `set-window-buffer' or when `display-buffer' displays it. 5961for instance, with `set-window-buffer' or when `display-buffer' displays it.
@@ -6011,7 +6030,7 @@ BITMAP is the corresponding fringe bitmap shown for the logical
6011cursor type. */); 6030cursor type. */);
6012 6031
6013 DEFVAR_PER_BUFFER ("scroll-up-aggressively", 6032 DEFVAR_PER_BUFFER ("scroll-up-aggressively",
6014 &BVAR (current_buffer, scroll_up_aggressively), Qfloatp, 6033 &BVAR (current_buffer, scroll_up_aggressively), Qfraction,
6015 doc: /* How far to scroll windows upward. 6034 doc: /* How far to scroll windows upward.
6016If you move point off the bottom, the window scrolls automatically. 6035If you move point off the bottom, the window scrolls automatically.
6017This variable controls how far it scrolls. The value nil, the default, 6036This variable controls how far it scrolls. The value nil, the default,
@@ -6024,7 +6043,7 @@ window scrolls by a full window height. Meaningful values are
6024between 0.0 and 1.0, inclusive. */); 6043between 0.0 and 1.0, inclusive. */);
6025 6044
6026 DEFVAR_PER_BUFFER ("scroll-down-aggressively", 6045 DEFVAR_PER_BUFFER ("scroll-down-aggressively",
6027 &BVAR (current_buffer, scroll_down_aggressively), Qfloatp, 6046 &BVAR (current_buffer, scroll_down_aggressively), Qfraction,
6028 doc: /* How far to scroll windows downward. 6047 doc: /* How far to scroll windows downward.
6029If you move point off the top, the window scrolls automatically. 6048If you move point off the top, the window scrolls automatically.
6030This variable controls how far it scrolls. The value nil, the default, 6049This variable controls how far it scrolls. The value nil, the default,
diff --git a/src/buffer.h b/src/buffer.h
index 5c1e1bb278c..3c29019554c 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -1135,6 +1135,7 @@ extern Lisp_Object Qbefore_change_functions;
1135extern Lisp_Object Qafter_change_functions; 1135extern Lisp_Object Qafter_change_functions;
1136extern Lisp_Object Qfirst_change_hook; 1136extern Lisp_Object Qfirst_change_hook;
1137extern Lisp_Object Qpriority, Qbefore_string, Qafter_string; 1137extern Lisp_Object Qpriority, Qbefore_string, Qafter_string;
1138extern Lisp_Object Qchoice, Qrange, Qleft, Qright, Qvertical_scroll_bar;
1138 1139
1139/* FOR_EACH_LIVE_BUFFER (LIST_VAR, BUF_VAR) followed by a statement is 1140/* FOR_EACH_LIVE_BUFFER (LIST_VAR, BUF_VAR) followed by a statement is
1140 a `for' loop which iterates over the buffers from Vbuffer_alist. */ 1141 a `for' loop which iterates over the buffers from Vbuffer_alist. */
diff --git a/src/data.c b/src/data.c
index 2de1c19452c..790d0fee981 100644
--- a/src/data.c
+++ b/src/data.c
@@ -971,6 +971,48 @@ do_symval_forwarding (register union Lisp_Fwd *valcontents)
971 } 971 }
972} 972}
973 973
974/* Used to signal a user-friendly error when symbol WRONG is
975 not a member of CHOICE, which should be a list of symbols. */
976
977static void
978wrong_choice (Lisp_Object choice, Lisp_Object wrong)
979{
980 ptrdiff_t i = 0, len = XINT (Flength (choice));
981 Lisp_Object obj, *args;
982
983 USE_SAFE_ALLOCA;
984 SAFE_ALLOCA_LISP (args, len * 2 + 1);
985
986 args[i++] = build_string ("One of ");
987
988 for (obj = choice; !NILP (obj); obj = XCDR (obj))
989 {
990 args[i++] = SYMBOL_NAME (XCAR (obj));
991 args[i++] = build_string (NILP (XCDR (obj)) ? " should be specified"
992 : (NILP (XCDR (XCDR (obj))) ? " or " : ", "));
993 }
994
995 obj = Fconcat (i, args);
996 SAFE_FREE ();
997 xsignal2 (Qerror, obj, wrong);
998}
999
1000/* Used to signal a user-friendly error if WRONG is not a number or
1001 integer/floating-point number outsize of inclusive MIN..MAX range. */
1002
1003static void
1004wrong_range (Lisp_Object min, Lisp_Object max, Lisp_Object wrong)
1005{
1006 Lisp_Object args[4];
1007
1008 args[0] = build_string ("Value should be from ");
1009 args[1] = Fnumber_to_string (min);
1010 args[2] = build_string (" to ");
1011 args[3] = Fnumber_to_string (max);
1012
1013 xsignal2 (Qerror, Fconcat (4, args), wrong);
1014}
1015
974/* Store NEWVAL into SYMBOL, where VALCONTENTS is found in the value cell 1016/* Store NEWVAL into SYMBOL, where VALCONTENTS is found in the value cell
975 of SYMBOL. If SYMBOL is buffer-local, VALCONTENTS should be the 1017 of SYMBOL. If SYMBOL is buffer-local, VALCONTENTS should be the
976 buffer-independent contents of the value cell: forwarded just one 1018 buffer-independent contents of the value cell: forwarded just one
@@ -1027,10 +1069,33 @@ store_symval_forwarding (union Lisp_Fwd *valcontents, register Lisp_Object newva
1027 int offset = XBUFFER_OBJFWD (valcontents)->offset; 1069 int offset = XBUFFER_OBJFWD (valcontents)->offset;
1028 Lisp_Object predicate = XBUFFER_OBJFWD (valcontents)->predicate; 1070 Lisp_Object predicate = XBUFFER_OBJFWD (valcontents)->predicate;
1029 1071
1030 if (!NILP (predicate) && !NILP (newval) 1072 if (!NILP (newval))
1031 && NILP (call1 (predicate, newval))) 1073 {
1032 wrong_type_argument (predicate, newval); 1074 if (SYMBOLP (predicate))
1075 {
1076 Lisp_Object prop;
1077
1078 if ((prop = Fget (predicate, Qchoice), !NILP (prop)))
1079 {
1080 if (NILP (Fmemq (newval, prop)))
1081 wrong_choice (prop, newval);
1082 }
1083 else if ((prop = Fget (predicate, Qrange), !NILP (prop)))
1084 {
1085 Lisp_Object min = XCAR (prop), max = XCDR (prop);
1033 1086
1087 if (!NUMBERP (newval)
1088 || !NILP (arithcompare (newval, min, ARITH_LESS))
1089 || !NILP (arithcompare (newval, max, ARITH_GRTR)))
1090 wrong_range (min, max, newval);
1091 }
1092 else if (FUNCTIONP (predicate))
1093 {
1094 if (NILP (call1 (predicate, newval)))
1095 wrong_type_argument (predicate, newval);
1096 }
1097 }
1098 }
1034 if (buf == NULL) 1099 if (buf == NULL)
1035 buf = current_buffer; 1100 buf = current_buffer;
1036 set_per_buffer_value (buf, offset, newval); 1101 set_per_buffer_value (buf, offset, newval);
diff --git a/src/frame.c b/src/frame.c
index 0ccc0f6fcfd..57270437d9f 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -78,7 +78,6 @@ Lisp_Object Qauto_raise, Qauto_lower;
78Lisp_Object Qborder_color, Qborder_width; 78Lisp_Object Qborder_color, Qborder_width;
79Lisp_Object Qcursor_color, Qcursor_type; 79Lisp_Object Qcursor_color, Qcursor_type;
80Lisp_Object Qheight, Qwidth; 80Lisp_Object Qheight, Qwidth;
81Lisp_Object Qleft, Qright;
82Lisp_Object Qicon_left, Qicon_top, Qicon_type, Qicon_name; 81Lisp_Object Qicon_left, Qicon_top, Qicon_type, Qicon_name;
83Lisp_Object Qtooltip; 82Lisp_Object Qtooltip;
84Lisp_Object Qinternal_border_width; 83Lisp_Object Qinternal_border_width;
@@ -4547,8 +4546,6 @@ syms_of_frame (void)
4547 DEFSYM (Qicon_left, "icon-left"); 4546 DEFSYM (Qicon_left, "icon-left");
4548 DEFSYM (Qicon_top, "icon-top"); 4547 DEFSYM (Qicon_top, "icon-top");
4549 DEFSYM (Qtooltip, "tooltip"); 4548 DEFSYM (Qtooltip, "tooltip");
4550 DEFSYM (Qleft, "left");
4551 DEFSYM (Qright, "right");
4552 DEFSYM (Quser_position, "user-position"); 4549 DEFSYM (Quser_position, "user-position");
4553 DEFSYM (Quser_size, "user-size"); 4550 DEFSYM (Quser_size, "user-size");
4554 DEFSYM (Qwindow_id, "window-id"); 4551 DEFSYM (Qwindow_id, "window-id");
diff --git a/src/frame.h b/src/frame.h
index 4fb98278a51..6841143f8da 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -1255,7 +1255,7 @@ extern Lisp_Object Qdisplay_type;
1255 1255
1256extern Lisp_Object Qx_resource_name; 1256extern Lisp_Object Qx_resource_name;
1257 1257
1258extern Lisp_Object Qleft, Qright, Qtop, Qbox, Qbottom; 1258extern Lisp_Object Qtop, Qbox, Qbottom;
1259extern Lisp_Object Qdisplay; 1259extern Lisp_Object Qdisplay;
1260 1260
1261extern Lisp_Object Qrun_hook_with_args; 1261extern Lisp_Object Qrun_hook_with_args;
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 8614fe57cb2..75d5c5aa680 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -30,6 +30,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
30#include "blockinput.h" 30#include "blockinput.h"
31#include "syssignal.h" 31#include "syssignal.h"
32#include "window.h" 32#include "window.h"
33#include "buffer.h"
33#include "gtkutil.h" 34#include "gtkutil.h"
34#include "termhooks.h" 35#include "termhooks.h"
35#include "keyboard.h" 36#include "keyboard.h"
diff --git a/src/keyboard.c b/src/keyboard.c
index 936d6687908..8fe6926a17c 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -348,7 +348,6 @@ static Lisp_Object Qmodifier_cache;
348Lisp_Object Qmode_line; 348Lisp_Object Qmode_line;
349Lisp_Object Qvertical_line; 349Lisp_Object Qvertical_line;
350Lisp_Object Qright_divider, Qbottom_divider; 350Lisp_Object Qright_divider, Qbottom_divider;
351static Lisp_Object Qvertical_scroll_bar;
352Lisp_Object Qmenu_bar; 351Lisp_Object Qmenu_bar;
353 352
354static Lisp_Object Qecho_keystrokes; 353static Lisp_Object Qecho_keystrokes;
@@ -11012,7 +11011,6 @@ syms_of_keyboard (void)
11012 11011
11013 DEFSYM (Qmode_line, "mode-line"); 11012 DEFSYM (Qmode_line, "mode-line");
11014 DEFSYM (Qvertical_line, "vertical-line"); 11013 DEFSYM (Qvertical_line, "vertical-line");
11015 DEFSYM (Qvertical_scroll_bar, "vertical-scroll-bar");
11016 DEFSYM (Qmenu_bar, "menu-bar"); 11014 DEFSYM (Qmenu_bar, "menu-bar");
11017 DEFSYM (Qright_divider, "right-divider"); 11015 DEFSYM (Qright_divider, "right-divider");
11018 DEFSYM (Qbottom_divider, "bottom-divider"); 11016 DEFSYM (Qbottom_divider, "bottom-divider");
diff --git a/src/nsfns.m b/src/nsfns.m
index b49aec43b65..8f1a45d03f1 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -73,8 +73,6 @@ extern Lisp_Object Qicon_type;
73extern Lisp_Object Qicon_name; 73extern Lisp_Object Qicon_name;
74extern Lisp_Object Qicon_left; 74extern Lisp_Object Qicon_left;
75extern Lisp_Object Qicon_top; 75extern Lisp_Object Qicon_top;
76extern Lisp_Object Qleft;
77extern Lisp_Object Qright;
78extern Lisp_Object Qtop; 76extern Lisp_Object Qtop;
79extern Lisp_Object Qdisplay; 77extern Lisp_Object Qdisplay;
80extern Lisp_Object Qvertical_scroll_bars; 78extern Lisp_Object Qvertical_scroll_bars;
diff --git a/src/nsterm.m b/src/nsterm.m
index 3a570628cbe..9420031645d 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -229,7 +229,7 @@ static unsigned convert_ns_to_X_keysym[] =
229 229
230static Lisp_Object Qmodifier_value; 230static Lisp_Object Qmodifier_value;
231Lisp_Object Qalt, Qcontrol, Qhyper, Qmeta, Qsuper; 231Lisp_Object Qalt, Qcontrol, Qhyper, Qmeta, Qsuper;
232extern Lisp_Object Qcursor_color, Qcursor_type, Qns, Qleft; 232extern Lisp_Object Qcursor_color, Qcursor_type, Qns;
233 233
234static Lisp_Object QUTF8_STRING; 234static Lisp_Object QUTF8_STRING;
235static Lisp_Object Qcocoa, Qgnustep; 235static Lisp_Object Qcocoa, Qgnustep;