all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* From mode-line-format to string?
@ 2002-09-05 15:42 Kai Großjohann
  2002-09-05 18:11 ` Kevin Rodgers
  0 siblings, 1 reply; 3+ messages in thread
From: Kai Großjohann @ 2002-09-05 15:42 UTC (permalink / raw)


I have the need for a variable with some of the features from
mode-line-format.  In particular, I'd like the concatenation features
and the list-with-first-element-being-variable feature.

So processing the value ("a" "b") should result in the string "ab".
(That's concatenation.)

And processing the value ((foo "valfoo") (bar "valbar")) should
result in "valfoovalbar" if both variables foo and bar are non-nil.
Else if bar is nil and foo is non-nil, "valfoo" should result, else if
foo is nil and bar is non-nil, "valbar" should result.

Is there a Lisp function or library that does this?

kai
-- 
A large number of young women don't trust men with beards.  (BFBS Radio)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: From mode-line-format to string?
  2002-09-05 15:42 From mode-line-format to string? Kai Großjohann
@ 2002-09-05 18:11 ` Kevin Rodgers
  2002-09-06  2:18   ` Miles Bader
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Rodgers @ 2002-09-05 18:11 UTC (permalink / raw)


Kai Großjohann wrote:

> I have the need for a variable with some of the features from
> mode-line-format.  In particular, I'd like the concatenation features
> and the list-with-first-element-being-variable feature.
> 
> So processing the value ("a" "b") should result in the string "ab".
> (That's concatenation.)
> 
> And processing the value ((foo "valfoo") (bar "valbar")) should
> result in "valfoovalbar" if both variables foo and bar are non-nil.
> Else if bar is nil and foo is non-nil, "valfoo" should result, else if
> foo is nil and bar is non-nil, "valbar" should result.
> 
> Is there a Lisp function or library that does this?


Sure:

 
http://groups.google.com/groups?selm=3CB48625.14978022%40ihs.com


;;; Description:
;;;
;;; Emacs doesn't provide distinct functions for (1) generating a string
;;; from `mode-line-format' and (2) displaying it in the mode line.  In
;;; src/xdisp.c, display_mode_element() does both, and it doesn't have a
;;; Lisp binding.  apply-mode-line-format.el defines an eponymous Lisp
;;; function that returns any `mode-line-format' template as a string.

-- 
Kevin Rodgers <kevinr@ihs.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: From mode-line-format to string?
  2002-09-05 18:11 ` Kevin Rodgers
@ 2002-09-06  2:18   ` Miles Bader
  0 siblings, 0 replies; 3+ messages in thread
From: Miles Bader @ 2002-09-06  2:18 UTC (permalink / raw)


Kevin Rodgers <kevinr@ihs.com> writes:
> ;;; Description:
> ;;;
> ;;; Emacs doesn't provide distinct functions for (1) generating a string
> ;;; from `mode-line-format' and (2) displaying it in the mode line.  In
> ;;; src/xdisp.c, display_mode_element() does both, and it doesn't have a
> ;;; Lisp binding.

Note that the CVS version of emacs now provides a lisp-callable
function for this, `format-mode-line':

   format-mode-line is a built-in function.
   (format-mode-line &optional FORMAT WINDOW NO-PROPS)

   Return the mode-line of selected window as a string.
   First optional arg FORMAT specifies a different format string (see
   `mode-line-format' for details) to use.  If FORMAT is t, return
   the buffer's header-line.  Second optional arg WINDOW specifies a
   different window to use as the context for the formatting.
   If third optional arg NO-PROPS is non-nil, string is not propertized.

-Miles
-- 
o The existentialist, not having a pillow, goes everywhere with the book by
  Sullivan, _I am going to spit on your graves_.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-09-06  2:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-09-05 15:42 From mode-line-format to string? Kai Großjohann
2002-09-05 18:11 ` Kevin Rodgers
2002-09-06  2:18   ` Miles Bader

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.