From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: joaotavora@gmail.com (=?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?=) Newsgroups: gmane.emacs.bugs Subject: bug#28814: [BUMP, PATCH] (26.0.90; When *xref* window is needed, original window-switching intent is lost ) Date: Wed, 25 Oct 2017 14:19:26 +0100 Message-ID: <87wp3js6u9.fsf@gmail.com> References: <87infjm3p3.fsf@gmail.com> <871slyi3lk.fsf_-_@gmail.com> <87lgk22ryu.fsf@gmail.com> <87fua91vis.fsf@gmail.com> <59F0413F.8010100@gmx.at> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1508937635 5439 195.159.176.226 (25 Oct 2017 13:20:35 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 25 Oct 2017 13:20:35 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux) Cc: 28814@debbugs.gnu.org, Dmitry Gutov To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Oct 25 15:20:26 2017 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 1e7LbM-00079w-Jq for geb-bug-gnu-emacs@m.gmane.org; Wed, 25 Oct 2017 15:20:08 +0200 Original-Received: from localhost ([::1]:48304 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7LbU-0007EE-16 for geb-bug-gnu-emacs@m.gmane.org; Wed, 25 Oct 2017 09:20:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55520) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7LbK-0007AL-Si for bug-gnu-emacs@gnu.org; Wed, 25 Oct 2017 09:20:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e7LbG-0005xQ-KQ for bug-gnu-emacs@gnu.org; Wed, 25 Oct 2017 09:20:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:52070) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e7LbG-0005xJ-FP for bug-gnu-emacs@gnu.org; Wed, 25 Oct 2017 09:20:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1e7LbG-0005z1-5H for bug-gnu-emacs@gnu.org; Wed, 25 Oct 2017 09:20:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: joaotavora@gmail.com (=?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?=) Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 25 Oct 2017 13:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 28814 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 28814-submit@debbugs.gnu.org id=B28814.150893757922962 (code B ref 28814); Wed, 25 Oct 2017 13:20:02 +0000 Original-Received: (at 28814) by debbugs.gnu.org; 25 Oct 2017 13:19:39 +0000 Original-Received: from localhost ([127.0.0.1]:60751 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e7Lat-0005yI-Cc for submit@debbugs.gnu.org; Wed, 25 Oct 2017 09:19:39 -0400 Original-Received: from mail-wr0-f196.google.com ([209.85.128.196]:44197) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e7Lar-0005y0-3J for 28814@debbugs.gnu.org; Wed, 25 Oct 2017 09:19:37 -0400 Original-Received: by mail-wr0-f196.google.com with SMTP id z55so17944094wrz.1 for <28814@debbugs.gnu.org>; Wed, 25 Oct 2017 06:19:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version; bh=UCbpZ91cG27p1K4pfQowLXR9I5T2g+CxuYp3dZOZTUQ=; b=VHu81xtjMcM22c3UUK9J0+T9+D1twIavZNUDBdHcnJYAXUuiVz6tbRKd24/P7oPz60 QD6Ju6v8PkLJs5RXq1BaUVpPzeXWgZ8atiSqFXUlPxo8i2VF2QjVAK4luX1nrHKyJP6w 74+OSutdi6d/T60Mh6bypthv/5yoqSu9zA/ZgNaxTLW1qvsnXtI32ikTX1eWfC+MJDzU lIjQXKJTuaQhJdHJuusHFrCBRfx1+soOt6we5BftAOw9x6h4FRImGw3ZfA/Ch3vZtZ+O rhX/jhC0Sg01NMfx5OQRl17tfoeHkcdwxVBfID340hpNb1PfmEAdtcxlCnhrkpuk2pDP cclw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references :user-agent:date:message-id:mime-version; bh=UCbpZ91cG27p1K4pfQowLXR9I5T2g+CxuYp3dZOZTUQ=; b=ZoOHw0yWZ1E2cCQPCGhmwgB1GYu1UWtouZby+beHeDHBZZXouCHER0fhKwsSPhIhIL 9kvZ7x1p2MB2z9YnGN3kBfpp3WYaN7FS1HVR1VSe875RSduW0hqJ9LITNaT3Iy8NVBx1 lsiM969rIUhP4VwRpvo4kQIr/zz56h+024StDKUPHFHJc+fvyk1nCIBPfE2TyoQhuj7O qh1fen8RRKJ5ZMKxa2BxL7wTdid0ent59JYewfoZbfc9sCKlisHx8CxHR8OHdRaYO610 BuNJWQP8FFlKJtVc8vRZ263jv1x28IjunCLHKgFRgUbIWL/PjVwVGiH+nid2FUYvUw1F DybA== X-Gm-Message-State: AMCzsaWX8DIH8C07He18o+7UCJ2HahzBgUhvna4u25EpR2M3FI0EPyxl NXuQW3ZcBpuOoGyYU/xvDF6P0Rks X-Google-Smtp-Source: ABhQp+Shr0SIF/5pInN7Aq7F+70Z0AzetePFefoyd0FOtp2Wr0JCC+lhEzIZbKkNS7kH7Yh29uO/6g== X-Received: by 10.223.156.144 with SMTP id d16mr2291951wre.29.1508937570114; Wed, 25 Oct 2017 06:19:30 -0700 (PDT) Original-Received: from lolita.yourcompany.com ([88.157.205.17]) by smtp.gmail.com with ESMTPSA id m26sm2683058wrb.81.2017.10.25.06.19.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Oct 2017 06:19:29 -0700 (PDT) In-Reply-To: <59F0413F.8010100@gmx.at> (martin rudalics's message of "Wed, 25 Oct 2017 09:46:07 +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:138955 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable martin rudalics writes: >> * 0003-Allow-split-window-sensibly-to-split-threshold-in-fu.patch >> >> This extends the exception granted by split-window-sensibly to >> single-window frames whose dimensions are below those of splitting >> thresholds to consider multi-window frames where all but one window is >> dedicated. > > Maybe the new behavior should be made customizable but this is for users > of dedicated windows to decide. > Hmmm, adding a defcustom sounds a bit heavy-handed to me. We=E2=80=99re tal= king about adding an option to preserve the behaviour of a failure. The docstring would certainly be hard to phrase. Perhaps we could just wait for the (quite improbable in my opinion) complaints of dedicated window users that expected their split-window operations to fail in certain extreme situations hence causing (un)expected frames to pop up? > In either case, instead of constructing > =E2=80=98window-list=E2=80=99 please consider using =E2=80=98walk-window-= tree=E2=80=99 for that part Done. See attached patch. Jo=C3=A3o --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0003-Allow-split-window-sensibly-to-split-threshold-in-fu.patch >From eb1a0ce0c66502bee41c090afcb04c65271196a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Mon, 23 Oct 2017 09:05:32 +0100 Subject: [PATCH 3/4] Allow split-window-sensibly to split threshold in further edge case As a fallback, and to avoid creating a frame, split-window-sensibly would previously disregard split-height-threshold if the window to be split is the frame's root window. This change slightly expands on that: it disregards the threshold if the window to be split is the frame's only usable window (it is either the only one, as before, or all the other windows are dedicated to some buffer and thus cannot be touched). * lisp/window.el (split-height-threshold): Adjust doc to match split-window-sensibly. (split-window-sensibly): Also disregard threshold if all other windows are dedicated. --- lisp/window.el | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/lisp/window.el b/lisp/window.el index c0a9ecd093..4814d12400 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -6465,8 +6465,9 @@ split-height-threshold vertically only if it has at least this many lines. If this is nil, `split-window-sensibly' is not allowed to split a window vertically. If, however, a window is the only window on its -frame, `split-window-sensibly' may split it vertically -disregarding the value of this variable." +frame, or all the other ones are dedicated, +`split-window-sensibly' may split it vertically disregarding the +value of this variable." :type '(choice (const nil) (integer :tag "lines")) :version "23.1" :group 'windows) @@ -6573,15 +6574,27 @@ split-window-sensibly ;; Split window horizontally. (with-selected-window window (split-window-right))) - (and (eq window (frame-root-window (window-frame window))) - (not (window-minibuffer-p window)) - ;; If WINDOW is the only window on its frame and is not the - ;; minibuffer window, try to split it vertically disregarding - ;; the value of `split-height-threshold'. - (let ((split-height-threshold 0)) - (when (window-splittable-p window) - (with-selected-window window - (split-window-below)))))))) + (and + ;; If WINDOW is the only usable window on its frame (it is + ;; the only one or, not being the only one, all the other + ;; ones are dedicated) and is not the minibuffer window, try + ;; to split it vertically disregarding the value of + ;; `split-height-threshold'. + (let ((frame (window-frame window))) + (or + (eq window (frame-root-window frame)) + (catch 'done + (walk-window-tree (lambda (w) + (unless (or (eq w window) + (window-dedicated-p w)) + (throw 'done nil))) + frame) + t))) + (not (window-minibuffer-p window)) + (let ((split-height-threshold 0)) + (when (window-splittable-p window) + (with-selected-window window + (split-window-below)))))))) (defun window--try-to-split-window (window &optional alist) "Try to split WINDOW. -- 2.14.2 --=-=-=--