Mercurial > emacs
comparison src/xdisp.c @ 90072:cb67264d6096
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-2
Merge from emacs--cvs-trunk--0
Patches applied:
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-83
- miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-84
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-3
- miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-4
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-5
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-6
- miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-11
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-12
Remove "-face" suffix from lazy-highlight face name
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-13
- miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-16
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-17
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-18
- miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-21
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-22
<no summary provided>
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-23
- miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-39
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-40
Fix regressions from latest reftex update
* miles@gnu.org--gnu-2005/gnus--rel--5.10--base-0
tag of miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-82
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-1
Merge from emacs--cvs-trunk--0
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-2
Merge from miles@gnu.org--gnu-2004
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-3
Merge from emacs--cvs-trunk--0
author | Miles Bader <miles@gnu.org> |
---|---|
date | Sun, 16 Jan 2005 03:40:12 +0000 |
parents | f6b4d0ebf147 92e1b372276b |
children | 2874904abbd4 |
comparison
equal
deleted
inserted
replaced
90071:f6b4d0ebf147 | 90072:cb67264d6096 |
---|---|
1 /* Display generation from window structure and buffer text. | 1 /* Display generation from window structure and buffer text. |
2 Copyright (C) 1985,86,87,88,93,94,95,97,98,99,2000,01,02,03,04 | 2 Copyright (C) 1985, 1986, 1987, 1988, 1993, 1994, 1995, 1997, 1998, 1999, |
3 Free Software Foundation, Inc. | 3 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. |
4 | 4 |
5 This file is part of GNU Emacs. | 5 This file is part of GNU Emacs. |
6 | 6 |
7 GNU Emacs is free software; you can redistribute it and/or modify | 7 GNU Emacs is free software; you can redistribute it and/or modify |
8 it under the terms of the GNU General Public License as published by | 8 it under the terms of the GNU General Public License as published by |
317 | 317 |
318 /* Non-nil means highlight trailing whitespace. */ | 318 /* Non-nil means highlight trailing whitespace. */ |
319 | 319 |
320 Lisp_Object Vshow_trailing_whitespace; | 320 Lisp_Object Vshow_trailing_whitespace; |
321 | 321 |
322 /* Non-nil means escape non-break space and hyphens. */ | |
323 | |
324 Lisp_Object Vshow_nonbreak_escape; | |
325 | |
322 #ifdef HAVE_WINDOW_SYSTEM | 326 #ifdef HAVE_WINDOW_SYSTEM |
323 extern Lisp_Object Voverflow_newline_into_fringe; | 327 extern Lisp_Object Voverflow_newline_into_fringe; |
324 | 328 |
325 /* Test if overflow newline into fringe. Called with iterator IT | 329 /* Test if overflow newline into fringe. Called with iterator IT |
326 at or past right window margin, and with IT->current_x set. */ | 330 at or past right window margin, and with IT->current_x set. */ |
344 Lisp_Object Qtrailing_whitespace; | 348 Lisp_Object Qtrailing_whitespace; |
345 | 349 |
346 /* Name and number of the face used to highlight escape glyphs. */ | 350 /* Name and number of the face used to highlight escape glyphs. */ |
347 | 351 |
348 Lisp_Object Qescape_glyph; | 352 Lisp_Object Qescape_glyph; |
349 int escape_glyph_face; | |
350 | 353 |
351 /* The symbol `image' which is the car of the lists used to represent | 354 /* The symbol `image' which is the car of the lists used to represent |
352 images in Lisp. */ | 355 images in Lisp. */ |
353 | 356 |
354 Lisp_Object Qimage; | 357 Lisp_Object Qimage; |
3266 it->dpend = default_invis_vector + 3; | 3269 it->dpend = default_invis_vector + 3; |
3267 } | 3270 } |
3268 | 3271 |
3269 it->dpvec_char_len = len; | 3272 it->dpvec_char_len = len; |
3270 it->current.dpvec_index = 0; | 3273 it->current.dpvec_index = 0; |
3274 it->dpvec_face_id = -1; | |
3271 | 3275 |
3272 /* Remember the current face id in case glyphs specify faces. | 3276 /* Remember the current face id in case glyphs specify faces. |
3273 IT's face is restored in set_iterator_to_next. */ | 3277 IT's face is restored in set_iterator_to_next. */ |
3274 it->saved_face_id = it->face_id; | 3278 it->saved_face_id = it->face_id; |
3275 it->method = next_element_from_display_vector; | 3279 it->method = next_element_from_display_vector; |
5005 { | 5009 { |
5006 it->dpvec_char_len = it->len; | 5010 it->dpvec_char_len = it->len; |
5007 it->dpvec = v->contents; | 5011 it->dpvec = v->contents; |
5008 it->dpend = v->contents + v->size; | 5012 it->dpend = v->contents + v->size; |
5009 it->current.dpvec_index = 0; | 5013 it->current.dpvec_index = 0; |
5014 it->dpvec_face_id = -1; | |
5010 it->saved_face_id = it->face_id; | 5015 it->saved_face_id = it->face_id; |
5011 it->method = next_element_from_display_vector; | 5016 it->method = next_element_from_display_vector; |
5012 it->ellipsis_p = 0; | 5017 it->ellipsis_p = 0; |
5013 } | 5018 } |
5014 else | 5019 else |
5036 || (it->c != '\n' | 5041 || (it->c != '\n' |
5037 && it->glyph_row && it->glyph_row->mode_line_p) | 5042 && it->glyph_row && it->glyph_row->mode_line_p) |
5038 || (it->c != '\n' && it->c != '\t')) | 5043 || (it->c != '\n' && it->c != '\t')) |
5039 : (it->multibyte_p | 5044 : (it->multibyte_p |
5040 ? (!CHAR_PRINTABLE_P (it->c) | 5045 ? (!CHAR_PRINTABLE_P (it->c) |
5041 || it->c == 0xA0 /* NO-BREAK SPACE */ | 5046 || (!NILP (Vshow_nonbreak_escape) |
5042 || it->c == 0xAD /* SOFT HYPHEN */) | 5047 && (it->c == 0xA0 /* NO-BREAK SPACE */ |
5048 || it->c == 0xAD /* SOFT HYPHEN */))) | |
5043 : (it->c >= 127 | 5049 : (it->c >= 127 |
5044 && (! unibyte_display_via_language_environment | 5050 && (! unibyte_display_via_language_environment |
5045 || (UNIBYTE_CHAR_HAS_MULTIBYTE_P (it->c))))))) | 5051 || (UNIBYTE_CHAR_HAS_MULTIBYTE_P (it->c))))))) |
5046 { | 5052 { |
5047 /* IT->c is a control character which must be displayed | 5053 /* IT->c is a control character which must be displayed |
5049 can be defined in the display table. Fill | 5055 can be defined in the display table. Fill |
5050 IT->ctl_chars with glyphs for what we have to | 5056 IT->ctl_chars with glyphs for what we have to |
5051 display. Then, set IT->dpvec to these glyphs. */ | 5057 display. Then, set IT->dpvec to these glyphs. */ |
5052 GLYPH g; | 5058 GLYPH g; |
5053 int ctl_len; | 5059 int ctl_len; |
5054 int face_id = escape_glyph_face; | 5060 int face_id, lface_id; |
5055 | 5061 GLYPH escape_glyph; |
5056 /* Find the face id if `escape-glyph' unless we recently did. */ | |
5057 if (face_id < 0) | |
5058 { | |
5059 Lisp_Object tem = Fget (Qescape_glyph, Qface); | |
5060 if (INTEGERP (tem)) | |
5061 face_id = XINT (tem); | |
5062 else | |
5063 face_id = 0; | |
5064 /* If there's overflow, use 0 instead. */ | |
5065 if (FAST_GLYPH_FACE (FAST_MAKE_GLYPH (0, face_id)) != face_id) | |
5066 face_id = 0; | |
5067 escape_glyph_face = face_id; | |
5068 } | |
5069 | 5062 |
5070 if (it->c < 128 && it->ctl_arrow_p) | 5063 if (it->c < 128 && it->ctl_arrow_p) |
5071 { | 5064 { |
5072 /* Set IT->ctl_chars[0] to the glyph for `^'. */ | 5065 /* Set IT->ctl_chars[0] to the glyph for `^'. */ |
5073 if (it->dp | 5066 if (it->dp |
5074 && INTEGERP (DISP_CTRL_GLYPH (it->dp)) | 5067 && INTEGERP (DISP_CTRL_GLYPH (it->dp)) |
5075 && GLYPH_CHAR_VALID_P (XINT (DISP_CTRL_GLYPH (it->dp)))) | 5068 && GLYPH_CHAR_VALID_P (XINT (DISP_CTRL_GLYPH (it->dp)))) |
5076 g = XINT (DISP_CTRL_GLYPH (it->dp)); | 5069 { |
5070 g = XINT (DISP_CTRL_GLYPH (it->dp)); | |
5071 lface_id = FAST_GLYPH_FACE (g); | |
5072 if (lface_id) | |
5073 { | |
5074 g = FAST_GLYPH_CHAR (g); | |
5075 face_id = merge_faces (it->f, Qt, lface_id, | |
5076 it->face_id); | |
5077 } | |
5078 } | |
5077 else | 5079 else |
5078 g = FAST_MAKE_GLYPH ('^', face_id); | 5080 { |
5081 /* Merge the escape-glyph face into the current face. */ | |
5082 face_id = merge_faces (it->f, Qescape_glyph, 0, | |
5083 it->face_id); | |
5084 g = '^'; | |
5085 } | |
5086 | |
5079 XSETINT (it->ctl_chars[0], g); | 5087 XSETINT (it->ctl_chars[0], g); |
5080 | 5088 g = it->c ^ 0100; |
5081 g = FAST_MAKE_GLYPH (it->c ^ 0100, face_id); | |
5082 XSETINT (it->ctl_chars[1], g); | 5089 XSETINT (it->ctl_chars[1], g); |
5083 ctl_len = 2; | 5090 ctl_len = 2; |
5091 goto display_control; | |
5084 } | 5092 } |
5085 else if (it->c == 0xA0 || it->c == 0xAD) | 5093 |
5094 if (it->dp | |
5095 && INTEGERP (DISP_ESCAPE_GLYPH (it->dp)) | |
5096 && GLYPH_CHAR_VALID_P (XFASTINT (DISP_ESCAPE_GLYPH (it->dp)))) | |
5086 { | 5097 { |
5087 /* Set IT->ctl_chars[0] to the glyph for `\\'. */ | 5098 escape_glyph = XFASTINT (DISP_ESCAPE_GLYPH (it->dp)); |
5088 if (it->dp | 5099 lface_id = FAST_GLYPH_FACE (escape_glyph); |
5089 && INTEGERP (DISP_ESCAPE_GLYPH (it->dp)) | 5100 if (lface_id) |
5090 && GLYPH_CHAR_VALID_P (XINT (DISP_ESCAPE_GLYPH (it->dp)))) | 5101 { |
5091 g = XINT (DISP_ESCAPE_GLYPH (it->dp)); | 5102 escape_glyph = FAST_GLYPH_CHAR (escape_glyph); |
5092 else | 5103 face_id = merge_faces (it->f, Qt, lface_id, |
5093 g = FAST_MAKE_GLYPH ('\\', face_id); | 5104 it->face_id); |
5094 XSETINT (it->ctl_chars[0], g); | 5105 } |
5095 | |
5096 g = FAST_MAKE_GLYPH (it->c == 0xAD ? '-' : ' ', face_id); | |
5097 XSETINT (it->ctl_chars[1], g); | |
5098 ctl_len = 2; | |
5099 } | 5106 } |
5100 else | 5107 else |
5101 { | 5108 { |
5102 unsigned char str[MAX_MULTIBYTE_LENGTH]; | 5109 /* Merge the escape-glyph face into the current face. */ |
5103 int len; | 5110 face_id = merge_faces (it->f, Qescape_glyph, 0, |
5104 int i; | 5111 it->face_id); |
5105 GLYPH escape_glyph; | 5112 escape_glyph = '\\'; |
5106 | 5113 } |
5107 /* Set IT->ctl_chars[0] to the glyph for `\\'. */ | 5114 |
5108 if (it->dp | 5115 if (it->c == 0xA0 || it->c == 0xAD) |
5109 && INTEGERP (DISP_ESCAPE_GLYPH (it->dp)) | 5116 { |
5110 && GLYPH_CHAR_VALID_P (XFASTINT (DISP_ESCAPE_GLYPH (it->dp)))) | 5117 XSETINT (it->ctl_chars[0], escape_glyph); |
5111 escape_glyph = XFASTINT (DISP_ESCAPE_GLYPH (it->dp)); | 5118 g = it->c == 0xAD ? '-' : ' '; |
5112 else | 5119 XSETINT (it->ctl_chars[1], g); |
5113 escape_glyph = FAST_MAKE_GLYPH ('\\', face_id); | 5120 ctl_len = 2; |
5114 | 5121 goto display_control; |
5115 if (CHAR_BYTE8_P (it->c)) | 5122 } |
5116 { | 5123 |
5117 str[0] = CHAR_TO_BYTE8 (it->c); | 5124 { |
5118 len = 1; | 5125 unsigned char str[MAX_MULTIBYTE_LENGTH]; |
5119 } | 5126 int len; |
5120 else if (it->c < 256) | 5127 int i; |
5121 { | 5128 |
5122 str[0] = it->c; | 5129 /* Set IT->ctl_chars[0] to the glyph for `\\'. */ |
5123 len = 1; | 5130 if (CHAR_BYTE8_P (it->c)) |
5124 } | 5131 { |
5125 else | 5132 str[0] = CHAR_TO_BYTE8 (it->c); |
5126 { | 5133 len = 1; |
5127 /* It's an invalid character, which | 5134 } |
5128 shouldn't happen actually, but due to | 5135 else if (it->c < 256) |
5129 bugs it may happen. Let's print the char | 5136 { |
5130 as is, there's not much meaningful we can | 5137 str[0] = it->c; |
5131 do with it. */ | 5138 len = 1; |
5139 } | |
5140 else | |
5141 { | |
5142 /* It's an invalid character, which shouldn't | |
5143 happen actually, but due to bugs it may | |
5144 happen. Let's print the char as is, there's | |
5145 not much meaningful we can do with it. */ | |
5132 str[0] = it->c; | 5146 str[0] = it->c; |
5133 str[1] = it->c >> 8; | 5147 str[1] = it->c >> 8; |
5134 str[2] = it->c >> 16; | 5148 str[2] = it->c >> 16; |
5135 str[3] = it->c >> 24; | 5149 str[3] = it->c >> 24; |
5136 len = 4; | 5150 len = 4; |
5137 } | 5151 } |
5138 | 5152 |
5139 for (i = 0; i < len; i++) | 5153 for (i = 0; i < len; i++) |
5140 { | 5154 { |
5141 XSETINT (it->ctl_chars[i * 4], escape_glyph); | 5155 XSETINT (it->ctl_chars[i * 4], escape_glyph); |
5142 /* Insert three more glyphs into IT->ctl_chars for | 5156 /* Insert three more glyphs into IT->ctl_chars for |
5143 the octal display of the character. */ | 5157 the octal display of the character. */ |
5144 g = FAST_MAKE_GLYPH (((str[i] >> 6) & 7) + '0', | 5158 g = ((str[i] >> 6) & 7) + '0'; |
5145 face_id); | 5159 XSETINT (it->ctl_chars[i * 4 + 1], g); |
5146 XSETINT (it->ctl_chars[i * 4 + 1], g); | 5160 g = ((str[i] >> 3) & 7) + '0'; |
5147 g = FAST_MAKE_GLYPH (((str[i] >> 3) & 7) + '0', | 5161 XSETINT (it->ctl_chars[i * 4 + 2], g); |
5148 face_id); | 5162 g = (str[i] & 7) + '0'; |
5149 XSETINT (it->ctl_chars[i * 4 + 2], g); | 5163 XSETINT (it->ctl_chars[i * 4 + 3], g); |
5150 g = FAST_MAKE_GLYPH ((str[i] & 7) + '0', | 5164 } |
5151 face_id); | 5165 ctl_len = len * 4; |
5152 XSETINT (it->ctl_chars[i * 4 + 3], g); | 5166 } |
5153 } | 5167 |
5154 ctl_len = len * 4; | 5168 display_control: |
5155 } | |
5156 | |
5157 /* Set up IT->dpvec and return first character from it. */ | 5169 /* Set up IT->dpvec and return first character from it. */ |
5158 it->dpvec_char_len = it->len; | 5170 it->dpvec_char_len = it->len; |
5159 it->dpvec = it->ctl_chars; | 5171 it->dpvec = it->ctl_chars; |
5160 it->dpend = it->dpvec + ctl_len; | 5172 it->dpend = it->dpvec + ctl_len; |
5161 it->current.dpvec_index = 0; | 5173 it->current.dpvec_index = 0; |
5174 it->dpvec_face_id = face_id; | |
5162 it->saved_face_id = it->face_id; | 5175 it->saved_face_id = it->face_id; |
5163 it->method = next_element_from_display_vector; | 5176 it->method = next_element_from_display_vector; |
5164 it->ellipsis_p = 0; | 5177 it->ellipsis_p = 0; |
5165 goto get_next; | 5178 goto get_next; |
5166 } | 5179 } |
5286 it->method = next_element_from_buffer; | 5299 it->method = next_element_from_buffer; |
5287 | 5300 |
5288 it->dpvec = NULL; | 5301 it->dpvec = NULL; |
5289 it->current.dpvec_index = -1; | 5302 it->current.dpvec_index = -1; |
5290 | 5303 |
5291 /* Recheck faces after display vector */ | |
5292 it->stop_charpos = 0; | |
5293 | |
5294 /* Skip over characters which were displayed via IT->dpvec. */ | 5304 /* Skip over characters which were displayed via IT->dpvec. */ |
5295 if (it->dpvec_char_len < 0) | 5305 if (it->dpvec_char_len < 0) |
5296 reseat_at_next_visible_line_start (it, 1); | 5306 reseat_at_next_visible_line_start (it, 1); |
5297 else if (it->dpvec_char_len > 0) | 5307 else if (it->dpvec_char_len > 0) |
5298 { | 5308 { |
5299 it->len = it->dpvec_char_len; | 5309 it->len = it->dpvec_char_len; |
5300 set_iterator_to_next (it, reseat_p); | 5310 set_iterator_to_next (it, reseat_p); |
5301 } | 5311 } |
5312 | |
5313 /* Recheck faces after display vector */ | |
5314 it->stop_charpos = IT_CHARPOS (*it); | |
5302 } | 5315 } |
5303 } | 5316 } |
5304 else if (it->method == next_element_from_string) | 5317 else if (it->method == next_element_from_string) |
5305 { | 5318 { |
5306 /* Current display element is a character from a Lisp string. */ | 5319 /* Current display element is a character from a Lisp string. */ |
5376 xassert (it->dpvec && it->current.dpvec_index >= 0); | 5389 xassert (it->dpvec && it->current.dpvec_index >= 0); |
5377 | 5390 |
5378 if (INTEGERP (*it->dpvec) | 5391 if (INTEGERP (*it->dpvec) |
5379 && GLYPH_CHAR_VALID_P (XFASTINT (*it->dpvec))) | 5392 && GLYPH_CHAR_VALID_P (XFASTINT (*it->dpvec))) |
5380 { | 5393 { |
5381 int lface_id; | |
5382 GLYPH g; | 5394 GLYPH g; |
5383 | 5395 |
5384 g = XFASTINT (it->dpvec[it->current.dpvec_index]); | 5396 g = XFASTINT (it->dpvec[it->current.dpvec_index]); |
5385 it->c = FAST_GLYPH_CHAR (g); | 5397 it->c = FAST_GLYPH_CHAR (g); |
5386 it->len = CHAR_BYTES (it->c); | 5398 it->len = CHAR_BYTES (it->c); |
5387 | 5399 |
5388 /* The entry may contain a face id to use. Such a face id is | 5400 /* The entry may contain a face id to use. Such a face id is |
5389 the id of a Lisp face, not a realized face. A face id of | 5401 the id of a Lisp face, not a realized face. A face id of |
5390 zero means no face is specified. */ | 5402 zero means no face is specified. */ |
5391 lface_id = FAST_GLYPH_FACE (g); | 5403 if (it->dpvec_face_id >= 0) |
5392 if (lface_id) | 5404 it->face_id = it->dpvec_face_id; |
5393 { | 5405 else |
5394 /* The function returns -1 if lface_id is invalid. */ | 5406 { |
5395 int face_id = ascii_face_of_lisp_face (it->f, lface_id); | 5407 int lface_id = FAST_GLYPH_FACE (g); |
5396 if (face_id >= 0) | 5408 if (lface_id > 0) |
5397 it->face_id = face_id; | 5409 it->face_id = merge_faces (it->f, Qt, lface_id, |
5410 it->saved_face_id); | |
5398 } | 5411 } |
5399 } | 5412 } |
5400 else | 5413 else |
5401 /* Display table entry is invalid. Return a space. */ | 5414 /* Display table entry is invalid. Return a space. */ |
5402 it->c = ' ', it->len = 1; | 5415 it->c = ' ', it->len = 1; |
11764 xassert (!NILP (w->buffer)); | 11777 xassert (!NILP (w->buffer)); |
11765 #if GLYPH_DEBUG | 11778 #if GLYPH_DEBUG |
11766 *w->desired_matrix->method = 0; | 11779 *w->desired_matrix->method = 0; |
11767 #endif | 11780 #endif |
11768 | 11781 |
11769 /* Force this to be looked up again for each redisp of each window. */ | |
11770 escape_glyph_face = -1; | |
11771 | |
11772 specbind (Qinhibit_point_motion_hooks, Qt); | 11782 specbind (Qinhibit_point_motion_hooks, Qt); |
11773 | 11783 |
11774 reconsider_clip_changes (w, buffer); | 11784 reconsider_clip_changes (w, buffer); |
11775 | 11785 |
11776 /* Has the mode line to be updated? */ | 11786 /* Has the mode line to be updated? */ |
16069 return n; | 16079 return n; |
16070 } | 16080 } |
16071 | 16081 |
16072 | 16082 |
16073 DEFUN ("format-mode-line", Fformat_mode_line, Sformat_mode_line, | 16083 DEFUN ("format-mode-line", Fformat_mode_line, Sformat_mode_line, |
16074 0, 4, 0, | 16084 1, 4, 0, |
16075 doc: /* Return the mode-line of selected window as a string. | 16085 doc: /* Format a string out of a mode line format specification. |
16076 First optional arg FORMAT specifies a different format string (see | 16086 First arg FORMAT specifies the mode line format (see `mode-line-format' |
16077 `mode-line-format' for details) to use. If FORMAT is t, return | 16087 for details) to use. |
16078 the buffer's header-line. Second optional arg WINDOW specifies a | 16088 |
16079 different window to use as the context for the formatting. | 16089 Optional second arg FACE specifies the face property to put |
16080 If third optional arg NO-PROPS is non-nil, string is not propertized. | 16090 on all characters for which no face is specified. |
16081 Fourth optional arg BUFFER specifies which buffer to use. */) | 16091 t means whatever face the window's mode line currently uses |
16082 (format, window, no_props, buffer) | 16092 \(either `mode-line' or `mode-line-inactive', depending). |
16083 Lisp_Object format, window, no_props, buffer; | 16093 nil means the default is no face property. |
16094 If FACE is an integer, the value string has no text properties. | |
16095 | |
16096 Optional third and fourth args WINDOW and BUFFER specify the window | |
16097 and buffer to use as the context for the formatting (defaults | |
16098 are the selected window and the window's buffer). */) | |
16099 (format, face, window, buffer) | |
16100 Lisp_Object format, face, window, buffer; | |
16084 { | 16101 { |
16085 struct it it; | 16102 struct it it; |
16086 int len; | 16103 int len; |
16087 struct window *w; | 16104 struct window *w; |
16088 struct buffer *old_buffer = NULL; | 16105 struct buffer *old_buffer = NULL; |
16089 enum face_id face_id = DEFAULT_FACE_ID; | 16106 int face_id = -1; |
16107 int no_props = INTEGERP (face); | |
16090 | 16108 |
16091 if (NILP (window)) | 16109 if (NILP (window)) |
16092 window = selected_window; | 16110 window = selected_window; |
16093 CHECK_WINDOW (window); | 16111 CHECK_WINDOW (window); |
16094 w = XWINDOW (window); | 16112 w = XWINDOW (window); |
16095 | 16113 |
16096 if (NILP (buffer)) | 16114 if (NILP (buffer)) |
16097 buffer = w->buffer; | 16115 buffer = w->buffer; |
16098 | |
16099 CHECK_BUFFER (buffer); | 16116 CHECK_BUFFER (buffer); |
16117 | |
16118 if (NILP (format)) | |
16119 return build_string (""); | |
16120 | |
16121 if (no_props) | |
16122 face = Qnil; | |
16123 | |
16124 if (!NILP (face)) | |
16125 { | |
16126 if (EQ (face, Qt)) | |
16127 face = (EQ (window, selected_window) ? Qmode_line : Qmode_line_inactive); | |
16128 face_id = lookup_named_face (XFRAME (WINDOW_FRAME (w)), face, 0, 0); | |
16129 } | |
16130 | |
16131 if (face_id < 0) | |
16132 face_id = DEFAULT_FACE_ID; | |
16100 | 16133 |
16101 if (XBUFFER (buffer) != current_buffer) | 16134 if (XBUFFER (buffer) != current_buffer) |
16102 { | 16135 { |
16103 old_buffer = current_buffer; | 16136 old_buffer = current_buffer; |
16104 set_buffer_internal_1 (XBUFFER (buffer)); | 16137 set_buffer_internal_1 (XBUFFER (buffer)); |
16105 } | 16138 } |
16106 | 16139 |
16107 if (NILP (format) || EQ (format, Qt)) | |
16108 { | |
16109 face_id = (NILP (format) | |
16110 ? CURRENT_MODE_LINE_FACE_ID (w) | |
16111 : HEADER_LINE_FACE_ID); | |
16112 format = (NILP (format) | |
16113 ? current_buffer->mode_line_format | |
16114 : current_buffer->header_line_format); | |
16115 } | |
16116 | |
16117 init_iterator (&it, w, -1, -1, NULL, face_id); | 16140 init_iterator (&it, w, -1, -1, NULL, face_id); |
16118 | 16141 |
16119 if (NILP (no_props)) | 16142 if (!no_props) |
16120 { | 16143 { |
16121 mode_line_string_face | 16144 mode_line_string_face = face; |
16122 = (face_id == MODE_LINE_FACE_ID ? Qmode_line | |
16123 : face_id == MODE_LINE_INACTIVE_FACE_ID ? Qmode_line_inactive | |
16124 : face_id == HEADER_LINE_FACE_ID ? Qheader_line : Qnil); | |
16125 | |
16126 mode_line_string_face_prop | 16145 mode_line_string_face_prop |
16127 = (NILP (mode_line_string_face) ? Qnil | 16146 = (NILP (face) ? Qnil : Fcons (Qface, Fcons (face, Qnil))); |
16128 : Fcons (Qface, Fcons (mode_line_string_face, Qnil))); | |
16129 | 16147 |
16130 /* We need a dummy last element in mode_line_string_list to | 16148 /* We need a dummy last element in mode_line_string_list to |
16131 indicate we are building the propertized mode-line string. | 16149 indicate we are building the propertized mode-line string. |
16132 Using mode_line_string_face_prop here GC protects it. */ | 16150 Using mode_line_string_face_prop here GC protects it. */ |
16133 mode_line_string_list | 16151 mode_line_string_list |
16146 pop_frame_kboard (); | 16164 pop_frame_kboard (); |
16147 | 16165 |
16148 if (old_buffer) | 16166 if (old_buffer) |
16149 set_buffer_internal_1 (old_buffer); | 16167 set_buffer_internal_1 (old_buffer); |
16150 | 16168 |
16151 if (NILP (no_props)) | 16169 if (!no_props) |
16152 { | 16170 { |
16153 Lisp_Object str; | 16171 Lisp_Object str; |
16154 mode_line_string_list = Fnreverse (mode_line_string_list); | 16172 mode_line_string_list = Fnreverse (mode_line_string_list); |
16155 str = Fmapconcat (intern ("identity"), XCDR (mode_line_string_list), | 16173 str = Fmapconcat (intern ("identity"), XCDR (mode_line_string_list), |
16156 make_string ("", 0)); | 16174 make_string ("", 0)); |
22496 DEFVAR_LISP ("show-trailing-whitespace", &Vshow_trailing_whitespace, | 22514 DEFVAR_LISP ("show-trailing-whitespace", &Vshow_trailing_whitespace, |
22497 doc: /* *Non-nil means highlight trailing whitespace. | 22515 doc: /* *Non-nil means highlight trailing whitespace. |
22498 The face used for trailing whitespace is `trailing-whitespace'. */); | 22516 The face used for trailing whitespace is `trailing-whitespace'. */); |
22499 Vshow_trailing_whitespace = Qnil; | 22517 Vshow_trailing_whitespace = Qnil; |
22500 | 22518 |
22519 DEFVAR_LISP ("show-nonbreak-escape", &Vshow_nonbreak_escape, | |
22520 doc: /* *Non-nil means display escape character before non-break space and hyphen. */); | |
22521 Vshow_nonbreak_escape = Qt; | |
22522 | |
22501 DEFVAR_LISP ("void-text-area-pointer", &Vvoid_text_area_pointer, | 22523 DEFVAR_LISP ("void-text-area-pointer", &Vvoid_text_area_pointer, |
22502 doc: /* *The pointer shape to show in void text areas. | 22524 doc: /* *The pointer shape to show in void text areas. |
22503 Nil means to show the text pointer. Other options are `arrow', `text', | 22525 Nil means to show the text pointer. Other options are `arrow', `text', |
22504 `hand', `vdrag', `hdrag', `modeline', and `hourglass'. */); | 22526 `hand', `vdrag', `hdrag', `modeline', and `hourglass'. */); |
22505 Vvoid_text_area_pointer = Qarrow; | 22527 Vvoid_text_area_pointer = Qarrow; |