unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Nick Roberts <nickrob@snap.net.nz>
Cc: emacs-devel@gnu.org
Subject: Re: format-mode-line
Date: Thu, 6 Jan 2005 13:21:38 +1300	[thread overview]
Message-ID: <16860.33938.337020.736393@farnswood.snap.net.nz> (raw)
In-Reply-To: <E1Cm1tP-0003Hp-WF@fencepost.gnu.org>

 >     I suggest changing format-mode-line so that FORMAT is not optional and not
 >     give a special meaning to nil and t. I think format-mode-line is currently
 >     always used with a value for FORMAT. If this is a good idea, I offer to do
 >     it and post my patch here.
 > 
 > The argument above seems convincing, so please do.

Here's the patch.

Nick

*** /home/nick/emacs/src/xdisp.c.~1.954.~	2005-01-06 12:32:47.000000000 +1300
--- /home/nick/emacs/src/xdisp.c	2005-01-06 12:44:01.000000000 +1300
***************
*** 15969,15982 ****
  
  
  DEFUN ("format-mode-line", Fformat_mode_line, Sformat_mode_line,
!        0, 4, 0,
         doc: /* Return the mode-line of selected window as a string.
! First optional arg FORMAT specifies the mode line format (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.
! Fourth optional arg BUFFER specifies which buffer to use.  */)
    (format, window, no_props, buffer)
       Lisp_Object format, window, no_props, buffer;
  {
--- 15969,15981 ----
  
  
  DEFUN ("format-mode-line", Fformat_mode_line, Sformat_mode_line,
!        1, 4, 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 a different window to
! use as the context for the formatting.  If third optional arg NO-PROPS is
! non-nil, string is not propertized.  Fourth optional arg BUFFER specifies
! which buffer to use.  */)
    (format, window, no_props, buffer)
       Lisp_Object format, window, no_props, buffer;
  {
***************
*** 16002,16017 ****
        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);
-       format = (NILP (format)
- 		? current_buffer->mode_line_format
- 		: current_buffer->header_line_format);
-     }
- 
    init_iterator (&it, w, -1, -1, NULL, face_id);
  
    if (NILP (no_props))
--- 16001,16006 ----

*** /home/nick/emacs/lispref/modes.texi.~1.82.~	2005-01-01 19:31:23.000000000 +1300
--- /home/nick/emacs/lispref/modes.texi	2005-01-06 12:53:46.000000000 +1300
***************
*** 1736,1753 ****
  the text that would appear in a mode line or header line
  based on certain mode-line specification.
  
! @defun format-mode-line &optional format window no-props buffer
  This function formats a line of text according to @var{format} as if
  it were generating the mode line for @var{window}, but instead of
  displaying the text in the mode line or the header line, it returns
  the text as a string.
  
! If @var{format} is @code{nil}, that means to use
! @code{mode-line-format} and return the text that would appear in the
! mode line.  If @var{format} is @code{t}, that means to use
! @code{header-line-format} so as to return the text that would appear
! in the header line (@code{""} if the window has no header line).
! The argument @var{window} defaults to the selected window.
  
  The value string normally has text properties that correspond to the
  faces, keymaps, etc., that the mode line would have.  If
--- 1736,1751 ----
  the text that would appear in a mode line or header line
  based on certain mode-line specification.
  
! @defun format-mode-line format &optional window no-props buffer
  This function formats a line of text according to @var{format} as if
  it were generating the mode line for @var{window}, but instead of
  displaying the text in the mode line or the header line, it returns
  the text as a string.
  
! For example, if @var{format} is @code{header-line-format} it returns the
! text that would appear in the header line (@code{""} if the window has
! no header line).  The argument @var{window} defaults to the selected
! window.
  
  The value string normally has text properties that correspond to the
  faces, keymaps, etc., that the mode line would have.  If

  reply	other threads:[~2005-01-06  0:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-04 12:25 format-mode-line Nick Roberts
2005-01-05  3:31 ` format-mode-line Richard Stallman
2005-01-06  0:21   ` Nick Roberts [this message]
2005-01-06 21:00     ` format-mode-line Kim F. Storm
2005-01-07  7:32       ` format-mode-line Nick Roberts
2005-01-07 23:04         ` format-mode-line Richard Stallman
2005-01-08 23:52           ` format-mode-line Stefan

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=16860.33938.337020.736393@farnswood.snap.net.nz \
    --to=nickrob@snap.net.nz \
    --cc=emacs-devel@gnu.org \
    /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).