From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#32536: displayed width of man pages Date: Mon, 03 Sep 2018 01:19:19 +0300 Organization: LINKOV.NET Message-ID: <8736urmtjs.fsf@mail.linkov.net> References: <878t4t70zb.fsf@himinbjorg.adminart.net> <87in3r1l7y.fsf@mail.linkov.net> <5B88E62F.20504@gmx.at> <87d0twam5z.fsf@mail.linkov.net> <5B8B8DC8.7020001@gmx.at> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1535928924 32212 195.159.176.226 (2 Sep 2018 22:55:24 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 2 Sep 2018 22:55:24 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) Cc: hw , 32536@debbugs.gnu.org To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Sep 03 00:55:20 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fwbH5-0008Cm-3w for geb-bug-gnu-emacs@m.gmane.org; Mon, 03 Sep 2018 00:55:19 +0200 Original-Received: from localhost ([::1]:42720 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fwbJB-00007x-GM for geb-bug-gnu-emacs@m.gmane.org; Sun, 02 Sep 2018 18:57:29 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:49147) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fwbIb-0007YR-3W for bug-gnu-emacs@gnu.org; Sun, 02 Sep 2018 18:56:54 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fwbBy-0001aY-BC for bug-gnu-emacs@gnu.org; Sun, 02 Sep 2018 18:50:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:38432) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fwbBy-0001Zu-5W for bug-gnu-emacs@gnu.org; Sun, 02 Sep 2018 18:50:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fwbBy-0003bj-26 for bug-gnu-emacs@gnu.org; Sun, 02 Sep 2018 18:50:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 02 Sep 2018 22:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 32536 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 32536-submit@debbugs.gnu.org id=B32536.153592858513800 (code B ref 32536); Sun, 02 Sep 2018 22:50:02 +0000 Original-Received: (at 32536) by debbugs.gnu.org; 2 Sep 2018 22:49:45 +0000 Original-Received: from localhost ([127.0.0.1]:43443 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fwbBg-0003aW-Ow for submit@debbugs.gnu.org; Sun, 02 Sep 2018 18:49:44 -0400 Original-Received: from pop.dreamhost.com ([64.90.62.162]:36870 helo=pdx1-sub0-mail-a9.g.dreamhost.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fwbBe-0003aO-FY for 32536@debbugs.gnu.org; Sun, 02 Sep 2018 18:49:43 -0400 Original-Received: from pdx1-sub0-mail-a9.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a9.g.dreamhost.com (Postfix) with ESMTP id EA19B7EA4D; Sun, 2 Sep 2018 15:49:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=linkov.net; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=linkov.net; bh=ugiIAGzMORuBT1w4FlAsYkFxFfA=; b= ZyO5OjUukDE2rNRQdGtVZQjV1ChlCl72Ob05hpZG0khToJBl7CQRO73gC76wSYMk ahdJ7gjvj6h3qwxm3C0/SSG9ila8D4c0bDw8qYR7P6CYUXEWVea6P3EG/qx2tSnk yvNhrn38I4MDPPCqVS7iGUml4LVLKieLT32pJBVsRAw= Original-Received: from localhost.linkov.net (m91-129-101-104.cust.tele2.ee [91.129.101.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by pdx1-sub0-mail-a9.g.dreamhost.com (Postfix) with ESMTPSA id 17A397E9E0; Sun, 2 Sep 2018 15:49:39 -0700 (PDT) In-Reply-To: <5B8B8DC8.7020001@gmx.at> (martin rudalics's message of "Sun, 02 Sep 2018 09:14:16 +0200") 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" Xref: news.gmane.org gmane.emacs.bugs:149981 Archived-At: --=-=-= Content-Type: text/plain >> Regarding the request for dynamic reformatting, I'm not sure if >> man pages should be reformatted on resizing windows (I remember >> seeing a window resize hook, but can't find it now). > > It's called 'window-size-change-functions'. Thanks, I tried window-size-change-functions, and it works pretty well with the patch attached. But there are a few problems: 1. In Man-mode we have to add hook window-size-change-functions only buffer-locally (using the arg LOCAL of add-hook) rather than globally, because otherwise we can't remove this hook when a Man buffer is not displayed anymore. But the problem is that buffer-local window-size-change-functions is called only when the current buffer is in Man-mode. If it's not, it's not called even when resizing of the current non-Man buffer causes the resize of a Man-mode buffer in an adjacent window. 2. What if the same Man-mode buffer is displayed in two adjacent windows side-by-side? I guess we need to find all windows with the same buffer, compare their widths, and call Man-update-manpage only in the window with minimal width. Also it seems window-size-change-functions is not called twice for every window with Man-mode buffer, this is good. 3. When windows are resized using the mouse, is it possible to call window-size-change-functions only when the mouse button is released? This will increase responsiveness. But the same problem will remain for keyboard resizing with e.g. C-x } } } A debounce-like function could help, but I can't find its Emacs Lisp implementation anywhere. I mean something similar to https://stackoverflow.com/questions/15927371/what-does-debounce-do It's easy to implement using timers, but better to have idiomatic implementation. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=Man-window-size-change.1.patch diff --git a/lisp/man.el b/lisp/man.el index 1a6eda13b7..f737594de7 100644 --- a/lisp/man.el +++ b/lisp/man.el @@ -1524,7 +1537,17 @@ Man-mode (set (make-local-variable 'outline-regexp) Man-heading-regexp) (set (make-local-variable 'outline-level) (lambda () 1)) (set (make-local-variable 'bookmark-make-record-function) - 'Man-bookmark-make-record)) + 'Man-bookmark-make-record) + (add-hook 'window-size-change-functions 'Man-window-size-change nil t)) + +(defun Man-window-size-change (frame) + (walk-windows (lambda (window) + (when (/= (window-pixel-width-before-size-change window) + (window-pixel-width window)) + (with-current-buffer (window-buffer window) + (when (derived-mode-p 'Man-mode) + (Man-update-manpage))))) + 'nomini frame)) (defun Man-build-section-list () "Build the list of manpage sections." --=-=-=--