2015-04-15 20:24:15 +00:00
|
|
|
|
;;; org-lint.el --- Linting for Org documents -*- lexical-binding: t; -*-
|
|
|
|
|
|
2023-01-01 10:31:12 +00:00
|
|
|
|
;; Copyright (C) 2015-2023 Free Software Foundation, Inc.
|
2015-04-15 20:24:15 +00:00
|
|
|
|
|
|
|
|
|
;; Author: Nicolas Goaziou <mail@nicolasgoaziou.fr>
|
|
|
|
|
;; Keywords: outlines, hypermedia, calendar, wp
|
|
|
|
|
|
2017-07-05 18:08:35 +00:00
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is free software; you can redistribute it and/or modify
|
2015-04-15 20:24:15 +00:00
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
2017-07-05 18:08:35 +00:00
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
2015-04-15 20:24:15 +00:00
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2017-09-13 22:52:52 +00:00
|
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
2015-04-15 20:24:15 +00:00
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
2021-12-01 15:09:13 +00:00
|
|
|
|
;; This library implements linting for Org syntax. The process is
|
|
|
|
|
;; started by calling `org-lint' command, which see.
|
2015-04-15 20:24:15 +00:00
|
|
|
|
|
2021-12-01 15:09:13 +00:00
|
|
|
|
;; New checkers are added by `org-lint-add-checker' function.
|
|
|
|
|
;; Internally, all checks are listed in `org-lint--checkers'.
|
2015-04-15 20:24:15 +00:00
|
|
|
|
|
|
|
|
|
;; Results are displayed in a special "*Org Lint*" buffer with
|
|
|
|
|
;; a dedicated major mode, derived from `tabulated-list-mode'.
|
|
|
|
|
;; In addition to the usual key-bindings inherited from it, "C-j" and
|
|
|
|
|
;; "TAB" display problematic line reported under point whereas "RET"
|
|
|
|
|
;; jumps to it. Also, "h" hides all reports similar to the current
|
|
|
|
|
;; one. Additionally, "i" removes them from subsequent reports.
|
|
|
|
|
|
2021-12-01 15:09:13 +00:00
|
|
|
|
;; Checks currently implemented report the following:
|
|
|
|
|
|
|
|
|
|
;; - duplicates CUSTOM_ID properties,
|
|
|
|
|
;; - duplicate NAME values,
|
|
|
|
|
;; - duplicate targets,
|
|
|
|
|
;; - duplicate footnote definitions,
|
|
|
|
|
;; - orphaned affiliated keywords,
|
|
|
|
|
;; - obsolete affiliated keywords,
|
|
|
|
|
;; - deprecated export block syntax,
|
|
|
|
|
;; - deprecated Babel header syntax,
|
|
|
|
|
;; - missing language in source blocks,
|
2023-04-20 12:11:19 +00:00
|
|
|
|
;; - missing backend in export blocks,
|
2021-12-01 15:09:13 +00:00
|
|
|
|
;; - invalid Babel call blocks,
|
|
|
|
|
;; - NAME values with a colon,
|
|
|
|
|
;; - wrong babel headers,
|
|
|
|
|
;; - invalid value in babel headers,
|
|
|
|
|
;; - misuse of CATEGORY keyword,
|
|
|
|
|
;; - "coderef" links with unknown destination,
|
|
|
|
|
;; - "custom-id" links with unknown destination,
|
|
|
|
|
;; - "fuzzy" links with unknown destination,
|
|
|
|
|
;; - "id" links with unknown destination,
|
|
|
|
|
;; - links to non-existent local files,
|
|
|
|
|
;; - SETUPFILE keywords with non-existent file parameter,
|
|
|
|
|
;; - INCLUDE keywords with misleading link parameter,
|
|
|
|
|
;; - obsolete markup in INCLUDE keyword,
|
|
|
|
|
;; - unknown items in OPTIONS keyword,
|
|
|
|
|
;; - spurious macro arguments or invalid macro templates,
|
|
|
|
|
;; - special properties in properties drawers,
|
|
|
|
|
;; - obsolete syntax for properties drawers,
|
|
|
|
|
;; - invalid duration in EFFORT property,
|
|
|
|
|
;; - missing definition for footnote references,
|
|
|
|
|
;; - missing reference for footnote definitions,
|
|
|
|
|
;; - non-footnote definitions in footnote section,
|
|
|
|
|
;; - probable invalid keywords,
|
|
|
|
|
;; - invalid blocks,
|
2023-06-11 14:50:20 +00:00
|
|
|
|
;; - mismatched repeaters in planning info line,
|
2021-12-01 15:09:13 +00:00
|
|
|
|
;; - misplaced planning info line,
|
|
|
|
|
;; - probable incomplete drawers,
|
|
|
|
|
;; - probable indented diary-sexps,
|
|
|
|
|
;; - obsolete QUOTE section,
|
|
|
|
|
;; - obsolete "file+application" link,
|
|
|
|
|
;; - obsolete escape syntax in links,
|
|
|
|
|
;; - spurious colons in tags,
|
|
|
|
|
;; - invalid bibliography file,
|
|
|
|
|
;; - missing "print_bibliography" keyword,
|
|
|
|
|
;; - invalid value for "cite_export" keyword,
|
|
|
|
|
;; - incomplete citation object.
|
2015-04-15 20:24:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
2022-08-04 13:53:05 +00:00
|
|
|
|
(require 'org-macs)
|
|
|
|
|
(org-assert-version)
|
|
|
|
|
|
2015-04-15 20:24:15 +00:00
|
|
|
|
(require 'cl-lib)
|
2018-11-26 23:04:41 +00:00
|
|
|
|
(require 'ob)
|
2021-11-30 14:39:17 +00:00
|
|
|
|
(require 'oc)
|
2018-11-26 23:04:41 +00:00
|
|
|
|
(require 'ol)
|
2020-07-02 17:36:34 +00:00
|
|
|
|
(require 'org-attach)
|
2015-04-15 20:24:15 +00:00
|
|
|
|
(require 'org-macro)
|
2022-01-16 07:07:25 +00:00
|
|
|
|
(require 'org-fold)
|
2015-04-15 20:24:15 +00:00
|
|
|
|
(require 'ox)
|
2021-12-01 15:09:13 +00:00
|
|
|
|
(require 'seq)
|
2015-04-15 20:24:15 +00:00
|
|
|
|
|
|
|
|
|
|
2021-12-01 15:09:13 +00:00
|
|
|
|
;;; Checkers structure
|
2015-04-15 20:24:15 +00:00
|
|
|
|
|
|
|
|
|
(cl-defstruct (org-lint-checker (:copier nil))
|
2021-12-01 15:09:13 +00:00
|
|
|
|
name summary function trust categories)
|
|
|
|
|
|
|
|
|
|
(defvar org-lint--checkers nil
|
|
|
|
|
"List of all available checkers.
|
|
|
|
|
This list is populated by `org-lint-add-checker' function.")
|
|
|
|
|
|
|
|
|
|
;;;###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))))
|
|
|
|
|
|
2021-12-01 15:15:08 +00:00
|
|
|
|
|
|
|
|
|
;;; Reports UI
|
|
|
|
|
|
|
|
|
|
(defvar org-lint--report-mode-map
|
|
|
|
|
(let ((map (make-sparse-keymap)))
|
|
|
|
|
(set-keymap-parent map tabulated-list-mode-map)
|
|
|
|
|
(define-key map (kbd "RET") 'org-lint--jump-to-source)
|
|
|
|
|
(define-key map (kbd "TAB") 'org-lint--show-source)
|
|
|
|
|
(define-key map (kbd "C-j") 'org-lint--show-source)
|
|
|
|
|
(define-key map (kbd "h") 'org-lint--hide-checker)
|
|
|
|
|
(define-key map (kbd "i") 'org-lint--ignore-checker)
|
|
|
|
|
map)
|
|
|
|
|
"Local keymap for `org-lint--report-mode' buffers.")
|
|
|
|
|
|
|
|
|
|
(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}"
|
|
|
|
|
(setf tabulated-list-format
|
|
|
|
|
`[("Line" 6
|
|
|
|
|
(lambda (a b)
|
|
|
|
|
(< (string-to-number (aref (cadr a) 0))
|
|
|
|
|
(string-to-number (aref (cadr b) 0))))
|
|
|
|
|
:right-align t)
|
|
|
|
|
("Trust" 5 t)
|
|
|
|
|
("Warning" 0 t)])
|
|
|
|
|
(tabulated-list-init-header))
|
|
|
|
|
|
|
|
|
|
(defun org-lint--generate-reports (buffer checkers)
|
|
|
|
|
"Generate linting report for BUFFER.
|
|
|
|
|
|
|
|
|
|
CHECKERS is the list of checkers used.
|
|
|
|
|
|
|
|
|
|
Return an alist (ID [LINE TRUST DESCRIPTION CHECKER]), suitable
|
|
|
|
|
for `tabulated-list-printer'."
|
|
|
|
|
(with-current-buffer buffer
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(let ((ast (org-element-parse-buffer))
|
|
|
|
|
(id 0)
|
|
|
|
|
(last-line 1)
|
|
|
|
|
(last-pos 1))
|
|
|
|
|
;; Insert unique ID for each report. Replace buffer positions
|
|
|
|
|
;; with line numbers.
|
|
|
|
|
(mapcar
|
|
|
|
|
(lambda (report)
|
|
|
|
|
(list
|
|
|
|
|
(cl-incf id)
|
|
|
|
|
(apply #'vector
|
|
|
|
|
(cons
|
|
|
|
|
(progn
|
|
|
|
|
(goto-char (car report))
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(prog1 (number-to-string
|
|
|
|
|
(cl-incf last-line
|
|
|
|
|
(count-lines last-pos (point))))
|
|
|
|
|
(setf last-pos (point))))
|
|
|
|
|
(cdr report)))))
|
|
|
|
|
;; Insert trust level in generated reports. Also sort them
|
|
|
|
|
;; by buffer position in order to optimize lines computation.
|
|
|
|
|
(sort (cl-mapcan
|
|
|
|
|
(lambda (c)
|
|
|
|
|
(let ((trust (symbol-name (org-lint-checker-trust c))))
|
|
|
|
|
(mapcar
|
|
|
|
|
(lambda (report)
|
|
|
|
|
(list (car report) trust (nth 1 report) c))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(funcall (org-lint-checker-function c)
|
|
|
|
|
ast)))))
|
|
|
|
|
checkers)
|
|
|
|
|
#'car-less-than-car))))))
|
|
|
|
|
|
|
|
|
|
(defvar-local org-lint--source-buffer nil
|
|
|
|
|
"Source buffer associated to current report buffer.")
|
|
|
|
|
|
|
|
|
|
(defvar-local org-lint--local-checkers nil
|
|
|
|
|
"List of checkers used to build current report.")
|
|
|
|
|
|
|
|
|
|
(defun org-lint--refresh-reports ()
|
|
|
|
|
(setq tabulated-list-entries
|
|
|
|
|
(org-lint--generate-reports org-lint--source-buffer
|
|
|
|
|
org-lint--local-checkers))
|
|
|
|
|
(tabulated-list-print))
|
|
|
|
|
|
|
|
|
|
(defun org-lint--current-line ()
|
|
|
|
|
"Return current report line, as a number."
|
|
|
|
|
(string-to-number (aref (tabulated-list-get-entry) 0)))
|
|
|
|
|
|
|
|
|
|
(defun org-lint--current-checker (&optional entry)
|
|
|
|
|
"Return current report checker.
|
|
|
|
|
When optional argument ENTRY is non-nil, use this entry instead
|
|
|
|
|
of current one."
|
|
|
|
|
(aref (if entry (nth 1 entry) (tabulated-list-get-entry)) 3))
|
|
|
|
|
|
|
|
|
|
(defun org-lint--display-reports (source checkers)
|
|
|
|
|
"Display linting reports for buffer SOURCE.
|
|
|
|
|
CHECKERS is the list of checkers used."
|
|
|
|
|
(let ((buffer (get-buffer-create "*Org Lint*")))
|
|
|
|
|
(with-current-buffer buffer
|
|
|
|
|
(org-lint--report-mode)
|
|
|
|
|
(setf org-lint--source-buffer source)
|
|
|
|
|
(setf org-lint--local-checkers checkers)
|
|
|
|
|
(org-lint--refresh-reports)
|
|
|
|
|
(add-hook 'tabulated-list-revert-hook #'org-lint--refresh-reports nil t))
|
|
|
|
|
(pop-to-buffer buffer)))
|
|
|
|
|
|
|
|
|
|
(defun org-lint--jump-to-source ()
|
|
|
|
|
"Move to source line that generated the report at point."
|
|
|
|
|
(interactive)
|
|
|
|
|
(let ((l (org-lint--current-line)))
|
|
|
|
|
(switch-to-buffer-other-window org-lint--source-buffer)
|
|
|
|
|
(org-goto-line l)
|
2022-01-16 07:07:25 +00:00
|
|
|
|
(org-fold-show-set-visibility 'local)
|
2021-12-01 15:15:08 +00:00
|
|
|
|
(recenter)))
|
|
|
|
|
|
|
|
|
|
(defun org-lint--show-source ()
|
|
|
|
|
"Show source line that generated the report at point."
|
|
|
|
|
(interactive)
|
|
|
|
|
(let ((buffer (current-buffer)))
|
|
|
|
|
(org-lint--jump-to-source)
|
|
|
|
|
(switch-to-buffer-other-window buffer)))
|
|
|
|
|
|
|
|
|
|
(defun org-lint--hide-checker ()
|
|
|
|
|
"Hide all reports from checker that generated the report at point."
|
|
|
|
|
(interactive)
|
|
|
|
|
(let ((c (org-lint--current-checker)))
|
|
|
|
|
(setf tabulated-list-entries
|
|
|
|
|
(cl-remove-if (lambda (e) (equal c (org-lint--current-checker e)))
|
|
|
|
|
tabulated-list-entries))
|
|
|
|
|
(tabulated-list-print)))
|
|
|
|
|
|
|
|
|
|
(defun org-lint--ignore-checker ()
|
|
|
|
|
"Ignore all reports from checker that generated the report at point.
|
|
|
|
|
Checker will also be ignored in all subsequent reports."
|
|
|
|
|
(interactive)
|
|
|
|
|
(setf org-lint--local-checkers
|
|
|
|
|
(remove (org-lint--current-checker) org-lint--local-checkers))
|
|
|
|
|
(org-lint--hide-checker))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Main function
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun org-lint (&optional arg)
|
|
|
|
|
"Check current Org buffer for syntax mistakes.
|
|
|
|
|
|
|
|
|
|
By default, run all checkers. With a `\\[universal-argument]' prefix ARG, \
|
|
|
|
|
select one
|
|
|
|
|
category of checkers only. With a `\\[universal-argument] \
|
|
|
|
|
\\[universal-argument]' prefix, run one precise
|
|
|
|
|
checker by its name.
|
|
|
|
|
|
|
|
|
|
ARG can also be a list of checker names, as symbols, to run."
|
|
|
|
|
(interactive "P")
|
|
|
|
|
(unless (derived-mode-p 'org-mode) (user-error "Not in an Org buffer"))
|
|
|
|
|
(when (called-interactively-p 'any)
|
|
|
|
|
(message "Org linting process starting..."))
|
|
|
|
|
(let ((checkers
|
|
|
|
|
(pcase arg
|
|
|
|
|
(`nil org-lint--checkers)
|
|
|
|
|
(`(4)
|
|
|
|
|
(let ((category
|
|
|
|
|
(completing-read
|
|
|
|
|
"Checker category: "
|
|
|
|
|
(mapcar #'org-lint-checker-categories org-lint--checkers)
|
|
|
|
|
nil t)))
|
|
|
|
|
(cl-remove-if-not
|
|
|
|
|
(lambda (c)
|
2022-06-01 16:28:23 +00:00
|
|
|
|
(assoc-string category (org-lint-checker-categories c)))
|
2021-12-01 15:15:08 +00:00
|
|
|
|
org-lint--checkers)))
|
|
|
|
|
(`(16)
|
|
|
|
|
(list
|
|
|
|
|
(let ((name (completing-read
|
|
|
|
|
"Checker name: "
|
|
|
|
|
(mapcar #'org-lint-checker-name org-lint--checkers)
|
|
|
|
|
nil t)))
|
|
|
|
|
(catch 'exit
|
|
|
|
|
(dolist (c org-lint--checkers)
|
|
|
|
|
(when (string= (org-lint-checker-name c) name)
|
|
|
|
|
(throw 'exit c)))))))
|
|
|
|
|
((pred consp)
|
|
|
|
|
(cl-remove-if-not (lambda (c) (memq (org-lint-checker-name c) arg))
|
|
|
|
|
org-lint--checkers))
|
|
|
|
|
(_ (user-error "Invalid argument `%S' for `org-lint'" arg)))))
|
|
|
|
|
(if (not (called-interactively-p 'any))
|
|
|
|
|
(org-lint--generate-reports (current-buffer) checkers)
|
|
|
|
|
(org-lint--display-reports (current-buffer) checkers)
|
|
|
|
|
(message "Org linting process completed"))))
|
|
|
|
|
|
2021-12-01 15:09:13 +00:00
|
|
|
|
|
|
|
|
|
;;; Checker functions
|
2015-04-15 20:24:15 +00:00
|
|
|
|
|
|
|
|
|
(defun org-lint--collect-duplicates
|
|
|
|
|
(ast type extract-key extract-position build-message)
|
|
|
|
|
"Helper function to collect duplicates in parse tree AST.
|
|
|
|
|
|
|
|
|
|
EXTRACT-KEY is a function extracting key. It is called with
|
|
|
|
|
a single argument: the element or object. Comparison is done
|
|
|
|
|
with `equal'.
|
|
|
|
|
|
|
|
|
|
EXTRACT-POSITION is a function returning position for the report.
|
|
|
|
|
It is called with two arguments, the object or element, and the
|
|
|
|
|
key.
|
|
|
|
|
|
|
|
|
|
BUILD-MESSAGE is a function creating the report message. It is
|
|
|
|
|
called with one argument, the key used for comparison."
|
|
|
|
|
(let* (keys
|
|
|
|
|
originals
|
|
|
|
|
reports
|
|
|
|
|
(make-report
|
|
|
|
|
(lambda (position value)
|
|
|
|
|
(push (list position (funcall build-message value)) reports))))
|
|
|
|
|
(org-element-map ast type
|
|
|
|
|
(lambda (datum)
|
|
|
|
|
(let ((key (funcall extract-key datum)))
|
|
|
|
|
(cond
|
|
|
|
|
((not key))
|
|
|
|
|
((assoc key keys) (cl-pushnew (assoc key keys) originals)
|
|
|
|
|
(funcall make-report (funcall extract-position datum key) key))
|
|
|
|
|
(t (push (cons key (funcall extract-position datum key)) keys))))))
|
|
|
|
|
(dolist (e originals reports) (funcall make-report (cdr e) (car e)))))
|
|
|
|
|
|
|
|
|
|
(defun org-lint-duplicate-custom-id (ast)
|
|
|
|
|
(org-lint--collect-duplicates
|
|
|
|
|
ast
|
|
|
|
|
'node-property
|
|
|
|
|
(lambda (property)
|
2022-10-04 21:42:27 +00:00
|
|
|
|
(and (org-string-equal-ignore-case
|
2022-07-26 17:47:03 +00:00
|
|
|
|
"CUSTOM_ID" (org-element-property :key property))
|
2015-04-15 20:24:15 +00:00
|
|
|
|
(org-element-property :value property)))
|
|
|
|
|
(lambda (property _) (org-element-property :begin property))
|
|
|
|
|
(lambda (key) (format "Duplicate CUSTOM_ID property \"%s\"" key))))
|
|
|
|
|
|
|
|
|
|
(defun org-lint-duplicate-name (ast)
|
|
|
|
|
(org-lint--collect-duplicates
|
|
|
|
|
ast
|
|
|
|
|
org-element-all-elements
|
|
|
|
|
(lambda (datum) (org-element-property :name datum))
|
|
|
|
|
(lambda (datum name)
|
|
|
|
|
(goto-char (org-element-property :begin datum))
|
|
|
|
|
(re-search-forward
|
2021-10-04 06:04:21 +00:00
|
|
|
|
(format "^[ \t]*#\\+[A-Za-z]+:[ \t]*%s[ \t]*$" (regexp-quote name)))
|
2015-04-15 20:24:15 +00:00
|
|
|
|
(match-beginning 0))
|
|
|
|
|
(lambda (key) (format "Duplicate NAME \"%s\"" key))))
|
|
|
|
|
|
|
|
|
|
(defun org-lint-duplicate-target (ast)
|
|
|
|
|
(org-lint--collect-duplicates
|
|
|
|
|
ast
|
|
|
|
|
'target
|
2017-09-07 12:34:25 +00:00
|
|
|
|
(lambda (target) (split-string (org-element-property :value target)))
|
2015-04-15 20:24:15 +00:00
|
|
|
|
(lambda (target _) (org-element-property :begin target))
|
|
|
|
|
(lambda (key)
|
|
|
|
|
(format "Duplicate target <<%s>>" (mapconcat #'identity key " ")))))
|
|
|
|
|
|
|
|
|
|
(defun org-lint-duplicate-footnote-definition (ast)
|
|
|
|
|
(org-lint--collect-duplicates
|
|
|
|
|
ast
|
|
|
|
|
'footnote-definition
|
|
|
|
|
(lambda (definition) (org-element-property :label definition))
|
|
|
|
|
(lambda (definition _) (org-element-property :post-affiliated definition))
|
|
|
|
|
(lambda (key) (format "Duplicate footnote definition \"%s\"" key))))
|
|
|
|
|
|
|
|
|
|
(defun org-lint-orphaned-affiliated-keywords (ast)
|
|
|
|
|
;; Ignore orphan RESULTS keywords, which could be generated from
|
|
|
|
|
;; a source block returning no value.
|
|
|
|
|
(let ((keywords (cl-set-difference org-element-affiliated-keywords
|
|
|
|
|
'("RESULT" "RESULTS")
|
|
|
|
|
:test #'equal)))
|
|
|
|
|
(org-element-map ast 'keyword
|
|
|
|
|
(lambda (k)
|
|
|
|
|
(let ((key (org-element-property :key k)))
|
|
|
|
|
(and (or (let ((case-fold-search t))
|
2016-07-25 13:21:12 +00:00
|
|
|
|
(string-match-p "\\`ATTR_[-_A-Za-z0-9]+\\'" key))
|
2015-04-15 20:24:15 +00:00
|
|
|
|
(member key keywords))
|
|
|
|
|
(list (org-element-property :post-affiliated k)
|
|
|
|
|
(format "Orphaned affiliated keyword: \"%s\"" key))))))))
|
|
|
|
|
|
|
|
|
|
(defun org-lint-obsolete-affiliated-keywords (_)
|
|
|
|
|
(let ((regexp (format "^[ \t]*#\\+%s:"
|
|
|
|
|
(regexp-opt '("DATA" "LABEL" "RESNAME" "SOURCE"
|
|
|
|
|
"SRCNAME" "TBLNAME" "RESULT" "HEADERS")
|
|
|
|
|
t)))
|
|
|
|
|
reports)
|
|
|
|
|
(while (re-search-forward regexp nil t)
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 10:18:00 +00:00
|
|
|
|
(let ((key (upcase (match-string-no-properties 1))))
|
2015-04-15 20:24:15 +00:00
|
|
|
|
(when (< (point)
|
|
|
|
|
(org-element-property :post-affiliated (org-element-at-point)))
|
|
|
|
|
(push
|
|
|
|
|
(list (line-beginning-position)
|
|
|
|
|
(format
|
|
|
|
|
"Obsolete affiliated keyword: \"%s\". Use \"%s\" instead"
|
|
|
|
|
key
|
|
|
|
|
(pcase key
|
|
|
|
|
("HEADERS" "HEADER")
|
|
|
|
|
("RESULT" "RESULTS")
|
|
|
|
|
(_ "NAME"))))
|
|
|
|
|
reports))))
|
|
|
|
|
reports))
|
|
|
|
|
|
2015-12-20 20:42:41 +00:00
|
|
|
|
(defun org-lint-deprecated-export-blocks (ast)
|
|
|
|
|
(let ((deprecated '("ASCII" "BEAMER" "HTML" "LATEX" "MAN" "MARKDOWN" "MD"
|
|
|
|
|
"ODT" "ORG" "TEXINFO")))
|
|
|
|
|
(org-element-map ast 'special-block
|
|
|
|
|
(lambda (b)
|
|
|
|
|
(let ((type (org-element-property :type b)))
|
|
|
|
|
(when (member-ignore-case type deprecated)
|
|
|
|
|
(list
|
|
|
|
|
(org-element-property :post-affiliated b)
|
|
|
|
|
(format
|
|
|
|
|
"Deprecated syntax for export block. Use \"BEGIN_EXPORT %s\" \
|
|
|
|
|
instead"
|
|
|
|
|
type))))))))
|
|
|
|
|
|
2015-04-15 20:24:15 +00:00
|
|
|
|
(defun org-lint-deprecated-header-syntax (ast)
|
|
|
|
|
(let* ((deprecated-babel-properties
|
2020-06-12 21:57:37 +00:00
|
|
|
|
;; DIR is also used for attachments.
|
|
|
|
|
(delete "dir"
|
|
|
|
|
(mapcar (lambda (arg) (downcase (symbol-name (car arg))))
|
|
|
|
|
org-babel-common-header-args-w-values)))
|
2015-04-15 20:24:15 +00:00
|
|
|
|
(deprecated-re
|
|
|
|
|
(format "\\`%s[ \t]" (regexp-opt deprecated-babel-properties t))))
|
|
|
|
|
(org-element-map ast '(keyword node-property)
|
|
|
|
|
(lambda (datum)
|
|
|
|
|
(let ((key (org-element-property :key datum)))
|
|
|
|
|
(pcase (org-element-type datum)
|
|
|
|
|
(`keyword
|
|
|
|
|
(let ((value (org-element-property :value datum)))
|
|
|
|
|
(and (string= key "PROPERTY")
|
|
|
|
|
(string-match deprecated-re value)
|
|
|
|
|
(list (org-element-property :begin datum)
|
|
|
|
|
(format "Deprecated syntax for \"%s\". \
|
|
|
|
|
Use header-args instead"
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 10:18:00 +00:00
|
|
|
|
(match-string-no-properties 1 value))))))
|
2015-04-15 20:24:15 +00:00
|
|
|
|
(`node-property
|
|
|
|
|
(and (member-ignore-case key deprecated-babel-properties)
|
|
|
|
|
(list
|
|
|
|
|
(org-element-property :begin datum)
|
|
|
|
|
(format "Deprecated syntax for \"%s\". \
|
|
|
|
|
Use :header-args: instead"
|
|
|
|
|
key))))))))))
|
|
|
|
|
|
|
|
|
|
(defun org-lint-missing-language-in-src-block (ast)
|
|
|
|
|
(org-element-map ast 'src-block
|
|
|
|
|
(lambda (b)
|
|
|
|
|
(unless (org-element-property :language b)
|
|
|
|
|
(list (org-element-property :post-affiliated b)
|
|
|
|
|
"Missing language in source block")))))
|
|
|
|
|
|
2023-05-31 08:40:47 +00:00
|
|
|
|
(defun org-lint-suspicious-language-in-src-block (ast)
|
|
|
|
|
(org-element-map ast 'src-block
|
|
|
|
|
(lambda (b)
|
|
|
|
|
(when-let ((lang (org-element-property :language b)))
|
|
|
|
|
(unless (functionp (intern (format "org-babel-execute:%s" lang)))
|
|
|
|
|
(list (org-element-property :post-affiliated b)
|
|
|
|
|
(format "Unknown source block language: '%s'" lang)))))))
|
|
|
|
|
|
2015-12-20 20:42:41 +00:00
|
|
|
|
(defun org-lint-missing-backend-in-export-block (ast)
|
|
|
|
|
(org-element-map ast 'export-block
|
|
|
|
|
(lambda (b)
|
|
|
|
|
(unless (org-element-property :type b)
|
|
|
|
|
(list (org-element-property :post-affiliated b)
|
2023-04-20 12:11:19 +00:00
|
|
|
|
"Missing backend in export block")))))
|
2015-12-20 20:42:41 +00:00
|
|
|
|
|
2015-04-15 20:24:15 +00:00
|
|
|
|
(defun org-lint-invalid-babel-call-block (ast)
|
|
|
|
|
(org-element-map ast 'babel-call
|
|
|
|
|
(lambda (b)
|
|
|
|
|
(cond
|
|
|
|
|
((not (org-element-property :call b))
|
|
|
|
|
(list (org-element-property :post-affiliated b)
|
|
|
|
|
"Invalid syntax in babel call block"))
|
|
|
|
|
((let ((h (org-element-property :end-header b)))
|
2016-07-25 13:21:12 +00:00
|
|
|
|
(and h (string-match-p "\\`\\[.*\\]\\'" h)))
|
2015-04-15 20:24:15 +00:00
|
|
|
|
(list
|
|
|
|
|
(org-element-property :post-affiliated b)
|
|
|
|
|
"Babel call's end header must not be wrapped within brackets"))))))
|
|
|
|
|
|
|
|
|
|
(defun org-lint-deprecated-category-setup (ast)
|
|
|
|
|
(org-element-map ast 'keyword
|
|
|
|
|
(let (category-flag)
|
|
|
|
|
(lambda (k)
|
|
|
|
|
(cond
|
|
|
|
|
((not (string= (org-element-property :key k) "CATEGORY")) nil)
|
|
|
|
|
(category-flag
|
|
|
|
|
(list (org-element-property :post-affiliated k)
|
|
|
|
|
"Spurious CATEGORY keyword. Set :CATEGORY: property instead"))
|
|
|
|
|
(t (setf category-flag t) nil))))))
|
|
|
|
|
|
|
|
|
|
(defun org-lint-invalid-coderef-link (ast)
|
|
|
|
|
(let ((info (list :parse-tree ast)))
|
|
|
|
|
(org-element-map ast 'link
|
|
|
|
|
(lambda (link)
|
|
|
|
|
(let ((ref (org-element-property :path link)))
|
|
|
|
|
(and (equal (org-element-property :type link) "coderef")
|
|
|
|
|
(not (ignore-errors (org-export-resolve-coderef ref info)))
|
|
|
|
|
(list (org-element-property :begin link)
|
|
|
|
|
(format "Unknown coderef \"%s\"" ref))))))))
|
|
|
|
|
|
|
|
|
|
(defun org-lint-invalid-custom-id-link (ast)
|
|
|
|
|
(let ((info (list :parse-tree ast)))
|
|
|
|
|
(org-element-map ast 'link
|
|
|
|
|
(lambda (link)
|
|
|
|
|
(and (equal (org-element-property :type link) "custom-id")
|
|
|
|
|
(not (ignore-errors (org-export-resolve-id-link link info)))
|
|
|
|
|
(list (org-element-property :begin link)
|
|
|
|
|
(format "Unknown custom ID \"%s\""
|
|
|
|
|
(org-element-property :path link))))))))
|
|
|
|
|
|
|
|
|
|
(defun org-lint-invalid-fuzzy-link (ast)
|
|
|
|
|
(let ((info (list :parse-tree ast)))
|
|
|
|
|
(org-element-map ast 'link
|
|
|
|
|
(lambda (link)
|
|
|
|
|
(and (equal (org-element-property :type link) "fuzzy")
|
|
|
|
|
(not (ignore-errors (org-export-resolve-fuzzy-link link info)))
|
|
|
|
|
(list (org-element-property :begin link)
|
|
|
|
|
(format "Unknown fuzzy location \"%s\""
|
|
|
|
|
(let ((path (org-element-property :path link)))
|
|
|
|
|
(if (string-prefix-p "*" path)
|
|
|
|
|
(substring path 1)
|
|
|
|
|
path)))))))))
|
|
|
|
|
|
|
|
|
|
(defun org-lint-invalid-id-link (ast)
|
|
|
|
|
(org-element-map ast 'link
|
|
|
|
|
(lambda (link)
|
|
|
|
|
(let ((id (org-element-property :path link)))
|
|
|
|
|
(and (equal (org-element-property :type link) "id")
|
|
|
|
|
(not (org-id-find id))
|
|
|
|
|
(list (org-element-property :begin link)
|
|
|
|
|
(format "Unknown ID \"%s\"" id)))))))
|
|
|
|
|
|
|
|
|
|
(defun org-lint-special-property-in-properties-drawer (ast)
|
|
|
|
|
(org-element-map ast 'node-property
|
|
|
|
|
(lambda (p)
|
|
|
|
|
(let ((key (org-element-property :key p)))
|
|
|
|
|
(and (member-ignore-case key org-special-properties)
|
|
|
|
|
(list (org-element-property :begin p)
|
|
|
|
|
(format
|
|
|
|
|
"Special property \"%s\" found in a properties drawer"
|
|
|
|
|
key)))))))
|
|
|
|
|
|
|
|
|
|
(defun org-lint-obsolete-properties-drawer (ast)
|
|
|
|
|
(org-element-map ast 'drawer
|
|
|
|
|
(lambda (d)
|
|
|
|
|
(when (equal (org-element-property :drawer-name d) "PROPERTIES")
|
2020-04-22 14:06:43 +00:00
|
|
|
|
(let ((headline? (org-element-lineage d '(headline)))
|
|
|
|
|
(before
|
|
|
|
|
(mapcar #'org-element-type
|
|
|
|
|
(assq d (reverse (org-element-contents
|
|
|
|
|
(org-element-property :parent d)))))))
|
|
|
|
|
(list (org-element-property :post-affiliated d)
|
|
|
|
|
(if (or (and headline? (member before '(nil (planning))))
|
|
|
|
|
(and (null headline?) (member before '(nil (comment)))))
|
|
|
|
|
"Incorrect contents for PROPERTIES drawer"
|
|
|
|
|
"Incorrect location for PROPERTIES drawer")))))))
|
2015-04-15 20:24:15 +00:00
|
|
|
|
|
2017-03-12 08:08:28 +00:00
|
|
|
|
(defun org-lint-invalid-effort-property (ast)
|
|
|
|
|
(org-element-map ast 'node-property
|
|
|
|
|
(lambda (p)
|
|
|
|
|
(when (equal "EFFORT" (org-element-property :key p))
|
|
|
|
|
(let ((value (org-element-property :value p)))
|
|
|
|
|
(and (org-string-nw-p value)
|
|
|
|
|
(not (org-duration-p value))
|
|
|
|
|
(list (org-element-property :begin p)
|
|
|
|
|
(format "Invalid effort duration format: %S" value))))))))
|
|
|
|
|
|
2015-04-15 20:24:15 +00:00
|
|
|
|
(defun org-lint-link-to-local-file (ast)
|
|
|
|
|
(org-element-map ast 'link
|
|
|
|
|
(lambda (l)
|
2020-06-25 18:58:35 +00:00
|
|
|
|
(let ((type (org-element-property :type l)))
|
|
|
|
|
(pcase type
|
|
|
|
|
((or "attachment" "file")
|
|
|
|
|
(let* ((path (org-element-property :path l))
|
|
|
|
|
(file (if (string= type "file")
|
|
|
|
|
path
|
2020-09-26 06:24:44 +00:00
|
|
|
|
(org-with-point-at (org-element-property :begin l)
|
|
|
|
|
(org-attach-expand path)))))
|
2020-06-25 18:58:35 +00:00
|
|
|
|
(and (not (file-remote-p file))
|
|
|
|
|
(not (file-exists-p file))
|
|
|
|
|
(list (org-element-property :begin l)
|
|
|
|
|
(format (if (org-element-lineage l '(link))
|
|
|
|
|
"Link to non-existent image file %S \
|
|
|
|
|
in description"
|
2020-09-26 06:24:44 +00:00
|
|
|
|
"Link to non-existent local file %S")
|
|
|
|
|
file)))))
|
2020-06-25 18:58:35 +00:00
|
|
|
|
(_ nil))))))
|
2015-04-15 20:24:15 +00:00
|
|
|
|
|
|
|
|
|
(defun org-lint-non-existent-setupfile-parameter (ast)
|
|
|
|
|
(org-element-map ast 'keyword
|
|
|
|
|
(lambda (k)
|
|
|
|
|
(when (equal (org-element-property :key k) "SETUPFILE")
|
2016-09-03 01:22:11 +00:00
|
|
|
|
(let ((file (org-unbracket-string
|
2019-03-14 17:11:00 +00:00
|
|
|
|
"\"" "\""
|
|
|
|
|
(org-element-property :value k))))
|
2021-05-18 14:31:39 +00:00
|
|
|
|
(and (not (org-url-p file))
|
2019-03-14 17:11:00 +00:00
|
|
|
|
(not (file-remote-p file))
|
2015-04-15 20:24:15 +00:00
|
|
|
|
(not (file-exists-p file))
|
|
|
|
|
(list (org-element-property :begin k)
|
2019-03-14 17:11:00 +00:00
|
|
|
|
(format "Non-existent setup file %S" file))))))))
|
2015-04-15 20:24:15 +00:00
|
|
|
|
|
|
|
|
|
(defun org-lint-wrong-include-link-parameter (ast)
|
|
|
|
|
(org-element-map ast 'keyword
|
|
|
|
|
(lambda (k)
|
|
|
|
|
(when (equal (org-element-property :key k) "INCLUDE")
|
2022-06-05 14:28:39 +00:00
|
|
|
|
(let* ((value (org-element-property :value k))
|
|
|
|
|
(path
|
2022-11-05 03:31:37 +00:00
|
|
|
|
(and (string-match "^\\(\".+?\"\\|\\S-+\\)[ \t]*" value)
|
2022-06-05 14:28:39 +00:00
|
|
|
|
(save-match-data
|
|
|
|
|
(org-strip-quotes (match-string 1 value))))))
|
|
|
|
|
(if (not path)
|
|
|
|
|
(list (org-element-property :post-affiliated k)
|
|
|
|
|
"Missing location argument in INCLUDE keyword")
|
|
|
|
|
(let* ((file (org-string-nw-p
|
|
|
|
|
(if (string-match "::\\(.*\\)\\'" path)
|
|
|
|
|
(substring path 0 (match-beginning 0))
|
|
|
|
|
path)))
|
|
|
|
|
(search (and (not (equal file path))
|
|
|
|
|
(org-string-nw-p (match-string 1 path)))))
|
|
|
|
|
(unless (org-url-p file)
|
|
|
|
|
(if (and file
|
|
|
|
|
(not (file-remote-p file))
|
|
|
|
|
(not (file-exists-p file)))
|
|
|
|
|
(list (org-element-property :post-affiliated k)
|
|
|
|
|
"Non-existent file argument in INCLUDE keyword")
|
|
|
|
|
(let* ((visiting (if file (find-buffer-visiting file)
|
|
|
|
|
(current-buffer)))
|
|
|
|
|
(buffer (or visiting (find-file-noselect file)))
|
|
|
|
|
(org-link-search-must-match-exact-headline t))
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(with-current-buffer buffer
|
|
|
|
|
(when (and search
|
|
|
|
|
(not (ignore-errors
|
|
|
|
|
(org-link-search search nil t))))
|
|
|
|
|
(list (org-element-property :post-affiliated k)
|
|
|
|
|
(format
|
|
|
|
|
"Invalid search part \"%s\" in INCLUDE keyword"
|
|
|
|
|
search))))
|
|
|
|
|
(unless visiting (kill-buffer buffer)))))))))))))
|
2015-04-15 20:24:15 +00:00
|
|
|
|
|
2015-12-20 20:42:41 +00:00
|
|
|
|
(defun org-lint-obsolete-include-markup (ast)
|
|
|
|
|
(let ((regexp (format "\\`\\(?:\".+\"\\|\\S-+\\)[ \t]+%s"
|
|
|
|
|
(regexp-opt
|
|
|
|
|
'("ASCII" "BEAMER" "HTML" "LATEX" "MAN" "MARKDOWN" "MD"
|
|
|
|
|
"ODT" "ORG" "TEXINFO")
|
|
|
|
|
t))))
|
|
|
|
|
(org-element-map ast 'keyword
|
|
|
|
|
(lambda (k)
|
|
|
|
|
(when (equal (org-element-property :key k) "INCLUDE")
|
|
|
|
|
(let ((case-fold-search t)
|
|
|
|
|
(value (org-element-property :value k)))
|
|
|
|
|
(when (string-match regexp value)
|
|
|
|
|
(let ((markup (match-string-no-properties 1 value)))
|
|
|
|
|
(list (org-element-property :post-affiliated k)
|
|
|
|
|
(format "Obsolete markup \"%s\" in INCLUDE keyword. \
|
|
|
|
|
Use \"export %s\" instead"
|
|
|
|
|
markup
|
|
|
|
|
markup))))))))))
|
|
|
|
|
|
2015-04-15 20:24:15 +00:00
|
|
|
|
(defun org-lint-unknown-options-item (ast)
|
|
|
|
|
(let ((allowed (delq nil
|
|
|
|
|
(append
|
|
|
|
|
(mapcar (lambda (o) (nth 2 o)) org-export-options-alist)
|
|
|
|
|
(cl-mapcan
|
|
|
|
|
(lambda (b)
|
|
|
|
|
(mapcar (lambda (o) (nth 2 o))
|
|
|
|
|
(org-export-backend-options b)))
|
|
|
|
|
org-export-registered-backends))))
|
|
|
|
|
reports)
|
|
|
|
|
(org-element-map ast 'keyword
|
|
|
|
|
(lambda (k)
|
|
|
|
|
(when (string= (org-element-property :key k) "OPTIONS")
|
|
|
|
|
(let ((value (org-element-property :value k))
|
|
|
|
|
(start 0))
|
2021-04-09 20:47:57 +00:00
|
|
|
|
(while (string-match "\\(.+?\\):\\((.*?)\\|\\S-+\\)?[ \t]*"
|
2015-04-15 20:24:15 +00:00
|
|
|
|
value
|
|
|
|
|
start)
|
|
|
|
|
(setf start (match-end 0))
|
|
|
|
|
(let ((item (match-string 1 value)))
|
|
|
|
|
(unless (member item allowed)
|
|
|
|
|
(push (list (org-element-property :post-affiliated k)
|
|
|
|
|
(format "Unknown OPTIONS item \"%s\"" item))
|
2021-04-09 20:47:57 +00:00
|
|
|
|
reports))
|
|
|
|
|
(unless (match-string 2 value)
|
|
|
|
|
(push (list (org-element-property :post-affiliated k)
|
|
|
|
|
(format "Missing value for option item %S" item))
|
|
|
|
|
reports))))))))
|
2015-04-15 20:24:15 +00:00
|
|
|
|
reports))
|
|
|
|
|
|
2023-06-17 12:07:02 +00:00
|
|
|
|
(defun org-lint-export-option-keywords (ast)
|
|
|
|
|
"Check for options keyword properties without EXPORT_."
|
|
|
|
|
(require 'ox)
|
|
|
|
|
(let (options reports)
|
|
|
|
|
(dolist (opt org-export-options-alist)
|
|
|
|
|
(when (stringp (nth 1 opt))
|
|
|
|
|
(cl-pushnew (nth 1 opt) options :test #'equal)))
|
|
|
|
|
(dolist (backend org-export-registered-backends)
|
|
|
|
|
(dolist (opt (org-export-backend-options backend))
|
|
|
|
|
(when (stringp (nth 1 opt))
|
|
|
|
|
(cl-pushnew (nth 1 opt) options :test #'equal))))
|
|
|
|
|
(org-element-map ast 'node-property
|
|
|
|
|
(lambda (node)
|
|
|
|
|
(when (member
|
|
|
|
|
(org-element-property :key node)
|
|
|
|
|
options)
|
|
|
|
|
(push (list (org-element-property :post-affiliated node)
|
|
|
|
|
(format "Potentially misspelled option \"%s\". Consider \"EXPORT_%s\"."
|
|
|
|
|
(org-element-property :key node)
|
|
|
|
|
(org-element-property :key node)))
|
|
|
|
|
reports))))
|
|
|
|
|
reports))
|
|
|
|
|
|
2015-04-15 20:24:15 +00:00
|
|
|
|
(defun org-lint-invalid-macro-argument-and-template (ast)
|
2021-04-19 00:06:01 +00:00
|
|
|
|
(let* ((reports nil)
|
|
|
|
|
(extract-placeholders
|
|
|
|
|
(lambda (template)
|
|
|
|
|
(let ((start 0)
|
|
|
|
|
args)
|
|
|
|
|
(while (string-match "\\$\\([1-9][0-9]*\\)" template start)
|
|
|
|
|
(setf start (match-end 0))
|
|
|
|
|
(push (string-to-number (match-string 1 template)) args))
|
|
|
|
|
(sort (org-uniquify args) #'<))))
|
|
|
|
|
(check-arity
|
|
|
|
|
(lambda (arity macro)
|
|
|
|
|
(let* ((name (org-element-property :key macro))
|
|
|
|
|
(pos (org-element-property :begin macro))
|
|
|
|
|
(args (org-element-property :args macro))
|
|
|
|
|
(l (length args)))
|
|
|
|
|
(cond
|
|
|
|
|
((< l (1- (car arity)))
|
|
|
|
|
(push (list pos (format "Missing arguments in macro %S" name))
|
|
|
|
|
reports))
|
|
|
|
|
((< l (car arity))
|
|
|
|
|
(push (list pos (format "Missing argument in macro %S" name))
|
|
|
|
|
reports))
|
|
|
|
|
((> l (1+ (cdr arity)))
|
|
|
|
|
(push (let ((spurious-args (nthcdr (cdr arity) args)))
|
|
|
|
|
(list pos
|
|
|
|
|
(format "Spurious arguments in macro %S: %s"
|
|
|
|
|
name
|
|
|
|
|
(mapconcat #'org-trim spurious-args ", "))))
|
|
|
|
|
reports))
|
|
|
|
|
((> l (cdr arity))
|
|
|
|
|
(push (list pos
|
|
|
|
|
(format "Spurious argument in macro %S: %s"
|
|
|
|
|
name
|
|
|
|
|
(org-last args)))
|
|
|
|
|
reports))
|
|
|
|
|
(t nil))))))
|
2015-04-15 20:24:15 +00:00
|
|
|
|
;; Check arguments for macro templates.
|
|
|
|
|
(org-element-map ast 'keyword
|
|
|
|
|
(lambda (k)
|
|
|
|
|
(when (string= (org-element-property :key k) "MACRO")
|
|
|
|
|
(let* ((value (org-element-property :value k))
|
|
|
|
|
(name (and (string-match "^\\S-+" value)
|
|
|
|
|
(match-string 0 value)))
|
|
|
|
|
(template (and name
|
|
|
|
|
(org-trim (substring value (match-end 0))))))
|
|
|
|
|
(cond
|
|
|
|
|
((not name)
|
|
|
|
|
(push (list (org-element-property :post-affiliated k)
|
|
|
|
|
"Missing name in MACRO keyword")
|
|
|
|
|
reports))
|
|
|
|
|
((not (org-string-nw-p template))
|
|
|
|
|
(push (list (org-element-property :post-affiliated k)
|
|
|
|
|
"Missing template in macro \"%s\"" name)
|
|
|
|
|
reports))
|
|
|
|
|
(t
|
|
|
|
|
(unless (let ((args (funcall extract-placeholders template)))
|
2015-09-16 12:36:29 +00:00
|
|
|
|
(equal (number-sequence 1 (or (org-last args) 0)) args))
|
2015-04-15 20:24:15 +00:00
|
|
|
|
(push (list (org-element-property :post-affiliated k)
|
|
|
|
|
(format "Unused placeholders in macro \"%s\""
|
|
|
|
|
name))
|
|
|
|
|
reports))))))))
|
|
|
|
|
;; Check arguments for macros.
|
|
|
|
|
(org-macro-initialize-templates)
|
|
|
|
|
(let ((templates (append
|
|
|
|
|
(mapcar (lambda (m) (cons m "$1"))
|
|
|
|
|
'("author" "date" "email" "title" "results"))
|
|
|
|
|
org-macro-templates)))
|
|
|
|
|
(org-element-map ast 'macro
|
|
|
|
|
(lambda (macro)
|
|
|
|
|
(let* ((name (org-element-property :key macro))
|
|
|
|
|
(template (cdr (assoc-string name templates t))))
|
2021-04-16 14:37:29 +00:00
|
|
|
|
(pcase template
|
|
|
|
|
(`nil
|
|
|
|
|
(push (list (org-element-property :begin macro)
|
|
|
|
|
(format "Undefined macro %S" name))
|
|
|
|
|
reports))
|
2021-04-19 00:06:01 +00:00
|
|
|
|
((guard (string= name "keyword"))
|
|
|
|
|
(funcall check-arity '(1 . 1) macro))
|
|
|
|
|
((guard (string= name "modification-time"))
|
|
|
|
|
(funcall check-arity '(1 . 2) macro))
|
|
|
|
|
((guard (string= name "n"))
|
|
|
|
|
(funcall check-arity '(0 . 2) macro))
|
|
|
|
|
((guard (string= name "property"))
|
|
|
|
|
(funcall check-arity '(1 . 2) macro))
|
|
|
|
|
((guard (string= name "time"))
|
|
|
|
|
(funcall check-arity '(1 . 1) macro))
|
|
|
|
|
((pred functionp)) ;ignore (eval ...) templates
|
2021-04-16 14:37:29 +00:00
|
|
|
|
(_
|
2021-04-19 00:06:01 +00:00
|
|
|
|
(let* ((arg-numbers (funcall extract-placeholders template))
|
|
|
|
|
(arity (if (null arg-numbers)
|
|
|
|
|
'(0 . 0)
|
|
|
|
|
(let ((m (apply #'max arg-numbers)))
|
|
|
|
|
(cons m m)))))
|
|
|
|
|
(funcall check-arity arity macro))))))))
|
2015-04-15 20:24:15 +00:00
|
|
|
|
reports))
|
|
|
|
|
|
|
|
|
|
(defun org-lint-undefined-footnote-reference (ast)
|
2022-02-13 21:13:41 +00:00
|
|
|
|
(let ((definitions
|
2023-05-16 10:41:53 +00:00
|
|
|
|
(org-element-map ast '(footnote-definition footnote-reference)
|
|
|
|
|
(lambda (f)
|
|
|
|
|
(and (or (org-element-type-p f 'footnote-definition)
|
|
|
|
|
(eq 'inline (org-element-property :type f)))
|
|
|
|
|
(org-element-property :label f))))))
|
2015-04-15 20:24:15 +00:00
|
|
|
|
(org-element-map ast 'footnote-reference
|
|
|
|
|
(lambda (f)
|
|
|
|
|
(let ((label (org-element-property :label f)))
|
2017-08-25 13:24:07 +00:00
|
|
|
|
(and (eq 'standard (org-element-property :type f))
|
2015-04-15 20:24:15 +00:00
|
|
|
|
(not (member label definitions))
|
|
|
|
|
(list (org-element-property :begin f)
|
|
|
|
|
(format "Missing definition for footnote [%s]"
|
|
|
|
|
label))))))))
|
|
|
|
|
|
|
|
|
|
(defun org-lint-unreferenced-footnote-definition (ast)
|
|
|
|
|
(let ((references (org-element-map ast 'footnote-reference
|
|
|
|
|
(lambda (f) (org-element-property :label f)))))
|
|
|
|
|
(org-element-map ast 'footnote-definition
|
|
|
|
|
(lambda (f)
|
|
|
|
|
(let ((label (org-element-property :label f)))
|
|
|
|
|
(and label
|
|
|
|
|
(not (member label references))
|
|
|
|
|
(list (org-element-property :post-affiliated f)
|
|
|
|
|
(format "No reference for footnote definition [%s]"
|
|
|
|
|
label))))))))
|
|
|
|
|
|
|
|
|
|
(defun org-lint-colon-in-name (ast)
|
|
|
|
|
(org-element-map ast org-element-all-elements
|
|
|
|
|
(lambda (e)
|
|
|
|
|
(let ((name (org-element-property :name e)))
|
|
|
|
|
(and name
|
2016-07-25 13:21:12 +00:00
|
|
|
|
(string-match-p ":" name)
|
2015-04-15 20:24:15 +00:00
|
|
|
|
(list (progn
|
|
|
|
|
(goto-char (org-element-property :begin e))
|
|
|
|
|
(re-search-forward
|
|
|
|
|
(format "^[ \t]*#\\+\\w+: +%s *$" (regexp-quote name)))
|
|
|
|
|
(match-beginning 0))
|
|
|
|
|
(format
|
|
|
|
|
"Name \"%s\" contains a colon; Babel cannot use it as input"
|
|
|
|
|
name)))))))
|
|
|
|
|
|
2023-06-11 14:50:20 +00:00
|
|
|
|
(defun org-lint-mismatched-planning-repeaters (ast)
|
|
|
|
|
(org-element-map ast 'planning
|
|
|
|
|
(lambda (e)
|
|
|
|
|
(let* ((scheduled (org-element-property :scheduled e))
|
|
|
|
|
(deadline (org-element-property :deadline e))
|
|
|
|
|
(scheduled-repeater-type (org-element-property
|
|
|
|
|
:repeater-type scheduled))
|
|
|
|
|
(deadline-repeater-type (org-element-property
|
|
|
|
|
:repeater-type deadline))
|
|
|
|
|
(scheduled-repeater-value (org-element-property
|
|
|
|
|
:repeater-value scheduled))
|
|
|
|
|
(deadline-repeater-value (org-element-property
|
|
|
|
|
:repeater-value deadline)))
|
|
|
|
|
(when (and scheduled deadline
|
|
|
|
|
(memq scheduled-repeater-type '(cumulate catch-up))
|
|
|
|
|
(memq deadline-repeater-type '(cumulate catch-up))
|
|
|
|
|
(> scheduled-repeater-value 0)
|
|
|
|
|
(> deadline-repeater-value 0)
|
|
|
|
|
(not
|
|
|
|
|
(and
|
|
|
|
|
(eq scheduled-repeater-type deadline-repeater-type)
|
|
|
|
|
(eq (org-element-property :repeater-unit scheduled)
|
|
|
|
|
(org-element-property :repeater-unit deadline))
|
|
|
|
|
(eql scheduled-repeater-value deadline-repeater-value))))
|
|
|
|
|
(list
|
|
|
|
|
(org-element-property :begin e)
|
|
|
|
|
"Different repeaters in SCHEDULED and DEADLINE timestamps."))))))
|
|
|
|
|
|
2015-04-15 20:24:15 +00:00
|
|
|
|
(defun org-lint-misplaced-planning-info (_)
|
|
|
|
|
(let ((case-fold-search t)
|
|
|
|
|
reports)
|
|
|
|
|
(while (re-search-forward org-planning-line-re nil t)
|
2023-05-16 10:41:53 +00:00
|
|
|
|
(unless (org-element-type-p
|
|
|
|
|
(org-element-at-point)
|
|
|
|
|
'(comment-block example-block export-block planning
|
|
|
|
|
src-block verse-block))
|
2015-04-15 20:24:15 +00:00
|
|
|
|
(push (list (line-beginning-position) "Misplaced planning info line")
|
|
|
|
|
reports)))
|
|
|
|
|
reports))
|
|
|
|
|
|
|
|
|
|
(defun org-lint-incomplete-drawer (_)
|
|
|
|
|
(let (reports)
|
|
|
|
|
(while (re-search-forward org-drawer-regexp nil t)
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 10:18:00 +00:00
|
|
|
|
(let ((name (org-trim (match-string-no-properties 0)))
|
2015-04-15 20:24:15 +00:00
|
|
|
|
(element (org-element-at-point)))
|
|
|
|
|
(pcase (org-element-type element)
|
2020-05-27 12:55:04 +00:00
|
|
|
|
(`drawer
|
|
|
|
|
;; Find drawer opening lines within non-empty drawers.
|
|
|
|
|
(let ((end (org-element-property :contents-end element)))
|
|
|
|
|
(when end
|
|
|
|
|
(while (re-search-forward org-drawer-regexp end t)
|
|
|
|
|
(let ((n (org-trim (match-string-no-properties 0))))
|
|
|
|
|
(push (list (line-beginning-position)
|
|
|
|
|
(format "Possible misleading drawer entry %S" n))
|
|
|
|
|
reports))))
|
|
|
|
|
(goto-char (org-element-property :end element))))
|
|
|
|
|
(`property-drawer
|
|
|
|
|
(goto-char (org-element-property :end element)))
|
2015-04-15 20:24:15 +00:00
|
|
|
|
((or `comment-block `example-block `export-block `src-block
|
|
|
|
|
`verse-block)
|
|
|
|
|
nil)
|
|
|
|
|
(_
|
2020-05-27 12:55:04 +00:00
|
|
|
|
;; Find drawer opening lines outside of any drawer.
|
2015-04-15 20:24:15 +00:00
|
|
|
|
(push (list (line-beginning-position)
|
2020-05-27 12:55:04 +00:00
|
|
|
|
(format "Possible incomplete drawer %S" name))
|
2015-04-15 20:24:15 +00:00
|
|
|
|
reports)))))
|
|
|
|
|
reports))
|
|
|
|
|
|
|
|
|
|
(defun org-lint-indented-diary-sexp (_)
|
|
|
|
|
(let (reports)
|
|
|
|
|
(while (re-search-forward "^[ \t]+%%(" nil t)
|
2023-05-16 10:41:53 +00:00
|
|
|
|
(unless (org-element-type-p
|
|
|
|
|
(org-element-at-point)
|
|
|
|
|
'(comment-block diary-sexp example-block export-block
|
|
|
|
|
src-block verse-block))
|
2015-04-15 20:24:15 +00:00
|
|
|
|
(push (list (line-beginning-position) "Possible indented diary-sexp")
|
|
|
|
|
reports)))
|
|
|
|
|
reports))
|
|
|
|
|
|
|
|
|
|
(defun org-lint-invalid-block (_)
|
|
|
|
|
(let ((case-fold-search t)
|
|
|
|
|
(regexp "^[ \t]*#\\+\\(BEGIN\\|END\\)\\(?::\\|_[^[:space:]]*\\)?[ \t]*")
|
|
|
|
|
reports)
|
|
|
|
|
(while (re-search-forward regexp nil t)
|
|
|
|
|
(let ((name (org-trim (buffer-substring-no-properties
|
|
|
|
|
(line-beginning-position) (line-end-position)))))
|
|
|
|
|
(cond
|
|
|
|
|
((and (string-prefix-p "END" (match-string 1) t)
|
|
|
|
|
(not (eolp)))
|
|
|
|
|
(push (list (line-beginning-position)
|
|
|
|
|
(format "Invalid block closing line \"%s\"" name))
|
|
|
|
|
reports))
|
2023-05-16 10:41:53 +00:00
|
|
|
|
((not (org-element-type-p
|
|
|
|
|
(org-element-at-point)
|
|
|
|
|
'(center-block comment-block dynamic-block example-block
|
|
|
|
|
export-block quote-block special-block
|
|
|
|
|
src-block verse-block)))
|
2015-04-15 20:24:15 +00:00
|
|
|
|
(push (list (line-beginning-position)
|
|
|
|
|
(format "Possible incomplete block \"%s\""
|
|
|
|
|
name))
|
|
|
|
|
reports)))))
|
|
|
|
|
reports))
|
|
|
|
|
|
|
|
|
|
(defun org-lint-invalid-keyword-syntax (_)
|
|
|
|
|
(let ((regexp "^[ \t]*#\\+\\([^[:space:]:]*\\)\\(?: \\|$\\)")
|
|
|
|
|
(exception-re
|
|
|
|
|
(format "[ \t]*#\\+%s\\(\\[.*\\]\\)?:\\(?: \\|$\\)"
|
|
|
|
|
(regexp-opt org-element-dual-keywords)))
|
|
|
|
|
reports)
|
|
|
|
|
(while (re-search-forward regexp nil t)
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 10:18:00 +00:00
|
|
|
|
(let ((name (match-string-no-properties 1)))
|
2015-04-15 20:24:15 +00:00
|
|
|
|
(unless (or (string-prefix-p "BEGIN" name t)
|
|
|
|
|
(string-prefix-p "END" name t)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(let ((case-fold-search t)) (looking-at exception-re))))
|
|
|
|
|
(push (list (match-beginning 0)
|
|
|
|
|
(format "Possible missing colon in keyword \"%s\"" name))
|
|
|
|
|
reports))))
|
|
|
|
|
reports))
|
|
|
|
|
|
|
|
|
|
(defun org-lint-extraneous-element-in-footnote-section (ast)
|
|
|
|
|
(org-element-map ast 'headline
|
|
|
|
|
(lambda (h)
|
|
|
|
|
(and (org-element-property :footnote-section-p h)
|
|
|
|
|
(org-element-map (org-element-contents h)
|
2015-11-06 12:04:20 +00:00
|
|
|
|
(cl-remove-if
|
2015-04-15 20:24:15 +00:00
|
|
|
|
(lambda (e)
|
2016-10-05 22:22:38 +00:00
|
|
|
|
(memq e '(comment comment-block footnote-definition
|
2015-04-15 20:24:15 +00:00
|
|
|
|
property-drawer section)))
|
|
|
|
|
org-element-all-elements)
|
|
|
|
|
(lambda (e)
|
2023-05-16 10:41:53 +00:00
|
|
|
|
(not (and (org-element-type-p e 'headline)
|
|
|
|
|
(org-element-property :commentedp e))))
|
2015-04-15 20:24:15 +00:00
|
|
|
|
nil t '(footnote-definition property-drawer))
|
|
|
|
|
(list (org-element-property :begin h)
|
2016-10-05 22:23:02 +00:00
|
|
|
|
"Extraneous elements in footnote section are not exported")))))
|
2015-04-15 20:24:15 +00:00
|
|
|
|
|
|
|
|
|
(defun org-lint-quote-section (ast)
|
|
|
|
|
(org-element-map ast '(headline inlinetask)
|
|
|
|
|
(lambda (h)
|
|
|
|
|
(let ((title (org-element-property :raw-value h)))
|
|
|
|
|
(and (or (string-prefix-p "QUOTE " title)
|
|
|
|
|
(string-prefix-p (concat org-comment-string " QUOTE ") title))
|
|
|
|
|
(list (org-element-property :begin h)
|
|
|
|
|
"Deprecated QUOTE section"))))))
|
|
|
|
|
|
2016-07-18 21:43:01 +00:00
|
|
|
|
(defun org-lint-file-application (ast)
|
|
|
|
|
(org-element-map ast 'link
|
|
|
|
|
(lambda (l)
|
|
|
|
|
(let ((app (org-element-property :application l)))
|
|
|
|
|
(and app
|
|
|
|
|
(list (org-element-property :begin l)
|
|
|
|
|
(format "Deprecated \"file+%s\" link type" app)))))))
|
|
|
|
|
|
2019-03-10 14:11:58 +00:00
|
|
|
|
(defun org-lint-percent-encoding-link-escape (ast)
|
|
|
|
|
(org-element-map ast 'link
|
|
|
|
|
(lambda (l)
|
|
|
|
|
(when (eq 'bracket (org-element-property :format l))
|
|
|
|
|
(let* ((uri (org-element-property :path l))
|
|
|
|
|
(start 0)
|
|
|
|
|
(obsolete-flag
|
|
|
|
|
(catch :obsolete
|
|
|
|
|
(while (string-match "%\\(..\\)?" uri start)
|
|
|
|
|
(setq start (match-end 0))
|
|
|
|
|
(unless (member (match-string 1 uri) '("25" "5B" "5D" "20"))
|
|
|
|
|
(throw :obsolete nil)))
|
|
|
|
|
(string-match-p "%" uri))))
|
|
|
|
|
(when obsolete-flag
|
|
|
|
|
(list (org-element-property :begin l)
|
|
|
|
|
"Link escaped with obsolete percent-encoding syntax")))))))
|
|
|
|
|
|
2015-04-15 20:24:15 +00:00
|
|
|
|
(defun org-lint-wrong-header-argument (ast)
|
|
|
|
|
(let* ((reports)
|
|
|
|
|
(verify
|
|
|
|
|
(lambda (datum language headers)
|
|
|
|
|
(let ((allowed
|
|
|
|
|
;; If LANGUAGE is specified, restrict allowed
|
|
|
|
|
;; headers to both LANGUAGE-specific and default
|
|
|
|
|
;; ones. Otherwise, accept headers from any loaded
|
|
|
|
|
;; language.
|
|
|
|
|
(append
|
|
|
|
|
org-babel-header-arg-names
|
|
|
|
|
(cl-mapcan
|
|
|
|
|
(lambda (l)
|
|
|
|
|
(let ((v (intern (format "org-babel-header-args:%s" l))))
|
|
|
|
|
(and (boundp v) (mapcar #'car (symbol-value v)))))
|
|
|
|
|
(if language (list language)
|
|
|
|
|
(mapcar #'car org-babel-load-languages))))))
|
|
|
|
|
(dolist (header headers)
|
|
|
|
|
(let ((h (symbol-name (car header)))
|
|
|
|
|
(p (or (org-element-property :post-affiliated datum)
|
|
|
|
|
(org-element-property :begin datum))))
|
|
|
|
|
(cond
|
|
|
|
|
((not (string-prefix-p ":" h))
|
|
|
|
|
(push
|
|
|
|
|
(list p
|
|
|
|
|
(format "Missing colon in header argument \"%s\"" h))
|
|
|
|
|
reports))
|
|
|
|
|
((assoc-string (substring h 1) allowed))
|
|
|
|
|
(t (push (list p (format "Unknown header argument \"%s\"" h))
|
|
|
|
|
reports)))))))))
|
|
|
|
|
(org-element-map ast '(babel-call inline-babel-call inline-src-block keyword
|
|
|
|
|
node-property src-block)
|
|
|
|
|
(lambda (datum)
|
|
|
|
|
(pcase (org-element-type datum)
|
|
|
|
|
((or `babel-call `inline-babel-call)
|
|
|
|
|
(funcall verify
|
|
|
|
|
datum
|
|
|
|
|
nil
|
|
|
|
|
(cl-mapcan #'org-babel-parse-header-arguments
|
|
|
|
|
(list
|
|
|
|
|
(org-element-property :inside-header datum)
|
|
|
|
|
(org-element-property :end-header datum)))))
|
|
|
|
|
(`inline-src-block
|
|
|
|
|
(funcall verify
|
|
|
|
|
datum
|
|
|
|
|
(org-element-property :language datum)
|
|
|
|
|
(org-babel-parse-header-arguments
|
|
|
|
|
(org-element-property :parameters datum))))
|
|
|
|
|
(`keyword
|
|
|
|
|
(when (string= (org-element-property :key datum) "PROPERTY")
|
|
|
|
|
(let ((value (org-element-property :value datum)))
|
2022-10-21 03:58:50 +00:00
|
|
|
|
(when (or (string-match "\\`header-args\\(?::\\(\\S-+\\)\\)?\\+ *"
|
|
|
|
|
value)
|
|
|
|
|
(string-match "\\`header-args\\(?::\\(\\S-+\\)\\)? *"
|
|
|
|
|
value))
|
2015-04-15 20:24:15 +00:00
|
|
|
|
(funcall verify
|
|
|
|
|
datum
|
|
|
|
|
(match-string 1 value)
|
|
|
|
|
(org-babel-parse-header-arguments
|
|
|
|
|
(substring value (match-end 0))))))))
|
|
|
|
|
(`node-property
|
|
|
|
|
(let ((key (org-element-property :key datum)))
|
|
|
|
|
(when (let ((case-fold-search t))
|
2022-10-21 03:58:50 +00:00
|
|
|
|
(or (string-match "\\`HEADER-ARGS\\(?::\\(\\S-+\\)\\)?\\+"
|
|
|
|
|
key)
|
|
|
|
|
(string-match "\\`HEADER-ARGS\\(?::\\(\\S-+\\)\\)?"
|
|
|
|
|
key)))
|
2015-04-15 20:24:15 +00:00
|
|
|
|
(funcall verify
|
|
|
|
|
datum
|
|
|
|
|
(match-string 1 key)
|
|
|
|
|
(org-babel-parse-header-arguments
|
|
|
|
|
(org-element-property :value datum))))))
|
|
|
|
|
(`src-block
|
|
|
|
|
(funcall verify
|
|
|
|
|
datum
|
|
|
|
|
(org-element-property :language datum)
|
|
|
|
|
(cl-mapcan #'org-babel-parse-header-arguments
|
|
|
|
|
(cons (org-element-property :parameters datum)
|
|
|
|
|
(org-element-property :header datum))))))))
|
|
|
|
|
reports))
|
|
|
|
|
|
2023-04-24 12:01:12 +00:00
|
|
|
|
(defun org-lint-empty-header-argument (ast)
|
|
|
|
|
(let* (reports)
|
|
|
|
|
(org-element-map ast '(babel-call inline-babel-call inline-src-block src-block)
|
|
|
|
|
(lambda (datum)
|
|
|
|
|
(let ((headers
|
|
|
|
|
(pcase (org-element-type datum)
|
|
|
|
|
((or `babel-call `inline-babel-call)
|
|
|
|
|
(cl-mapcan
|
|
|
|
|
(lambda (header) (org-babel-parse-header-arguments header 'no-eval))
|
|
|
|
|
(list
|
|
|
|
|
(org-element-property :inside-header datum)
|
|
|
|
|
(org-element-property :end-header datum))))
|
|
|
|
|
(`inline-src-block
|
|
|
|
|
(org-babel-parse-header-arguments
|
|
|
|
|
(org-element-property :parameters datum)
|
|
|
|
|
'no-eval))
|
|
|
|
|
(`src-block
|
|
|
|
|
(cl-mapcan
|
|
|
|
|
(lambda (header) (org-babel-parse-header-arguments header 'no-eval))
|
|
|
|
|
(cons (org-element-property :parameters datum)
|
|
|
|
|
(org-element-property :header datum)))))))
|
|
|
|
|
(dolist (header headers)
|
|
|
|
|
(when (not (cdr header))
|
|
|
|
|
(push
|
|
|
|
|
(list
|
|
|
|
|
(or (org-element-property :post-affiliated datum)
|
|
|
|
|
(org-element-property :begin datum))
|
|
|
|
|
(format "Empty value in header argument \"%s\"" (symbol-name (car header))))
|
|
|
|
|
reports))))))
|
|
|
|
|
reports))
|
|
|
|
|
|
2015-04-15 20:24:15 +00:00
|
|
|
|
(defun org-lint-wrong-header-value (ast)
|
|
|
|
|
(let (reports)
|
|
|
|
|
(org-element-map ast
|
|
|
|
|
'(babel-call inline-babel-call inline-src-block src-block)
|
|
|
|
|
(lambda (datum)
|
|
|
|
|
(let* ((type (org-element-type datum))
|
|
|
|
|
(language (org-element-property :language datum))
|
|
|
|
|
(allowed-header-values
|
|
|
|
|
(append (and language
|
|
|
|
|
(let ((v (intern (concat "org-babel-header-args:"
|
|
|
|
|
language))))
|
|
|
|
|
(and (boundp v) (symbol-value v))))
|
|
|
|
|
org-babel-common-header-args-w-values))
|
|
|
|
|
(datum-header-values
|
2016-09-18 22:56:34 +00:00
|
|
|
|
(org-babel-parse-header-arguments
|
|
|
|
|
(org-trim
|
|
|
|
|
(pcase type
|
|
|
|
|
(`src-block
|
|
|
|
|
(mapconcat
|
|
|
|
|
#'identity
|
|
|
|
|
(cons (org-element-property :parameters datum)
|
|
|
|
|
(org-element-property :header datum))
|
|
|
|
|
" "))
|
|
|
|
|
(`inline-src-block
|
|
|
|
|
(or (org-element-property :parameters datum) ""))
|
|
|
|
|
(_
|
|
|
|
|
(concat
|
|
|
|
|
(org-element-property :inside-header datum)
|
|
|
|
|
" "
|
|
|
|
|
(org-element-property :end-header datum))))))))
|
2015-04-15 20:24:15 +00:00
|
|
|
|
(dolist (header datum-header-values)
|
|
|
|
|
(let ((allowed-values
|
|
|
|
|
(cdr (assoc-string (substring (symbol-name (car header)) 1)
|
|
|
|
|
allowed-header-values))))
|
|
|
|
|
(unless (memq allowed-values '(:any nil))
|
|
|
|
|
(let ((values (cdr header))
|
|
|
|
|
groups-alist)
|
2017-09-07 12:34:25 +00:00
|
|
|
|
(dolist (v (if (stringp values) (split-string values)
|
2015-04-15 20:24:15 +00:00
|
|
|
|
(list values)))
|
|
|
|
|
(let ((valid-value nil))
|
|
|
|
|
(catch 'exit
|
|
|
|
|
(dolist (group allowed-values)
|
|
|
|
|
(cond
|
|
|
|
|
((not (funcall
|
|
|
|
|
(if (stringp v) #'assoc-string #'assoc)
|
|
|
|
|
v group))
|
|
|
|
|
(when (memq :any group)
|
|
|
|
|
(setf valid-value t)
|
|
|
|
|
(push (cons group v) groups-alist)))
|
|
|
|
|
((assq group groups-alist)
|
|
|
|
|
(push
|
|
|
|
|
(list
|
|
|
|
|
(or (org-element-property :post-affiliated datum)
|
|
|
|
|
(org-element-property :begin datum))
|
|
|
|
|
(format
|
|
|
|
|
"Forbidden combination in header \"%s\": %s, %s"
|
|
|
|
|
(car header)
|
|
|
|
|
(cdr (assq group groups-alist))
|
|
|
|
|
v))
|
|
|
|
|
reports)
|
|
|
|
|
(throw 'exit nil))
|
|
|
|
|
(t (push (cons group v) groups-alist)
|
|
|
|
|
(setf valid-value t))))
|
|
|
|
|
(unless valid-value
|
|
|
|
|
(push
|
|
|
|
|
(list
|
|
|
|
|
(or (org-element-property :post-affiliated datum)
|
|
|
|
|
(org-element-property :begin datum))
|
|
|
|
|
(format "Unknown value \"%s\" for header \"%s\""
|
|
|
|
|
v
|
|
|
|
|
(car header)))
|
|
|
|
|
reports))))))))))))
|
|
|
|
|
reports))
|
|
|
|
|
|
2018-05-14 15:41:04 +00:00
|
|
|
|
(defun org-lint-spurious-colons (ast)
|
|
|
|
|
(org-element-map ast '(headline inlinetask)
|
|
|
|
|
(lambda (h)
|
|
|
|
|
(when (member "" (org-element-property :tags h))
|
|
|
|
|
(list (org-element-property :begin h)
|
|
|
|
|
"Tags contain a spurious colon")))))
|
|
|
|
|
|
2021-11-30 14:39:17 +00:00
|
|
|
|
(defun org-lint-non-existent-bibliography (ast)
|
|
|
|
|
(org-element-map ast 'keyword
|
|
|
|
|
(lambda (k)
|
|
|
|
|
(when (equal "BIBLIOGRAPHY" (org-element-property :key k))
|
|
|
|
|
(let ((file (org-strip-quotes (org-element-property :value k))))
|
|
|
|
|
(and (not (file-remote-p file))
|
|
|
|
|
(not (file-exists-p file))
|
|
|
|
|
(list (org-element-property :begin k)
|
|
|
|
|
(format "Non-existent bibliography %S" file))))))))
|
|
|
|
|
|
|
|
|
|
(defun org-lint-missing-print-bibliography (ast)
|
|
|
|
|
(and (org-element-map ast 'citation #'identity nil t)
|
|
|
|
|
(not (org-element-map ast 'keyword
|
|
|
|
|
(lambda (k)
|
|
|
|
|
(equal "PRINT_BIBLIOGRAPHY" (org-element-property :key k)))
|
|
|
|
|
nil t))
|
|
|
|
|
(list
|
|
|
|
|
(list (point-max) "Possibly missing \"PRINT_BIBLIOGRAPHY\" keyword"))))
|
|
|
|
|
|
|
|
|
|
(defun org-lint-invalid-cite-export-declaration (ast)
|
|
|
|
|
(org-element-map ast 'keyword
|
|
|
|
|
(lambda (k)
|
|
|
|
|
(when (equal "CITE_EXPORT" (org-element-property :key k))
|
|
|
|
|
(let ((value (org-element-property :value k))
|
|
|
|
|
(source (org-element-property :begin k)))
|
|
|
|
|
(if (equal value "")
|
|
|
|
|
(list source "Missing export processor name")
|
|
|
|
|
(condition-case _
|
|
|
|
|
(pcase (org-cite-read-processor-declaration value)
|
|
|
|
|
(`(,(and (pred symbolp) name)
|
|
|
|
|
,(pred string-or-null-p)
|
|
|
|
|
,(pred string-or-null-p))
|
|
|
|
|
(unless (org-cite-get-processor name)
|
|
|
|
|
(list source "Unknown cite export processor %S" name)))
|
|
|
|
|
(_
|
|
|
|
|
(list source "Invalid cite export processor declaration")))
|
|
|
|
|
(error
|
|
|
|
|
(list source "Invalid cite export processor declaration")))))))))
|
|
|
|
|
|
|
|
|
|
(defun org-lint-incomplete-citation (ast)
|
|
|
|
|
(org-element-map ast 'plain-text
|
|
|
|
|
(lambda (text)
|
|
|
|
|
(and (string-match-p org-element-citation-prefix-re text)
|
|
|
|
|
;; XXX: The code below signals the error at the beginning
|
|
|
|
|
;; of the paragraph containing the faulty object. It is
|
|
|
|
|
;; not very accurate but may be enough for now.
|
|
|
|
|
(list (org-element-property :contents-begin
|
|
|
|
|
(org-element-property :parent text))
|
|
|
|
|
"Possibly incomplete citation markup")))))
|
2017-02-17 12:23:26 +00:00
|
|
|
|
|
2023-04-04 10:05:03 +00:00
|
|
|
|
(defun org-lint-item-number (ast)
|
|
|
|
|
(org-element-map ast 'item
|
|
|
|
|
(lambda (item)
|
|
|
|
|
(unless (org-element-property :counter item)
|
|
|
|
|
(when-let* ((bullet (org-element-property :bullet item))
|
|
|
|
|
(bullet-number
|
|
|
|
|
(cond
|
|
|
|
|
((string-match "[A-Za-z]" bullet)
|
|
|
|
|
(- (string-to-char (upcase (match-string 0 bullet)))
|
|
|
|
|
64))
|
|
|
|
|
((string-match "[0-9]+" bullet)
|
|
|
|
|
(string-to-number (match-string 0 bullet)))))
|
|
|
|
|
(true-number
|
|
|
|
|
(org-list-get-item-number
|
|
|
|
|
(org-element-property :begin item)
|
|
|
|
|
(org-element-property :structure item)
|
|
|
|
|
(org-list-prevs-alist (org-element-property :structure item))
|
|
|
|
|
(org-list-parents-alist (org-element-property :structure item)))))
|
|
|
|
|
(unless (equal bullet-number (car (last true-number)))
|
|
|
|
|
(list
|
|
|
|
|
(org-element-property :begin item)
|
|
|
|
|
(format "Bullet counter \"%s\" is not the same with item position %d. Consider adding manual [@%d] counter."
|
|
|
|
|
bullet (car (last true-number)) bullet-number))))))))
|
|
|
|
|
|
2023-03-22 12:35:22 +00:00
|
|
|
|
(defun org-lint-LaTeX-$ (ast)
|
2023-05-13 10:38:56 +00:00
|
|
|
|
"Report semi-obsolete $...$ LaTeX fragments.
|
|
|
|
|
AST is the buffer parse tree."
|
2023-03-22 12:35:22 +00:00
|
|
|
|
(org-element-map ast 'latex-fragment
|
|
|
|
|
(lambda (fragment)
|
|
|
|
|
(and (string-match-p "^[$][^$]" (org-element-property :value fragment))
|
|
|
|
|
(list (org-element-property :begin fragment)
|
|
|
|
|
"Potentially confusing LaTeX fragment format. Prefer using more reliable \\(...\\)")))))
|
2023-07-01 10:01:40 +00:00
|
|
|
|
(defun org-lint-LaTeX-$-ambiguous (_)
|
|
|
|
|
"Report LaTeX fragment-like text.
|
|
|
|
|
AST is the buffer parse tree."
|
|
|
|
|
(org-with-wide-buffer
|
|
|
|
|
(let ((ambiguous-latex-re (rx "$." digit))
|
|
|
|
|
report context)
|
|
|
|
|
(while (re-search-forward ambiguous-latex-re nil t)
|
|
|
|
|
(setq context (org-element-context))
|
|
|
|
|
(when (or (eq 'latex-fragment (org-element-type context))
|
|
|
|
|
(memq 'latex-fragment (org-element-restriction context)))
|
|
|
|
|
(push
|
|
|
|
|
(list
|
|
|
|
|
(point)
|
|
|
|
|
"$ symbol potentially matching LaTeX fragment boundary. Consider using \\dollar entity.")
|
|
|
|
|
report)))
|
|
|
|
|
report)))
|
2023-05-13 10:38:56 +00:00
|
|
|
|
(defun org-lint-timestamp-syntax (ast)
|
|
|
|
|
"Report malformed timestamps.
|
|
|
|
|
AST is the buffer parse tree."
|
|
|
|
|
(org-element-map ast 'timestamp
|
|
|
|
|
(lambda (timestamp)
|
|
|
|
|
(let ((expected (org-element-interpret-data timestamp))
|
|
|
|
|
(actual (buffer-substring-no-properties
|
|
|
|
|
(org-element-property :begin timestamp)
|
|
|
|
|
(org-element-property :end timestamp))))
|
|
|
|
|
(unless (equal expected actual)
|
2023-05-13 10:42:05 +00:00
|
|
|
|
(list (org-element-property :begin timestamp)
|
2023-05-13 10:38:56 +00:00
|
|
|
|
(format "Potentially malformed timestamp. Recognized: %s" expected)))))))
|
2021-12-01 15:09:13 +00:00
|
|
|
|
|
|
|
|
|
;;; Checkers declaration
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'duplicate-custom-id
|
|
|
|
|
"Report duplicates CUSTOM_ID properties"
|
|
|
|
|
#'org-lint-duplicate-custom-id
|
|
|
|
|
:categories '(link))
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'duplicate-name
|
|
|
|
|
"Report duplicate NAME values"
|
|
|
|
|
#'org-lint-duplicate-name
|
|
|
|
|
:categories '(babel 'link))
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'duplicate-target
|
|
|
|
|
"Report duplicate targets"
|
|
|
|
|
#'org-lint-duplicate-target
|
|
|
|
|
:categories '(link))
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'duplicate-footnote-definition
|
|
|
|
|
"Report duplicate footnote definitions"
|
|
|
|
|
#'org-lint-duplicate-footnote-definition
|
|
|
|
|
:categories '(footnote))
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'orphaned-affiliated-keywords
|
|
|
|
|
"Report orphaned affiliated keywords"
|
|
|
|
|
#'org-lint-orphaned-affiliated-keywords
|
|
|
|
|
:trust 'low)
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'obsolete-affiliated-keywords
|
|
|
|
|
"Report obsolete affiliated keywords"
|
|
|
|
|
#'org-lint-obsolete-affiliated-keywords
|
|
|
|
|
:categories '(obsolete))
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'deprecated-export-blocks
|
|
|
|
|
"Report deprecated export block syntax"
|
|
|
|
|
#'org-lint-deprecated-export-blocks
|
|
|
|
|
:trust 'low :categories '(obsolete export))
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'deprecated-header-syntax
|
|
|
|
|
"Report deprecated Babel header syntax"
|
|
|
|
|
#'org-lint-deprecated-header-syntax
|
|
|
|
|
:trust 'low :categories '(obsolete babel))
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'missing-language-in-src-block
|
|
|
|
|
"Report missing language in source blocks"
|
|
|
|
|
#'org-lint-missing-language-in-src-block
|
|
|
|
|
:categories '(babel))
|
|
|
|
|
|
2023-05-31 08:40:47 +00:00
|
|
|
|
(org-lint-add-checker 'suspicious-language-in-src-block
|
|
|
|
|
"Report suspicious language in source blocks"
|
|
|
|
|
#'org-lint-suspicious-language-in-src-block
|
|
|
|
|
:trust 'low :categories '(babel))
|
|
|
|
|
|
2021-12-01 15:09:13 +00:00
|
|
|
|
(org-lint-add-checker 'missing-backend-in-export-block
|
2023-04-20 12:11:19 +00:00
|
|
|
|
"Report missing backend in export blocks"
|
2021-12-01 15:09:13 +00:00
|
|
|
|
#'org-lint-missing-backend-in-export-block
|
|
|
|
|
:categories '(export))
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'invalid-babel-call-block
|
|
|
|
|
"Report invalid Babel call blocks"
|
|
|
|
|
#'org-lint-invalid-babel-call-block
|
|
|
|
|
:categories '(babel))
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'colon-in-name
|
|
|
|
|
"Report NAME values with a colon"
|
|
|
|
|
#'org-lint-colon-in-name
|
|
|
|
|
:categories '(babel))
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'wrong-header-argument
|
|
|
|
|
"Report wrong babel headers"
|
|
|
|
|
#'org-lint-wrong-header-argument
|
|
|
|
|
:categories '(babel))
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'wrong-header-value
|
|
|
|
|
"Report invalid value in babel headers"
|
|
|
|
|
#'org-lint-wrong-header-value
|
|
|
|
|
:categories '(babel) :trust 'low)
|
|
|
|
|
|
2023-04-24 12:01:12 +00:00
|
|
|
|
(org-lint-add-checker 'empty-header-argument
|
|
|
|
|
"Report empty values in babel headers"
|
|
|
|
|
#'org-lint-empty-header-argument
|
|
|
|
|
:categories '(babel) :trust 'low)
|
|
|
|
|
|
2021-12-01 15:09:13 +00:00
|
|
|
|
(org-lint-add-checker 'deprecated-category-setup
|
|
|
|
|
"Report misuse of CATEGORY keyword"
|
|
|
|
|
#'org-lint-deprecated-category-setup
|
|
|
|
|
:categories '(obsolete))
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'invalid-coderef-link
|
|
|
|
|
"Report \"coderef\" links with unknown destination"
|
|
|
|
|
#'org-lint-invalid-coderef-link
|
|
|
|
|
:categories '(link))
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'invalid-custom-id-link
|
|
|
|
|
"Report \"custom-id\" links with unknown destination"
|
|
|
|
|
#'org-lint-invalid-custom-id-link
|
|
|
|
|
:categories '(link))
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'invalid-fuzzy-link
|
|
|
|
|
"Report \"fuzzy\" links with unknown destination"
|
|
|
|
|
#'org-lint-invalid-fuzzy-link
|
|
|
|
|
:categories '(link))
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'invalid-id-link
|
|
|
|
|
"Report \"id\" links with unknown destination"
|
|
|
|
|
#'org-lint-invalid-id-link
|
|
|
|
|
:categories '(link))
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'link-to-local-file
|
|
|
|
|
"Report links to non-existent local files"
|
|
|
|
|
#'org-lint-link-to-local-file
|
|
|
|
|
:categories '(link) :trust 'low)
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'non-existent-setupfile-parameter
|
|
|
|
|
"Report SETUPFILE keywords with non-existent file parameter"
|
|
|
|
|
#'org-lint-non-existent-setupfile-parameter
|
|
|
|
|
:trust 'low)
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'wrong-include-link-parameter
|
|
|
|
|
"Report INCLUDE keywords with misleading link parameter"
|
|
|
|
|
#'org-lint-wrong-include-link-parameter
|
|
|
|
|
:categories '(export) :trust 'low)
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'obsolete-include-markup
|
|
|
|
|
"Report obsolete markup in INCLUDE keyword"
|
|
|
|
|
#'org-lint-obsolete-include-markup
|
|
|
|
|
:categories '(obsolete export) :trust 'low)
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'unknown-options-item
|
|
|
|
|
"Report unknown items in OPTIONS keyword"
|
|
|
|
|
#'org-lint-unknown-options-item
|
|
|
|
|
:categories '(export) :trust 'low)
|
|
|
|
|
|
2023-06-17 12:07:02 +00:00
|
|
|
|
(org-lint-add-checker 'misspelled-export-option
|
|
|
|
|
"Report potentially misspelled export options in properties."
|
|
|
|
|
#'org-lint-export-option-keywords
|
|
|
|
|
:categories '(export) :trust 'low)
|
|
|
|
|
|
2021-12-01 15:09:13 +00:00
|
|
|
|
(org-lint-add-checker 'invalid-macro-argument-and-template
|
|
|
|
|
"Report spurious macro arguments or invalid macro templates"
|
|
|
|
|
#'org-lint-invalid-macro-argument-and-template
|
|
|
|
|
:categories '(export) :trust 'low)
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'special-property-in-properties-drawer
|
|
|
|
|
"Report special properties in properties drawers"
|
|
|
|
|
#'org-lint-special-property-in-properties-drawer
|
|
|
|
|
:categories '(properties))
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'obsolete-properties-drawer
|
|
|
|
|
"Report obsolete syntax for properties drawers"
|
|
|
|
|
#'org-lint-obsolete-properties-drawer
|
|
|
|
|
:categories '(obsolete properties))
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'invalid-effort-property
|
|
|
|
|
"Report invalid duration in EFFORT property"
|
|
|
|
|
#'org-lint-invalid-effort-property
|
|
|
|
|
:categories '(properties))
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'undefined-footnote-reference
|
|
|
|
|
"Report missing definition for footnote references"
|
|
|
|
|
#'org-lint-undefined-footnote-reference
|
|
|
|
|
:categories '(footnote))
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'unreferenced-footnote-definition
|
|
|
|
|
"Report missing reference for footnote definitions"
|
|
|
|
|
#'org-lint-unreferenced-footnote-definition
|
|
|
|
|
:categories '(footnote))
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'extraneous-element-in-footnote-section
|
|
|
|
|
"Report non-footnote definitions in footnote section"
|
|
|
|
|
#'org-lint-extraneous-element-in-footnote-section
|
|
|
|
|
:categories '(footnote))
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'invalid-keyword-syntax
|
|
|
|
|
"Report probable invalid keywords"
|
|
|
|
|
#'org-lint-invalid-keyword-syntax
|
|
|
|
|
:trust 'low)
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'invalid-block
|
|
|
|
|
"Report invalid blocks"
|
|
|
|
|
#'org-lint-invalid-block
|
|
|
|
|
:trust 'low)
|
|
|
|
|
|
2023-06-11 14:50:20 +00:00
|
|
|
|
(org-lint-add-checker 'mismatched-planning-repeaters
|
|
|
|
|
"Report mismatched repeaters in planning info line"
|
|
|
|
|
#'org-lint-mismatched-planning-repeaters
|
|
|
|
|
:trust 'low)
|
|
|
|
|
|
2021-12-01 15:09:13 +00:00
|
|
|
|
(org-lint-add-checker 'misplaced-planning-info
|
|
|
|
|
"Report misplaced planning info line"
|
|
|
|
|
#'org-lint-misplaced-planning-info
|
|
|
|
|
:trust 'low)
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'incomplete-drawer
|
|
|
|
|
"Report probable incomplete drawers"
|
|
|
|
|
#'org-lint-incomplete-drawer
|
|
|
|
|
:trust 'low)
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'indented-diary-sexp
|
|
|
|
|
"Report probable indented diary-sexps"
|
|
|
|
|
#'org-lint-indented-diary-sexp
|
|
|
|
|
:trust 'low)
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'quote-section
|
|
|
|
|
"Report obsolete QUOTE section"
|
|
|
|
|
#'org-lint-quote-section
|
|
|
|
|
:categories '(obsolete) :trust 'low)
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'file-application
|
|
|
|
|
"Report obsolete \"file+application\" link"
|
|
|
|
|
#'org-lint-file-application
|
|
|
|
|
:categories '(link obsolete))
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'percent-encoding-link-escape
|
|
|
|
|
"Report obsolete escape syntax in links"
|
|
|
|
|
#'org-lint-percent-encoding-link-escape
|
|
|
|
|
:categories '(link obsolete) :trust 'low)
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'spurious-colons
|
|
|
|
|
"Report spurious colons in tags"
|
|
|
|
|
#'org-lint-spurious-colons
|
|
|
|
|
:categories '(tags))
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'non-existent-bibliography
|
|
|
|
|
"Report invalid bibliography file"
|
|
|
|
|
#'org-lint-non-existent-bibliography
|
|
|
|
|
:categories '(cite))
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'missing-print-bibliography
|
|
|
|
|
"Report missing \"print_bibliography\" keyword"
|
|
|
|
|
#'org-lint-missing-print-bibliography
|
|
|
|
|
:categories '(cite))
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'invalid-cite-export-declaration
|
|
|
|
|
"Report invalid value for \"cite_export\" keyword"
|
|
|
|
|
#'org-lint-invalid-cite-export-declaration
|
|
|
|
|
:categories '(cite))
|
|
|
|
|
|
|
|
|
|
(org-lint-add-checker 'incomplete-citation
|
|
|
|
|
"Report incomplete citation object"
|
|
|
|
|
#'org-lint-incomplete-citation
|
|
|
|
|
:categories '(cite) :trust 'low)
|
|
|
|
|
|
2023-04-04 10:05:03 +00:00
|
|
|
|
(org-lint-add-checker 'item-number
|
|
|
|
|
"Report inconsistent item numbers in lists"
|
|
|
|
|
#'org-lint-item-number
|
|
|
|
|
:categories '(plain-list))
|
|
|
|
|
|
2023-03-22 12:35:22 +00:00
|
|
|
|
(org-lint-add-checker 'LaTeX-$
|
|
|
|
|
"Report potentially confusing $...$ LaTeX markup."
|
|
|
|
|
#'org-lint-LaTeX-$
|
|
|
|
|
:categories '(markup))
|
2023-07-01 10:01:40 +00:00
|
|
|
|
(org-lint-add-checker 'LaTeX-$
|
|
|
|
|
"Report $ that might be treated as LaTeX fragment boundary."
|
|
|
|
|
#'org-lint-LaTeX-$-ambiguous
|
|
|
|
|
:categories '(markup) :trust 'low)
|
2023-05-13 10:38:56 +00:00
|
|
|
|
(org-lint-add-checker 'timestamp-syntax
|
|
|
|
|
"Report malformed timestamps."
|
|
|
|
|
#'org-lint-timestamp-syntax
|
|
|
|
|
:categories '(timestamp) :trust 'low)
|
2023-03-22 12:35:22 +00:00
|
|
|
|
|
2015-04-15 20:24:15 +00:00
|
|
|
|
(provide 'org-lint)
|
2020-02-18 21:57:37 +00:00
|
|
|
|
|
2020-02-18 22:37:24 +00:00
|
|
|
|
;; Local variables:
|
|
|
|
|
;; generated-autoload-file: "org-loaddefs.el"
|
|
|
|
|
;; End:
|
|
|
|
|
|
2015-04-15 20:24:15 +00:00
|
|
|
|
;;; org-lint.el ends here
|