unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Stefan Monnier" <monnier+gnu/emacs@RUM.cs.yale.edu>
Subject: mode-line-element-to-string
Date: Thu, 11 Apr 2002 10:11:46 -0400	[thread overview]
Message-ID: <200204111411.g3BEBkF30552@rum.cs.yale.edu> (raw)


Any objection to the patch below ?
I'd also welcome comments, especially suggestions for a better name.


	Stefan


--- xdisp.c.~1.746.~	Mon Apr  8 15:43:35 2002
+++ xdisp.c	Thu Apr 11 10:09:05 2002
@@ -7169,8 +7169,6 @@
  ***********************************************************************/
 
 
-#ifdef HAVE_WINDOW_SYSTEM
-
 /* A buffer for constructing frame titles in it; allocated from the
    heap in init_xdisp and resized as needed in store_frame_title_char.  */
 
@@ -7237,6 +7235,26 @@
   return n;
 }
 
+DEFUN ("mode-line-element-to-string", Fmode_line_element_to_string,
+       Smode_line_element_to_string, 1, 1, 0,
+       doc: /* Return the string corresponding to a mode-line-element.  */)
+  (fmt)
+     Lisp_Object fmt;
+{
+  struct it it;
+  int len;
+
+  frame_title_ptr = frame_title_buf;
+  init_iterator (&it, XWINDOW (selected_window), -1, -1,
+  		 NULL, DEFAULT_FACE_ID);
+  display_mode_element (&it , 0, -1, -1, fmt, Qnil, 0);
+  len = frame_title_ptr - frame_title_buf;
+  frame_title_ptr = NULL;
+  return make_string (frame_title_buf, len);
+}
+
+
+#ifdef HAVE_WINDOW_SYSTEM
 
 /* Set the title of FRAME, if it has changed.  The title format is
    Vicon_title_format if FRAME is iconified, otherwise it is
@@ -7301,11 +7319,6 @@
     }
 }
 
-#else /* not HAVE_WINDOW_SYSTEM */
-
-#define frame_title_ptr ((char *)0)
-#define store_frame_title(str, mincol, maxcol) 0
-
 #endif /* not HAVE_WINDOW_SYSTEM */
 
 
@@ -13628,7 +13641,10 @@
    PROPS is a property list to add to any string we encounter.
 
    If RISKY is nonzero, remove (disregard) any properties in any string 
-   we encounter, and ignore :eval and :propertize.  */
+   we encounter, and ignore :eval and :propertize.
+
+   If the global variable `frame_title_ptr' is non-NULL, then the output
+   is passed to `store_frame_title' instead of `display_string'.  */
 
 static int
 display_mode_element (it, depth, field_width, precision, elt, props, risky)
@@ -14868,6 +14884,7 @@
 #ifdef HAVE_WINDOW_SYSTEM
   defsubr (&Stool_bar_lines_needed);
 #endif
+  defsubr (&Smode_line_element_to_string);
 
   staticpro (&Qmenu_bar_update_hook);
   Qmenu_bar_update_hook = intern ("menu-bar-update-hook");
@@ -15263,15 +15280,14 @@
 	default_invis_vector[i] = make_number ('.');
     }
 
-#ifdef HAVE_WINDOW_SYSTEM
   {
-    /* Allocate the buffer for frame titles.  */
+    /* Allocate the buffer for frame titles.
+       Also used for mode-line-element-to-string.  */
     int size = 100;
     frame_title_buf = (char *) xmalloc (size);
     frame_title_buf_end = frame_title_buf + size;
     frame_title_ptr = NULL;
   }
-#endif /* HAVE_WINDOW_SYSTEM */
   
   help_echo_showing_p = 0;
 }

             reply	other threads:[~2002-04-11 14:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-11 14:11 Stefan Monnier [this message]
2002-04-11 15:06 ` mode-line-element-to-string Miles Bader
2002-04-11 17:13 ` mode-line-element-to-string Juanma Barranquero
2002-04-11 18:14   ` mode-line-element-to-string Stefan Monnier
2002-04-12  3:13 ` mode-line-element-to-string Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200204111411.g3BEBkF30552@rum.cs.yale.edu \
    --to=monnier+gnu/emacs@rum.cs.yale.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).