# HG changeset patch # User Richard M. Stallman # Date 1017954636 0 # Node ID ea58bae14724885f896fbdc26e7b67e82a9c899b # Parent ff17e15cf8c8435f81f49943f20362c99f9dd60d (display_mode_element): New arg RISKY. Disregard text props found or specified within a variable that isn't marked risky-local-variable. (Qrisky_local_variable): New variable. (syms_of_xdisp): Init and staticpro it. diff -r ff17e15cf8c8 -r ea58bae14724 src/xdisp.c --- a/src/xdisp.c Thu Apr 04 20:52:47 2002 +0000 +++ b/src/xdisp.c Thu Apr 04 21:10:36 2002 +0000 @@ -226,6 +226,8 @@ Lisp_Object Qinhibit_eval_during_redisplay; Lisp_Object Qbuffer_position, Qposition, Qobject; +Lisp_Object Qrisky_local_variable; + /* Holds the list (error). */ Lisp_Object list_of_error; @@ -760,7 +762,7 @@ static int display_line P_ ((struct it *)); static int display_mode_lines P_ ((struct window *)); static int display_mode_line P_ ((struct window *, enum face_id, Lisp_Object)); -static int display_mode_element P_ ((struct it *, int, int, int, Lisp_Object, Lisp_Object)); +static int display_mode_element P_ ((struct it *, int, int, int, Lisp_Object, Lisp_Object, int)); static char *decode_mode_spec P_ ((struct window *, int, int, int, int *)); static void display_menu_bar P_ ((struct window *)); static int display_count_lines P_ ((int, int, int, int, int *)); @@ -4945,17 +4947,17 @@ /* Move iterator IT to a specified buffer or X position within one line on the display without producing glyphs. - Begin to skip at IT's current position. Skip to TO_CHARPOS or TO_X - whichever is reached first. - - TO_CHARPOS <= 0 means no TO_CHARPOS is specified. - - TO_X < 0 means that no TO_X is specified. TO_X is normally a value - 0 <= TO_X <= IT->last_visible_x. This means in particular, that - TO_X includes the amount by which a window is horizontally - scrolled. - - Value is + OP should be a bit mask including some or all of these bits: + MOVE_TO_X: Stop on reaching x-position TO_X. + MOVE_TO_POS: Stop on reaching buffer or string position TO_CHARPOS. + Regardless of OP's value, stop in reaching the end of the display line. + + TO_X is normally a value 0 <= TO_X <= IT->last_visible_x. + This means, in particular, that TO_X includes window's horizontal + scroll amount. + + The return value has several possible values that + say what condition caused the scan to stop: MOVE_POS_MATCH_OR_ZV - when TO_POS or ZV was reached. @@ -7282,7 +7284,7 @@ frame_title_ptr = frame_title_buf; init_iterator (&it, XWINDOW (f->selected_window), -1, -1, NULL, DEFAULT_FACE_ID); - display_mode_element (&it, 0, -1, -1, fmt, Qnil); + display_mode_element (&it, 0, -1, -1, fmt, Qnil, 0); len = frame_title_ptr - frame_title_buf; frame_title_ptr = NULL; set_buffer_internal_1 (obuf); @@ -13578,7 +13580,7 @@ kboard-local variables in the mode_line_format will get the right values. */ push_frame_kboard (it.f); - display_mode_element (&it, 0, 0, 0, format, Qnil); + display_mode_element (&it, 0, 0, 0, format, Qnil, 0); pop_frame_kboard (); /* Fill up with spaces. */ @@ -13621,14 +13623,20 @@ characters to display from ELT's representation. See display_string for details. - Returns the hpos of the end of the text generated by ELT. */ + Returns the hpos of the end of the text generated by ELT. + + PROPS is a property list to add to any string we encounter. + + If RISKY is nonzero, remove (disregard) any properties in any string + we encounter, and ignore :eval and :propertize. */ static int -display_mode_element (it, depth, field_width, precision, elt, props) +display_mode_element (it, depth, field_width, precision, elt, props, risky) struct it *it; int depth; int field_width, precision; Lisp_Object elt, props; + int risky; { int n = 0, field, prec; int literal = 0; @@ -13647,15 +13655,16 @@ unsigned char c; unsigned char *this, *lisp_string; - if (!NILP (props)) + if (!NILP (props) || risky) { Lisp_Object oprops, aelt; oprops = Ftext_properties_at (make_number (0), elt); - if (NILP (Fequal (props, oprops))) + + if (NILP (Fequal (props, oprops)) || risky) { /* If the starting string has properties, merge the specified ones onto the existing ones. */ - if (! NILP (oprops)) + if (! NILP (oprops) && !risky) { Lisp_Object tem; @@ -13752,7 +13761,8 @@ if (c == 'M') n += display_mode_element (it, depth, field, prec, - Vglobal_mode_string, props); + Vglobal_mode_string, props, + risky); else if (c != 0) { int multibyte; @@ -13813,6 +13823,12 @@ literally. */ { register Lisp_Object tem; + + /* If the variable is not marked as risky to set + then its contents are risky to use. */ + if (NILP (Fget (elt, Qrisky_local_variable))) + risky = 1; + tem = Fboundp (elt); if (!NILP (tem)) { @@ -13851,24 +13867,30 @@ /* An element of the form (:eval FORM) means evaluate FORM and use the result as mode line elements. */ + if (risky) + break; + if (CONSP (XCDR (elt))) { Lisp_Object spec; spec = safe_eval (XCAR (XCDR (elt))); n += display_mode_element (it, depth, field_width - n, - precision - n, spec, props); + precision - n, spec, props, + risky); } } else if (EQ (car, QCpropertize)) { + /* An element of the form (:propertize ELT PROPS...) + means display ELT but applying properties PROPS. */ + + if (risky) + break; + if (CONSP (XCDR (elt))) - { - /* An element of the form (:propertize ELT PROPS...) - means display ELT but applying properties PROPS. */ - n += display_mode_element (it, depth, field_width - n, - precision - n, XCAR (XCDR (elt)), - XCDR (XCDR (elt))); - } + n += display_mode_element (it, depth, field_width - n, + precision - n, XCAR (XCDR (elt)), + XCDR (XCDR (elt)), risky); } else if (SYMBOLP (car)) { @@ -13933,7 +13955,8 @@ && (precision <= 0 || n < precision)) { n += display_mode_element (it, depth, field_width - n, - precision - n, XCAR (elt), props); + precision - n, XCAR (elt), + props, risky); elt = XCDR (elt); } } @@ -14922,6 +14945,8 @@ staticpro (&Qbuffer_position); Qobject = intern ("object"); staticpro (&Qobject); + Qrisky_local_variable = intern ("risky-local-variable"); + staticpro (&Qrisky_local_variable); list_of_error = Fcons (intern ("error"), Qnil); staticpro (&list_of_error);