From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs 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 Message-ID: References: <53913bd9-2bdc-0f70-f7b4-744283e0512f@ieee.org> <87d07rmb6j.fsf@mail.linkov.net> <87zhau5bfw.fsf@mail.linkov.net> <66f63b16-307a-919c-1d25-60ff63f92ae6@ieee.org> <87bln8u3xq.fsf@mail.linkov.net> <851cd382-4b2e-447a-2212-919c8a4ce908@ieee.org> <87d07lykkd.fsf@mail.linkov.net> <83bln5rbah.fsf@gnu.org> <87zhaozlvo.fsf@mail.linkov.net> <87v9kr8t1s.fsf@mail.linkov.net> <87zh9yuw5o.fsf@mail.linkov.net> <87zh9xuhq2.fsf@mail.linkov.net> <5c6d82c4-436e-9014-7dc7-0897caf76403@yandex.ru> <83367ovyah.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------46E2D8ADF5B4FEA8A17A437F" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="125863"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 Cc: 40919@debbugs.gnu.org, tspiteri@ieee.org, juri@linkov.net To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue May 26 01:18:10 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jdMMD-000Wh5-P9 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 26 May 2020 01:18:09 +0200 Original-Received: from localhost ([::1]:39710 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jdMMC-0004Il-RO for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 25 May 2020 19:18:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46248) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jdMM6-0004IS-L3 for bug-gnu-emacs@gnu.org; Mon, 25 May 2020 19:18:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:59492) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jdMM6-0002FM-CS for bug-gnu-emacs@gnu.org; Mon, 25 May 2020 19:18:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jdMM6-0006Pi-7U for bug-gnu-emacs@gnu.org; Mon, 25 May 2020 19:18:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 25 May 2020 23:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 40919 X-GNU-PR-Package: emacs Original-Received: via spool by 40919-submit@debbugs.gnu.org id=B40919.159044866724630 (code B ref 40919); Mon, 25 May 2020 23:18:02 +0000 Original-Received: (at 40919) by debbugs.gnu.org; 25 May 2020 23:17:47 +0000 Original-Received: from localhost ([127.0.0.1]:42805 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jdMLq-0006PC-JE for submit@debbugs.gnu.org; Mon, 25 May 2020 19:17:47 -0400 Original-Received: from mail-wr1-f43.google.com ([209.85.221.43]:41796) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jdMLo-0006Ow-C7 for 40919@debbugs.gnu.org; Mon, 25 May 2020 19:17:44 -0400 Original-Received: by mail-wr1-f43.google.com with SMTP id j10so2987194wrw.8 for <40919@debbugs.gnu.org>; Mon, 25 May 2020 16:17:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=O3WyNIFptkEUkXdNcTnOvrUyXidlj1SR+IMskXZqyPg=; b=n8sCgiYX1bgQLMIQaKpk8mVOiGuGRDTevm9H0G+0I/6G0s6ZCSIC7WPQuTdrqLCzOt 9DeDrgi6rgwVTqAv/oscWxRREZ04MKXQz8qnxAOE42oE1bRzzLGqZU/KRYbEFSygWgzY ki+pG5n4pZ16flUcQ0NWo3WB2/qkuN0acX9aCa4Fhr4Bgd8ml7I2SpfzmrTA29gJl3LI 8kHjOfCzrTEfdcYAsoNTAc0sL6bxqDtn3f3DAjBPt9hLCoxwIky1ZZk+C5gsT9/Sv3Bh dbPR5/B9xzg4U0AmEI34A9dQiljSKm1KP8VVIJhIgg0ebCY6adOKTK0PbgA6E2lj+/MR s4Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language; bh=O3WyNIFptkEUkXdNcTnOvrUyXidlj1SR+IMskXZqyPg=; b=Oak/qz9E18E7OvDSssySd/6Pey1HSZPZgtyfrGbF/V//f23vEbm1C3xbp2mSmFVkPg 263NFXzb81rSw1d0Gbdw9O5RXZm8qiktsbH85cVHPTJxZI+OCDRiWQ9bghO9jwr0Js9d afWVJn5nmqPIdNyscXq92swYxejzBE7UJZA1xWoDtFKWUCSB4v1iYf63OBuHCaYSlgNH 3Hd+baklC0MbFDM5CTvwl6Gll7+26/8Nfhw7e1g6K04Z+PSqNukM+VELHOhuw3Fo2lAw N0gt7m4RAKfPEkIoVrhVuhcW+pWuGFp48YkMzYdVSYdHSPWYs9d11v9V9Zr4qkP1DYAM b+UQ== X-Gm-Message-State: AOAM5338bLzffvVlcRbM8l9N+NdGDkRyb2EBz3XYqCVqzj79JEgPCPUL bca+OF+/Fzx58ZkNXm56QqI= X-Google-Smtp-Source: ABdhPJwTrHnNyIY+9QRMjto9KmV5KhAZe46dcszBWAy7Ge9sZ6XK/+6sbB4t/d+LsI2h8uHUbG5jnw== X-Received: by 2002:adf:ecc8:: with SMTP id s8mr16377588wro.279.1590448658116; Mon, 25 May 2020 16:17:38 -0700 (PDT) Original-Received: from [192.168.0.3] ([66.205.73.129]) by smtp.googlemail.com with ESMTPSA id y37sm2409773wrd.55.2020.05.25.16.17.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 25 May 2020 16:17:37 -0700 (PDT) In-Reply-To: <83367ovyah.fsf@gnu.org> Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:181007 Archived-At: This is a multi-part message in MIME format. --------------46E2D8ADF5B4FEA8A17A437F Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit 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). --------------46E2D8ADF5B4FEA8A17A437F Content-Type: text/x-patch; charset=UTF-8; name="next-error-extract-case-2-keep-current-behavior.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="next-error-extract-case-2-keep-current-behavior.diff" 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) --------------46E2D8ADF5B4FEA8A17A437F--