GNU bug report logs -
#44611
Prefix arg for xref-goto-xref
Previous Next
Reported by: Juri Linkov <juri <at> linkov.net>
Date: Fri, 13 Nov 2020 08:33:01 UTC
Severity: normal
Tags: fixed
Fixed in version 28.0.50
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
Full log
Message #229 received at 44611 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
>> (defun next-error-quit-window ()
>> (when (and (eq current-prefix-arg 0)
>> (not (eq next-error-last-buffer (current-buffer))))
>> (let ((window (get-buffer-window next-error-last-buffer)))
>> (when (window-live-p window)
>> (with-selected-window window
>> (quit-restore-window window))))))
>> (add-hook 'next-error-hook 'next-error-quit-window)
>
> Since next-error-hook is a defcustom, perhaps we can/should include this
> function as one of the advertised values in :type?
>
> Even if we keep the list nil by default.
I completely forgot that we have 'next-error-found-function',
so implemented it with 'next-error-hook'. I don't remember
why we have both.
Anyway, here is a patch with corrections from Martin:
[next-error-quit-window.patch (text/x-diff, inline)]
diff --git a/lisp/simple.el b/lisp/simple.el
index 94d79c2bf1..73020c2c8e 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -377,11 +377,22 @@ next-error-internal
(not (eq prev next-error-last-buffer)))
(message "Current locus from %s" next-error-last-buffer)))))
+(defun next-error-quit-window (from-buffer to-buffer)
+ "Quit window of FROM-BUFFER when the prefix arg is 0.
+Intended to be used in `next-error-found-function'."
+ (when (and (eq current-prefix-arg 0) from-buffer
+ (not (eq from-buffer to-buffer)))
+ (let ((window (get-buffer-window from-buffer)))
+ (when (window-live-p window)
+ (quit-restore-window window)))))
+
(defcustom next-error-found-function #'ignore
"Function called when a next locus is found and displayed.
Function is called with two arguments: a FROM-BUFFER buffer
from which next-error navigated, and a target buffer TO-BUFFER."
:type '(choice (const :tag "No default" ignore)
+ (const :tag "Quit previous window with M-0"
+ next-error-quit-window)
(function :tag "Other function"))
:group 'next-error
:version "27.1")
This bug report was last modified 4 years and 88 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.