GNU bug report logs - #47050
28.0.50; [PATCH] `next-error-find-buffer' does things in the wrong order

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Nick Dokos <ndokos@HIDDEN>; Keywords: moreinfo patch; dated Wed, 10 Mar 2021 15:06:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Added tag(s) moreinfo. Request was from Stefan Kangas <stefan@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 47050 <at> debbugs.gnu.org:


Received: (at 47050) by debbugs.gnu.org; 15 Mar 2021 17:10:56 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 15 13:10:56 2021
Received: from localhost ([127.0.0.1]:36669 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lLqk3-0000rL-OB
	for submit <at> debbugs.gnu.org; Mon, 15 Mar 2021 13:10:55 -0400
Received: from relay11.mail.gandi.net ([217.70.178.231]:43211)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <juri@HIDDEN>) id 1lLqjz-0000qS-Ml
 for 47050 <at> debbugs.gnu.org; Mon, 15 Mar 2021 13:10:52 -0400
Received: from mail.gandi.net (m91-129-108-46.cust.tele2.ee [91.129.108.46])
 (Authenticated sender: juri@HIDDEN)
 by relay11.mail.gandi.net (Postfix) with ESMTPSA id 905F6100008;
 Mon, 15 Mar 2021 17:10:43 +0000 (UTC)
From: Juri Linkov <juri@HIDDEN>
To: Nick Dokos <ndokos@HIDDEN>
Subject: Re: bug#47050: 28.0.50; [PATCH] `next-error-find-buffer' does
 things in the wrong  order
Organization: LINKOV.NET
References: <875z20xgmq.fsf@HIDDEN>
Date: Mon, 15 Mar 2021 19:07:12 +0200
In-Reply-To: <875z20xgmq.fsf@HIDDEN> (Nick Dokos's message
 of "Tue, 09 Mar 2021 14:37:49 -0500")
Message-ID: <87y2eooa0v.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 47050
Cc: 47050 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

> The doc for `next-error' says:
> ...
> I interpreted that to mean that if I create e.g. two `grep' buffers and
> rename them uniquely to `*grep*<2>' and `*grep<3>', then switching
> to one or the other of them and calling `next-error' would use the hits
> from that buffer. However it always uses the hits from the last-used grep
> buffer and I have to change that explicitly, by calling
> `next-error-select-buffer', instead of letting the current buffer
> determine it.

Please try to customize 'next-error-find-buffer-function' to this value:

  (const :tag "Current buffer if next-error capable and outside navigation"
         next-error-buffer-unnavigated-current)

It provides the behavior that you described.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#47050; Package emacs. Full text available.

Message received at 47050 <at> debbugs.gnu.org:


Received: (at 47050) by debbugs.gnu.org; 11 Mar 2021 19:24:49 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 11 14:24:49 2021
Received: from localhost ([127.0.0.1]:54929 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lKQvR-0001jV-4m
	for submit <at> debbugs.gnu.org; Thu, 11 Mar 2021 14:24:49 -0500
Received: from relay9-d.mail.gandi.net ([217.70.183.199]:49515)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <juri@HIDDEN>) id 1lKQvO-0001jG-I9
 for 47050 <at> debbugs.gnu.org; Thu, 11 Mar 2021 14:24:48 -0500
X-Originating-IP: 91.129.108.46
Received: from mail.gandi.net (m91-129-108-46.cust.tele2.ee [91.129.108.46])
 (Authenticated sender: juri@HIDDEN)
 by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 2195EFF80C;
 Thu, 11 Mar 2021 19:24:38 +0000 (UTC)
From: Juri Linkov <juri@HIDDEN>
To: Nick Dokos <ndokos@HIDDEN>
Subject: Re: bug#47050: 28.0.50; [PATCH] `next-error-find-buffer' does
 things in the wrong  order
Organization: LINKOV.NET
References: <875z20xgmq.fsf@HIDDEN>
Date: Thu, 11 Mar 2021 21:23:54 +0200
In-Reply-To: <875z20xgmq.fsf@HIDDEN> (Nick Dokos's message
 of "Tue, 09 Mar 2021 14:37:49 -0500")
Message-ID: <87h7lhh4tx.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 47050
Cc: 47050 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

> The doc for `next-error' says:
> ...
> I interpreted that to mean that if I create e.g. two `grep' buffers and
> rename them uniquely to `*grep*<2>' and `*grep<3>', then switching
> to one or the other of them and calling `next-error' would use the hits
> from that buffer. However it always uses the hits from the last-used grep
> buffer and I have to change that explicitly, by calling
> `next-error-select-buffer', instead of letting the current buffer
> determine it.
>
> The problem is caused by `next-error-find-buffer' which does things in
> the (IMO) wrong order: it first checks for next-error-last-buffer and
> then it checks for the current buffer.

Please try the following use case:

0. emacs -Q
1. call `grep' (anywhere) that displays the *grep* buffer
2. switch to the the *grep* buffer
3. in the *grep* buffer call `occur' that displays the *Occur* buffer
   with matches from the *grep* buffer
4. switch to the *Occur* buffer
5. type C-x ` (`next-error') in the *Occur* buffer
6. type C-x ` again - it continues visiting hits from the *Occur* buffer

But with your patch the second C-x ` will stop visiting hits
from the *Occur* buffer.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#47050; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 10 Mar 2021 15:05:12 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 10 10:05:12 2021
Received: from localhost ([127.0.0.1]:51528 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lK0Od-0003jP-HV
	for submit <at> debbugs.gnu.org; Wed, 10 Mar 2021 10:05:11 -0500
Received: from lists.gnu.org ([209.51.188.17]:35796)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <geb-bug-gnu-emacs@HIDDEN>)
 id 1lK0Oc-0003jH-28
 for submit <at> debbugs.gnu.org; Wed, 10 Mar 2021 10:05:10 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:44576)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <geb-bug-gnu-emacs@HIDDEN>)
 id 1lK0OZ-0001rp-M5
 for bug-gnu-emacs@HIDDEN; Wed, 10 Mar 2021 10:05:09 -0500
Received: from ciao.gmane.io ([116.202.254.214]:42284)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <geb-bug-gnu-emacs@HIDDEN>)
 id 1lK0OX-0003xS-SQ
 for bug-gnu-emacs@HIDDEN; Wed, 10 Mar 2021 10:05:07 -0500
Received: from list by ciao.gmane.io with local (Exim 4.92)
 (envelope-from <geb-bug-gnu-emacs@HIDDEN>)
 id 1lK0OU-0009rz-98
 for bug-gnu-emacs@HIDDEN; Wed, 10 Mar 2021 16:05:02 +0100
X-Injected-Via-Gmane: http://gmane.org/
To: bug-gnu-emacs@HIDDEN
From: Nick Dokos <ndokos@HIDDEN>
Subject: 28.0.50;
 [PATCH] `next-error-find-buffer' does things in the wrong  order
Date: Tue, 09 Mar 2021 14:37:49 -0500
Message-ID: <875z20xgmq.fsf@HIDDEN>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)
Cancel-Lock: sha1:1Ljf7Eh2vIdoYFTGEj44mMVCM+A=
Received-SPF: pass client-ip=116.202.254.214;
 envelope-from=geb-bug-gnu-emacs@HIDDEN; helo=ciao.gmane.io
X-Spam_score_int: 16
X-Spam_score: 1.6
X-Spam_bar: +
X-Spam_report: (1.6 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_12_24=1.049,
 DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1,
 FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001,
 HEADER_FROM_DIFFERENT_DOMAINS=0.249, NML_ADSP_CUSTOM_MED=0.9,
 SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 3.2 (+++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview:  The doc for `next-error' says: <quote> C-x ` normally uses
 the most recently started compilation, grep, or occur buffer. It can also
 operate on any buffer with output from the M-x compile, M-x grep commands,
 or, more generally, on [...] 
 Content analysis details:   (3.2 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 1.0 FORGED_GMAIL_RCVD      'From' gmail.com does not match 'Received'
 headers
 0.9 SPF_FAIL               SPF: sender does not match SPF record (fail)
 [SPF failed: Please see http://www.openspf.org/Why?s=mfrom;
 id=geb-bug-gnu-emacs%40m.gmane-mx.org; ip=209.51.188.17; r=debbugs.gnu.org]
 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level
 mail domains are different
 -0.0 SPF_HELO_PASS          SPF: HELO matches SPF record
 0.0 FREEMAIL_FROM          Sender email is commonly abused enduser mail
 provider (ndokos[at]gmail.com)
 0.8 DATE_IN_PAST_12_24     Date: is 12 to 24 hours before Received: date
 0.0 RCVD_IN_MSPIKE_H3      RBL: Good reputation (+3)
 [209.51.188.17 listed in wl.mailspike.net]
 -2.3 RCVD_IN_DNSWL_MED      RBL: Sender listed at https://www.dnswl.org/,
 medium trust [209.51.188.17 listed in list.dnswl.org]
 0.2 FREEMAIL_FORGED_FROMDOMAIN 2nd level domains in From and
 EnvelopeFrom freemail headers are different
 0.0 RCVD_IN_MSPIKE_WL      Mailspike good senders
 1.9 SPOOFED_FREEMAIL       No description available.
 0.4 SPOOF_GMAIL_MID        From Gmail but it doesn't seem to be...
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.1 (/)

The doc for `next-error' says:

<quote>
C-x ` normally uses the most recently started
compilation, grep, or occur buffer.  It can also operate on any
buffer with output from the M-x compile, M-x grep commands, or,
more generally, on any buffer in Compilation mode or with
Compilation Minor mode enabled, or any buffer in which
‘next-error-function’ is bound to an appropriate function.
To specify use of a particular buffer for error messages, type
C-x ` in that buffer.  You can also use the command
‘next-error-select-buffer’ to select the buffer to use for the subsequent
invocation of ‘next-error’.
</quote>

I interpreted that to mean that if I create e.g. two `grep' buffers and
rename them uniquely to `*grep*<2>' and `*grep<3>', then switching
to one or the other of them and calling `next-error' would use the hits
from that buffer. However it always uses the hits from the last-used grep
buffer and I have to change that explicitly, by calling
`next-error-select-buffer', instead of letting the current buffer
determine it.

The problem is caused by `next-error-find-buffer' which does things in
the (IMO) wrong order: it first checks for next-error-last-buffer and
then it checks for the current buffer.

Here is a patch to reverse the order:

--8<---------------cut here---------------start------------->8---
diff --git a/lisp/simple.el b/lisp/simple.el
index f8050091d5..8796b612cc 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -298,15 +298,15 @@ next-error-find-buffer
    (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.
+   ;; 2. 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))
+   ;; 3. 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)
-   ;; 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))
    ;; 4. Look for any acceptable buffer.
    (let ((buffers (buffer-list)))
      (while (and buffers
--8<---------------cut here---------------end--------------->8---


This arose in a question on the Emacs SE:

https://emacs.stackexchange.com/questions/63807/is-there-a-way-to-get-two-separate-next-error-lists-so-i-can-bind-them-to-two-di

---------------------------------------------------------------------------


In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.25, cairo version 1.16.0)
 of 2021-03-07 built on pierrot.dokosmarshall.org
Repository revision: 997142a4ddc98158cb71bdcef58df5a24f9a9a5c
Repository branch: comint-send-input-timeout
Windowing system distributor 'Fedora Project', version 11.0.12010000
System Description: Fedora 33 (Thirty Three)

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY
INOTIFY PDUMPER PNG RSVG SOUND THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE
XIM XPM GTK3 ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Fundamental

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg epg-config gnus-util rmail
rmail-loaddefs auth-source cl-seq eieio eieio-core cl-macs
eieio-loaddefs password-cache json map text-property-search seq byte-opt
gv bytecomp byte-compile cconv mm-decode mm-bodies mm-encode mail-parse
rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mail-utils time-date subr-x thingatpt
cl-loaddefs cl-lib iso-transl tooltip eldoc electric uniquify ediff-hook
vc-hooks lisp-float-type mwheel term/x-win x-win term/common-win x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list replace
newcomment text-mode elisp-mode lisp-mode prog-mode register page
tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame
minibuffer cl-generic cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite charscript charprop case-table epa-hook jka-cmpr-hook help
simple abbrev obarray cl-preloaded nadvice button loaddefs faces
cus-face macroexp files window text-properties overlay sha1 md5 base64
format env code-pages mule custom widget hashtable-print-readable
backquote threads dbusbind inotify lcms2 dynamic-setting
system-font-setting font-render-setting cairo move-toolbar gtk x-toolkit
x multi-tty make-network-process emacs)

Memory information:
((conses 16 54100 9914)
 (symbols 48 6694 1)
 (strings 32 18784 1955)
 (string-bytes 1 617945)
 (vectors 16 13356)
 (vector-slots 8 176023 12810)
 (floats 8 21 50)
 (intervals 56 235 0)
 (buffers 992 12))

-- 
Nick



-- 
Nick







Acknowledgement sent to Nick Dokos <ndokos@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#47050; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sun, 4 Apr 2021 00:45:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.