From: Juri Linkov <juri@linkov.net>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: 20489@debbugs.gnu.org
Subject: bug#20489: 25.0.50; next-error-find-buffer chooses non-current buffer without good reason
Date: Mon, 06 Nov 2017 23:53:00 +0200 [thread overview]
Message-ID: <877ev36pmr.fsf@mail.linkov.net> (raw)
In-Reply-To: <86wq0q602w.fsf@yandex.ru> (Dmitry Gutov's message of "Sun, 03 May 2015 02:17:43 +0300")
[-- Attachment #1: Type: text/plain, Size: 154 bytes --]
It seems this discussion that came to a standstill here
hopefully is revived and reached a preliminary consensus in bug#28864.
Here's the current patch:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: next-error-5.patch --]
[-- Type: text/x-diff, Size: 5279 bytes --]
diff --git a/lisp/simple.el b/lisp/simple.el
index 375a79e..ceefbc1 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -143,6 +143,7 @@ next-error-last-buffer
A buffer becomes most recent when its compilation, grep, or
similar mode is started, or when it is used with \\[next-error]
or \\[compile-goto-error].")
+(make-variable-buffer-local 'next-error-last-buffer)
(defvar next-error-function nil
"Function to use to find the next error in the current buffer.
@@ -191,6 +192,31 @@ next-error-buffer-p
(and extra-test-inclusive
(funcall extra-test-inclusive))))))
+(defcustom next-error-find-buffer-function nil
+ "Function called to find a `next-error' capable buffer."
+ :type '(choice (const :tag "Single next-error capable buffer on selected frame"
+ next-error-buffer-on-selected-frame)
+ (const :tag "No default" nil)
+ (function :tag "Other function"))
+ :group 'next-error
+ :version "27.1")
+
+(defun next-error-buffer-on-selected-frame (&optional avoid-current
+ extra-test-inclusive
+ extra-test-exclusive)
+ "Return a single visible next-error buffer on the selected frame."
+ (let ((window-buffers
+ (delete-dups
+ (delq nil (mapcar (lambda (w)
+ (if (next-error-buffer-p
+ (window-buffer w)
+ avoid-current
+ extra-test-inclusive extra-test-exclusive)
+ (window-buffer w)))
+ (window-list))))))
+ (if (eq (length window-buffers) 1)
+ (car window-buffers))))
+
(defun next-error-find-buffer (&optional avoid-current
extra-test-inclusive
extra-test-exclusive)
@@ -207,18 +233,11 @@ next-error-find-buffer
that would normally be considered usable. If it returns nil,
that buffer is rejected."
(or
- ;; 1. If one window on the selected frame displays such buffer, return it.
- (let ((window-buffers
- (delete-dups
- (delq nil (mapcar (lambda (w)
- (if (next-error-buffer-p
- (window-buffer w)
- avoid-current
- extra-test-inclusive extra-test-exclusive)
- (window-buffer w)))
- (window-list))))))
- (if (eq (length window-buffers) 1)
- (car window-buffers)))
+ ;; 1. If a customizable function returns a buffer, use it.
+ (when next-error-find-buffer-function
+ (funcall next-error-find-buffer-function avoid-current
+ extra-test-inclusive
+ extra-test-exclusive))
;; 2. If next-error-last-buffer is an acceptable buffer, use that.
(if (and next-error-last-buffer
(next-error-buffer-p next-error-last-buffer avoid-current
@@ -283,11 +302,20 @@ next-error
(when buffer
;; We know here that next-error-function is a valid symbol we can funcall
(with-current-buffer buffer
+ ;; Allow next-error to be used from the next-error capable buffer.
+ (setq next-error-last-buffer buffer)
(funcall next-error-function (prefix-numeric-value arg) reset)
;; Override possible change of next-error-last-buffer in next-error-function
(setq next-error-last-buffer buffer)
+ (setq-default next-error-last-buffer buffer)
(when next-error-recenter
(recenter next-error-recenter))
+ (message "%s error from %s"
+ (cond (reset "First")
+ ((eq (prefix-numeric-value arg) 0) "Current")
+ ((< (prefix-numeric-value arg) 0) "Previous")
+ (t "Next"))
+ next-error-last-buffer)
(run-hooks 'next-error-hook)))))
(defun next-error-internal ()
@@ -295,13 +323,26 @@ next-error-internal
(let ((buffer (current-buffer)))
;; We know here that next-error-function is a valid symbol we can funcall
(with-current-buffer buffer
+ ;; Allow next-error to be used from the next-error capable buffer.
+ (setq next-error-last-buffer buffer)
(funcall next-error-function 0 nil)
;; Override possible change of next-error-last-buffer in next-error-function
(setq next-error-last-buffer buffer)
+ (setq-default next-error-last-buffer buffer)
(when next-error-recenter
(recenter next-error-recenter))
+ (message "Current error from %s" next-error-last-buffer)
(run-hooks 'next-error-hook))))
+(defun next-error-select-buffer (buffer)
+ "Select a `next-error' capable buffer and set it as the last used."
+ (interactive
+ (list (get-buffer
+ (read-buffer "Select next-error buffer: " nil nil
+ (lambda (b) (next-error-buffer-p (cdr b)))))))
+ (setq next-error-last-buffer buffer)
+ (setq-default next-error-last-buffer buffer))
+
(defalias 'goto-next-locus 'next-error)
(defalias 'next-match 'next-error)
next prev parent reply other threads:[~2017-11-06 21:53 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-02 23:17 bug#20489: 25.0.50; next-error-find-buffer chooses non-current buffer without good reason Dmitry Gutov
2015-05-03 5:49 ` Stefan Monnier
2015-05-03 12:56 ` Dmitry Gutov
2015-05-04 22:03 ` Ted Zlatanov
2015-05-04 22:22 ` Dmitry Gutov
2015-05-04 22:33 ` Ted Zlatanov
2015-05-05 15:05 ` Dmitry Gutov
2015-05-05 15:15 ` Ted Zlatanov
2016-01-24 21:10 ` Juri Linkov
2016-01-25 6:23 ` Dmitry Gutov
2016-01-25 21:55 ` Juri Linkov
2016-01-25 23:36 ` Dmitry Gutov
2016-01-27 0:57 ` Juri Linkov
2016-01-27 2:43 ` Dmitry Gutov
2016-01-27 22:57 ` Juri Linkov
2016-01-27 23:28 ` Dmitry Gutov
2016-01-28 23:59 ` Juri Linkov
2016-01-29 0:35 ` Dmitry Gutov
2016-01-29 23:44 ` Juri Linkov
2016-01-30 0:57 ` Dmitry Gutov
2016-01-30 23:43 ` Juri Linkov
2016-01-31 0:39 ` Dmitry Gutov
2016-01-31 21:57 ` Juri Linkov
2016-01-31 22:38 ` Dmitry Gutov
2016-02-02 0:44 ` Juri Linkov
2016-02-02 1:40 ` Dmitry Gutov
2016-02-03 0:35 ` Juri Linkov
2016-02-04 1:00 ` Dmitry Gutov
2016-02-22 0:01 ` Dmitry Gutov
2016-02-22 17:22 ` Eli Zaretskii
2016-02-22 17:30 ` Dmitry Gutov
2016-02-22 17:39 ` Eli Zaretskii
2016-02-22 18:09 ` Dmitry Gutov
2016-02-22 18:11 ` Dmitry Gutov
2016-02-22 19:07 ` Eli Zaretskii
2016-02-27 10:14 ` Eli Zaretskii
2016-02-29 3:15 ` Dmitry Gutov
2016-02-29 16:23 ` Eli Zaretskii
2016-02-29 23:30 ` Dmitry Gutov
2017-11-06 21:53 ` Juri Linkov [this message]
2018-02-15 22:16 ` Juri Linkov
2018-02-27 1:21 ` Dmitry Gutov
2018-02-27 1:54 ` Dmitry Gutov
2018-02-27 18:07 ` Dmitry Gutov
2018-02-27 21:16 ` Juri Linkov
2018-02-28 2:13 ` Dmitry Gutov
2018-02-28 21:17 ` Juri Linkov
2018-03-02 1:19 ` Dmitry Gutov
2018-03-06 22:17 ` Juri Linkov
2018-03-07 14:11 ` Dmitry Gutov
2018-03-07 21:11 ` Juri Linkov
2018-03-12 22:08 ` Dmitry Gutov
2018-02-28 21:25 ` Juri Linkov
2018-03-01 22:58 ` Juri Linkov
2018-03-02 1:26 ` Dmitry Gutov
2018-03-06 22:25 ` Juri Linkov
2018-03-07 14:08 ` Dmitry Gutov
2018-03-07 21:03 ` Juri Linkov
2018-02-28 21:32 ` Juri Linkov
2018-03-02 0:54 ` Dmitry Gutov
2018-03-01 23:04 ` Juri Linkov
2018-03-02 1:30 ` Dmitry Gutov
2018-02-28 17:33 ` Richard Stallman
2018-02-21 21:30 ` Juri Linkov
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877ev36pmr.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=20489@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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.