Subject: RE: bug#2588: 23.0.90; Man buffer improperly formatted - wrong width

From: "Drew Adams" <[email-masked]>
Date: Sat, 7 Mar 2009 08:20:01 -0800

> From: Eli Zaretskii Sent: Saturday, March 07, 2009 5:58 AM
> > M-x set-variable RET pop-up-frames RET t
> >  
> > Resize the current frame so that it is, say, only 30 chars wide.
> >  
> > M-x man RET bash RET
> >  
> > Buffer *Man bash* is shown in a new frame. The frame has the usual
> > default width of 80 chars.  But the text of the buffer is 
> > formatted to be only 30 chars wide.
> 
> I cannot reproduce this on my system, but I think I know why, see
> below.
> 
> > This same bug exists for Emacs 22 (e.g. 22.3) and Emacs 21
> > (e.g. 21.3.1).  Emacs 20 (e.g. 20.7) has no such bug.  
> 
> That's because Emacs 20 didn't set COLUMNS in the environment before
> invoking the `man' program.  But that had other adverse effects on X,
> see the comments in man.el where it sets COLUMNS.
> 
> > In Emacs 21, the bug occurs even without loading the two 
> > Cywin helper libraries.  With my SHELL var set to /bin/bash.exe,
> > I cannot test Emacs 22 or 23 without loading those libraries,
> > but I suspect the same bug occurs, as it does in Emacs 21.  IOW,
> > I don't think this has anything to do with using Cygwin.
> 
> Actually, it does have something to do with Cygwin: I'm guessing your
> man.exe comes from Cygwin, and tries to honor the COLUMNS environment
> variable.  My man.exe is a natively compiled clone of the Unix `man'
> command, and it doesn't pay attention to COLUMNS, so it always
> produces text whose width assumes an 80-column display, no matter what
> COLUMNS says.

That makes sense.

That Emacs sets COLUMNS to `Man-width' is fine. The problem is apparently that
If `Man-width' is not defined (as a positive integer) then Emacs sets COLUMNS to
the current `frame-width'. That's the cause of the bug, AFAICT. Logically, the
current (soon to be previous) frame width is 100% irrelevant to `man's display.