From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?UTF-8?Q?Llu=C3=ADs?= Newsgroups: gmane.emacs.bugs Subject: bug#23169: 24.5; Inconsistent text reflow in man pages depending on window configuration Date: Sat, 02 Apr 2016 13:30:38 +0200 Message-ID: <8737r46ye9.fsf@fimbulvetr.bsc.es> References: <87bn5ug55o.fsf@fimbulvetr.bsc.es> <83egaqvbio.fsf@gnu.org> <87oa9t8iq4.fsf@fimbulvetr.bsc.es> <8337r5teg7.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1459596691 15583 80.91.229.3 (2 Apr 2016 11:31:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 2 Apr 2016 11:31:31 +0000 (UTC) Cc: 23169@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Apr 02 13:31:20 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1amJlv-0000I6-BY for geb-bug-gnu-emacs@m.gmane.org; Sat, 02 Apr 2016 13:31:19 +0200 Original-Received: from localhost ([::1]:48989 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1amJlu-0005po-Te for geb-bug-gnu-emacs@m.gmane.org; Sat, 02 Apr 2016 07:31:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33139) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1amJlj-0005dC-AW for bug-gnu-emacs@gnu.org; Sat, 02 Apr 2016 07:31:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1amJle-00019P-8d for bug-gnu-emacs@gnu.org; Sat, 02 Apr 2016 07:31:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:50697) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1amJle-00019J-5F for bug-gnu-emacs@gnu.org; Sat, 02 Apr 2016 07:31:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1amJle-0001h2-03 for bug-gnu-emacs@gnu.org; Sat, 02 Apr 2016 07:31:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Llu=C3=ADs?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 02 Apr 2016 11:31:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23169 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 23169-submit@debbugs.gnu.org id=B23169.14595966495886 (code B ref 23169); Sat, 02 Apr 2016 11:31:01 +0000 Original-Received: (at 23169) by debbugs.gnu.org; 2 Apr 2016 11:30:49 +0000 Original-Received: from localhost ([127.0.0.1]:47824 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1amJlR-0001WW-Cx for submit@debbugs.gnu.org; Sat, 02 Apr 2016 07:30:49 -0400 Original-Received: from mout.gmx.net ([212.227.15.19]:55516) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1amJlP-0001QX-K4 for 23169@debbugs.gnu.org; Sat, 02 Apr 2016 07:30:48 -0400 Original-Received: from localhost ([84.88.51.85]) by mail.gmx.com (mrgmx003) with ESMTPSA (Nemesis) id 0Ltr89-1ZlEqS0vbB-011F1C; Sat, 02 Apr 2016 13:30:41 +0200 In-Reply-To: <8337r5teg7.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 01 Apr 2016 20:40:40 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-Provags-ID: V03:K0:e6mDoXdtaAqH8EVore1V+nKBy9KXXpEqoDHMO+9dI2+PxxEptx8 kaLyrFdeRKD+pqSrHs+J9Yr/1h9cmGsa78dAZzzS9B0SBIhfftOexiotve3aq1uht923wxD woeBaaMtm5L3lp0zDS8ibCYaRnWPmibNjqUyLjcytKoRlCrunYZhoSY4TQyJUTKSSmZBzFu M3/hC1aXdKPzxSOwQBHog== X-UI-Out-Filterresults: notjunk:1;V01:K0:VOGbAGePrH0=:c3ta4/Hv0Fr83yQ2tP3zpt LzCrmyZyqYOhg+52IAj/3h5x24MMk+nUbm9+Rvxf/z157imTPySdw0qZEMDYYTiyjNQvojfxI P/jnyZttZjbXrDHxZVMfibboXoQE2fpulWnULqpWs0p08jNn1mbWF63RFZXDhufRP9d7AW3TB 5fmni875CUoB77wkZf96J9713jSblnYmZUALOtFS3qneUb16LIeGGjPHZazpTY3ojLMP7qG39 yqohEMeu5FY6GF7JmeMVpPuqVA/fIzhtonnd1XhuB24zAfbQVtC4nZEVSKqQEZKMrt8dmggqE xy3fB2HURBqI+wZYjY/LAWCEb4MNRTp6DksaHEFb8sVzcv/K10VJm+qmnV9F2btD9Dld5O64c cIGKZAdOw5cARm7d2ztkFbm/qwoEFNbFOK1KBL5LXadbNjkRifMfLs4dleYYC8IdaRd48gDuz thrfuqUMBJCBY7zEtg6f+uxQ/608jeV6igcI/2KxB+Je48a8S9afysHNe/s+w1ByIt7xOyS8I q8kUO3i3Fh5hEO05S5eQVplBZ4IUTZcjNue4JAc303jmjFbnV57GmlY4ejQY+X2VyQTyVenTb /HrPUWPci1ktrdI+WC23uYX910H25F9W85k4xj99fdy9y1sNXt8oF5+DtyPTrd+kimBXGof5h z1+tgH2D5vhyH+OaE0jh7orxI0HpTKKKcWcBZCh2Qg0WtHWX4FAXVr/C8aoQDwrWrsdKZgeze ie3XwTCH7YBT2jmpXoXfmFwwrtKcG/h27LtxQiq1cTcJuHu4v6/6rW36rG2CYIA530mNT1Uj X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:115867 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Eli Zaretskii writes: >> From: Llu=C3=ADs >> Cc: 23169@debbugs.gnu.org >> Date: Fri, 01 Apr 2016 17:13:55 +0200 >>=20 >> > The usual way to fix these problems is to set Man-width to a non-nil >> > value, as appropriate for your frame/window dimensions. Would that >> > solve the problem for you? >>=20 >> Thing is I don't know the width of the window that will be used, since i= n some >> cases it does not exist yet: >>=20 >> +-----+ +--+--+ >> | | | | | >> | | -> M-x man man -> | | | >> | | | | | >> +-----+ +--+--+ > Isn't the window that man will use half of the window before the > command? Then you know the width in advance, because you are familiar > with your window and frame configurations That's only one case. Maybe display-buffer ends up creating a smaller window (depending on its configuration hooks), or maybe it ends up reusing some ot= her window. >> The ideal without breaking the asynchronicity would be to somehow displa= y the >> new buffer on a window before populating it (display-buffer might or mig= ht not >> reuse a window here), calculate its window's width, set COLUMNS, asynchr= onously >> call man to populate the buffer, and then really show the buffer on the = previous >> window. >>=20 >> The only problem is that creating a temporary window just to calculate i= ts width >> could annoy people because the contents won't be shown yet. > Yes, that's the problem. Martin's "pretend" argument to display-buffer could be a way out of this conundrum. Also, here's a patch for an alternative fix. Thanks, Lluis --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=man.el.patch --- /tmp/old/man.el 2016-04-02 13:09:14.588221106 +0200 +++ /tmp/man.el 2016-04-02 13:28:07.580237516 +0200 @@ -1001,7 +1001,16 @@ (error "No item under point") (man man-args))) -(defmacro Man-start-calling (&rest body) +(defun Man-buffer-or-window-width (buffer-or-window) + "Get width of window used after BUFFER-OR-WINDOW is displayed." + (if (windowp buffer-or-window) + (window-width buffer-or-window) + (save-window-excursion + (window-width (display-buffer buffer-or-window + ;; As used by `Man-notify-when-ready'. + 'not-this-window))))) + +(defmacro Man-start-calling (buffer-or-window &rest body) "Start the man command in `body' after setting up the environment" `(let ((process-environment (copy-sequence process-environment)) ;; The following is so Awk script gets \n intact @@ -1040,7 +1049,7 @@ ((and (integerp Man-width) (> Man-width 0)) Man-width) (Man-width (frame-width)) - ((window-width)))))) + ((Man-buffer-or-window-width ,buffer-or-window)))))) ;; 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). @@ -1062,7 +1071,7 @@ (setq buffer-undo-list t) (setq Man-original-frame (selected-frame)) (setq Man-arguments man-args)) - (Man-start-calling + (Man-start-calling buffer (if (fboundp 'start-process) (set-process-sentinel (start-process manual-program buffer @@ -1099,7 +1108,7 @@ (inhibit-read-only t) (buffer-read-only nil)) (erase-buffer) - (Man-start-calling + (Man-start-calling (frame-selected-window) (call-process shell-file-name nil (list (current-buffer) nil) nil shell-command-switch (format (Man-build-man-command) Man-arguments))) --=-=-=--