emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Malcolm Purvis <malcolm@purvis.id.au>
To: emacs-orgmode@gnu.org
Subject: [PATCH] Add next-error support to org-lint report buffer
Date: Sat, 14 Dec 2024 18:25:08 +1100	[thread overview]
Message-ID: <m2msgyu3or.fsf@purvis.id.au> (raw)

Years of muscle memory have made me expect that the output of 
linter tools can be processed with `next-error' (C-x `).  This 
isn't the case with org-lint.  This patch hooks the org linter 
report into the next-error infrastructure.

I should have my copyright assignment on file with the FSF.

Malcolm

 
* doc/org-manual.org (Org Syntax): Add next-error keybinding  * 
etc/ORG-NEWS:  * lisp/org-lint.el: Register org-lint report buffer 
with next-error infra.  Add callback function to display error. 
--- 
 doc/org-manual.org | 12 ++++++------ etc/ORG-NEWS       |  5 
 +++++ lisp/org-lint.el   | 35 +++++++++++++++++++++++++++++++++++ 
 3 files changed, 46 insertions(+), 6 deletions(-) 
 
diff --git a/doc/org-manual.org b/doc/org-manual.org index 
d95a9350e..7f6683428 100644 --- a/doc/org-manual.org +++ 
b/doc/org-manual.org @@ -20874,12 +20874,12 @@ a "trust level", 
since false-positive are possible.  From there, you 
 can operate on the reports with the following keys: 
 #+attr_texinfo: :columns 0.22 0.78 
-| {{{kbd(C-j)}}}, {{{kbd(TAB)}}} | Display the offending line 
-| | {{{kbd(RET)}}}                 | Move point to the offending 
-| line            | {{{kbd(g)}}}                   | Check the 
-| document again                    | {{{kbd(h)}}} 
-| | Hide all reports from the same checker      | {{{kbd(i)}}} 
-| | Also remove them from all subsequent checks | {{{kbd(S)}}} 
-| | Sort reports by the column at point         | +| 
-| {{{kbd(C-j)}}}, {{{kbd(TAB)}}} | Display the offending line 
-| | +| {{{kbd(RET)}}}                 | Move point to the 
-| offending line                       | +| {{{kbd(C-x `)}}} 
-| | Move to the next report and display the offending line | +| 
-| {{{kbd(g)}}}                   | Check the document again 
-| | +| {{{kbd(h)}}}                   | Hide all reports from the 
-| same checker                 | +| {{{kbd(i)}}} 
-| | Also remove them from all subsequent checks            | 
  
 ** Context Dependent Documentation :PROPERTIES: 
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 
08857962b..a38b761ad 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS 
@@ -355,6 +355,11 @@ The Texinfo exporter no longer removes links 
from headings.  This 
 applies to all headings, below and above the =H= and =toc= export 
 =#+OPTIONS:=.  
+*** next-error supports =org-lint= reports + +The command 
=next-error= can now be used to jump to the next +=org-lint= 
error.  + 
 * Version 9.7  ** Important announcements and breaking changes 
diff --git a/lisp/org-lint.el b/lisp/org-lint.el index 
c85d839bc..040934235 100644 --- a/lisp/org-lint.el +++ 
b/lisp/org-lint.el @@ -172,6 +172,35 @@ are additional check 
identifiers to be removed." 
 \f ;;; Reports UI  
+;; next-error support +(defvar org-lint--next-error-top-of-buffer 
t +  "Is the next error the one at the first line of the buffer? 
+ +Unlike compilation and grep buffers the first line of the org 
lint +report refers to an error.  This needs special handling.") 
+ +(defun org-lint--next-error-function (n &optional reset) + 
"Find and display the next line error in the report.  +N is an 
integer specifying by how many errors to move.  +RESET is a 
boolean which, if non-nil, says to go back to the beginning +of 
the errors before moving.  + +This function is the local support 
for the next-error machinery."  +  (when reset +    (setq 
org-lint--next-error-top-of-buffer t) +    (goto-char 
(point-min))) +  (when org-lint--next-error-top-of-buffer + 
(setq +     org-lint--next-error-top-of-buffer nil +     n (1- 
n))) ; In compilation buffers, point starts before the + 
; first error, so stepping forward one brings you to + 
; the first error.  Here the first error is on the + 
; first line so adjust the count accordingly.  +  (forward-line n) 
+  (org-lint--show-source)) + +;; Report mode + 
 (defvar org-lint--report-mode-map 
   (let ((map (make-sparse-keymap))) 
     (set-keymap-parent map tabulated-list-mode-map) 
@@ -186,6 +215,12 @@ are additional check identifiers to be 
removed." 
 (define-derived-mode org-lint--report-mode tabulated-list-mode 
 "OrgLint" 
   "Major mode used to display reports emitted during linting. 
 \\{org-lint--report-mode-map}" 
+  ;; next-error support.  +  (make-local-variable 
'org-lint--next-error-top-of-buffer) +  (setq + 
next-error-function 'org-lint--next-error-function + 
next-error-last-buffer (current-buffer)) + 
   (setf tabulated-list-format 
 	`[("Line" 6 (lambda (a b) 
--  2.47.1 
 

-- 
          Malcolm Purvis <malcolm@purvis.id.au>


             reply	other threads:[~2024-12-14  7:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-14  7:25 Malcolm Purvis [this message]
2024-12-24 11:02 ` [PATCH] Add next-error support to org-lint report buffer Ihor Radchenko
2024-12-27 23:42   ` Malcolm Purvis
2024-12-28 15:12     ` Ihor Radchenko

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.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2msgyu3or.fsf@purvis.id.au \
    --to=malcolm@purvis.id.au \
    --cc=emacs-orgmode@gnu.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/org-mode.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).