Skip to content

Fix org-lint line number handling - #2165

Merged
bbatsov merged 1 commit into
flycheck:masterfrom
aaronjensen:org-lint-line-number-correction
Jul 16, 2026
Merged

Fix org-lint line number handling#2165
bbatsov merged 1 commit into
flycheck:masterfrom
aaronjensen:org-lint-line-number-correction

Conversation

@aaronjensen

Copy link
Copy Markdown
Member

Corrects this issue:

Error from syntax checker org-lint: Wrong type argument: number-or-marker-p, #("7" 0 1 (org-lint-marker #<marker at 178 in [D] Some File>))

May be Emacs 31 specific. Referenced in #2161

nelhage added a commit to nelhage/elisp that referenced this pull request Apr 13, 2026
flycheck's built-in org-lint checker passes the line number from
`org-lint' directly to `flycheck-error-new-at', but org-lint returns
it as a propertized string, not an integer, causing:

  Wrong type argument: number-or-marker-p, #("1199" ...)

Override the checker to coerce the line to a number. Upstream fix is
pending in flycheck/flycheck#2165.
hlissner added a commit to doomemacs/core that referenced this pull request May 11, 2026
Due to type errors caused by the new org-lint flycheck checker
introduced recently (and pulled in in db26d6f).

Amend: db26d6f
Ref: flycheck/flycheck#2161
Ref: flycheck/flycheck#2165
@dmgerman

Copy link
Copy Markdown

While we wait for it to be addressed, this is how I patched my configuration. it a work around until the bug is fixed.

  • flycheck: patch locally until addressed

In Emacs 31, org-lint returns a propertized string for the line number
instead of an integer. flycheck 36.0 passes it raw to
flycheck-error-new-at, which expects an integer. The fix (adding a
string-to-number conversion) is tracked as an uncommitted patch in the
flycheck repo; apply it here until it lands upstream.

#+begin_src emacs-lisp :exports both
(with-eval-after-load 'flycheck
  (if (and (version<= "31.0.6" emacs-version)
           (string= flycheck-version "36.0"))
      (setf (flycheck-checker-get 'org-lint 'start)
            (lambda (checker callback)
              (condition-case err
                  (let ((errors
                         (delq nil
                               (mapcar
                                (lambda (e)
                                  (pcase e
                                    (`(,_n [,line ,_trust ,desc ,_checker])
                                     (flycheck-error-new-at
                                      (if (stringp line)
                                          (string-to-number line)
                                        line)
                                      nil 'info desc
                                      :checker checker))
                                    (_
                                     (flycheck-error-new-at
                                      1 nil 'warning
                                      (format "Unexpected org-lint format: %S" e)
                                      :checker checker))))
                                (org-lint)))))
                    (funcall callback 'finished errors))
                (error (funcall callback 'errored
                                (error-message-string err))))))
    (warn "flycheck org-lint: patch not applied (emacs %s, flycheck %s) — check if still needed"
          emacs-version flycheck-version)))
#+end_src

@RicardoSwitchNetwork

Copy link
Copy Markdown

What about using (flycheck-string-to-number-safe line) nil 'info desc?

@bbatsov
bbatsov merged commit a6c80bf into flycheck:master Jul 16, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants