all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: Juri Linkov <juri@linkov.net>
Cc: Lars Ingebrigtsen <larsi@gnus.org>, 47300@debbugs.gnu.org
Subject: bug#47300: delete-window to select window with same position
Date: Sat, 22 May 2021 10:05:20 +0200	[thread overview]
Message-ID: <b7456042-dbcf-c048-bd77-23f9b8057b4f@gmx.at> (raw)
In-Reply-To: <0c239adb-e9d5-1fe9-4c4c-2da1603002f7@gmx.at>

[-- Attachment #1: Type: text/plain, Size: 471 bytes --]

 > 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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: window.el.diff --]
[-- Type: text/x-patch; name="window.el.diff", Size: 1827 bytes --]

diff --git a/lisp/window.el b/lisp/window.el
index a403daf10b..32742f07c5 100644
--- 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

  reply	other threads:[~2021-05-22  8:05 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-21 20:31 bug#47300: delete-window to select window with same position Juri Linkov
2021-05-18 14:49 ` Lars Ingebrigtsen
2021-05-18 16:00   ` martin rudalics
2021-05-18 20:17     ` Juri Linkov
2021-05-19  7:42       ` martin rudalics
2021-05-19 16:07         ` Juri Linkov
2021-05-19 17:41           ` martin rudalics
2021-05-22  8:05             ` martin rudalics [this message]
2021-05-22 21:25               ` Juri Linkov
2021-05-23  8:43                 ` martin rudalics
2021-05-25  6:50                 ` martin rudalics
2021-05-26 21:29                   ` Juri Linkov
2021-05-27 15:20                     ` martin rudalics
2021-05-31 20:46                       ` Juri Linkov
2021-06-02  9:08                         ` martin rudalics
2021-06-03 21:20                           ` Juri Linkov
2021-06-04  9:19                             ` martin rudalics
2021-06-04 16:29                               ` Juri Linkov
2021-06-06  7:43                                 ` martin rudalics
2021-06-06 20:47                                   ` Juri Linkov
2021-06-07  7:35                                     ` martin rudalics
2021-06-07 21:00                                       ` Juri Linkov
2021-06-10  7:44                                         ` martin rudalics
2021-06-11 17:06                                           ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b7456042-dbcf-c048-bd77-23f9b8057b4f@gmx.at \
    --to=rudalics@gmx.at \
    --cc=47300@debbugs.gnu.org \
    --cc=juri@linkov.net \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.