Received: (at 77809) by debbugs.gnu.org; 15 Apr 2025 06:31:30 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Tue Apr 15 02:31:30 2025 Received: from localhost ([127.0.0.1]:50224 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1u4ZpS-00078X-2z for submit <at> debbugs.gnu.org; Tue, 15 Apr 2025 02:31:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46528) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1u4ZpM-00078C-Nc for 77809 <at> debbugs.gnu.org; Tue, 15 Apr 2025 02:31:25 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1u4ZpH-0004s4-4c; Tue, 15 Apr 2025 02:31:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=0Zh8zK9kRXYs9NcsRI/xv5DqBr5bxyFoHOJHZjeXTVY=; b=ZTdofu4AAtm7 9jfoGfpqgbCnLR3mf9yJlWe8p6hNuOXZvBwXlqJSjwhc5RlC60OvIdv6jnk5x5JEqNf2XiuR0ltB+ NlDuYR8FO7m1mgzTATyNL2PizYLYchD7mdoQW8CANI1ooqYvnJDeSLGa+fZtkekoiN0KxD3X5+1eX 01edfS+UD5JYjGPhioaiiMnJVAtIw0DA+f9vK5XB+LE33/17Ur2llVRculVWFEQDupjwzuf0lCzO0 vvjpVL51M5kmoh6XFXNr04sW+g3h+h9gHB7GZ2OEl3mpModIW5B6BcGCVkbLW8jIZfCQrFe8Uo6Pb hlImDwhJd7TOcGh7e/8FjQ==; Date: Tue, 15 Apr 2025 09:30:23 +0300 Message-Id: <867c3mhr7k.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> To: matthewktromp@HIDDEN, Spencer Baugh <sbaugh@HIDDEN> In-Reply-To: <85o6wy78s2.fsf@HIDDEN> (matthewktromp@HIDDEN) Subject: Re: bug#77809: adding next-error support for flymake diagnostics buffers References: <85o6wy78s2.fsf@HIDDEN> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 77809 Cc: 77809 <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: -3.3 (---) > From: matthewktromp@HIDDEN > Date: Mon, 14 Apr 2025 17:06:21 -0400 > > Tags: patch > > This patch adds next-error support for flymake diagnostics buffers. > Buffers created with `flymake-show-buffer-diagnostics' and > `flymake-show-project-diagnostics' are now next-error enabled, and > `next-error' and `previous-error' will navigate through their listed > diagnostics. Many buffers which use Flymake already support next-error, don't they? Won't this conflict with those cases? Adding Spencer to the discussion.
bug-gnu-emacs@HIDDEN
:bug#77809
; Package emacs
.
Full text available.Received: (at submit) by debbugs.gnu.org; 14 Apr 2025 21:07:02 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Apr 14 17:07:02 2025 Received: from localhost ([127.0.0.1]:49272 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1u4R1B-0001v1-SY for submit <at> debbugs.gnu.org; Mon, 14 Apr 2025 17:07:02 -0400 Received: from lists.gnu.org ([2001:470:142::17]:58982) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <matthewktromp@HIDDEN>) id 1u4R19-0001uc-PR for submit <at> debbugs.gnu.org; Mon, 14 Apr 2025 17:07:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <matthewktromp@HIDDEN>) id 1u4R12-0000Fm-D1 for bug-gnu-emacs@HIDDEN; Mon, 14 Apr 2025 17:06:53 -0400 Received: from mail-qk1-x72b.google.com ([2607:f8b0:4864:20::72b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <matthewktromp@HIDDEN>) id 1u4R10-0005RP-IS for bug-gnu-emacs@HIDDEN; Mon, 14 Apr 2025 17:06:52 -0400 Received: by mail-qk1-x72b.google.com with SMTP id af79cd13be357-7c54a9d3fcaso521842685a.2 for <bug-gnu-emacs@HIDDEN>; Mon, 14 Apr 2025 14:06:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744664804; x=1745269604; darn=gnu.org; h=mime-version:message-id:date:subject:to:from:from:to:cc:subject :date:message-id:reply-to; bh=0M2luttl0Cx85xiXJE69bqLqb2RzBAFxudwLeEWL5PI=; b=dlNLyPsrBIIPIiyhfQfQJiJjYcfslnLQooeQX0AgHqPwwKQXHjkBMSjN/3vu5Yo79g 8OsHlFZ3GQB7tkzpZtY23oTi5QMYHpF+t26+yuyN1A82OrSXabGgaGnJ5Cap1fOTqgwq Gh2+eWdm6k2kWY6fL2M7zLgjJgt/VWURS4kKOAu2nsTVr997fSb0+cKuqX5wPpBWm12C 51SKF/iaEPz4Q06Oh/CHvn3/DWP5MAQkXzYTXcjyU4WBSrcWR66t6dtpC99xmAdDW6oJ ZuuIaG/4AErlUp0Zpcedk7hrzNG5gj9IWoeVEko+dhC81N+xUFT68kyFua1rMP3qrl/H SAvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744664804; x=1745269604; h=mime-version:message-id:date:subject:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=0M2luttl0Cx85xiXJE69bqLqb2RzBAFxudwLeEWL5PI=; b=Q/KEnv74Za1bWb1oHJwQAq5y3aaGe3P1YLinDgP1L/yi1K5Zf8JGlTepeer9SPKbZV +6OgAUP/mtU2JHIN+85fGR65sc5acD1xAU7dUcnIihxkqOSOVJ2sR9Q75095nhwti1yU G19NN+RNKb5eUAGZ24FNRyPUzmaMnDrHUKqyoCZfopZwhWuHq5wwVH/vkyEKM5vhhbDg mbRcjXesX17IKcocQeugI3M3bxjY5nDVg4DGctQV4OFQ+IMPSVHml8LVlMDRqnIfH1qg Hd2UkePftYnInompMCh82Jq2cGMZJJQ/fJiM92zDlBblyIvzIvDKvCid0ZGI767rXvXI XIOg== X-Gm-Message-State: AOJu0Yzib/YfLLdQQr7k/zKzFrH/RRpYA1LK1tqIOvoOwKdaC9hTb9+O ijg0X8T/7G7+xfcDMzuHKascEWkG0PY3rJn/T373hbZr0FwiickKuINjt7cI X-Gm-Gg: ASbGncvGTMhdzy4rEWeKdpKgjHFfv9STcSRdE2ZoDEhAauLtWFQRFTvOr8SOuezhbwP W5NmTxz2tqEHmy6hY0iH0GKl+LnAfJnssaCJcoKm1KozyT4v/xx1ovOZ74pb+X4nRpoiasXVjSd EvziUc4EDDiQlhEzpPONFfebUY3so2cGWQqvCJJeWN5gS8Gi/xQRxN4OtccN/wm3HbvUKr7RJ5J pmlvQmnynR8SOqGl8keHUjEjwtTd2LUeMjlP/OYCaj4j6Gru1tK11Lz7lgk6ATByn0MOEAKbUZp 3YfYXcUbKGwH1Fbd/zAE4oRM1NUkmaPjZ0hROZAKsAVO6gF0SsTJ X-Google-Smtp-Source: AGHT+IGn08AXikM4EA5xV8wjyuuG7voo1XPVoCc6DD6gcMIBbIzxVCK8JZltCftrP2YjlCPKMWqhmw== X-Received: by 2002:a05:620a:d89:b0:7c5:42c8:ac82 with SMTP id af79cd13be357-7c7af10c952mr1972227585a.23.1744664804165; Mon, 14 Apr 2025 14:06:44 -0700 (PDT) Received: from localhost ([96.224.136.38]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7c7a895273csm786147285a.33.2025.04.14.14.06.23 for <bug-gnu-emacs@HIDDEN> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Apr 2025 14:06:25 -0700 (PDT) From: matthewktromp@HIDDEN To: bug-gnu-emacs@HIDDEN Subject: adding next-error support for flymake diagnostics buffers Date: Mon, 14 Apr 2025 17:06:21 -0400 Message-ID: <85o6wy78s2.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::72b; envelope-from=matthewktromp@HIDDEN; helo=mail-qk1-x72b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) 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.0 (/) --=-=-= Content-Type: text/plain Tags: patch This patch adds next-error support for flymake diagnostics buffers. Buffers created with `flymake-show-buffer-diagnostics' and `flymake-show-project-diagnostics' are now next-error enabled, and `next-error' and `previous-error' will navigate through their listed diagnostics. In GNU Emacs 30.1.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.18.2, Xaw3d scroll bars) Windowing system distributor 'The X.Org Foundation', version 11.0.12101016 System Description: NixOS 24.11 (Vicuna) Configured using: 'configure --prefix=/nix/store/yffwm14bwi3vask5wfx6pcrdgxck61ba-emacs-30.1 --disable-build-details --with-modules --with-x-toolkit=lucid --with-cairo --with-xft --with-compress-install --with-toolkit-scroll-bars --with-native-compilation --without-imagemagick --with-mailutils --without-small-ja-dic --with-tree-sitter --with-xinput2 --without-xwidgets --with-dbus --with-selinux' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-next-error-support-for-flymake-diagnostics-buffers.patch diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index 6cc7e1f7a79..002e587b029 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el @@ -1390,6 +1390,10 @@ flymake-mode-map (format "<%s> <mouse-1>" flymake-fringe-indicator-position) #'flymake-show-buffer-diagnostics-at-event-line) +(defvar-local flymake-current-diagnostic-line 0 + "The line of the most recently focused diagnostic in the flymake +diagnostics buffer.") + ;;;###autoload (define-minor-mode flymake-mode "Toggle Flymake mode on or off. @@ -1881,7 +1885,8 @@ flymake-pulse-momentary-highlight-region (defun flymake-show-diagnostic (pos &optional other-window) "Show location of diagnostic at POS." (interactive (list (point) t)) - (let* ((id (or (tabulated-list-get-id pos) + (let* ((diagnostics-buffer (current-buffer)) + (id (or (tabulated-list-get-id pos) (user-error "Nothing at point"))) (diag (plist-get id :diagnostic)) (locus (flymake--diag-locus diag)) @@ -1890,6 +1895,7 @@ flymake-show-diagnostic (visit (lambda (b e) (goto-char b) (flymake-pulse-momentary-highlight-region b e)))) + (setq flymake-current-diagnostic-line (line-number-at-pos pos)) (with-current-buffer (cond ((bufferp locus) locus) (t (find-file-noselect locus))) (with-selected-window @@ -1905,6 +1911,8 @@ flymake-show-diagnostic (car beg) (cdr beg)))) (funcall visit bbeg bend))))) + (setq next-error-buffer diagnostics-buffer + next-error-last-buffer diagnostics-buffer) (current-buffer)))) (defun flymake-goto-diagnostic (pos) @@ -2008,6 +2016,23 @@ flymake--diagnostics-base-tabulated-list-format ("Backend" 8 t) ("Message" 0 t)]) +(defun flymake--diagnostics-next-error (n &optional reset) + "`next-error-function' for flymake diagnostics buffers. +N is an integer representing how many errors to move. +If RESET is non-nil, returns to the beginning of the errors before +moving." + (let ((line (if reset 1 flymake-current-diagnostic-line)) + (total-lines (count-lines (point-min) (point-max)))) + (goto-char (point-min)) + (unless (zerop total-lines) + (let ((target-line (+ line n))) + (setq target-line (max 1 target-line)) + (setq target-line (min target-line total-lines)) + (forward-line (1- target-line)))) + (when-let ((win (get-buffer-window nil t))) + (set-window-point win (point))) + (flymake-goto-diagnostic (point)))) + (define-derived-mode flymake-diagnostics-buffer-mode tabulated-list-mode "Flymake diagnostics" "A mode for listing Flymake diagnostics." @@ -2015,6 +2040,9 @@ flymake-diagnostics-buffer-mode (setq tabulated-list-format flymake--diagnostics-base-tabulated-list-format) (setq tabulated-list-entries 'flymake--diagnostics-buffer-entries) + + (setq-local next-error-function #'flymake--diagnostics-next-error) + (tabulated-list-init-header)) (defun flymake--diagnostics-buffer-name () @@ -2036,6 +2064,7 @@ flymake-show-buffer-diagnostics (current-buffer))))) (with-current-buffer target (setq flymake--diagnostics-buffer-source source) + (setq next-error-last-buffer (current-buffer)) (revert-buffer) (display-buffer (current-buffer) `((display-buffer-reuse-window @@ -2085,6 +2114,9 @@ flymake-project-diagnostics-mode (setq tabulated-list-format (vconcat [("File" 25 t)] flymake--diagnostics-base-tabulated-list-format)) + + (setq-local next-error-function #'flymake--diagnostics-next-error) + (setq tabulated-list-entries 'flymake--project-diagnostics-entries) (tabulated-list-init-header)) @@ -2149,6 +2181,7 @@ flymake-show-project-diagnostics (with-current-buffer buffer (flymake-project-diagnostics-mode) (setq-local flymake--project-diagnostic-list-project prj) + (setq next-error-last-buffer (current-buffer)) (revert-buffer) (display-buffer (current-buffer) `((display-buffer-reuse-window --=-=-=--
matthewktromp@HIDDEN
:bug-gnu-emacs@HIDDEN
.
Full text available.bug-gnu-emacs@HIDDEN
:bug#77809
; Package emacs
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.