From: Juri Linkov <juri@linkov.net>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: 44611@debbugs.gnu.org
Subject: bug#44611: Prefix arg for xref-goto-xref
Date: Fri, 11 Dec 2020 11:30:25 +0200 [thread overview]
Message-ID: <877dpopuli.fsf@linkov.net> (raw)
In-Reply-To: <48f942f9-a557-0185-25fe-612e78cd9071@yandex.ru> (Dmitry Gutov's message of "Sun, 15 Nov 2020 03:05:16 +0200")
[-- Attachment #1: Type: text/plain, Size: 890 bytes --]
>>>> 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:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: xref-pop-marker-stack-kill.patch --]
[-- Type: text/x-diff, Size: 1404 bytes --]
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)
next prev parent reply other threads:[~2020-12-11 9:30 UTC|newest]
Thread overview: 83+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-13 8:18 bug#44611: Prefix arg for xref-goto-xref Juri Linkov
2020-11-13 11:20 ` Dmitry Gutov
2020-11-14 20:36 ` Juri Linkov
2020-11-15 1:05 ` Dmitry Gutov
2020-11-15 19:51 ` Juri Linkov
2020-11-15 22:25 ` Dmitry Gutov
2020-11-15 22:52 ` Drew Adams
2020-11-15 23:11 ` João Távora
2020-12-19 20:38 ` Juri Linkov
2020-12-19 21:41 ` Dmitry Gutov
2020-12-19 22:36 ` João Távora
2020-12-19 23:59 ` Dmitry Gutov
2020-12-20 20:32 ` João Távora
2020-12-20 20:45 ` Dmitry Gutov
2020-12-22 0:52 ` João Távora
2020-12-20 3:26 ` Eli Zaretskii
2020-12-20 8:39 ` Juri Linkov
2020-12-20 15:43 ` Eli Zaretskii
2020-12-20 16:10 ` Dmitry Gutov
2020-12-22 8:58 ` Juri Linkov
2020-12-22 12:20 ` Dmitry Gutov
2020-12-22 15:53 ` Eli Zaretskii
2020-12-22 21:20 ` Juri Linkov
2020-12-23 15:08 ` Eli Zaretskii
2020-12-23 16:20 ` Dmitry Gutov
2020-12-23 16:46 ` Eli Zaretskii
2020-12-23 18:45 ` Dmitry Gutov
2020-12-23 19:23 ` Eli Zaretskii
2020-12-23 19:56 ` Dmitry Gutov
2020-12-23 20:30 ` Eli Zaretskii
2020-12-23 21:24 ` Dmitry Gutov
2020-12-24 17:44 ` Eli Zaretskii
2020-12-24 20:19 ` Juri Linkov
2020-12-24 20:44 ` Eli Zaretskii
2020-12-25 9:20 ` Juri Linkov
2020-12-25 11:44 ` Eli Zaretskii
2020-12-25 15:24 ` Dmitry Gutov
2020-12-27 16:22 ` Juri Linkov
2020-12-27 17:16 ` martin rudalics
2020-12-27 18:53 ` Dmitry Gutov
2020-12-28 17:24 ` Juri Linkov
2021-01-18 1:17 ` Dmitry Gutov
2021-01-19 17:56 ` Juri Linkov
2021-01-19 19:38 ` Dmitry Gutov
2021-02-01 17:16 ` Juri Linkov
2021-03-16 18:15 ` Juri Linkov
2021-03-17 8:45 ` martin rudalics
[not found] ` <87sg4vgef6.fsf@mail.linkov.net>
2021-03-16 23:38 ` Dmitry Gutov
2021-03-17 17:23 ` Juri Linkov
2021-03-17 21:48 ` Dmitry Gutov
2020-12-27 16:20 ` Juri Linkov
2020-12-27 18:21 ` Eli Zaretskii
2020-12-28 0:54 ` Dmitry Gutov
2020-12-28 9:16 ` Juri Linkov
2021-04-22 15:18 ` Dmitry Gutov
[not found] ` <1fa6bd28-0524-011e-86c2-60c8faab51f8@yandex.ru>
2021-04-22 17:03 ` Eli Zaretskii
2021-04-22 17:44 ` Dmitry Gutov
2021-04-22 17:47 ` Eli Zaretskii
2021-04-22 17:56 ` Dmitry Gutov
2020-12-25 16:01 ` Dmitry Gutov
2021-04-23 10:41 ` Dmitry Gutov
2021-04-23 10:53 ` Eli Zaretskii
2021-04-24 9:56 ` Eli Zaretskii
2021-04-24 10:01 ` Dmitry Gutov
2020-12-23 21:10 ` Juri Linkov
2020-12-24 3:36 ` Eli Zaretskii
2020-12-24 21:38 ` Dmitry Gutov
2020-12-25 7:37 ` Eli Zaretskii
2020-12-25 12:14 ` Dmitry Gutov
2020-12-25 13:32 ` Eli Zaretskii
2020-12-25 14:49 ` Dmitry Gutov
2020-12-25 15:42 ` Eli Zaretskii
2020-12-28 0:36 ` Dmitry Gutov
2020-12-22 9:24 ` João Távora
2020-12-11 9:30 ` Juri Linkov [this message]
2020-12-11 11:19 ` Dmitry Gutov
2020-12-11 12:08 ` Eli Zaretskii
2020-12-12 20:39 ` Juri Linkov
2020-12-13 15:10 ` Eli Zaretskii
2020-12-13 20:20 ` Juri Linkov
2020-12-13 20:50 ` João Távora
2020-12-14 16:16 ` Eli Zaretskii
2020-12-14 16:34 ` Dmitry Gutov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877dpopuli.fsf@linkov.net \
--to=juri@linkov.net \
--cc=44611@debbugs.gnu.org \
--cc=dgutov@yandex.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).