From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Stefan Monnier" Newsgroups: gmane.emacs.devel Subject: mode-line-element-to-string Date: Thu, 11 Apr 2002 10:11:46 -0400 Sender: emacs-devel-admin@gnu.org Message-ID: <200204111411.g3BEBkF30552@rum.cs.yale.edu> NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1018541289 11718 127.0.0.1 (11 Apr 2002 16:08:09 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Thu, 11 Apr 2002 16:08:09 +0000 (UTC) Return-path: Original-Received: from hermes.netfonds.no ([195.204.10.138]) by main.gmane.org with esmtp (Exim 3.33 #1 (Debian)) id 16vh3Z-0000o2-02 for ; Thu, 11 Apr 2002 18:04:17 +0200 Original-Received: from quimby.gnus.org (quimby.gnus.org [80.91.224.244]) by hermes.netfonds.no (8.10.1/8.9.3) with ESMTP id g3BECcf00339 for ; Thu, 11 Apr 2002 16:12:38 +0200 (CEST) Original-Received: from fencepost.gnu.org ([199.232.76.164]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 16vfZL-0001s6-00 for ; Thu, 11 Apr 2002 16:28:59 +0200 Original-Received: from localhost ([127.0.0.1] helo=fencepost.gnu.org) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 16vfJ9-0007EJ-00; Thu, 11 Apr 2002 10:12:15 -0400 Original-Received: from rum.cs.yale.edu ([128.36.229.169]) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 16vfIh-0007D7-00 for ; Thu, 11 Apr 2002 10:11:47 -0400 Original-Received: (from monnier@localhost) by rum.cs.yale.edu (8.11.6/8.11.6) id g3BEBkF30552; Thu, 11 Apr 2002 10:11:46 -0400 X-Mailer: exmh version 2.4 06/23/2000 with nmh-1.0.4 Original-To: emacs-devel@gnu.org Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.9 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.devel:2545 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:2545 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; }