unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stephen Berman <stephen.berman@gmx.net>
To: Stefan Monnier <monnier@IRO.UMontreal.CA>
Cc: 7307@debbugs.gnu.org
Subject: bug#7307: 24.0.50; Mode line had more than just dashes removed
Date: Fri, 05 Nov 2010 17:18:12 +0100	[thread overview]
Message-ID: <87vd4b68xn.fsf@escher.home> (raw)
In-Reply-To: <jwveib3pzpn.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Tue, 02 Nov 2010 10:32:55 -0400")

On Tue, 02 Nov 2010 10:32:55 -0400 Stefan Monnier <monnier@IRO.UMontreal.CA> wrote:

>> Hm, this may be conceptually simpler but at least for me not simpler to
>> implement, if I understand what you're suggesting, namely, that the
>> filler character should be provided by a defcustom, which is defined in
>> xdisp.c; is that right?  Before I try to do that, is the following
>> consistent with what you're suggesting (aside from lack the
>> configurability)?  If not, could you be more specific?
>
> Yes, that's pretty much what I meant, except for the lack
> of configurability.  To make it configurable, we'll need to build the
> lots_of_<foo> string dynamically in all cases.  Maybe that can be done
> by removing the test of field_width.

How about something like the following patch?  This builds the string
dynamically by filling decode_mode_spec_buf to the desired length,
dispensing with an additional lots_of_<foo> string.  AFAICT this gives
good results (though I admittedly haven't been able to find a case where
lots_of_filler (replacing lots_of_dashes) is used; what is such a
case?).

I also exposed the string character variable mode_line_filler to Lisp,
so it could be customizable, but I haven't been able to figure out how
to update the mode line with a new character.  Also, I don't know the
right way to set the default value: I assume it shouldn't be done in
decode_mode_spec() as below but at the top level together with the
DEFVAR, but then how can it be associated with the window whose mode
line is being constructed?

Steve Berman


*** /home/steve/bzr/emacs/trunk/src/xdisp.c	2010-10-24 13:56:16.000000000 +0200
--- /home/steve/bzr/emacs/quickfixes/src/xdisp.c	2010-11-05 16:02:21.000000000 +0100
***************
*** 642,647 ****
--- 642,652 ----
  
  int line_number_displayed;
  
+ /* Filler character used by the "%-" mode line spec.  Defaults to ' '
+    on a graphical display and to '-' on a tty.  */
+ 
+ static EMACS_INT mode_line_filler;
+ 
  /* Maximum buffer size for which to display line numbers.  */
  
  Lisp_Object Vline_number_display_limit;
***************
*** 19267,19274 ****
     Note we operate on the current buffer for most purposes,
     the exception being w->base_line_pos.  */
  
- static char lots_of_dashes[] = "--------------------------------------------------------------------------------------------------------------------------------------------";
- 
  static const char *
  decode_mode_spec (struct window *w, register int c, int field_width,
  		  int precision, Lisp_Object *string)
--- 19272,19277 ----
***************
*** 19277,19282 ****
--- 19280,19286 ----
    struct frame *f = XFRAME (WINDOW_FRAME (w));
    char *decode_mode_spec_buf = f->decode_mode_spec_buffer;
    struct buffer *b = current_buffer;
+   mode_line_filler = (FRAME_WINDOW_P (f)) ? ' ' : '-';
  
    obj = Qnil;
    *string = Qnil;
***************
*** 19338,19358 ****
      case '-':
        {
  	register int i;
! 
! 	/* Let lots_of_dashes be a string of infinite length.  */
! 	if (mode_line_target == MODE_LINE_NOPROP ||
! 	    mode_line_target == MODE_LINE_STRING)
! 	  return "--";
! 	if (field_width <= 0
! 	    || field_width > sizeof (lots_of_dashes))
! 	  {
! 	    for (i = 0; i < FRAME_MESSAGE_BUF_SIZE (f) - 1; ++i)
! 	      decode_mode_spec_buf[i] = '-';
! 	    decode_mode_spec_buf[i] = '\0';
! 	    return decode_mode_spec_buf;
! 	  }
! 	else
! 	  return lots_of_dashes;
        }
  
      case 'b':
--- 19342,19362 ----
      case '-':
        {
  	register int i;
! 	int fill_len;
! 	int lots_of_filler = 140 * sizeof (char);
!   
! 	/* Make a string of mode_line_filler characters.  */
! 	fill_len = 
! 	  (mode_line_target == MODE_LINE_NOPROP
! 	   || mode_line_target == MODE_LINE_STRING) 
! 	  ? 2
! 	  : ((field_width <= 0 || field_width > lots_of_filler)
! 	     ? FRAME_MESSAGE_BUF_SIZE (f) - 1 
! 	     : lots_of_filler);
! 	for (i = 0; i < fill_len; ++i)
! 	  decode_mode_spec_buf[i] = mode_line_filler;
! 	decode_mode_spec_buf[i] = '\0';
! 	return decode_mode_spec_buf;
        }
  
      case 'b':
***************
*** 26191,26196 ****
--- 26195,26204 ----
      doc: /* String (or mode line construct) included (normally) in `mode-line-format'.  */);
    Vglobal_mode_string = Qnil;
  
+   DEFVAR_INT ("mode-line-filler", &mode_line_filler,
+     doc: /* Filler character used by the "%-" mode line spec.
+ Defaults to ' ' on a graphical display and to '-' on a tty.  */);
+ 
    DEFVAR_LISP ("overlay-arrow-position", &Voverlay_arrow_position,
      doc: /* Marker for where to display an arrow on top of the buffer text.
  This must be the beginning of a line in order to work.





  reply	other threads:[~2010-11-05 16:18 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-29 23:05 bug#7307: 24.0.50; Mode line had more than just dashes removed Stephen Berman
2010-10-30  6:51 ` Eli Zaretskii
2010-10-30 13:27   ` Stephen Berman
2010-10-30 13:49     ` Eli Zaretskii
2010-10-30 15:23       ` Stephen Berman
2010-10-31  3:54     ` Stefan Monnier
2010-11-01 18:11       ` Stephen Berman
2010-11-01 19:32         ` Eli Zaretskii
2010-11-01 23:35           ` Stephen Berman
2010-11-02  5:35             ` Eli Zaretskii
2010-11-02  6:31               ` Eli Zaretskii
2010-11-02 14:32         ` Stefan Monnier
2010-11-05 16:18           ` Stephen Berman [this message]
2010-11-05 18:45             ` Andreas Schwab
2010-11-05 23:08               ` Stephen Berman
2010-11-08 18:28             ` Stefan Monnier
2010-11-21  0:37               ` Stephen Berman
2010-10-31  0:49 ` James Cloos
2010-11-01 18:11   ` Stephen Berman
2012-06-03  9:05 ` Chong Yidong

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=87vd4b68xn.fsf@escher.home \
    --to=stephen.berman@gmx.net \
    --cc=7307@debbugs.gnu.org \
    --cc=monnier@IRO.UMontreal.CA \
    /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).