From c53a1624ad040f9f3ab788d7e3959c9eb585183e Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Thu, 4 Apr 2002 21:10:36 +0000 Subject: [PATCH] (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. --- src/xdisp.c | 79 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 52 insertions(+), 27 deletions(-) diff --git a/src/xdisp.c b/src/xdisp.c index 224f495cb5e..9dd35bae58f 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -226,6 +226,8 @@ Lisp_Object Qgrow_only; 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 try_window_id P_ ((struct window *)); 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 @@ next_element_from_composition (it) /* 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. + 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 < 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. + 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. - Value is + 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 @@ x_consider_frame_title (frame) 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 @@ display_mode_line (w, face_id, format) 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 @@ Lisp_Object mode_line_proptrans_alist; 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 @@ display_mode_element (it, depth, field_width, precision, elt, props) 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 @@ display_mode_element (it, depth, field_width, precision, elt, props) 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 @@ display_mode_element (it, depth, field_width, precision, elt, props) 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 @@ display_mode_element (it, depth, field_width, precision, elt, props) /* 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 @@ display_mode_element (it, depth, field_width, precision, elt, props) && (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 @@ syms_of_xdisp () 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); -- 2.39.2