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#32790: 27.0.50; point jumps unexpectedly after delete-window Date: Thu, 08 Nov 2018 23:53:23 +0200 Organization: LINKOV.NET Message-ID: <87bm6zme24.fsf@mail.linkov.net> References: <87efdnsp2k.fsf@mail.linkov.net> <87in1phhx2.fsf@mail.linkov.net> <5BD2C52E.2060607@gmx.at> <87ftwrgwp2.fsf@mail.linkov.net> <5BD57A8D.8080408@gmx.at> <875zxmx95h.fsf@mail.linkov.net> <5BD70F14.8080509@gmx.at> <87lg6g750v.fsf@mail.linkov.net> <5BD81D97.2000000@gmx.at> <87bm7bru1c.fsf@mail.linkov.net> <5BD963C8.9090905@gmx.at> <87h8h195ki.fsf@mail.linkov.net> <5BDAC159.1060008@gmx.at> <87muqsh11q.fsf@mail.linkov.net> <5BDC0E81.1050806@gmx.at> <87tvkwh4bp.fsf@mail.linkov.net> <5BE00F12.5000703@gmx.at> <87d0rjuq8c.fsf@mail.linkov.net> <5BE15552.4040507@gmx.at> <87y3a5rgm2.fsf@mail.linkov.net> <5BE2AF28.2020505@gmx.at> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1541714762 8280 195.159.176.226 (8 Nov 2018 22:06:02 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 8 Nov 2018 22:06:02 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) Cc: 32790@debbugs.gnu.org To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Nov 08 23:05:57 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 1gKsR2-0001xR-42 for geb-bug-gnu-emacs@m.gmane.org; Thu, 08 Nov 2018 23:05:56 +0100 Original-Received: from localhost ([::1]:59205 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKsT8-000604-Lh for geb-bug-gnu-emacs@m.gmane.org; Thu, 08 Nov 2018 17:08:06 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34749) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKsR6-0003fl-Gc for bug-gnu-emacs@gnu.org; Thu, 08 Nov 2018 17:06:03 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gKsJO-0003ah-I4 for bug-gnu-emacs@gnu.org; Thu, 08 Nov 2018 16:58:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:37690) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gKsJO-0003Zt-5v for bug-gnu-emacs@gnu.org; Thu, 08 Nov 2018 16:58:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gKsJN-0001Fd-Qx for bug-gnu-emacs@gnu.org; Thu, 08 Nov 2018 16:58: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: Thu, 08 Nov 2018 21:58:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 32790 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 32790-submit@debbugs.gnu.org id=B32790.15417142624759 (code B ref 32790); Thu, 08 Nov 2018 21:58:01 +0000 Original-Received: (at 32790) by debbugs.gnu.org; 8 Nov 2018 21:57:42 +0000 Original-Received: from localhost ([127.0.0.1]:41943 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gKsJ4-0001Eh-9b for submit@debbugs.gnu.org; Thu, 08 Nov 2018 16:57:42 -0500 Original-Received: from goldenrod.birch.relay.mailchannels.net ([23.83.209.74]:50585) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gKsJ2-0001EY-8q for 32790@debbugs.gnu.org; Thu, 08 Nov 2018 16:57:41 -0500 X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id BEC52123F3B; Thu, 8 Nov 2018 21:57:38 +0000 (UTC) Original-Received: from pdx1-sub0-mail-a66.g.dreamhost.com (unknown [100.96.19.74]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 633F21246CB; Thu, 8 Nov 2018 21:57:38 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from pdx1-sub0-mail-a66.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.16.2); Thu, 08 Nov 2018 21:57:38 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jurta@jurta.org X-MailChannels-Auth-Id: dreamhost X-Arithmetic-Left: 64edf9362d9d4f5d_1541714258512_2481456414 X-MC-Loop-Signature: 1541714258512:2030821698 X-MC-Ingress-Time: 1541714258512 Original-Received: from pdx1-sub0-mail-a66.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a66.g.dreamhost.com (Postfix) with ESMTP id 25D3A806E1; Thu, 8 Nov 2018 13:57:38 -0800 (PST) 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:content-transfer-encoding; s=linkov.net; bh=2/LbjN St8kJwBpgu+hdqw4jAtfI=; b=oxKUjZa5217Tzhb+yOv9Po5+pJiPL85AnvH/qq 3PB19JS45s/b5vy1phew8nyBGMNz+/WGNPGQedUiXfBFc/PaPcq56J2/0HRctdib cf3N52vUq00cwsSJM/CU3kCVpcUPBWEpIZqcxtzGjhhLBGX21FOISgVO8cDbmNtV 5hxOA= Original-Received: from mail.jurta.org (m91-129-107-244.cust.tele2.ee [91.129.107.244]) (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-a66.g.dreamhost.com (Postfix) with ESMTPSA id 8FDE8806DF; Thu, 8 Nov 2018 13:57:36 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a66 In-Reply-To: <5BE2AF28.2020505@gmx.at> (martin rudalics's message of "Wed, 07 Nov 2018 10:23:52 +0100") X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: -100 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtkedrkedugdduheejucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgdpffftgfetoffjqffuvfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufhofhffjgfkfgggtgfgsehtkeertddtreejnecuhfhrohhmpefluhhrihcunfhinhhkohhvuceojhhurhhisehlihhnkhhovhdrnhgvtheqnecukfhppeeluddruddvledruddtjedrvdeggeenucfrrghrrghmpehmohguvgepshhmthhppdhhvghlohepmhgrihhlrdhjuhhrthgrrdhorhhgpdhinhgvthepledurdduvdelrddutdejrddvgeegpdhrvghtuhhrnhdqphgrthhhpefluhhrihcunfhinhhkohhvuceojhhurhhisehlihhnkhhovhdrnhgvtheqpdhmrghilhhfrhhomhepjhhurhhisehlihhnkhhovhdrnhgvthdpnhhrtghpthhtoheprhhuuggrlhhitghssehgmhigrdgrthenucevlhhushhtvghrufhiiigvpedt 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:152179 Archived-At: In bug#33258 I tried to use inhibit-select-window in display-buffer-overriding-action, but it's better just to use a prefix arg to determine whether the window should remain selected, e.g. =E2=80=98C-u S-M-up=E2=80=99 means no-select, or =E2=80=98M-- S-M-le= ft=E2=80=99 means no-select and use the bottom egde, etc. The only problem is that I can't decide what window to use for window-in-direction and split-window in display-buffer-overriding-action: an original window that was selected at the moment of =E2=80=98S-M-up=E2=80= =99 invocation, or a selected window that is current at the moment when display-buffer-overriding-action is applied? Please see the questions in the comments of this patch: diff --git a/lisp/windmove.el b/lisp/windmove.el index 598e495c7a..ea4506049b 100644 --- a/lisp/windmove.el +++ b/lisp/windmove.el @@ -1,4 +1,4 @@ -;;; windmove.el --- directional window-selection routines +;;; windmove.el --- directional window-selection routines -*- lexical-b= inding:t -*- ;; ;; Copyright (C) 1998-2018 Free Software Foundation, Inc. ;; @@ -571,6 +571,104 @@ windmove-default-keybindings (global-set-key (vector (append modifiers '(up))) 'windmove-up) (global-set-key (vector (append modifiers '(down))) 'windmove-down)) =20 +;;; Directional window display + +(defun windmove-display-in-direction (dir &optional arg) + "Display the next buffer in the window at direction DIR. +Create a new window if there is no window in that direction. +If prefix ARG is `C-u' or `M--', restore the previously selected window. +With no prefix ARG, or with prefix ARG equal to zero, a displayed window= is +relative to the position of point in the selected window; otherwise it i= s +relative to the first edge (for positive ARG or `C-u') or the last edge +(for negative ARG or `M--') of the selected window." + (interactive) + (let* ((command this-command) + (action display-buffer-overriding-action) + (minibuffer-depth (minibuffer-depth)) + (selected-window (selected-window)) + (restore-window (or (consp arg) (eq arg '-))) + (clearfun (make-symbol "clear-display-buffer-overriding-action"= )) + (exitfun + (lambda () + (setq display-buffer-overriding-action action) + (when (and restore-window (window-live-p selected-window)) + (select-window selected-window)) + (remove-hook 'post-command-hook clearfun)))) + (fset clearfun + (lambda () + (unless (or + ;; Remove the hook immediately + ;; after exiting the minibuffer. + (> (minibuffer-depth) minibuffer-depth) + ;; But don't remove immediately after + ;; adding the hook by the same command below. + (eq this-command command)) + (funcall exitfun)))) + (add-hook 'post-command-hook clearfun) + (push (lambda (buffer alist) + (unless (> (minibuffer-depth) minibuffer-depth) + (let ((window (if (eq dir 'same-window) + (selected-window) ;; or maybe `selected-window'? + (window-in-direction + dir selected-window nil ;; or `nil' inste= ad of `selected-window'? + (and arg (prefix-numeric-value arg)) + windmove-wrap-around))) + (type 'reuse)) + (unless window + ;; maybe use `selected-window' in WINDOW arg of split-window? + (setq window (split-window nil nil dir) type 'window)) + (window--display-buffer buffer window type alist)))) + display-buffer-overriding-action) + (message "[display-%s]" dir))) + +;;;###autoload +(defun windmove-display-left (&optional arg) + "Display the next buffer in window to the left of the current one. +With a prefix argument, restore the previously selected window." + (interactive "P") + (windmove-display-in-direction 'left arg)) + +;;;###autoload +(defun windmove-display-up (&optional arg) + "Display the next buffer in window above the current one. +With a prefix argument, restore the previously selected window." + (interactive "P") + (windmove-display-in-direction 'up arg)) + +;;;###autoload +(defun windmove-display-right (&optional arg) + "Display the next buffer in window to the right of the current one. +With a prefix argument, restore the previously selected window." + (interactive "P") + (windmove-display-in-direction 'right arg)) + +;;;###autoload +(defun windmove-display-down (&optional arg) + "Display the next buffer in window below the current one. +With a prefix argument, restore the previously selected window." + (interactive "P") + (windmove-display-in-direction 'down arg)) + +;;;###autoload +(defun windmove-display-same-window (&optional arg) + "Display the next buffer in the same window." + (interactive "P") + (windmove-display-in-direction 'same-window arg)) + +;;;###autoload +(defun windmove-display-default-keybindings (&optional modifiers) + "Set up keybindings for directional display. +Keybindings are of the form MODIFIERS-{left,right,up,down}, +where MODIFIERS is either a list of modifiers or a single modifier. +Default value of MODIFIERS is `shift-meta'." + (interactive) + (unless modifiers (setq modifiers '(shift meta))) + (unless (listp modifiers) (setq modifiers (list modifiers))) + (global-set-key (vector (append modifiers '(left))) 'windmove-display= -left) + (global-set-key (vector (append modifiers '(right))) 'windmove-display= -right) + (global-set-key (vector (append modifiers '(up))) 'windmove-display= -up) + (global-set-key (vector (append modifiers '(down))) 'windmove-display= -down) + (global-set-key (vector (append modifiers '(?0))) 'windmove-display= -same-window)) =20 (provide 'windmove) =20