From: Dmitry Gutov <dgutov@yandex.ru>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 40919@debbugs.gnu.org, tspiteri@ieee.org, juri@linkov.net
Subject: bug#40919: 27.0.91; next-error-select-buffer does not always behave as documented
Date: Tue, 26 May 2020 02:17:34 +0300 [thread overview]
Message-ID: <f6dc0c2c-ced0-6277-5994-311e081c84d7@yandex.ru> (raw)
In-Reply-To: <83367ovyah.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 1966 bytes --]
On 25.05.2020 18:17, Eli Zaretskii wrote:
>>> Yes, this will fix the reported problem of customizability.
>>> Maybe Eli will agree to fix this in emacs-27.
>>
>> I can post the corresponding patch, if it helps.
>
> It's okay to add a defcustom and a new function, but the other part of
> the patch changes the default behavior, and that is less okay. Can we
> do one without the other?
The defcustom already exists. It currently defaults to #'ignore (do
nothing). It is called in case #1.
The attached patch moves case #2 into a new function and makes it the
default value of the said defcustom (thus case #2 effectively moves into
case #1). As a result, the default behavior doesn't change, but the user
will have a much easier time turning off case #2.
> (Btw, the textual descriptions of the options both in the patch and
> those already in the code are confusingly obscure, so much so that I
> don't think I could understand what each one does.)
Knowing the subject matter somewhat, I think the descriptions are
meaningful enough, but to make sense of them one has to understand how
the whole feature comes together. E.g. at what times
next-error-find-buffer is called.
> All in all, I feel (for quite some time) that this area is
> over-engineered and keeps bumping into more and more unintended
> consequences. Maybe it's time to take a step back and rethink the
> entire subject? (But definitely not on the release branch.)
That's what we're doing here.
If the attached patch is accepted for emacs-27, then on master we'll
change next-error-find-buffer-function's default back to #'ignore (thus
reverting to the previous path that I sent). And see if we find problems
with how the result is working.
So in the end, next-error-find-buffer-function will have three possible
values:
- Pre Emacs 27 behavior.
- Emacs 27 behavior (extracted in the attached patch).
- Simplified behavior with less buffer-local state (Emacs 28, hopefully).
[-- Attachment #2: next-error-extract-case-2-keep-current-behavior.diff --]
[-- Type: text/x-patch, Size: 4333 bytes --]
diff --git a/lisp/simple.el b/lisp/simple.el
index 111afa69d1..a4b81719ce 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -199,7 +199,7 @@ next-error-buffer-p
(and extra-test-inclusive
(funcall extra-test-inclusive))))))
-(defcustom next-error-find-buffer-function #'ignore
+(defcustom next-error-find-buffer-function #'next-error-no-navigation-try-current
"Function called to find a `next-error' capable buffer.
This functions takes the same three arguments as the function
`next-error-find-buffer', and should return the buffer to be
@@ -211,6 +211,8 @@ next-error-find-buffer-function
:type '(choice (const :tag "No default" ignore)
(const :tag "Single next-error capable buffer on selected frame"
next-error-buffer-on-selected-frame)
+ (const :tag "Current buffer if next-error capable and outside navigation"
+ next-error-no-navigation-try-current)
(function :tag "Other function"))
:group 'next-error
:version "27.1")
@@ -240,6 +242,22 @@ next-error-buffer-on-selected-frame
(if (eq (length window-buffers) 1)
(car window-buffers))))
+(defun next-error-no-navigation-try-current (&optional
+ avoid-current
+ extra-test-inclusive
+ extra-test-exclusive)
+ "Try the current buffer when outside navigation.
+But return nil if we navigated to the current buffer by the means
+of `next-error' command. Othewise, return it if it's next-error
+capable."
+ ;; Check that next-error-buffer has no buffer-local value
+ ;; (i.e. we never navigated to the current buffer from another),
+ ;; and the current buffer is a `next-error' capable buffer.
+ (if (and (not (local-variable-p 'next-error-buffer))
+ (next-error-buffer-p (current-buffer) avoid-current
+ extra-test-inclusive extra-test-exclusive))
+ (current-buffer)))
+
(defun next-error-find-buffer (&optional avoid-current
extra-test-inclusive
extra-test-exclusive)
@@ -260,24 +278,16 @@ next-error-find-buffer
(funcall next-error-find-buffer-function avoid-current
extra-test-inclusive
extra-test-exclusive)
- ;; 2. If next-error-buffer has no buffer-local value
- ;; (i.e. never navigated to the current buffer from another),
- ;; and the current buffer is a `next-error' capable buffer,
- ;; use it unconditionally, so next-error will always use it.
- (if (and (not (local-variable-p 'next-error-buffer))
- (next-error-buffer-p (current-buffer) avoid-current
- extra-test-inclusive extra-test-exclusive))
- (current-buffer))
- ;; 3. If next-error-last-buffer is an acceptable buffer, use that.
+ ;; 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
extra-test-inclusive extra-test-exclusive))
next-error-last-buffer)
- ;; 4. If the current buffer is acceptable, choose it.
+ ;; 3. If the current buffer is acceptable, choose it.
(if (next-error-buffer-p (current-buffer) avoid-current
extra-test-inclusive extra-test-exclusive)
(current-buffer))
- ;; 5. Look for any acceptable buffer.
+ ;; 4. Look for any acceptable buffer.
(let ((buffers (buffer-list)))
(while (and buffers
(not (next-error-buffer-p
@@ -285,7 +295,7 @@ next-error-find-buffer
extra-test-inclusive extra-test-exclusive)))
(setq buffers (cdr buffers)))
(car buffers))
- ;; 6. Use the current buffer as a last resort if it qualifies,
+ ;; 5. Use the current buffer as a last resort if it qualifies,
;; even despite AVOID-CURRENT.
(and avoid-current
(next-error-buffer-p (current-buffer) nil
@@ -293,7 +303,7 @@ next-error-find-buffer
(progn
(message "This is the only buffer with error message locations")
(current-buffer)))
- ;; 7. Give up.
+ ;; 6. Give up.
(error "No buffers contain error message locations")))
(defun next-error (&optional arg reset)
next prev parent reply other threads:[~2020-05-25 23:17 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-28 1:51 bug#40919: 27.0.91; next-error-select-buffer does not always behave as documented Trevor Spiteri
2020-04-28 11:37 ` Trevor Spiteri
2020-04-28 23:40 ` Juri Linkov
2020-04-29 0:13 ` Trevor Spiteri
2020-04-29 20:38 ` Juri Linkov
2020-04-29 22:40 ` Trevor Spiteri
2020-04-30 20:14 ` Juri Linkov
2020-04-30 23:18 ` Trevor Spiteri
2020-05-02 23:38 ` Juri Linkov
2020-05-03 2:40 ` Eli Zaretskii
2020-05-03 22:36 ` Juri Linkov
2020-05-19 1:48 ` Dmitry Gutov
2020-05-19 22:21 ` Juri Linkov
2020-05-21 23:57 ` Dmitry Gutov
2020-05-23 22:24 ` Juri Linkov
2020-05-23 23:30 ` Dmitry Gutov
2020-05-24 21:48 ` Juri Linkov
2020-05-25 1:58 ` Dmitry Gutov
2020-05-25 15:17 ` Eli Zaretskii
2020-05-25 23:17 ` Dmitry Gutov [this message]
2020-05-26 16:06 ` Eli Zaretskii
2020-05-26 16:20 ` Dmitry Gutov
2020-05-26 16:33 ` Eli Zaretskii
2020-05-26 20:39 ` Dmitry Gutov
2020-05-27 19:18 ` Dmitry Gutov
2020-05-30 22:29 ` Juri Linkov
2020-06-10 23:03 ` Juri Linkov
2020-06-10 23:28 ` Dmitry Gutov
2020-06-11 13:11 ` Eli Zaretskii
2020-06-11 22:39 ` Juri Linkov
2020-06-12 7:06 ` Eli Zaretskii
2020-06-13 22:53 ` Juri Linkov
2020-06-14 23:17 ` Juri Linkov
2020-05-28 23:07 ` Dmitry Gutov
2020-06-01 22:41 ` Juri Linkov
2020-06-01 23:04 ` Dmitry Gutov
2020-06-10 23:05 ` Juri Linkov
2020-06-10 23:32 ` Dmitry Gutov
2020-06-11 22:43 ` Juri Linkov
2020-06-14 11:50 ` Dmitry Gutov
2020-06-14 23:15 ` Juri Linkov
2020-06-15 7:58 ` Dmitry Gutov
2020-06-24 23:38 ` 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
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=f6dc0c2c-ced0-6277-5994-311e081c84d7@yandex.ru \
--to=dgutov@yandex.ru \
--cc=40919@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=juri@linkov.net \
--cc=tspiteri@ieee.org \
/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).