From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#51062: Customizable window resizing Date: Tue, 11 Jan 2022 19:35:33 +0200 Organization: LINKOV.NET Message-ID: <86pmoynpju.fsf@mail.linkov.net> References: <87zgrm2h6v.fsf@mail.linkov.net> <63433373-a57b-a68a-8ccc-6d4a9192d9a4@gmx.at> <871r4oahjx.fsf@mail.linkov.net> <87wnmfk40w.fsf@mail.linkov.net> <87a6jbil4d.fsf@mail.linkov.net> <87o87mmjth.fsf@mail.linkov.net> <377a69a2-7694-bd7a-ac63-409e5064e5c9@gmx.at> <86czlf1fv8.fsf@mail.linkov.net> <3c447b7e-7ce3-14fe-03d5-63cb7f75d783@gmx.at> <86bl0rgas3.fsf@mail.linkov.net> <7c39d839-3405-dad3-4e45-90152744e48f@gmx.at> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1018"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) Cc: 51062@debbugs.gnu.org To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jan 11 18:43:57 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n7LBc-00009R-Ou for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 11 Jan 2022 18:43:56 +0100 Original-Received: from localhost ([::1]:43504 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n7LBb-0008DS-5y for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 11 Jan 2022 12:43:55 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:41850) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n7L4w-0006ng-Bf for bug-gnu-emacs@gnu.org; Tue, 11 Jan 2022 12:37:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:34324) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n7L4w-0002xI-1p for bug-gnu-emacs@gnu.org; Tue, 11 Jan 2022 12:37:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n7L4v-0007S9-UT for bug-gnu-emacs@gnu.org; Tue, 11 Jan 2022 12:37:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 11 Jan 2022 17:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51062 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 51062-submit@debbugs.gnu.org id=B51062.164192257628562 (code B ref 51062); Tue, 11 Jan 2022 17:37:01 +0000 Original-Received: (at 51062) by debbugs.gnu.org; 11 Jan 2022 17:36:16 +0000 Original-Received: from localhost ([127.0.0.1]:55458 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n7L4C-0007Qa-21 for submit@debbugs.gnu.org; Tue, 11 Jan 2022 12:36:16 -0500 Original-Received: from relay5-d.mail.gandi.net ([217.70.183.197]:52753) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n7L48-0007QD-3m; Tue, 11 Jan 2022 12:36:14 -0500 Original-Received: (Authenticated sender: juri@linkov.net) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 43B691C0004; Tue, 11 Jan 2022 17:36:03 +0000 (UTC) In-Reply-To: <7c39d839-3405-dad3-4e45-90152744e48f@gmx.at> (martin rudalics's message of "Tue, 4 Jan 2022 11:27:11 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:223947 Archived-At: close 51062 29.0.50 thanks >>> "shrink-buffer-if-larger-than-buffer"? Maybe this should become >>> 'shrink-buffer-window-if-larger-than-buffer' then. >> >> Should such a function be added to window.el? > > Maybe. But we could also rename the first argument of > 'shrink-window-if-larger-than-buffer' to WINDOW-OR-BUFFER. This can't be generalized because vc uses specific logic: (let ((window (get-buffer-window buffer t))) (with-current-buffer buffer ... (when window (shrink-window-if-larger-than-buffer window)))) >>> With the usual problem what to do when there are two windows showing >>> that buffer. >> >> It's understandable why vc-diff-internal and vc-diff-finish >> use get-buffer-window to get a window: >> >> vc-diff-internal: >> (pop-to-buffer (current-buffer)) >> (let ((buf (current-buffer))) >> (vc-run-delayed (vc-diff-finish buf ... >> >> vc-diff-finish: >> (let ((window (get-buffer-window buffer t))) >> (with-current-buffer buffer >> ... >> (when window >> (shrink-window-if-larger-than-buffer window)))) >> >> This is needed to handle the case when the window was deleted >> before the vc command finished. >> >> But why vc-log-internal-common doesn't so the same? >> >> vc-log-internal-common: >> (pop-to-buffer buffer) >> (vc-run-delayed >> ... >> (shrink-window-if-larger-than-buffer) >> >> So I posted a patch in bug#52855 to use the same function >> that relies on get-buffer-window in both cases. >> >> But it seems you propose to remember the window with e.g. >> >> (setq window (pop-to-buffer (current-buffer))) >> >> then to use it in: >> >> (run-hook-with-args 'vc-diff-finish-functions window) >> >> where the defalut value of 'vc-diff-finish-functions' is: >> >> '(shrink-window-if-larger-than-buffer) >> >> Then 'shrink-buffer-window-if-larger-than-buffer' is not needed. > > Personally I dislike abusing hooks like that. But I probably do not use > vc-... much either. And it would require a weird condition: (when window (run-hook-with-args 'vc-diff-finish-functions window)) > So do whatever you like more. So instead of above, I pushed the original patch with a better function name 'vc-shrink-buffer-window'.