* mode-line-element-to-string
@ 2002-04-11 14:11 Stefan Monnier
2002-04-11 15:06 ` mode-line-element-to-string Miles Bader
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Stefan Monnier @ 2002-04-11 14:11 UTC (permalink / 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;
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: mode-line-element-to-string
2002-04-11 14:11 mode-line-element-to-string Stefan Monnier
@ 2002-04-11 15:06 ` Miles Bader
2002-04-11 17:13 ` mode-line-element-to-string Juanma Barranquero
2002-04-12 3:13 ` mode-line-element-to-string Richard Stallman
2 siblings, 0 replies; 5+ messages in thread
From: Miles Bader @ 2002-04-11 15:06 UTC (permalink / raw)
Cc: emacs-devel
"Stefan Monnier" <monnier+gnu/emacs@RUM.cs.yale.edu> writes:
> I'd also welcome comments, especially suggestions for a better name.
`format-mode-line-string' ? [ala `format-time-string' ]
...or something like that
-mILes
--
97% of everything is grunge
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: mode-line-element-to-string
2002-04-11 14:11 mode-line-element-to-string Stefan Monnier
2002-04-11 15:06 ` mode-line-element-to-string Miles Bader
@ 2002-04-11 17:13 ` 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
2 siblings, 1 reply; 5+ messages in thread
From: Juanma Barranquero @ 2002-04-11 17:13 UTC (permalink / raw)
Cc: emacs-devel
> Any objection to the patch below ?
> I'd also welcome comments, especially suggestions for a better name.
emacs -q --no-site-file
M-x ielm
C-c C-b *scratch*
<Enter> ; enough times for the ELISP>
; prompt to be at the bottom
; of the Window
(mode-line-element-to-string "%c/%l") ; repeat till it crashes
Eventually it crashes in `display-count-lines'.
/L/e/k/t/u
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: mode-line-element-to-string
2002-04-11 17:13 ` mode-line-element-to-string Juanma Barranquero
@ 2002-04-11 18:14 ` Stefan Monnier
0 siblings, 0 replies; 5+ messages in thread
From: Stefan Monnier @ 2002-04-11 18:14 UTC (permalink / raw)
Cc: Stefan Monnier, emacs-devel
>
> > Any objection to the patch below ?
> > I'd also welcome comments, especially suggestions for a better name.
>
> emacs -q --no-site-file
> M-x ielm
> C-c C-b *scratch*
> <Enter> ; enough times for the ELISP>
> ; prompt to be at the bottom
> ; of the Window
> (mode-line-element-to-string "%c/%l") ; repeat till it crashes
>
> Eventually it crashes in `display-count-lines'.
Damn! The code relies on the current-buffer being the
buffer displayed in the selected-window. Hmmm...
Stefan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: mode-line-element-to-string
2002-04-11 14:11 mode-line-element-to-string Stefan Monnier
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-12 3:13 ` Richard Stallman
2 siblings, 0 replies; 5+ messages in thread
From: Richard Stallman @ 2002-04-12 3:13 UTC (permalink / raw)
Cc: emacs-devel
I have not checked the details, but this seems useful.
I propose the name format-mode-line-element
since that has verb that says what it does.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2002-04-12 3:13 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-04-11 14:11 mode-line-element-to-string Stefan Monnier
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
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.