diff options
Diffstat (limited to '.ai/scripts/lint-org.el')
| -rw-r--r-- | .ai/scripts/lint-org.el | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/.ai/scripts/lint-org.el b/.ai/scripts/lint-org.el index 64b78d0..2e97db0 100644 --- a/.ai/scripts/lint-org.el +++ b/.ai/scripts/lint-org.el @@ -19,8 +19,13 @@ ;; misplaced-planning-info merge multi-line CLOSED:/DEADLINE:/SCHEDULED: ;; misplaced-heading (markdown-bold) **X.** at start of line → *X.* ;; +;; Suppressed (false positives — neither fixed nor surfaced): +;; misplaced-heading (verbatim-*) =*** Foo= inside body prose — verbatim +;; asterisks are never a real misplaced +;; heading, so the item is dropped silently +;; cj-comment src-block false flags see `lo--cj-comment-block-opener-p' +;; ;; Judgment categories (emitted on stdout): -;; misplaced-heading (verbatim-*) =*** Foo= inside body prose ;; link-to-local-file broken file: links ;; invalid-fuzzy-link broken *Heading refs ;; suspicious-language-in-src-block unknown source-block language @@ -56,8 +61,9 @@ path as an org section dated today. The file is created if missing.") '(item-number missing-language-in-src-block misplaced-planning-info) "org-lint checker names that are always treated as mechanical.") -;; misplaced-heading is split case-by-case (markdown-bold vs verbatim-asterisk) -;; in `lo--handle-item'. +;; misplaced-heading is split case-by-case in `lo--handle-item': markdown-bold +;; is auto-fixed, verbatim-asterisk is suppressed as a false positive, anything +;; else is surfaced as judgment. ;;; --------------------------------------------------------------------------- ;;; org-lint result accessors @@ -182,6 +188,21 @@ misplaced-heading. Pattern: `**X**` at the start of the line, X a short prose run without asterisks." (and (lo--find-markdown-bold-line line) t)) +(defun lo--verbatim-asterisk-at-line-p (line) + "Non-nil if LINE (or LINE - 1) carries an =...=-wrapped run of heading +asterisks inside body prose, e.g. =** DONE= or =*** Foo=. org-lint reads the +verbatim asterisks as a possible heading and flags the line, but verbatim +markup is never a real misplaced heading. Like `lo--find-markdown-bold-line', +this checks LINE - 1 too, since org-lint often marks the blank line after the +offender. The match is anywhere on the line (the span sits mid-sentence)." + (save-excursion + (cl-loop for candidate in (list (1- line) line) + when (and (>= candidate 1) + (progn (lo--goto-line candidate) + (re-search-forward "=\\*+ [^=\n]*=" + (line-end-position) t))) + return candidate))) + (defun lo-fix-markdown-bold (line) "Convert a leading `**X**` near LINE to `*X*` (org single-asterisk bold). Uses `lo--find-markdown-bold-line' to locate the actual offender, since @@ -251,9 +272,15 @@ Craig-specific annotation marker rather than Babel src-block syntax." ((eq name 'misplaced-planning-info) (lo--apply-or-preview name line msg #'lo-fix-misplaced-planning)) ((eq name 'misplaced-heading) - (if (lo--markdown-bold-at-line-p line) - (lo--apply-or-preview name line msg #'lo-fix-markdown-bold) - (lo--emit-judgment name line msg))) + (cond + ((lo--markdown-bold-at-line-p line) + (lo--apply-or-preview name line msg #'lo-fix-markdown-bold)) + ;; Verbatim =** Foo= inside prose is never a real misplaced heading; + ;; suppress silently like the cj-comment case — no fix, no judgment. + ((lo--verbatim-asterisk-at-line-p line) + nil) + (t + (lo--emit-judgment name line msg)))) (t (lo--emit-judgment name line msg))))) |
