changeset 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 2fdd6bff1b75
children 77893ec9b41e
files src/xdisp.c
diffstat 1 files changed, 35 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/src/xdisp.c	Thu Jan 13 08:02:42 2005 +0000
+++ b/src/xdisp.c	Thu Jan 13 09:36:01 2005 +0000
@@ -15978,54 +15978,55 @@
 
 
 DEFUN ("format-mode-line", Fformat_mode_line, Sformat_mode_line,
-       1, 5, 0,
-       doc: /* Return the mode-line of selected window as a string.
-First arg FORMAT specifies the mode line format (see `mode-line-format' for
-details) to use.  Second (optional) arg WINDOW specifies the window to
-use as the context for the formatting (default is the selected window).
-
-If third (optional) arg NO-PROPS is non-nil, the value string has
-no text properties.  The fourth (optional) arg BUFFER specifies
-which buffer to use (default, the current buffer).
-
-Fifth (optional) arg FACE specifies the face property to put
+       1, 4, 0,
+       doc: /* Format a string out of a mode line format specification.
+First arg FORMAT specifies the mode line format (see `mode-line-format'
+for details) to use.
+
+Optional second arg FACE specifies the face property to put
 on all characters for which no face is specified.
 t means whatever face the window's mode line currently uses
 \(either `mode-line' or `mode-line-inactive', depending).
-nil means the default is no face property.  */)
-  (format, window, no_props, buffer, face)
-     Lisp_Object format, window, no_props, buffer, face;
+nil means the default is no face property.
+If FACE is an integer, the value string has no text properties.
+
+Optional third and fourth args WINDOW and BUFFER specify the window
+and buffer to use as the context for the formatting (defaults
+are the selected window and the window's buffer).  */)
+  (format, face, window, buffer)
+     Lisp_Object format, face, window, buffer;
 {
   struct it it;
   int len;
   struct window *w;
   struct buffer *old_buffer = NULL;
-  enum face_id face_id;
+  int face_id = -1;
+  int no_props = INTEGERP (face);
 
   if (NILP (window))
     window = selected_window;
   CHECK_WINDOW (window);
   w = XWINDOW (window);
 
-  if (EQ (face, Qt))
-    face = (EQ (window, selected_window) ? Qmode_line : Qmode_line_inactive);
+  if (NILP (buffer))
+    buffer = w->buffer;
+  CHECK_BUFFER (buffer);
+
+  if (NILP (format))
+    return build_string ("");
+
+  if (no_props)
+    face = Qnil;
 
   if (!NILP (face))
     {
-      Lisp_Object tem = Fget (face, Qface);
-      if (INTEGERP (tem))
-	face_id = XINT (tem);
-      else
-	{
-	  face = Qnil;
-	  face_id = DEFAULT_FACE_ID;
-	}
-    }
-
-  if (NILP (buffer))
-    buffer = w->buffer;
-
-  CHECK_BUFFER (buffer);
+      if (EQ (face, Qt))
+	face = (EQ (window, selected_window) ? Qmode_line : Qmode_line_inactive);
+      face_id = lookup_named_face (XFRAME (WINDOW_FRAME (w)), face, 0, 0);
+    }
+
+  if (face_id < 0)
+    face_id = DEFAULT_FACE_ID;
 
   if (XBUFFER (buffer) != current_buffer)
     {
@@ -16033,20 +16034,13 @@
       set_buffer_internal_1 (XBUFFER (buffer));
     }
 
-  if (NILP (format) || EQ (format, Qt))
-    face_id = (NILP (format)
-	       ? CURRENT_MODE_LINE_FACE_ID (w)
-	       : HEADER_LINE_FACE_ID);
-
   init_iterator (&it, w, -1, -1, NULL, face_id);
 
-  if (NILP (no_props))
+  if (!no_props)
     {
       mode_line_string_face = face;
-
       mode_line_string_face_prop
-	= (NILP (mode_line_string_face) ? Qnil
-	   : Fcons (Qface, Fcons (mode_line_string_face, Qnil)));
+	= (NILP (face) ? Qnil : Fcons (Qface, Fcons (face, Qnil)));
 
       /* We need a dummy last element in mode_line_string_list to
 	 indicate we are building the propertized mode-line string.
@@ -16069,7 +16063,7 @@
   if (old_buffer)
     set_buffer_internal_1 (old_buffer);
 
-  if (NILP (no_props))
+  if (!no_props)
     {
       Lisp_Object str;
       mode_line_string_list = Fnreverse (mode_line_string_list);