Function: org-lint-add-checker

org-lint-add-checker is an autoloaded and byte-compiled function defined in org-lint.el.gz.

Signature

(org-lint-add-checker NAME SUMMARY FUN &rest PROPS)

Documentation

Add a new checker for linter.

NAME is a unique check identifier, as a non-nil symbol. SUMMARY is a short description of the check, as a string.

The check is done calling the function FUN with one mandatory argument, the parse tree describing the current Org buffer. Such function calls are wrapped within a save-excursion and point is always at point-min. Its return value has to be an alist (POSITION MESSAGE) where POSITION refer to the buffer position of the error, as an integer, and MESSAGE is a one-line string describing the error.

Optional argument PROPS provides additional information about the checker. Currently, two properties are supported:

  :categories

     Categories relative to the check, as a list of symbol. They
     are used for filtering when calling org-lint. Checkers
     not explicitly associated to a category are collected in the
     default one.

  :trust

    The trust level one can have in the check. It is either
    low or high, depending on the heuristics implemented and
    the nature of the check. This has an indicative value only
    and is displayed along reports.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-lint.el.gz
;;;###autoload
(defun org-lint-add-checker (name summary fun &rest props)
  "Add a new checker for linter.

NAME is a unique check identifier, as a non-nil symbol.  SUMMARY
is a short description of the check, as a string.

The check is done calling the function FUN with one mandatory
argument, the parse tree describing the current Org buffer.  Such
function calls are wrapped within a `save-excursion' and point is
always at `point-min'.  Its return value has to be an
alist (POSITION MESSAGE) where POSITION refer to the buffer
position of the error, as an integer, and MESSAGE is a one-line
string describing the error.

Optional argument PROPS provides additional information about the
checker.  Currently, two properties are supported:

  `:categories'

     Categories relative to the check, as a list of symbol.  They
     are used for filtering when calling `org-lint'.  Checkers
     not explicitly associated to a category are collected in the
     `default' one.

  `:trust'

    The trust level one can have in the check.  It is either
    `low' or `high', depending on the heuristics implemented and
    the nature of the check.  This has an indicative value only
    and is displayed along reports."
  (declare (indent 1))
  ;; Sanity checks.
  (pcase name
    (`nil (error "Name field is mandatory for checkers"))
    ((pred symbolp) nil)
    (_ (error "Invalid type for name field")))
  (unless (functionp fun)
    (error "Checker field is expected to be a valid function"))
  ;; Install checker in `org-lint--checkers'; uniquify by name.
  (setq org-lint--checkers
        (cons (apply #'make-org-lint-checker
                     :name name
                     :summary summary
                     :function fun
                     props)
              (seq-remove (lambda (c) (eq name (org-lint-checker-name c)))
                          org-lint--checkers))))