From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#44611: Prefix arg for xref-goto-xref Date: Fri, 11 Dec 2020 11:30:25 +0200 Message-ID: <877dpopuli.fsf@linkov.net> References: <87k0up68e4.fsf@mail.linkov.net> <99772eb6-5a4e-7cf6-259d-0e9429e6bf97@yandex.ru> <878sb3n0a9.fsf@mail.linkov.net> <48f942f9-a557-0185-25fe-612e78cd9071@yandex.ru> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9623"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: 44611@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Dec 11 11:00:23 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1knfDp-0002OB-OQ for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 11 Dec 2020 11:00:21 +0100 Original-Received: from localhost ([::1]:34632 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knfDo-0002T5-Om for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 11 Dec 2020 05:00:20 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33130) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knfDY-0002PO-PD for bug-gnu-emacs@gnu.org; Fri, 11 Dec 2020 05:00:05 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:56708) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1knfDW-00027L-R3 for bug-gnu-emacs@gnu.org; Fri, 11 Dec 2020 05:00:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1knfDW-0007Ro-MY for bug-gnu-emacs@gnu.org; Fri, 11 Dec 2020 05:00:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 11 Dec 2020 10:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44611 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed Original-Received: via spool by 44611-submit@debbugs.gnu.org id=B44611.160768079928583 (code B ref 44611); Fri, 11 Dec 2020 10:00:02 +0000 Original-Received: (at 44611) by debbugs.gnu.org; 11 Dec 2020 09:59:59 +0000 Original-Received: from localhost ([127.0.0.1]:40016 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1knfDG-0007QW-1t for submit@debbugs.gnu.org; Fri, 11 Dec 2020 04:59:59 -0500 Original-Received: from relay3-d.mail.gandi.net ([217.70.183.195]:43495) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1knfDC-0007QF-Hp for 44611@debbugs.gnu.org; Fri, 11 Dec 2020 04:59:45 -0500 X-Originating-IP: 91.129.99.98 Original-Received: from mail.gandi.net (m91-129-99-98.cust.tele2.ee [91.129.99.98]) (Authenticated sender: juri@linkov.net) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id B782E6000B; Fri, 11 Dec 2020 09:59:34 +0000 (UTC) In-Reply-To: <48f942f9-a557-0185-25fe-612e78cd9071@yandex.ru> (Dmitry Gutov's message of "Sun, 15 Nov 2020 03:05:16 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:195737 Archived-At: --=-=-= Content-Type: text/plain >>>> Like e.g. 'quit-window' allows using a prefix argument >>>> to change its behavior by relying on (interactive "P"), >>>> xref-goto-xref should do the same: >>> >>> The proposed change is not quite the same (bury instead of kill), but if it >>> really helps, go ahead. >> I don't know how important would be to kill *xref* instead of burying. > > Indeed, probably not at all important. I'm just saying the parallel seems > very rough. > > Which might or might not be important from the standpoint of trying to > unify different behaviors in Emacs, to make them more "regular". What do you think about adding a prefix arg 'KILL' to xref-pop-marker-stack that would behave exactly like the same arg 'KILL' in quit-window? This is very useful when there is a need to quickly peek with 'M-.', and to kill the temporary buffer when going back with 'C-u M-,'. Here is the implementation: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=xref-pop-marker-stack-kill.patch diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index 6e99e9d8ac..1bfd7be154 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -401,17 +401,23 @@ xref-push-marker-stack (ring-insert xref--marker-ring (or m (point-marker)))) ;;;###autoload -(defun xref-pop-marker-stack () - "Pop back to where \\[xref-find-definitions] was last invoked." - (interactive) +(defun xref-pop-marker-stack (&optional kill) + "Pop back to where \\[xref-find-definitions] was last invoked. +With prefix argument KILL non-nil, kill the previous buffer instead of +burying it." + (interactive "P") (let ((ring xref--marker-ring)) (when (ring-empty-p ring) (user-error "Marker stack is empty")) - (let ((marker (ring-remove ring 0))) - (switch-to-buffer (or (marker-buffer marker) - (user-error "The marked buffer has been deleted"))) + (let* ((marker (ring-remove ring 0)) + (new-buffer (or (marker-buffer marker) + (user-error "The marked buffer has been deleted"))) + (old-buffer (current-buffer))) + (switch-to-buffer new-buffer) (goto-char (marker-position marker)) (set-marker marker nil nil) + (when (and kill (not (eq old-buffer new-buffer))) + (kill-buffer old-buffer)) (run-hooks 'xref-after-return-hook)))) (defvar xref--current-item nil) --=-=-=--