From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#33992: 27.0.50; xref-find-definitions wastes too much space Date: Mon, 10 Jun 2019 03:35:36 +0300 Message-ID: References: <87muoe7jrs.fsf@mail.linkov.net> <87a7hp43a5.fsf@mail.linkov.net> <205acda7-07a3-d85c-378c-c178f9f76b55@yandex.ru> <87o95l4ht4.fsf@mail.linkov.net> <64f42172-460f-a633-1c80-23d34b5c0d07@yandex.ru> <87lg0m96bm.fsf@mail.linkov.net> <87ftpfqvvg.fsf@mail.linkov.net> <437558cf-3bd5-a6c7-e9d7-d22a87064d78@yandex.ru> <871s0ifj1k.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="214443"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 Cc: 33992-done@debbugs.gnu.org, =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jun 10 02:36:20 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 esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1ha8IN-000tSh-3H for geb-bug-gnu-emacs@m.gmane.org; Mon, 10 Jun 2019 02:36:19 +0200 Original-Received: from localhost ([::1]:39292 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1ha8ID-0002ZB-NI for geb-bug-gnu-emacs@m.gmane.org; Sun, 09 Jun 2019 20:36:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38553) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1ha8I7-0002Y9-RA for bug-gnu-emacs@gnu.org; Sun, 09 Jun 2019 20:36:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ha8I6-00083k-TN for bug-gnu-emacs@gnu.org; Sun, 09 Jun 2019 20:36:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42110) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ha8I6-00083d-Lw for bug-gnu-emacs@gnu.org; Sun, 09 Jun 2019 20:36:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ha8I6-0000DA-GS for bug-gnu-emacs@gnu.org; Sun, 09 Jun 2019 20:36:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 10 Jun 2019 00:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33992 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 33992-done@debbugs.gnu.org id=D33992.1560126947787 (code D ref 33992); Mon, 10 Jun 2019 00:36:02 +0000 Original-Received: (at 33992-done) by debbugs.gnu.org; 10 Jun 2019 00:35:47 +0000 Original-Received: from localhost ([127.0.0.1]:55654 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ha8Hr-0000Cd-8b for submit@debbugs.gnu.org; Sun, 09 Jun 2019 20:35:47 -0400 Original-Received: from mail-wr1-f43.google.com ([209.85.221.43]:39725) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ha8Hp-0000CP-4I for 33992-done@debbugs.gnu.org; Sun, 09 Jun 2019 20:35:46 -0400 Original-Received: by mail-wr1-f43.google.com with SMTP id x4so4713376wrt.6 for <33992-done@debbugs.gnu.org>; Sun, 09 Jun 2019 17:35:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=KaOtDSPN7vXLJDD5zctb7dfUmkvVzvyG/ZDOlD8kItc=; b=E1CgD20CFlKBzudQdKxj99p+Bo05o/hRVW/CIuV795hC/shpkOcJhY45NW5+6hnTq0 JSEkKmGDejBtcTqt5uX1jY3jZBh60AssznwIk0WBlJy9zn/M0rWzmtxluP4MNNytN4va RF76zf+Omoli7+c/K/DsPSMJfOdLwHI2fsTaPMEdHoW2+sRsguFpQkjiGtJdQlovsRpD 4TMdkuuDam08bvtV/QCKVfxOlwlRUfd6R1Wr8mXXSpIRf8pP6JevHcT5IL8v8juplyHc VOstaqw6BMDXPOVkfNOIDE8SmUgL8ADKSL5qJrwiWAx0J+Qjvwea2HbbpPt9Yi541GTm QgNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=KaOtDSPN7vXLJDD5zctb7dfUmkvVzvyG/ZDOlD8kItc=; b=S6zS5NTZtYqGKijIv3j8kPBWsGsRJsy+MYUWeHMTjqu3fSHfS5yy8+Ypr/TyuE6/Lf HypK2RW85tQRgWWi8YthrFR4hE9jHnooiUdRc0jc+0shilwm9WaSx7ZrfhNrcNw4hvCh YbXLgZE1WypN5NRXfeJJN5mhvzMpQ24ltDvc1Vx9f1Z02AWJL26p3qpmp95If8LIqGwQ IOcxXFK/cn/1+0Kkc4INVCFZTCNRS02PNr4mTgXi8LhU/B59HP4j7ecPI2Paa72Ipcs1 lNNBl7HFGKNBcM9ahQzJCFs38rZNE6SDAGeqPvsHRDjmbTbs439e9R1p0TncrokysPZk tmOQ== X-Gm-Message-State: APjAAAU1yWkAjUs7IMr0cYWzxWaxkBz0qRJqAS4Rj1ynsy+72oTTd7vW 6f9FQUDJBfwDPH+I4M5xZHI= X-Google-Smtp-Source: APXvYqySOExqPxz2t0nJTGCbj9nMG79k4RXdxCfNJTgEsv0Tb1cX1HBPTJ6MmkgReahrUW3qIIOF4w== X-Received: by 2002:a5d:5446:: with SMTP id w6mr29893150wrv.164.1560126939197; Sun, 09 Jun 2019 17:35:39 -0700 (PDT) Original-Received: from [192.168.1.3] ([185.105.174.23]) by smtp.googlemail.com with ESMTPSA id l190sm7013099wml.25.2019.06.09.17.35.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 Jun 2019 17:35:38 -0700 (PDT) In-Reply-To: <871s0ifj1k.fsf@mail.linkov.net> Content-Language: en-US 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:160311 Archived-At: Hi Juri, On 28.05.2019 23:35, Juri Linkov wrote: > FWIW, this is what I currently use to customize xref-find-definitions > to act more like Completions: > > (custom-set-variables > '(display-buffer-alist > '((display-buffer-to-xref-p display-buffer-in-direction > (direction . below) > (window-height . fit-window-to-buffer))))) > > (defun display-buffer-to-xref-p (buffer-name _action) > (and (string-match-p "\\`\\*\\(xref\\)\\*\\(\\|<[0-9]+>\\)\\'" > buffer-name) > (memq this-command '(xref-find-definitions)))) > > (with-eval-after-load 'xref > (defvar xref--original-command nil) > (advice-add 'xref-find-definitions :after > (lambda (&rest _args) > (with-current-buffer (window-buffer) > (setq-local xref--original-command 'xref-find-definitions)))) > (define-key xref--button-map [(control ?m)] > (lambda () > (interactive) > (if (memq xref--original-command '(xref-find-definitions)) > (call-interactively 'xref-quit-and-goto-xref) > (setq xref--original-window nil) > (call-interactively 'xref-goto-xref))))) JFYI, one of the changes I've pushed yesterday was the patch I've shown before, and it should let you have the same behavior with one line: (setq xref-show-definitions-function 'xref--show-defs-buffer-at-bottom) It doesn't seem like xref-quit-and-goto-xref works well, though. It doesn't always honor the intention to open the location in the window the command was called from. It can show the location in a different window, and then if I press M-, from there, Emacs does not return to the previous window configuration. I've tracked this down to xref--show-pos-in-buf. Apparently, calling display-buffer with `((display-buffer-in-previous-window) (previous-window . ,xref--original-window)) as its second argument doesn't do the trick. Looking at it, it contains logic where when (eq window (selected-window)), it sets best-window to something else (in particular, it can favor a window where this buffer had been displayed previously). So, should some other action function be used? I can trace this choice back to your commit 94b320849e9 where this bug was apparently introduced.