Subject: bug#2588: closed (Re: bug#2588: 23.0.90; Man buffer improperly formatted - wrong width)

From: [email-masked] (GNU bug Tracking System)
Date: Wed, 02 Jul 2014 00:19:05 +0000

Your bug report

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

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
2588: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=2588
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#2588: 23.0.90; Man buffer improperly formatted - wrong width
From: Juri Linkov <[email-masked]>
To: Stefan Monnier <[email-masked]>
Cc: [email-masked]
Date: Wed, 02 Jul 2014 02:57:42 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

Version: 24.4.50

>> The problem is, AFAICS, that with pop-up-frames `man' is run _before_
>> the frame to display its output is created.  To do what you want we
>
> We could try to fix this: I think it would actually be desirable to pop
> up the frame immediately and then asynchronously fill it as man's output
> comes in.

Now this is implemented in bug#17831 merged with bug#2588, but to fix
the original issue of running `man' with pop-up-frames in a frame that
is 30 chars wide, required an additional change (now installed as well)
to select the window after popping up the frame to get its real width
(since display-buffer in Man-notify method `friendly' doesn't select
the window):

=== modified file 'lisp/man.el'
--- lisp/man.el	2014-05-09 07:02:00 +0000
+++ lisp/man.el	2014-07-01 23:54:32 +0000
@@ -1030,15 +1030,22 @@ (defmacro Man-start-calling (&rest body)
     ;;               ther is available).
     (when (or window-system
 	      (not (or (getenv "MANWIDTH") (getenv "COLUMNS"))))
-      ;; This isn't strictly correct, since we don't know how
-      ;; the page will actually be displayed, but it seems
-      ;; reasonable.
+      ;; Since the page buffer is displayed beforehand,
+      ;; we can select its window and get the window/frame width.
       (setenv "COLUMNS" (number-to-string
 			 (cond
 			  ((and (integerp Man-width) (> Man-width 0))
 			   Man-width)
-			  (Man-width (frame-width))
-			  ((window-width))))))
+			  (Man-width
+			   (if (window-live-p (get-buffer-window (current-buffer) t))
+			       (with-selected-window (get-buffer-window (current-buffer) t)
+				 (frame-width))
+			     (frame-width)))
+			  (t
+			   (if (window-live-p (get-buffer-window (current-buffer) t))
+			       (with-selected-window (get-buffer-window (current-buffer) t)
+				 (window-width))
+			     (window-width)))))))
     ;; Since man-db 2.4.3-1, man writes plain text with no escape
     ;; sequences when stdout is not a tty.	In 2.5.0, the following
     ;; env-var was added to allow control of this (see Debian Bug#340673).

Subject: 23.0.90; Man buffer improperly formatted - wrong width
From: "Drew Adams" <[email-masked]>
To: <[email-masked]>
Date: Fri, 6 Mar 2009 12:51:59 -0800

emacs -Q
 
load library cygwin-mount.el, then setup-cygwin.el:
 
http://www.emacswiki.org/emacs/cygwin-mount.el
http://www.emacswiki.org/emacs/setup-cygwin.el
 
Use /bin/bash.exe as SHELL.
 
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.  Clearly a mismatch and not what a user
expects or intends.
 
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.  
 
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.
 
Please don't suggest customizing `Man-frame-parameters' or some such.
This should just work, normally, with no need for any user tweaking.
Setting `pop-up-frames' to non-nil does not imply that you want the
Man output (in a normal-width frame) to have the same width as the
frame that was current when you called `man'.

In GNU Emacs 23.0.90.1 (i386-mingw-nt5.1.2600)
 of 2009-02-01 on SOFT-MJASON
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (3.4)'