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: Mon, 05 Nov 2018 00:21:14 +0200 Organization: LINKOV.NET Message-ID: <87tvkwh4bp.fsf@mail.linkov.net> References: <87efdnsp2k.fsf@mail.linkov.net> <87woqcnwas.fsf@mail.linkov.net> <5BCC3757.9020204@gmx.at> <87bm7njk2f.fsf@mail.linkov.net> <5BCD934D.4070906@gmx.at> <878t2owo8i.fsf@mail.linkov.net> <5BD03F4D.1000900@gmx.at> <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> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1541370283 1309 195.159.176.226 (4 Nov 2018 22:24:43 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 4 Nov 2018 22:24:43 +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 Sun Nov 04 23:24:38 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 1gJQov-0000D8-2b for geb-bug-gnu-emacs@m.gmane.org; Sun, 04 Nov 2018 23:24:37 +0100 Original-Received: from localhost ([::1]:60421 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gJQr1-000636-9h for geb-bug-gnu-emacs@m.gmane.org; Sun, 04 Nov 2018 17:26:47 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37342) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gJQnS-0002he-DK for bug-gnu-emacs@gnu.org; Sun, 04 Nov 2018 17:23:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gJQnP-0001Rr-6K for bug-gnu-emacs@gnu.org; Sun, 04 Nov 2018 17:23:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:58355) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gJQnP-0001RY-1a for bug-gnu-emacs@gnu.org; Sun, 04 Nov 2018 17:23:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gJQnO-0001yp-TK for bug-gnu-emacs@gnu.org; Sun, 04 Nov 2018 17:23:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <87efdnsp2k.fsf@mail.linkov.net> Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 04 Nov 2018 22:23:02 +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.15413701717563 (code B ref 32790); Sun, 04 Nov 2018 22:23:02 +0000 Original-Received: (at 32790) by debbugs.gnu.org; 4 Nov 2018 22:22:51 +0000 Original-Received: from localhost ([127.0.0.1]:34378 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gJQnD-0001xu-Dm for submit@debbugs.gnu.org; Sun, 04 Nov 2018 17:22:51 -0500 Original-Received: from bisque.maple.relay.mailchannels.net ([23.83.214.18]:59509) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gJQnB-0001xm-My for 32790@debbugs.gnu.org; Sun, 04 Nov 2018 17:22:50 -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 A361F5C3863; Sun, 4 Nov 2018 22:22:48 +0000 (UTC) Original-Received: from pdx1-sub0-mail-a60.g.dreamhost.com (unknown [100.96.19.74]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 4E6255C39B7; Sun, 4 Nov 2018 22:22:48 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from pdx1-sub0-mail-a60.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); Sun, 04 Nov 2018 22:22:48 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jurta@jurta.org X-MailChannels-Auth-Id: dreamhost X-Illustrious-Daffy: 763683f401ff23bc_1541370168475_195172697 X-MC-Loop-Signature: 1541370168475:188764287 X-MC-Ingress-Time: 1541370168474 Original-Received: from pdx1-sub0-mail-a60.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a60.g.dreamhost.com (Postfix) with ESMTP id 13EF08027D; Sun, 4 Nov 2018 14:22:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=linkov.net; h=from:to:cc :subject:references:date:message-id:mime-version:content-type; s=linkov.net; bh=OBIUrRRWPALdDue0ypIpifzHOxU=; b=H+jvxFAIi+shmM OD8t2FWQOw+gHc1hOkNinujPQyoEvbWgRon3hPbCbvT3VyEc4BbBdCjl9Mxdy7cB Ek3l8wJvgAn7OMKmalVVePrTDoONkD1rggFuDVb7jg30jdLkwMEyPn2W3QsOsuzI 4baXRv+UeA6qdjDl38O95HWKzROmU= Original-Received: from mail.jurta.org (m91-129-101-157.cust.tele2.ee [91.129.101.157]) (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-a60.g.dreamhost.com (Postfix) with ESMTPSA id 0F9F68027B; Sun, 4 Nov 2018 14:22:46 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a60 X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: -100 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtkedrjeeggddtiecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucggtfgfnhhsuhgsshgtrhhisggvpdfftffgtefojffquffvnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvffuohhffffkfgggtgesthdtredttdertdenucfhrhhomheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqeenucfkphepledurdduvdelrddutddurdduheejnecurfgrrhgrmhepmhhouggvpehsmhhtphdphhgvlhhopehmrghilhdrjhhurhhtrgdrohhrghdpihhnvghtpeeluddruddvledruddtuddrudehjedprhgvthhurhhnqdhprghthheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqedpmhgrihhlfhhrohhmpehjuhhriheslhhinhhkohhvrdhnvghtpdhnrhgtphhtthhopehruhgurghlihgtshesghhmgidrrghtnecuvehluhhsthgvrhfuihiivgeptd 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:152034 Archived-At: > I had that in mind as a side-effect. But we should really get rid of > this split-first-decide-what-to-put-there-afterwards approach first. I agree split-first-decide-what-to-put-there-afterwards is too ugly. So following your suggestion I reimplemented this feature in windmove.el because it fits its description "directional window-selection routines": diff --git a/lisp/windmove.el b/lisp/windmove.el index 42e10b591f..69f2a9665a 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-binding:t -*- ;; ;; Copyright (C) 1998-2018 Free Software Foundation, Inc. ;; @@ -551,6 +571,86 @@ windmove-default-keybindings (global-set-key (vector (append modifiers '(up))) 'windmove-up) (global-set-key (vector (append modifiers '(down))) 'windmove-down)) +;;; Directional window display + +(defun windmove-display-in-direction (dir) + "Display the next buffer in the window at direction DIR. +Create a new window if there is no window in that direction." + (interactive) + (let* ((command this-command) + (depth (minibuffer-depth)) + (action display-buffer-overriding-action) + (clearfun (make-symbol "clear-display-buffer-overriding-action")) + (exitfun + (lambda () + (setq display-buffer-overriding-action action) + (remove-hook 'post-command-hook clearfun)))) + (fset clearfun + (lambda () + (unless (or + ;; Remove the hook immediately + ;; after exiting the minibuffer. + (> (minibuffer-depth) depth) + ;; But don't remove immediately after + ;; adding the hook by the same command. + (eq this-command command)) + (funcall exitfun)))) + (add-hook 'post-command-hook clearfun) + (push (lambda (buffer alist) + (unless (> (minibuffer-depth) depth) + (let ((win (if (eq dir 'same-window) + (selected-window) + (or (window-in-direction dir) + (split-window nil nil dir))))) + (window--display-buffer + buffer win (if (eq dir 'same-window) 'reuse 'window) 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." + (interactive "P") + (windmove-display-in-direction 'left)) + +;;;###autoload +(defun windmove-display-up (&optional _arg) + "Display the next buffer in window above the current one." + (interactive "P") + (windmove-display-in-direction 'up)) + +;;;###autoload +(defun windmove-display-right (&optional _arg) + "Display the next buffer in window to the right of the current one." + (interactive "P") + (windmove-display-in-direction 'right)) + +;;;###autoload +(defun windmove-display-down (&optional _arg) + "Display the next buffer in window below the current one." + (interactive "P") + (windmove-display-in-direction 'down)) + +;;;###autoload +(defun windmove-display-same-window (&optional _arg) + "Display the next buffer in window below the current one." + (interactive "P") + (windmove-display-in-direction 'same-window)) + +;;;###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)) (provide 'windmove)