GNU bug report logs -
#20489
25.0.50; next-error-find-buffer chooses non-current buffer without good reason
Previous Next
Reported by: Dmitry Gutov <dgutov <at> yandex.ru>
Date: Sat, 2 May 2015 23:19:01 UTC
Severity: normal
Found in version 25.0.50
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
Full log
Message #175 received at 20489 <at> debbugs.gnu.org (full text, mbox):
> But this requires a feature that is not yet implemented, namely
> a customization like ‘display-buffer-from-alist’ to match the source
> buffer name (that was the current buffer before navigation) instead
> of the target buffer (the buffer to display) like ‘display-buffer-alist’
> currently specifies.
Actually no new feature is needed, ‘display-buffer-alist’ is powerful enough,
and this can be easily implemented with a few lines of code:
1. next-error for *xref* to reuse the same window:
(push '(display-buffer-condition-next-error
display-buffer-same-window)
display-buffer-alist)
(defun display-buffer-condition-next-error (_buffer-name _action)
(memq this-command '(next-error previous-error)))
2. with e.g. two *grep* windows, typing RET to select the right locus window:
(push '(display-buffer-condition-from-next-error-buffer
display-buffer-in-next-error-last-window
(inhibit-same-window . t))
display-buffer-alist)
(defun display-buffer-condition-from-next-error-buffer (_buffer-name _action)
(string-match-p "\\`\\*\\(compilation\\|grep\\|Occur\\)\\*\\(\\|<[0-9]+>\\)\\'"
(buffer-name (current-buffer))))
(defun display-buffer-in-next-error-last-window (buffer alist)
"Return a window used to display the last next-error buffer."
(let* ((window (car (delq nil
(mapcar (lambda (w) (when (and (local-variable-p 'next-error-last-buffer
(window-buffer w))
(eq (current-buffer)
(buffer-local-value
'next-error-last-buffer
(window-buffer w))))
w))
(window-list-1 nil 'nomini))))))
(when (window-live-p window)
window
(prog1 (window--display-buffer buffer window 'reuse alist)
(unless (cdr (assq 'inhibit-switch-frame alist))
(window--maybe-raise-frame (window-frame window)))))))
This bug report was last modified 7 years and 72 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.