Mercurial > emacs
comparison src/xdisp.c @ 32175:e5d99e8cbd94
(handle_single_display_prop): Use safe_call1.
(safe_call): Renamed from call_function.
(safe_call1): New function.
(handle_fontified_prop): Use safe_call1 instead of call1.
(safe_eval): Renamed from eval_form.
(safe_eval_handler): Renamed from eval_handler.
(handle_single_display_prop, display_mode_element): Use safe_eval
instead of eval_form.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Thu, 05 Oct 2000 19:29:05 +0000 |
parents | 85c245edb7d7 |
children | 5d2167f8c6a6 |
comparison
equal
deleted
inserted
replaced
32174:13415f4f854a | 32175:e5d99e8cbd94 |
---|---|
662 static Lisp_Object unwind_redisplay P_ ((Lisp_Object)); | 662 static Lisp_Object unwind_redisplay P_ ((Lisp_Object)); |
663 static int string_char_and_length P_ ((unsigned char *, int, int *)); | 663 static int string_char_and_length P_ ((unsigned char *, int, int *)); |
664 static struct text_pos display_prop_end P_ ((struct it *, Lisp_Object, | 664 static struct text_pos display_prop_end P_ ((struct it *, Lisp_Object, |
665 struct text_pos)); | 665 struct text_pos)); |
666 static int compute_window_start_on_continuation_line P_ ((struct window *)); | 666 static int compute_window_start_on_continuation_line P_ ((struct window *)); |
667 static Lisp_Object eval_handler P_ ((Lisp_Object)); | 667 static Lisp_Object safe_eval_handler P_ ((Lisp_Object)); |
668 static void insert_left_trunc_glyphs P_ ((struct it *)); | 668 static void insert_left_trunc_glyphs P_ ((struct it *)); |
669 static struct glyph_row *get_overlay_arrow_glyph_row P_ ((struct window *)); | 669 static struct glyph_row *get_overlay_arrow_glyph_row P_ ((struct window *)); |
670 static void extend_face_to_end_of_line P_ ((struct it *)); | 670 static void extend_face_to_end_of_line P_ ((struct it *)); |
671 static int append_space P_ ((struct it *, int)); | 671 static int append_space P_ ((struct it *, int)); |
672 static void make_cursor_line_fully_visible P_ ((struct window *)); | 672 static void make_cursor_line_fully_visible P_ ((struct window *)); |
1087 | 1087 |
1088 /*********************************************************************** | 1088 /*********************************************************************** |
1089 Lisp form evaluation | 1089 Lisp form evaluation |
1090 ***********************************************************************/ | 1090 ***********************************************************************/ |
1091 | 1091 |
1092 /* Error handler for eval_form and call_function. */ | 1092 /* Error handler for safe_eval and safe_call. */ |
1093 | 1093 |
1094 static Lisp_Object | 1094 static Lisp_Object |
1095 eval_handler (arg) | 1095 safe_eval_handler (arg) |
1096 Lisp_Object arg; | 1096 Lisp_Object arg; |
1097 { | 1097 { |
1098 return Qnil; | 1098 return Qnil; |
1099 } | 1099 } |
1100 | 1100 |
1101 | 1101 |
1102 /* Evaluate SEXPR and return the result, or nil if something went | 1102 /* Evaluate SEXPR and return the result, or nil if something went |
1103 wrong. */ | 1103 wrong. */ |
1104 | 1104 |
1105 Lisp_Object | 1105 Lisp_Object |
1106 eval_form (sexpr) | 1106 safe_eval (sexpr) |
1107 Lisp_Object sexpr; | 1107 Lisp_Object sexpr; |
1108 { | 1108 { |
1109 int count = specpdl_ptr - specpdl; | 1109 int count = specpdl_ptr - specpdl; |
1110 struct gcpro gcpro1; | 1110 struct gcpro gcpro1; |
1111 Lisp_Object val; | 1111 Lisp_Object val; |
1112 | 1112 |
1113 GCPRO1 (sexpr); | 1113 GCPRO1 (sexpr); |
1114 specbind (Qinhibit_redisplay, Qt); | 1114 specbind (Qinhibit_redisplay, Qt); |
1115 val = internal_condition_case_1 (Feval, sexpr, Qerror, eval_handler); | 1115 val = internal_condition_case_1 (Feval, sexpr, Qerror, safe_eval_handler); |
1116 UNGCPRO; | 1116 UNGCPRO; |
1117 return unbind_to (count, val); | 1117 return unbind_to (count, val); |
1118 } | 1118 } |
1119 | 1119 |
1120 | 1120 |
1121 /* Call function ARGS[0] with arguments ARGS[1] to ARGS[NARGS - 1]. | 1121 /* Call function ARGS[0] with arguments ARGS[1] to ARGS[NARGS - 1]. |
1122 Return the result, or nil if something went wrong. */ | 1122 Return the result, or nil if something went wrong. */ |
1123 | 1123 |
1124 Lisp_Object | 1124 Lisp_Object |
1125 call_function (nargs, args) | 1125 safe_call (nargs, args) |
1126 int nargs; | 1126 int nargs; |
1127 Lisp_Object *args; | 1127 Lisp_Object *args; |
1128 { | 1128 { |
1129 int count = specpdl_ptr - specpdl; | 1129 int count = specpdl_ptr - specpdl; |
1130 Lisp_Object val; | 1130 Lisp_Object val; |
1132 | 1132 |
1133 GCPRO1 (args[0]); | 1133 GCPRO1 (args[0]); |
1134 gcpro1.nvars = nargs; | 1134 gcpro1.nvars = nargs; |
1135 specbind (Qinhibit_redisplay, Qt); | 1135 specbind (Qinhibit_redisplay, Qt); |
1136 val = internal_condition_case_2 (Ffuncall, nargs, args, Qerror, | 1136 val = internal_condition_case_2 (Ffuncall, nargs, args, Qerror, |
1137 eval_handler); | 1137 safe_eval_handler); |
1138 UNGCPRO; | 1138 UNGCPRO; |
1139 return unbind_to (count, val); | 1139 return unbind_to (count, val); |
1140 } | |
1141 | |
1142 | |
1143 /* Call function FN with one argument ARG. | |
1144 Return the result, or nil if something went wrong. */ | |
1145 | |
1146 Lisp_Object | |
1147 safe_call1 (fn, arg) | |
1148 Lisp_Object fn, arg; | |
1149 { | |
1150 Lisp_Object args[2]; | |
1151 args[0] = fn; | |
1152 args[1] = arg; | |
1153 return safe_call (2, args); | |
1140 } | 1154 } |
1141 | 1155 |
1142 | 1156 |
1143 | 1157 |
1144 /*********************************************************************** | 1158 /*********************************************************************** |
1889 val = Vfontification_functions; | 1903 val = Vfontification_functions; |
1890 specbind (Qfontification_functions, Qnil); | 1904 specbind (Qfontification_functions, Qnil); |
1891 specbind (Qafter_change_functions, Qnil); | 1905 specbind (Qafter_change_functions, Qnil); |
1892 | 1906 |
1893 if (!CONSP (val) || EQ (XCAR (val), Qlambda)) | 1907 if (!CONSP (val) || EQ (XCAR (val), Qlambda)) |
1894 call1 (val, pos); | 1908 safe_call1 (val, pos); |
1895 else | 1909 else |
1896 { | 1910 { |
1897 Lisp_Object globals, fn; | 1911 Lisp_Object globals, fn; |
1898 struct gcpro gcpro1, gcpro2; | 1912 struct gcpro gcpro1, gcpro2; |
1899 | 1913 |
1915 CONSP (globals); | 1929 CONSP (globals); |
1916 globals = XCDR (globals)) | 1930 globals = XCDR (globals)) |
1917 { | 1931 { |
1918 fn = XCAR (globals); | 1932 fn = XCAR (globals); |
1919 if (!EQ (fn, Qt)) | 1933 if (!EQ (fn, Qt)) |
1920 call1 (fn, pos); | 1934 safe_call1 (fn, pos); |
1921 } | 1935 } |
1922 } | 1936 } |
1923 else | 1937 else |
1924 call1 (fn, pos); | 1938 safe_call1 (fn, pos); |
1925 } | 1939 } |
1926 | 1940 |
1927 UNGCPRO; | 1941 UNGCPRO; |
1928 } | 1942 } |
1929 | 1943 |
2451 CHARPOS (pt) = PT; | 2465 CHARPOS (pt) = PT; |
2452 BYTEPOS (pt) = PT_BYTE; | 2466 BYTEPOS (pt) = PT_BYTE; |
2453 TEMP_SET_PT_BOTH (CHARPOS (end_pos), BYTEPOS (end_pos)); | 2467 TEMP_SET_PT_BOTH (CHARPOS (end_pos), BYTEPOS (end_pos)); |
2454 } | 2468 } |
2455 | 2469 |
2456 form = eval_form (form); | 2470 form = safe_eval (form); |
2457 | 2471 |
2458 if (BUFFERP (object)) | 2472 if (BUFFERP (object)) |
2459 TEMP_SET_PT_BOTH (CHARPOS (pt), BYTEPOS (pt)); | 2473 TEMP_SET_PT_BOTH (CHARPOS (pt), BYTEPOS (pt)); |
2460 UNGCPRO; | 2474 UNGCPRO; |
2461 } | 2475 } |
2491 } | 2505 } |
2492 else if (FUNCTIONP (it->font_height)) | 2506 else if (FUNCTIONP (it->font_height)) |
2493 { | 2507 { |
2494 /* Call function with current height as argument. | 2508 /* Call function with current height as argument. |
2495 Value is the new height. */ | 2509 Value is the new height. */ |
2496 Lisp_Object args[2], height; | 2510 Lisp_Object height; |
2497 | 2511 height = safe_call1 (it->font_height, |
2498 args[0] = it->font_height; | 2512 face->lface[LFACE_HEIGHT_INDEX]); |
2499 args[1] = face->lface[LFACE_HEIGHT_INDEX]; | |
2500 height = call_function (2, args); | |
2501 | |
2502 if (NUMBERP (height)) | 2513 if (NUMBERP (height)) |
2503 new_height = XFLOATINT (height); | 2514 new_height = XFLOATINT (height); |
2504 } | 2515 } |
2505 else if (NUMBERP (it->font_height)) | 2516 else if (NUMBERP (it->font_height)) |
2506 { | 2517 { |
2517 current specified height to get the new height. */ | 2528 current specified height to get the new height. */ |
2518 Lisp_Object value; | 2529 Lisp_Object value; |
2519 int count = specpdl_ptr - specpdl; | 2530 int count = specpdl_ptr - specpdl; |
2520 | 2531 |
2521 specbind (Qheight, face->lface[LFACE_HEIGHT_INDEX]); | 2532 specbind (Qheight, face->lface[LFACE_HEIGHT_INDEX]); |
2522 value = eval_form (it->font_height); | 2533 value = safe_eval (it->font_height); |
2523 unbind_to (count, Qnil); | 2534 unbind_to (count, Qnil); |
2524 | 2535 |
2525 if (NUMBERP (value)) | 2536 if (NUMBERP (value)) |
2526 new_height = XFLOATINT (value); | 2537 new_height = XFLOATINT (value); |
2527 } | 2538 } |
12409 /* An element of the form (:eval FORM) means evaluate FORM | 12420 /* An element of the form (:eval FORM) means evaluate FORM |
12410 and use the result as mode line elements. */ | 12421 and use the result as mode line elements. */ |
12411 struct gcpro gcpro1; | 12422 struct gcpro gcpro1; |
12412 Lisp_Object spec; | 12423 Lisp_Object spec; |
12413 | 12424 |
12414 spec = eval_form (XCAR (XCDR (elt))); | 12425 spec = safe_eval (XCAR (XCDR (elt))); |
12415 GCPRO1 (spec); | 12426 GCPRO1 (spec); |
12416 n += display_mode_element (it, depth, field_width - n, | 12427 n += display_mode_element (it, depth, field_width - n, |
12417 precision - n, spec); | 12428 precision - n, spec); |
12418 UNGCPRO; | 12429 UNGCPRO; |
12419 } | 12430 } |