From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.bugs Subject: bug#47300: delete-window to select window with same position Date: Sat, 22 May 2021 10:05:20 +0200 Message-ID: References: <87a6qw43gg.fsf@mail.linkov.net> <87pmxodrmq.fsf@gnus.org> <7f870f9b-95ad-6b5d-82aa-1bcfe5cc880a@gmx.at> <87fsyk0w92.fsf@mail.linkov.net> <2ec3b911-4fb1-4b13-a5b8-28278a5c43ba@gmx.at> <87h7iyzvh5.fsf@mail.linkov.net> <0c239adb-e9d5-1fe9-4c4c-2da1603002f7@gmx.at> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------F3CA85BA3FCD7C283CC891F0" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6328"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Lars Ingebrigtsen , 47300@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat May 22 10:06:23 2021 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 1lkMeN-0001Qw-Bw for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 22 May 2021 10:06:23 +0200 Original-Received: from localhost ([::1]:43208 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lkMeM-0003GJ-EN for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 22 May 2021 04:06:22 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lkMe6-0003Cr-9k for bug-gnu-emacs@gnu.org; Sat, 22 May 2021 04:06:06 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54968) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lkMe2-00007V-Nl for bug-gnu-emacs@gnu.org; Sat, 22 May 2021 04:06:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lkMe2-00059S-I0 for bug-gnu-emacs@gnu.org; Sat, 22 May 2021 04:06:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: martin rudalics Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 22 May 2021 08:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47300 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 47300-submit@debbugs.gnu.org id=B47300.162167073119766 (code B ref 47300); Sat, 22 May 2021 08:06:02 +0000 Original-Received: (at 47300) by debbugs.gnu.org; 22 May 2021 08:05:31 +0000 Original-Received: from localhost ([127.0.0.1]:38281 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lkMdX-00058j-3Q for submit@debbugs.gnu.org; Sat, 22 May 2021 04:05:31 -0400 Original-Received: from mout.gmx.net ([212.227.15.18]:54645) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lkMdT-00058U-NO for 47300@debbugs.gnu.org; Sat, 22 May 2021 04:05:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1621670721; bh=rXbT79Y9m6E7PDU5L3raDZ8mosLJAEw6wr54JVFw1kQ=; h=X-UI-Sender-Class:Subject:From:To:Cc:References:Date:In-Reply-To; b=HvA29SqdaGxNAfAqwjtoTT0wUVYUaqCbnfdxaqzM5MFTUV/VvX/C4RDuFZKiV9YjA PwTMSyR4ey2JdQbV4DOmJaowuY/u+rIK0JRdRpIYiXWV+R2CeZUrJ3GFHIpkqRMI22 0wUHX06AkNEzAkf1Ts8mMbKB72T9fegI8//kfxqU= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from [192.168.1.100] ([213.142.96.249]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MacOW-1l9MvT1SsE-00c9x9; Sat, 22 May 2021 10:05:21 +0200 In-Reply-To: <0c239adb-e9d5-1fe9-4c4c-2da1603002f7@gmx.at> Content-Language: en-US X-Provags-ID: V03:K1:zKwzkFuPMMtsFOXERNLyExfvKYz+DNv/syXbZBl1ipEBucbfaNw /hcnIXv4NhMPCLo8p3NLpIs1EVPOxtrH8sJhZCbxatrUavURwIxX8Bu1ZNye4hJSbanHOwB 15zT2J1T8DRSYxANXy80ncq/b+HmCVII81+luVwIfGNYCOcTvAkEwXEIHASAMHMam/CtTsb Q69QETfnssGd7YYMr+djw== X-UI-Out-Filterresults: notjunk:1;V03:K0:2udq0oWeOSE=:rCA0YhytwppHKXiJ9TjZl+ j+5OvqToD//3RkBT+gCoXhbI7cw6BieLuFaZTv25vneCfowKS+lvBg2OiqAd2ZpNGWuh79UFH NQqqyYMDBXm9oftczm6RIxeyvEp0r6Oj3e9bLbd2SGTQaOhsOucb3PxgJarrFqc3uUkWNbu/P d4d4pTvlEL5O2pIQmhWyDUk6+Sr/RDVS2cwmtTgEzmM1eewvrYdiuaC44mq8BrOIQKl0ekkPg YMlI9/R5LaaZ7RWmFbqqO1C5mgZjIouViufwqmFHdJ3iB5xxMbGx6uNdMNZc1Q/s+bechM0Gm eTYKr6t6Ftx0HeK8d82NqGebc/WR1wX4btyHgUpIzV8zYPXagPELF+OjH5cb8Q5BuGnW5MiP4 C0s59VU8k4PsTWmV6dvEqgbMvT35o4Z+utl3nrKxJx4FNdXHkvuV6dDTzVT+I+FfDFiwjbCU+ CfC//26z8+DFTXvXpTikUPFYQh34gVUYCzfJFtdc8NPlU49aGiZBTBxTXjOpqEDqWeez53lSj Ulg4F3qC39oPZ8LUGR+mjQwrERA70aOk22dL2foBuLyjqNI2weiGQtT/uiRFf+agNxm7gJA9I sTS1qLPgFvRnBLtCzkjEmbRAxhjAbD1LdVCKQPCKf8L1eoSrkOtM4mRBSieiAHD075HuokXvR Ki8q3rdnN2xzQZ8SRnMvAtuy8BN2KAPdesgPHoqMCNHYSYvjiXCaCp82Got9cT0b37L0M9t1/ NjfqomqLumfLOTobV1N7craUStbdjIFWThsslDFE0g4nrv2YpeBvpzaSx07G9YEDS+OZ7wcV 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:207016 Archived-At: This is a multi-part message in MIME format. --------------F3CA85BA3FCD7C283CC891F0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit > No. You probably have to save the old position of the deleted window's > point in frame coordinates and have the function that selects the new > window use the window that is now at that frame position. Just to explain what I meant above look at the attached patch. I think we should then move the `get-mru-window' call to `delete-window' too and combine them all with the 'no-other-window' check so we never select a window with NORECORD nil twice here. martin --------------F3CA85BA3FCD7C283CC891F0 Content-Type: text/x-patch; name="window.el.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="window.el.diff" diff --git a/lisp/window.el b/lisp/window.el index a403daf10b..32742f07c5 100644 =2D-- a/lisp/window.el +++ b/lisp/window.el @@ -4800,6 +4800,8 @@ window--in-subtree-p (throw 'done t) (setq parent (window-parent parent)))))))) +(defvar delete-window-use-posn-at-point nil) + (defun delete-window (&optional window) "Delete WINDOW. WINDOW must be a valid window and defaults to the selected one. @@ -4822,7 +4824,7 @@ delete-window (let* ((frame (window-frame window)) (function (window-parameter window 'delete-window)) (parent (window-parent window)) - atom-root) + atom-root posn-at-point window-at-posn-at-point) (window--check frame) (catch 'done ;; Handle window parameters. @@ -4871,10 +4873,20 @@ delete-window (t ;; Can't do without resizing fixed-size windows. (window--resize-siblings window (- size) horizontal t))) + (when delete-window-use-posn-at-point + ;; Remember WINDOW's position at point. + (setq posn-at-point (posn-at-point nil window))) ;; Actually delete WINDOW. - (delete-window-internal window) + (delete-window-internal window) (window--pixel-to-total frame horizontal) - (when (and frame-selected + (when (and posn-at-point + (setq window-at-posn-at-point + (window-at (car (nth 6 posn-at-point)) + (cdr (nth 6 posn-at-point)) + frame))) + ;; Select window at WINDOW's position at point. + (select-window window-at-posn-at-point)) + (when (and frame-selected (window-parameter (frame-selected-window frame) 'no-other-window)) ;; `delete-window-internal' has selected a window that should --------------F3CA85BA3FCD7C283CC891F0--