you as part of the interpreter's command loop or as the result of
calling Lisp functions like `sit-for'. The C function `redisplay'
in xdisp.c is the only entry into the inner redisplay code. (Or,
- let's say almost---see the the description of direct update
+ let's say almost---see the description of direct update
operations, below.).
The following diagram shows how redisplay code is invoked. As you
Lisp_Object Qinhibit_eval_during_redisplay;
Lisp_Object Qbuffer_position, Qposition, Qobject;
+Lisp_Object Qrisky_local_variable;
+
/* Functions called to fontify regions of text. */
Lisp_Object Vfontification_functions;
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));
+static int display_mode_element P_ ((struct it *, int, int, int, 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 *));
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);
+ display_mode_element (&it, 0, -1, -1, fmt, 0);
len = frame_title_ptr - frame_title_buf;
frame_title_ptr = NULL;
set_buffer_internal (obuf);
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);
+ display_mode_element (&it, 0, 0, 0, format, 0);
pop_frame_kboard ();
/* Fill up with spaces. */
FIELD_WIDTH is the number of characters the display of ELT should
occupy in the mode line, and PRECISION is the maximum number of
characters to display from ELT's representation. See
- display_string for details. *
+ display_string for details.
+
+ RISKY non-zero means ELT's contents are risky to use.
Returns the hpos of the end of the text generated by ELT. */
static int
-display_mode_element (it, depth, field_width, precision, elt)
+display_mode_element (it, depth, field_width, precision, elt, risky)
struct it *it;
int depth;
int field_width, precision;
Lisp_Object elt;
+ int risky;
{
int n = 0, field, prec;
unsigned char *this = XSTRING (elt)->data;
unsigned char *lisp_string = this;
+ /* Remove text properties from mode-line elements whose values
+ come from variables not marked as risky. */
+ if (risky)
+ {
+ Lisp_Object props;
+
+ props = Ftext_properties_at (make_number (0), elt);
+ if (!NILP (props))
+ {
+ elt = Fcopy_sequence (elt);
+ Fset_text_properties (make_number (0), Flength (elt),
+ Qnil, elt);
+ }
+ /* We've copied ELT, so we need to update this and
+ lisp_string. */
+ this = XSTRING (elt)->data;
+ lisp_string = this;
+ }
+
while ((precision <= 0 || n < precision)
&& *this
&& (frame_title_ptr
if (c == 'M')
n += display_mode_element (it, depth, field, prec,
- Vglobal_mode_string);
+ Vglobal_mode_string, risky);
else if (c != 0)
{
int multibyte;
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))
{
If first element is a symbol, process the cadr or caddr recursively
according to whether the symbol's value is non-nil or nil. */
car = XCAR (elt);
- if (EQ (car, QCeval) && CONSP (XCDR (elt)))
+ if (EQ (car, QCeval))
{
/* An element of the form (:eval FORM) means evaluate FORM
and use the result as mode line elements. */
- struct gcpro gcpro1;
- Lisp_Object spec;
-
- spec = safe_eval (XCAR (XCDR (elt)));
- GCPRO1 (spec);
- n += display_mode_element (it, depth, field_width - n,
- precision - n, spec);
- UNGCPRO;
+
+ if (risky)
+ break;
+
+ if (CONSP (XCDR (elt)))
+ {
+ struct gcpro gcpro1;
+ Lisp_Object spec;
+
+ spec = safe_eval (XCAR (XCDR (elt)));
+ GCPRO1 (spec);
+ n += display_mode_element (it, depth, field_width - n,
+ precision - n, spec, risky);
+ UNGCPRO;
+ }
}
else if (SYMBOLP (car))
{
&& (precision <= 0 || n < precision))
{
n += display_mode_element (it, depth, field_width - n,
- precision - n, XCAR (elt));
+ precision - n, XCAR (elt), risky);
elt = XCDR (elt);
}
}
staticpro (&Qbuffer_position);
Qobject = intern ("object");
staticpro (&Qobject);
+ Qrisky_local_variable = intern ("risky-local-variable");
+ staticpro (&Qrisky_local_variable);
last_arrow_position = Qnil;
last_arrow_string = Qnil;