Mercurial > emacs
comparison src/xdisp.c @ 44396:ea58bae14724
(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.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 04 Apr 2002 21:10:36 +0000 |
parents | f532fa5aeca1 |
children | c71959ed4615 |
comparison
equal
deleted
inserted
replaced
44395:ff17e15cf8c8 | 44396:ea58bae14724 |
---|---|
223 Lisp_Object QCeval, Qwhen, QCfile, QCdata, QCpropertize; | 223 Lisp_Object QCeval, Qwhen, QCfile, QCdata, QCpropertize; |
224 Lisp_Object Qfontified; | 224 Lisp_Object Qfontified; |
225 Lisp_Object Qgrow_only; | 225 Lisp_Object Qgrow_only; |
226 Lisp_Object Qinhibit_eval_during_redisplay; | 226 Lisp_Object Qinhibit_eval_during_redisplay; |
227 Lisp_Object Qbuffer_position, Qposition, Qobject; | 227 Lisp_Object Qbuffer_position, Qposition, Qobject; |
228 | |
229 Lisp_Object Qrisky_local_variable; | |
228 | 230 |
229 /* Holds the list (error). */ | 231 /* Holds the list (error). */ |
230 Lisp_Object list_of_error; | 232 Lisp_Object list_of_error; |
231 | 233 |
232 /* Functions called to fontify regions of text. */ | 234 /* Functions called to fontify regions of text. */ |
758 static int try_window_reusing_current_matrix P_ ((struct window *)); | 760 static int try_window_reusing_current_matrix P_ ((struct window *)); |
759 static int try_window_id P_ ((struct window *)); | 761 static int try_window_id P_ ((struct window *)); |
760 static int display_line P_ ((struct it *)); | 762 static int display_line P_ ((struct it *)); |
761 static int display_mode_lines P_ ((struct window *)); | 763 static int display_mode_lines P_ ((struct window *)); |
762 static int display_mode_line P_ ((struct window *, enum face_id, Lisp_Object)); | 764 static int display_mode_line P_ ((struct window *, enum face_id, Lisp_Object)); |
763 static int display_mode_element P_ ((struct it *, int, int, int, Lisp_Object, Lisp_Object)); | 765 static int display_mode_element P_ ((struct it *, int, int, int, Lisp_Object, Lisp_Object, int)); |
764 static char *decode_mode_spec P_ ((struct window *, int, int, int, int *)); | 766 static char *decode_mode_spec P_ ((struct window *, int, int, int, int *)); |
765 static void display_menu_bar P_ ((struct window *)); | 767 static void display_menu_bar P_ ((struct window *)); |
766 static int display_count_lines P_ ((int, int, int, int, int *)); | 768 static int display_count_lines P_ ((int, int, int, int, int *)); |
767 static int display_string P_ ((unsigned char *, Lisp_Object, Lisp_Object, | 769 static int display_string P_ ((unsigned char *, Lisp_Object, Lisp_Object, |
768 int, int, struct it *, int, int, int, int)); | 770 int, int, struct it *, int, int, int, int)); |
4943 ***********************************************************************/ | 4945 ***********************************************************************/ |
4944 | 4946 |
4945 /* Move iterator IT to a specified buffer or X position within one | 4947 /* Move iterator IT to a specified buffer or X position within one |
4946 line on the display without producing glyphs. | 4948 line on the display without producing glyphs. |
4947 | 4949 |
4948 Begin to skip at IT's current position. Skip to TO_CHARPOS or TO_X | 4950 OP should be a bit mask including some or all of these bits: |
4949 whichever is reached first. | 4951 MOVE_TO_X: Stop on reaching x-position TO_X. |
4950 | 4952 MOVE_TO_POS: Stop on reaching buffer or string position TO_CHARPOS. |
4951 TO_CHARPOS <= 0 means no TO_CHARPOS is specified. | 4953 Regardless of OP's value, stop in reaching the end of the display line. |
4952 | 4954 |
4953 TO_X < 0 means that no TO_X is specified. TO_X is normally a value | 4955 TO_X is normally a value 0 <= TO_X <= IT->last_visible_x. |
4954 0 <= TO_X <= IT->last_visible_x. This means in particular, that | 4956 This means, in particular, that TO_X includes window's horizontal |
4955 TO_X includes the amount by which a window is horizontally | 4957 scroll amount. |
4956 scrolled. | 4958 |
4957 | 4959 The return value has several possible values that |
4958 Value is | 4960 say what condition caused the scan to stop: |
4959 | 4961 |
4960 MOVE_POS_MATCH_OR_ZV | 4962 MOVE_POS_MATCH_OR_ZV |
4961 - when TO_POS or ZV was reached. | 4963 - when TO_POS or ZV was reached. |
4962 | 4964 |
4963 MOVE_X_REACHED | 4965 MOVE_X_REACHED |
7280 set_buffer_internal_1 (XBUFFER (XWINDOW (f->selected_window)->buffer)); | 7282 set_buffer_internal_1 (XBUFFER (XWINDOW (f->selected_window)->buffer)); |
7281 fmt = FRAME_ICONIFIED_P (f) ? Vicon_title_format : Vframe_title_format; | 7283 fmt = FRAME_ICONIFIED_P (f) ? Vicon_title_format : Vframe_title_format; |
7282 frame_title_ptr = frame_title_buf; | 7284 frame_title_ptr = frame_title_buf; |
7283 init_iterator (&it, XWINDOW (f->selected_window), -1, -1, | 7285 init_iterator (&it, XWINDOW (f->selected_window), -1, -1, |
7284 NULL, DEFAULT_FACE_ID); | 7286 NULL, DEFAULT_FACE_ID); |
7285 display_mode_element (&it, 0, -1, -1, fmt, Qnil); | 7287 display_mode_element (&it, 0, -1, -1, fmt, Qnil, 0); |
7286 len = frame_title_ptr - frame_title_buf; | 7288 len = frame_title_ptr - frame_title_buf; |
7287 frame_title_ptr = NULL; | 7289 frame_title_ptr = NULL; |
7288 set_buffer_internal_1 (obuf); | 7290 set_buffer_internal_1 (obuf); |
7289 | 7291 |
7290 /* Set the title only if it's changed. This avoids consing in | 7292 /* Set the title only if it's changed. This avoids consing in |
13576 | 13578 |
13577 /* Temporarily make frame's keyboard the current kboard so that | 13579 /* Temporarily make frame's keyboard the current kboard so that |
13578 kboard-local variables in the mode_line_format will get the right | 13580 kboard-local variables in the mode_line_format will get the right |
13579 values. */ | 13581 values. */ |
13580 push_frame_kboard (it.f); | 13582 push_frame_kboard (it.f); |
13581 display_mode_element (&it, 0, 0, 0, format, Qnil); | 13583 display_mode_element (&it, 0, 0, 0, format, Qnil, 0); |
13582 pop_frame_kboard (); | 13584 pop_frame_kboard (); |
13583 | 13585 |
13584 /* Fill up with spaces. */ | 13586 /* Fill up with spaces. */ |
13585 display_string (" ", Qnil, Qnil, 0, 0, &it, 10000, -1, -1, 0); | 13587 display_string (" ", Qnil, Qnil, 0, 0, &it, 10000, -1, -1, 0); |
13586 | 13588 |
13619 FIELD_WIDTH is the number of characters the display of ELT should | 13621 FIELD_WIDTH is the number of characters the display of ELT should |
13620 occupy in the mode line, and PRECISION is the maximum number of | 13622 occupy in the mode line, and PRECISION is the maximum number of |
13621 characters to display from ELT's representation. See | 13623 characters to display from ELT's representation. See |
13622 display_string for details. | 13624 display_string for details. |
13623 | 13625 |
13624 Returns the hpos of the end of the text generated by ELT. */ | 13626 Returns the hpos of the end of the text generated by ELT. |
13627 | |
13628 PROPS is a property list to add to any string we encounter. | |
13629 | |
13630 If RISKY is nonzero, remove (disregard) any properties in any string | |
13631 we encounter, and ignore :eval and :propertize. */ | |
13625 | 13632 |
13626 static int | 13633 static int |
13627 display_mode_element (it, depth, field_width, precision, elt, props) | 13634 display_mode_element (it, depth, field_width, precision, elt, props, risky) |
13628 struct it *it; | 13635 struct it *it; |
13629 int depth; | 13636 int depth; |
13630 int field_width, precision; | 13637 int field_width, precision; |
13631 Lisp_Object elt, props; | 13638 Lisp_Object elt, props; |
13639 int risky; | |
13632 { | 13640 { |
13633 int n = 0, field, prec; | 13641 int n = 0, field, prec; |
13634 int literal = 0; | 13642 int literal = 0; |
13635 | 13643 |
13636 tail_recurse: | 13644 tail_recurse: |
13645 { | 13653 { |
13646 /* A string: output it and check for %-constructs within it. */ | 13654 /* A string: output it and check for %-constructs within it. */ |
13647 unsigned char c; | 13655 unsigned char c; |
13648 unsigned char *this, *lisp_string; | 13656 unsigned char *this, *lisp_string; |
13649 | 13657 |
13650 if (!NILP (props)) | 13658 if (!NILP (props) || risky) |
13651 { | 13659 { |
13652 Lisp_Object oprops, aelt; | 13660 Lisp_Object oprops, aelt; |
13653 oprops = Ftext_properties_at (make_number (0), elt); | 13661 oprops = Ftext_properties_at (make_number (0), elt); |
13654 if (NILP (Fequal (props, oprops))) | 13662 |
13663 if (NILP (Fequal (props, oprops)) || risky) | |
13655 { | 13664 { |
13656 /* If the starting string has properties, | 13665 /* If the starting string has properties, |
13657 merge the specified ones onto the existing ones. */ | 13666 merge the specified ones onto the existing ones. */ |
13658 if (! NILP (oprops)) | 13667 if (! NILP (oprops) && !risky) |
13659 { | 13668 { |
13660 Lisp_Object tem; | 13669 Lisp_Object tem; |
13661 | 13670 |
13662 oprops = Fcopy_sequence (oprops); | 13671 oprops = Fcopy_sequence (oprops); |
13663 tem = props; | 13672 tem = props; |
13750 /* Note that either PRECISION <= 0 or N < PRECISION. */ | 13759 /* Note that either PRECISION <= 0 or N < PRECISION. */ |
13751 prec = precision - n; | 13760 prec = precision - n; |
13752 | 13761 |
13753 if (c == 'M') | 13762 if (c == 'M') |
13754 n += display_mode_element (it, depth, field, prec, | 13763 n += display_mode_element (it, depth, field, prec, |
13755 Vglobal_mode_string, props); | 13764 Vglobal_mode_string, props, |
13765 risky); | |
13756 else if (c != 0) | 13766 else if (c != 0) |
13757 { | 13767 { |
13758 int multibyte; | 13768 int multibyte; |
13759 int bytepos, charpos; | 13769 int bytepos, charpos; |
13760 unsigned char *spec; | 13770 unsigned char *spec; |
13811 as if it appeared here directly. Avoid error if symbol void. | 13821 as if it appeared here directly. Avoid error if symbol void. |
13812 Special case: if value of symbol is a string, output the string | 13822 Special case: if value of symbol is a string, output the string |
13813 literally. */ | 13823 literally. */ |
13814 { | 13824 { |
13815 register Lisp_Object tem; | 13825 register Lisp_Object tem; |
13826 | |
13827 /* If the variable is not marked as risky to set | |
13828 then its contents are risky to use. */ | |
13829 if (NILP (Fget (elt, Qrisky_local_variable))) | |
13830 risky = 1; | |
13831 | |
13816 tem = Fboundp (elt); | 13832 tem = Fboundp (elt); |
13817 if (!NILP (tem)) | 13833 if (!NILP (tem)) |
13818 { | 13834 { |
13819 tem = Fsymbol_value (elt); | 13835 tem = Fsymbol_value (elt); |
13820 /* If value is a string, output that string literally: | 13836 /* If value is a string, output that string literally: |
13849 if (EQ (car, QCeval)) | 13865 if (EQ (car, QCeval)) |
13850 { | 13866 { |
13851 /* An element of the form (:eval FORM) means evaluate FORM | 13867 /* An element of the form (:eval FORM) means evaluate FORM |
13852 and use the result as mode line elements. */ | 13868 and use the result as mode line elements. */ |
13853 | 13869 |
13870 if (risky) | |
13871 break; | |
13872 | |
13854 if (CONSP (XCDR (elt))) | 13873 if (CONSP (XCDR (elt))) |
13855 { | 13874 { |
13856 Lisp_Object spec; | 13875 Lisp_Object spec; |
13857 spec = safe_eval (XCAR (XCDR (elt))); | 13876 spec = safe_eval (XCAR (XCDR (elt))); |
13858 n += display_mode_element (it, depth, field_width - n, | 13877 n += display_mode_element (it, depth, field_width - n, |
13859 precision - n, spec, props); | 13878 precision - n, spec, props, |
13879 risky); | |
13860 } | 13880 } |
13861 } | 13881 } |
13862 else if (EQ (car, QCpropertize)) | 13882 else if (EQ (car, QCpropertize)) |
13863 { | 13883 { |
13884 /* An element of the form (:propertize ELT PROPS...) | |
13885 means display ELT but applying properties PROPS. */ | |
13886 | |
13887 if (risky) | |
13888 break; | |
13889 | |
13864 if (CONSP (XCDR (elt))) | 13890 if (CONSP (XCDR (elt))) |
13865 { | 13891 n += display_mode_element (it, depth, field_width - n, |
13866 /* An element of the form (:propertize ELT PROPS...) | 13892 precision - n, XCAR (XCDR (elt)), |
13867 means display ELT but applying properties PROPS. */ | 13893 XCDR (XCDR (elt)), risky); |
13868 n += display_mode_element (it, depth, field_width - n, | |
13869 precision - n, XCAR (XCDR (elt)), | |
13870 XCDR (XCDR (elt))); | |
13871 } | |
13872 } | 13894 } |
13873 else if (SYMBOLP (car)) | 13895 else if (SYMBOLP (car)) |
13874 { | 13896 { |
13875 tem = Fboundp (car); | 13897 tem = Fboundp (car); |
13876 elt = XCDR (elt); | 13898 elt = XCDR (elt); |
13931 while (CONSP (elt) | 13953 while (CONSP (elt) |
13932 && --limit > 0 | 13954 && --limit > 0 |
13933 && (precision <= 0 || n < precision)) | 13955 && (precision <= 0 || n < precision)) |
13934 { | 13956 { |
13935 n += display_mode_element (it, depth, field_width - n, | 13957 n += display_mode_element (it, depth, field_width - n, |
13936 precision - n, XCAR (elt), props); | 13958 precision - n, XCAR (elt), |
13959 props, risky); | |
13937 elt = XCDR (elt); | 13960 elt = XCDR (elt); |
13938 } | 13961 } |
13939 } | 13962 } |
13940 } | 13963 } |
13941 break; | 13964 break; |
14920 staticpro (&Qposition); | 14943 staticpro (&Qposition); |
14921 Qbuffer_position = intern ("buffer-position"); | 14944 Qbuffer_position = intern ("buffer-position"); |
14922 staticpro (&Qbuffer_position); | 14945 staticpro (&Qbuffer_position); |
14923 Qobject = intern ("object"); | 14946 Qobject = intern ("object"); |
14924 staticpro (&Qobject); | 14947 staticpro (&Qobject); |
14948 Qrisky_local_variable = intern ("risky-local-variable"); | |
14949 staticpro (&Qrisky_local_variable); | |
14925 | 14950 |
14926 list_of_error = Fcons (intern ("error"), Qnil); | 14951 list_of_error = Fcons (intern ("error"), Qnil); |
14927 staticpro (&list_of_error); | 14952 staticpro (&list_of_error); |
14928 | 14953 |
14929 last_arrow_position = Qnil; | 14954 last_arrow_position = Qnil; |