Mercurial > emacs
comparison src/xdisp.c @ 59514:92e1b372276b
(Fformat_mode_line): Fix last change. Remove NO_PROPS arg
(specify 0 for FACE instead). Reorder arg list. Doc fix.
author | Kim F. Storm <storm@cua.dk> |
---|---|
date | Thu, 13 Jan 2005 09:36:01 +0000 |
parents | 1cf4d84c9eb7 |
children | 14875395f75b cb67264d6096 |
comparison
equal
deleted
inserted
replaced
59513:2fdd6bff1b75 | 59514:92e1b372276b |
---|---|
15976 return n; | 15976 return n; |
15977 } | 15977 } |
15978 | 15978 |
15979 | 15979 |
15980 DEFUN ("format-mode-line", Fformat_mode_line, Sformat_mode_line, | 15980 DEFUN ("format-mode-line", Fformat_mode_line, Sformat_mode_line, |
15981 1, 5, 0, | 15981 1, 4, 0, |
15982 doc: /* Return the mode-line of selected window as a string. | 15982 doc: /* Format a string out of a mode line format specification. |
15983 First arg FORMAT specifies the mode line format (see `mode-line-format' for | 15983 First arg FORMAT specifies the mode line format (see `mode-line-format' |
15984 details) to use. Second (optional) arg WINDOW specifies the window to | 15984 for details) to use. |
15985 use as the context for the formatting (default is the selected window). | 15985 |
15986 | 15986 Optional second arg FACE specifies the face property to put |
15987 If third (optional) arg NO-PROPS is non-nil, the value string has | |
15988 no text properties. The fourth (optional) arg BUFFER specifies | |
15989 which buffer to use (default, the current buffer). | |
15990 | |
15991 Fifth (optional) arg FACE specifies the face property to put | |
15992 on all characters for which no face is specified. | 15987 on all characters for which no face is specified. |
15993 t means whatever face the window's mode line currently uses | 15988 t means whatever face the window's mode line currently uses |
15994 \(either `mode-line' or `mode-line-inactive', depending). | 15989 \(either `mode-line' or `mode-line-inactive', depending). |
15995 nil means the default is no face property. */) | 15990 nil means the default is no face property. |
15996 (format, window, no_props, buffer, face) | 15991 If FACE is an integer, the value string has no text properties. |
15997 Lisp_Object format, window, no_props, buffer, face; | 15992 |
15993 Optional third and fourth args WINDOW and BUFFER specify the window | |
15994 and buffer to use as the context for the formatting (defaults | |
15995 are the selected window and the window's buffer). */) | |
15996 (format, face, window, buffer) | |
15997 Lisp_Object format, face, window, buffer; | |
15998 { | 15998 { |
15999 struct it it; | 15999 struct it it; |
16000 int len; | 16000 int len; |
16001 struct window *w; | 16001 struct window *w; |
16002 struct buffer *old_buffer = NULL; | 16002 struct buffer *old_buffer = NULL; |
16003 enum face_id face_id; | 16003 int face_id = -1; |
16004 int no_props = INTEGERP (face); | |
16004 | 16005 |
16005 if (NILP (window)) | 16006 if (NILP (window)) |
16006 window = selected_window; | 16007 window = selected_window; |
16007 CHECK_WINDOW (window); | 16008 CHECK_WINDOW (window); |
16008 w = XWINDOW (window); | 16009 w = XWINDOW (window); |
16009 | 16010 |
16010 if (EQ (face, Qt)) | |
16011 face = (EQ (window, selected_window) ? Qmode_line : Qmode_line_inactive); | |
16012 | |
16013 if (!NILP (face)) | |
16014 { | |
16015 Lisp_Object tem = Fget (face, Qface); | |
16016 if (INTEGERP (tem)) | |
16017 face_id = XINT (tem); | |
16018 else | |
16019 { | |
16020 face = Qnil; | |
16021 face_id = DEFAULT_FACE_ID; | |
16022 } | |
16023 } | |
16024 | |
16025 if (NILP (buffer)) | 16011 if (NILP (buffer)) |
16026 buffer = w->buffer; | 16012 buffer = w->buffer; |
16027 | |
16028 CHECK_BUFFER (buffer); | 16013 CHECK_BUFFER (buffer); |
16014 | |
16015 if (NILP (format)) | |
16016 return build_string (""); | |
16017 | |
16018 if (no_props) | |
16019 face = Qnil; | |
16020 | |
16021 if (!NILP (face)) | |
16022 { | |
16023 if (EQ (face, Qt)) | |
16024 face = (EQ (window, selected_window) ? Qmode_line : Qmode_line_inactive); | |
16025 face_id = lookup_named_face (XFRAME (WINDOW_FRAME (w)), face, 0, 0); | |
16026 } | |
16027 | |
16028 if (face_id < 0) | |
16029 face_id = DEFAULT_FACE_ID; | |
16029 | 16030 |
16030 if (XBUFFER (buffer) != current_buffer) | 16031 if (XBUFFER (buffer) != current_buffer) |
16031 { | 16032 { |
16032 old_buffer = current_buffer; | 16033 old_buffer = current_buffer; |
16033 set_buffer_internal_1 (XBUFFER (buffer)); | 16034 set_buffer_internal_1 (XBUFFER (buffer)); |
16034 } | 16035 } |
16035 | 16036 |
16036 if (NILP (format) || EQ (format, Qt)) | |
16037 face_id = (NILP (format) | |
16038 ? CURRENT_MODE_LINE_FACE_ID (w) | |
16039 : HEADER_LINE_FACE_ID); | |
16040 | |
16041 init_iterator (&it, w, -1, -1, NULL, face_id); | 16037 init_iterator (&it, w, -1, -1, NULL, face_id); |
16042 | 16038 |
16043 if (NILP (no_props)) | 16039 if (!no_props) |
16044 { | 16040 { |
16045 mode_line_string_face = face; | 16041 mode_line_string_face = face; |
16046 | |
16047 mode_line_string_face_prop | 16042 mode_line_string_face_prop |
16048 = (NILP (mode_line_string_face) ? Qnil | 16043 = (NILP (face) ? Qnil : Fcons (Qface, Fcons (face, Qnil))); |
16049 : Fcons (Qface, Fcons (mode_line_string_face, Qnil))); | |
16050 | 16044 |
16051 /* We need a dummy last element in mode_line_string_list to | 16045 /* We need a dummy last element in mode_line_string_list to |
16052 indicate we are building the propertized mode-line string. | 16046 indicate we are building the propertized mode-line string. |
16053 Using mode_line_string_face_prop here GC protects it. */ | 16047 Using mode_line_string_face_prop here GC protects it. */ |
16054 mode_line_string_list | 16048 mode_line_string_list |
16067 pop_frame_kboard (); | 16061 pop_frame_kboard (); |
16068 | 16062 |
16069 if (old_buffer) | 16063 if (old_buffer) |
16070 set_buffer_internal_1 (old_buffer); | 16064 set_buffer_internal_1 (old_buffer); |
16071 | 16065 |
16072 if (NILP (no_props)) | 16066 if (!no_props) |
16073 { | 16067 { |
16074 Lisp_Object str; | 16068 Lisp_Object str; |
16075 mode_line_string_list = Fnreverse (mode_line_string_list); | 16069 mode_line_string_list = Fnreverse (mode_line_string_list); |
16076 str = Fmapconcat (intern ("identity"), XCDR (mode_line_string_list), | 16070 str = Fmapconcat (intern ("identity"), XCDR (mode_line_string_list), |
16077 make_string ("", 0)); | 16071 make_string ("", 0)); |