From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Newsgroups: gmane.emacs.bugs Subject: bug#33870: 27.0.50; xref-goto-xref not configurable Date: Mon, 07 Jan 2019 14:21:55 +0000 Message-ID: References: <87a7ktqqx7.fsf@mail.linkov.net> <9215183d-0a44-88b5-5b3c-d0da31f749ad@yandex.ru> <878t02egph.fsf@mail.linkov.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1546870867 26709 195.159.176.226 (7 Jan 2019 14:21:07 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 7 Jan 2019 14:21:07 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (windows-nt) Cc: 33870@debbugs.gnu.org, Dmitry Gutov To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jan 07 15:21:02 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ggVm1-0006nl-Cq for geb-bug-gnu-emacs@m.gmane.org; Mon, 07 Jan 2019 15:21:01 +0100 Original-Received: from localhost ([127.0.0.1]:35666 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggVo8-0008FS-85 for geb-bug-gnu-emacs@m.gmane.org; Mon, 07 Jan 2019 09:23:12 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:58088) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggVo0-0008FD-K5 for bug-gnu-emacs@gnu.org; Mon, 07 Jan 2019 09:23:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ggVny-0006EC-W6 for bug-gnu-emacs@gnu.org; Mon, 07 Jan 2019 09:23:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48471) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ggVny-0006Dz-Qk for bug-gnu-emacs@gnu.org; Mon, 07 Jan 2019 09:23:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ggVny-00036i-Eb for bug-gnu-emacs@gnu.org; Mon, 07 Jan 2019 09:23:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: =?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: Mon, 07 Jan 2019 14:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33870 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 33870-submit@debbugs.gnu.org id=B33870.154687092911861 (code B ref 33870); Mon, 07 Jan 2019 14:23:02 +0000 Original-Received: (at 33870) by debbugs.gnu.org; 7 Jan 2019 14:22:09 +0000 Original-Received: from localhost ([127.0.0.1]:47752 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ggVn6-00035E-Al for submit@debbugs.gnu.org; Mon, 07 Jan 2019 09:22:08 -0500 Original-Received: from mail-wr1-f44.google.com ([209.85.221.44]:39055) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ggVn4-00034k-Ni for 33870@debbugs.gnu.org; Mon, 07 Jan 2019 09:22:07 -0500 Original-Received: by mail-wr1-f44.google.com with SMTP id t27so594260wra.6 for <33870@debbugs.gnu.org>; Mon, 07 Jan 2019 06:22:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=kJzmDJCq4aOvYGzOGj9e2DJ4wyipvGaSQ9cxZrDkrac=; b=ogW3MCnYd1Eyh7lYnbYaIBnPqzfiHkp42l5KGdbR6MCLGbiMtXMYNWlc6BUhpmNIPv RlWksgMBW8Z+6SGo0FlgAbIGb4UXOWc0iD6yWmZxNd/p/SfPz2Ou6lQBlnNfN+k92m/K OjpTDP8mL5Q/QaksDK8GcmQw7ouuQItinq0N9pMsHE1WhVdPzomGUGlW59nZXqVVWN9L ln8vHlVOwpOzEo7+CdI/WVL6lsGN/8PXugu4AV4Ncgn8Ie0u2QBCOBT/CTFmcqw923we Ym6q8OsEzChc9YLMbHybksWcO2Dvx0+D+tqKJbc0pCewXsf3QywspLQ5SkXeOwGkXwEu o9Uw== 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:references:date:in-reply-to :message-id:user-agent:mime-version; bh=kJzmDJCq4aOvYGzOGj9e2DJ4wyipvGaSQ9cxZrDkrac=; b=fL/xt0QQqtEmqVS6kweezK82+ZiJScm3MBvLisItLBIMGwZIHUXoXA1PBju5D/es2v gxvBS6ZPOiFwwxMqDuIwZ3ORTfAowBEVbEgUYiFkF6f4WSn+iQe8emnkfpmu5O/1FKuQ rjWafKVtnQNBPiodwSM6l1lrdzmuUbndGYhOZ5xP6zEnAHXea7VO9jOx0q6/kZhb5AyG 4I+XUxyS+xIboaNkTsYpm3eA+4PiC3ToGxI6sv2QnoTjGn/D+Ufs5f+q96I7a31OWWKf CY2IaDFApoyURNDXUiVH4AiUzfuamYzqE/M+1AblRUphSun5ZXUb+Ik65rfM/boP1dyM kbHg== X-Gm-Message-State: AJcUukd4h/CSDnGlLalxfDHazHcW7Iy3atjNGdU6UdGxha3J4JXxwE/6 Lk2zw6ldwBORZFOySrWTym7ygkY4 X-Google-Smtp-Source: ALg8bN5419WKDdminmUPCvRqY96004Xz6h8wu4w3OLq4W/m4VZz4geOu75uvq8RYr2HN0hnRQsc/Og== X-Received: by 2002:a5d:6a42:: with SMTP id t2mr56503262wrw.50.1546870920413; Mon, 07 Jan 2019 06:22:00 -0800 (PST) Original-Received: from GONDOMAR.yourcompany.com (mail1.siscog.pt. [89.115.233.242]) by smtp.gmail.com with ESMTPSA id o8sm46455231wrx.15.2019.01.07.06.21.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Jan 2019 06:21:59 -0800 (PST) In-Reply-To: <878t02egph.fsf@mail.linkov.net> (Juri Linkov's message of "Thu, 03 Jan 2019 02:18:50 +0200") X-Antivirus: AVG (VPS 190107-2, 07-01-2019), Outbound message X-Antivirus-Status: Clean 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: 209.51.188.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:154221 Archived-At: --=-=-= Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Juri Linkov writes: > Hi Jo=E3o > >> Any simplification to the implementation that keeps the >> "keep original window intent" behavior across xref >> intermediate buffers is very welcome. > > Thanks for the explanation. Now I understand better the intent in > xref--show-pos-in-buf. Generally, I'd like to see the =93keep original > window intent=94 behavior in more places, e.g. in *Occur*, *grep*, etc. > Based on your explanation, I've been able to write the patch that does > the following: Hi again, Juri After re-reading your patch more closely and giving it some more testing, I've discovered it breaks an existing use case: Emacs -Q C-x 2 ;; split-window-horizontally C-x 4 . ;; xref-find-definitions-other-window xref-backend-definitions RET C-n RET ;; in the resulting *xref* buffer =20=20=20 Expected xref.el to appear in the bottom window which was my original intent when I said "other window". In the current master this works OK, in your patch it doesn't. But don't worry, I've fixed that. In the patch that I attach to this message, none of the current UI changes is changed, but the xref window should now be configurable as is the original request of this bug. I've also renamed window.el's window--display-buffer to window-display-buffer throughout Emacs (i.e. made it public). After we merge this, we can continue the discussion about the changing the xref UI in the other bug you opened, bug#33992 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Make-xref-s-choice-of-windows-easier-to-configure.patch >From 424fe397c86026469a3853e86ca486d549f58100 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Mon, 7 Jan 2019 14:16:35 +0000 Subject: [PATCH] Make xref's choice of windows easier to configure Fixes: bug#33870 Allow for the usual user configuration strategies involving display-buffer-alist, etc. while maintaining the "keep original window intent" of xref-find-definitions, xref-find-references, etc. * lisp/windmove.el (windmove-display-in-direction): Use window--display-buffer. * lisp/window.el (display-buffer-in-atom-window): (window--make-major-side-window): (display-buffer-in-side-window): (display-buffer-in-side-window): (display-buffer-in-side-window): (display-buffer-use-some-frame): (display-buffer-same-window): (display-buffer-reuse-window): (display-buffer-reuse-mode-window): (display-buffer-pop-up-frame): (display-buffer-pop-up-window): (display-buffer-in-child-frame): (display-buffer-below-selected): (display-buffer-below-selected): (display-buffer-below-selected): (display-buffer-below-selected): (display-buffer-at-bottom): (display-buffer-in-previous-window): (display-buffer-use-some-window): Use window-display-buffer. (window-display-buffer): Rename from window--display-buffer. * lisp/progmodes/xref.el (xref--show-pos-in-buf): Use window-display-buffer. --- lisp/progmodes/xref.el | 5 ++--- lisp/windmove.el | 2 +- lisp/window.el | 46 +++++++++++++++++++++--------------------- 3 files changed, 26 insertions(+), 27 deletions(-) diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index 87ce2299c5..20eaa51bef 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -482,9 +482,8 @@ xref--show-pos-in-buf (window-live-p xref--original-window) (or (not (window-dedicated-p xref--original-window)) (eq (window-buffer xref--original-window) buf))) - `(,(lambda (buf _alist) - (set-window-buffer xref--original-window buf) - xref--original-window)))))) + `(,(lambda (buf alist) + (window-display-buffer buf xref--original-window 'reuse alist))))))) (with-selected-window (with-selected-window ;; Just before `display-buffer', place ourselves in the diff --git a/lisp/windmove.el b/lisp/windmove.el index 65270d9bbe..54f0098de7 100644 --- a/lisp/windmove.el +++ b/lisp/windmove.el @@ -626,7 +626,7 @@ windmove-display-in-direction (type 'reuse)) (unless window (setq window (split-window nil nil dir) type 'window)) - (setq new-window (window--display-buffer buffer window type alist))))) + (setq new-window (window-display-buffer buffer window type alist))))) display-buffer-overriding-action) (message "[display-%s]" dir))) diff --git a/lisp/window.el b/lisp/window.el index 37d82c060c..cf923f7dc6 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -700,7 +700,7 @@ display-buffer-in-atom-window (set-window-parameter window 'window-atom 'main)) (set-window-parameter new 'window-atom side) ;; Display BUFFER in NEW and return NEW. - (window--display-buffer + (window-display-buffer buffer new 'window alist display-buffer-mark-dedicated)))) (defun window--atom-check-1 (window) @@ -985,7 +985,7 @@ window--make-major-side-window (with-current-buffer buffer (setq window--sides-shown t)) ;; Install BUFFER in new window and return WINDOW. - (window--display-buffer buffer window 'window alist 'side)))) + (window-display-buffer buffer window 'window alist 'side)))) (defun display-buffer-in-side-window (buffer alist) "Display BUFFER in a side window of the selected frame. @@ -1113,7 +1113,7 @@ display-buffer-in-side-window ;; Reuse `this-window'. (with-current-buffer buffer (setq window--sides-shown t)) - (window--display-buffer + (window-display-buffer buffer this-window 'reuse alist dedicated)) (and (or (not max-slots) (< slots max-slots)) (or (and next-window @@ -1131,7 +1131,7 @@ display-buffer-in-side-window (set-window-parameter window 'window-slot slot) (with-current-buffer buffer (setq window--sides-shown t)) - (window--display-buffer + (window-display-buffer buffer window 'window alist dedicated)) (and best-window ;; Reuse `best-window'. @@ -1140,7 +1140,7 @@ display-buffer-in-side-window (set-window-parameter best-window 'window-slot slot) (with-current-buffer buffer (setq window--sides-shown t)) - (window--display-buffer + (window-display-buffer buffer best-window 'reuse alist dedicated))))))))) (defun window-toggle-side-windows (&optional frame) @@ -6748,7 +6748,7 @@ window--even-window-sizes (/ (- (window-total-height window) (window-total-height)) 2)) (error nil)))))) -(defun window--display-buffer (buffer window type &optional alist dedicated) +(defun window-display-buffer (buffer window type &optional alist dedicated) "Display BUFFER in WINDOW. TYPE must be one of the symbols `reuse', `window' or `frame' and is passed unaltered to `display-buffer-record-window'. ALIST is @@ -7190,7 +7190,7 @@ display-buffer-use-some-frame frame nil (cdr (assq 'inhibit-same-window alist)))))) (when window (prog1 - (window--display-buffer + (window-display-buffer buffer window 'reuse alist display-buffer-mark-dedicated) (unless (cdr (assq 'inhibit-switch-frame alist)) (window--maybe-raise-frame frame)))))) @@ -7204,7 +7204,7 @@ display-buffer-same-window (unless (or (cdr (assq 'inhibit-same-window alist)) (window-minibuffer-p) (window-dedicated-p)) - (window--display-buffer buffer (selected-window) 'reuse alist))) + (window-display-buffer buffer (selected-window) 'reuse alist))) (defun display-buffer--maybe-same-window (buffer alist) "Conditionally display BUFFER in the selected window. @@ -7252,7 +7252,7 @@ display-buffer-reuse-window (get-buffer-window-list buffer 'nomini frames)))))) (when (window-live-p window) - (prog1 (window--display-buffer buffer window 'reuse alist) + (prog1 (window-display-buffer buffer window 'reuse alist) (unless (cdr (assq 'inhibit-switch-frame alist)) (window--maybe-raise-frame (window-frame window))))))) @@ -7316,7 +7316,7 @@ display-buffer-reuse-mode-window derived-mode-same-frame derived-mode-other-frame)))) (when (window-live-p window) - (prog1 (window--display-buffer buffer window 'reuse alist) + (prog1 (window-display-buffer buffer window 'reuse alist) (unless (cdr (assq 'inhibit-switch-frame alist)) (window--maybe-raise-frame (window-frame window))))))))) @@ -7356,7 +7356,7 @@ display-buffer-pop-up-frame (with-current-buffer buffer (setq frame (funcall fun))) (setq window (frame-selected-window frame))) - (prog1 (window--display-buffer + (prog1 (window-display-buffer buffer window 'frame alist display-buffer-mark-dedicated) (unless (cdr (assq 'inhibit-switch-frame alist)) (window--maybe-raise-frame frame)))))) @@ -7386,7 +7386,7 @@ display-buffer-pop-up-window (window--try-to-split-window (get-lru-window frame t) alist)))) - (prog1 (window--display-buffer + (prog1 (window-display-buffer buffer window 'window alist display-buffer-mark-dedicated) (unless (cdr (assq 'inhibit-switch-frame alist)) (window--maybe-raise-frame (window-frame window))))))) @@ -7452,7 +7452,7 @@ display-buffer-in-child-frame (setq frame (make-frame parameters)) (setq window (frame-selected-window frame)))) - (prog1 (window--display-buffer + (prog1 (window-display-buffer buffer window 'frame alist display-buffer-mark-dedicated) (unless (cdr (assq 'inhibit-switch-frame alist)) (window--maybe-raise-frame frame))))) @@ -7476,7 +7476,7 @@ display-buffer-below-selected (eq buffer (window-buffer window)) (or (not (numberp min-height)) (>= (window-height window) min-height) - ;; 'window--display-buffer' can resize this window if + ;; 'window-display-buffer' can resize this window if ;; and only if it has a 'quit-restore' parameter ;; certifying that it always showed BUFFER before. (let ((height (window-height window)) @@ -7484,7 +7484,7 @@ display-buffer-below-selected (and quit-restore (eq (nth 1 quit-restore) 'window) (window-resizable-p window (- min-height height))))) - (window--display-buffer buffer window 'reuse alist)) + (window-display-buffer buffer window 'reuse alist)) (and (not (frame-parameter nil 'unsplittable)) (or (not (numberp min-height)) (window-sizable-p nil (- min-height))) @@ -7492,7 +7492,7 @@ display-buffer-below-selected split-width-threshold) (setq window (window--try-to-split-window (selected-window) alist))) - (window--display-buffer + (window-display-buffer buffer window 'window alist display-buffer-mark-dedicated)) (and (setq window (window-in-direction 'below)) (not (window-dedicated-p window)) @@ -7500,7 +7500,7 @@ display-buffer-below-selected ;; A window that showed another buffer before cannot ;; be resized. (>= (window-height window) min-height)) - (window--display-buffer + (window-display-buffer buffer window 'reuse alist display-buffer-mark-dedicated))))) (defun display-buffer--maybe-at-bottom (buffer alist) @@ -7533,20 +7533,20 @@ display-buffer-at-bottom (setq bottom-window window)))) nil nil 'nomini) (or (and bottom-window-shows-buffer - (window--display-buffer + (window-display-buffer buffer bottom-window 'reuse alist display-buffer-mark-dedicated)) (and (not (frame-parameter nil 'unsplittable)) (let (split-width-threshold) (setq window (window--try-to-split-window bottom-window alist))) - (window--display-buffer + (window-display-buffer buffer window 'window alist display-buffer-mark-dedicated)) (and (not (frame-parameter nil 'unsplittable)) (setq window (split-window-no-error (window-main-window))) - (window--display-buffer + (window-display-buffer buffer window 'window alist display-buffer-mark-dedicated)) (and (setq window bottom-window) (not (window-dedicated-p window)) - (window--display-buffer + (window-display-buffer buffer window 'reuse alist display-buffer-mark-dedicated))))) (defun display-buffer-in-previous-window (buffer alist) @@ -7603,7 +7603,7 @@ display-buffer-in-previous-window (setq best-window window))) ;; Return best or second best window found. (when (setq window (or best-window second-best-window)) - (window--display-buffer buffer window 'reuse alist)))) + (window-display-buffer buffer window 'reuse alist)))) (defun display-buffer-use-some-window (buffer alist) "Display BUFFER in an existing window. @@ -7643,7 +7643,7 @@ display-buffer-use-some-window (error nil))) (prog1 - (window--display-buffer buffer window 'reuse alist) + (window-display-buffer buffer window 'reuse alist) (window--even-window-sizes window) (unless (cdr (assq 'inhibit-switch-frame alist)) (window--maybe-raise-frame (window-frame window))))))) -- 2.19.2 --=-=-=--