From: Juri Linkov <juri@linkov.net>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: 28864@debbugs.gnu.org, Noam Postavsky <npostavs@gmail.com>,
Tino Calancha <tino.calancha@gmail.com>
Subject: bug#28864: 25.3.50; next-error-no-select does select
Date: Sun, 29 Oct 2017 00:07:34 +0300 [thread overview]
Message-ID: <87po97vuoh.fsf@localhost> (raw)
In-Reply-To: <7821c28e-3bf5-0bab-46ab-23f3a02566a8@yandex.ru> (Dmitry Gutov's message of "Wed, 25 Oct 2017 01:23:20 +0300")
[-- Attachment #1: Type: text/plain, Size: 675 bytes --]
>> So do you propose to prefer buffer-local next-error-last-buffer
>> instead of window-local next-error-last-buffer?
>
> Maybe something like this:
>
> - Make next-error-last-buffer always buffer-local.
I believe this patch is a change for the better:
1. makes next-error-function buffer-local
2. sets both buffer-local and global values
3. adds customizable next-error-find-buffer-function
4. moves window-on-frame-visibility code to separate function
that can be used to customize for backward-compatibility
5. adds next-error-select-buffer to manually switch to another
next-error capable buffer
6. message to show which next-error buffer is currently used
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: next-error-1.patch --]
[-- Type: text/x-diff, Size: 6497 bytes --]
diff --git a/lisp/simple.el b/lisp/simple.el
index 12d65e5..2371d08 100644
*** a/lisp/simple.el
--- b/lisp/simple.el
***************
*** 143,148 ****
--- 143,149 ----
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-function)
(defvar next-error-function nil
"Function to use to find the next error in the current buffer.
***************
*** 191,196 ****
--- 192,221 ----
(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 "Buffer on selected frame" next-error-buffer-on-selected-frame)
+ (const :tag "No default" nil)
+ (function :tag "Other function"))
+ :group 'next-error
+ :version "27.0")
+
+ (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,224 ****
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)))
;; 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
--- 232,242 ----
that would normally be considered usable. If it returns nil,
that buffer is rejected."
(or
! ;; 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
***************
*** 279,301 ****
`compilation-error-regexp-alist'."
(interactive "P")
(if (consp arg) (setq reset t arg nil))
! (when (setq next-error-last-buffer (next-error-find-buffer))
;; we know here that next-error-function is a valid symbol we can funcall
! (with-current-buffer next-error-last-buffer
! (funcall next-error-function (prefix-numeric-value arg) reset)
(when next-error-recenter
(recenter next-error-recenter))
(run-hooks 'next-error-hook))))
! (defun next-error-internal ()
! "Visit the source code corresponding to the `next-error' message at point."
! (setq next-error-last-buffer (current-buffer))
! ;; we know here that next-error-function is a valid symbol we can funcall
! (with-current-buffer next-error-last-buffer
! (funcall next-error-function 0 nil)
! (when next-error-recenter
! (recenter next-error-recenter))
! (run-hooks 'next-error-hook)))
(defalias 'goto-next-locus 'next-error)
(defalias 'next-match 'next-error)
--- 297,339 ----
`compilation-error-regexp-alist'."
(interactive "P")
(if (consp arg) (setq reset t arg nil))
! (let ((next-error-buffer (next-error-find-buffer)))
! (when next-error-buffer
! ;; we know here that next-error-function is a valid symbol we can funcall
! (with-current-buffer next-error-last-buffer
! (funcall next-error-function (prefix-numeric-value arg) reset)
! ;; next-error-function might change the value of
! ;; next-error-last-buffer, so set it later
! (setq next-error-last-buffer next-error-buffer)
! (setq-default next-error-last-buffer next-error-last-buffer)
! (when next-error-recenter
! (recenter next-error-recenter))
! (message "Next error buffer from %s" next-error-last-buffer)
! (run-hooks 'next-error-hook)))))
!
! (defun next-error-internal ()
! "Visit the source code corresponding to the `next-error' message at point."
! (let ((next-error-buffer (current-buffer)))
;; we know here that next-error-function is a valid symbol we can funcall
! (with-current-buffer next-error-buffer
! (funcall next-error-function 0 nil)
! ;; next-error-function might change the value of
! ;; next-error-last-buffer, so set it later
! (setq next-error-last-buffer next-error-buffer)
! (setq-default next-error-last-buffer next-error-last-buffer)
(when next-error-recenter
(recenter next-error-recenter))
+ (message "Next error buffer from %s" next-error-last-buffer)
(run-hooks 'next-error-hook))))
! (defun next-error-select-buffer (next-error-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 next-error-buffer)
! (setq-default next-error-last-buffer next-error-last-buffer))
(defalias 'goto-next-locus 'next-error)
(defalias 'next-match 'next-error)
next prev parent reply other threads:[~2017-10-28 21:07 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-16 13:07 bug#28864: 25.3.50; next-error-no-select does select Tino Calancha
2017-10-17 13:37 ` Dmitry Gutov
2017-10-17 14:17 ` Tino Calancha
2017-10-18 7:44 ` Dmitry Gutov
2017-10-20 7:21 ` Tino Calancha
2017-10-20 21:49 ` Dmitry Gutov
2017-10-21 3:52 ` Tino Calancha
2017-10-22 20:32 ` Juri Linkov
2017-10-22 22:29 ` Dmitry Gutov
2017-10-23 20:12 ` Juri Linkov
2017-10-23 20:23 ` Dmitry Gutov
2017-10-24 20:22 ` Juri Linkov
2017-10-24 22:23 ` Dmitry Gutov
2017-10-25 23:58 ` Dmitry Gutov
2017-10-28 21:07 ` Juri Linkov [this message]
2017-10-28 22:46 ` Dmitry Gutov
2017-10-29 21:42 ` Juri Linkov
2017-10-30 14:59 ` Dmitry Gutov
2017-10-30 18:30 ` Eli Zaretskii
2017-10-30 21:13 ` Dmitry Gutov
2017-10-30 21:15 ` Juri Linkov
2017-10-30 21:14 ` Juri Linkov
2017-10-31 0:02 ` Dmitry Gutov
2017-10-31 21:56 ` Juri Linkov
2017-10-31 23:42 ` Dmitry Gutov
2017-11-02 22:00 ` Juri Linkov
2017-11-05 13:37 ` Dmitry Gutov
2017-11-06 21:41 ` Juri Linkov
2017-10-28 20:54 ` Juri Linkov
2017-10-28 22:42 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87po97vuoh.fsf@localhost \
--to=juri@linkov.net \
--cc=28864@debbugs.gnu.org \
--cc=dgutov@yandex.ru \
--cc=npostavs@gmail.com \
--cc=tino.calancha@gmail.com \
/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.