mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-11-24 07:20:29 +00:00
lisp/org-lint.el (misplaced-heading): New linter
* lisp/org-lint.el (org-lint-misplaced-heading): Add new linter function to detect heading lines accidentally merged with the line above.
This commit is contained in:
parent
6003637a4d
commit
a8a0a45d24
@ -386,6 +386,17 @@ called with one argument, the key used for comparison."
|
||||
(t (push (cons key (funcall extract-position datum key)) keys))))))
|
||||
(dolist (e originals reports) (funcall make-report (cdr e) (car e)))))
|
||||
|
||||
(defun org-lint-misplaced-heading (ast)
|
||||
"Check for accidentally misplaced heading lines."
|
||||
(org-with-point-at ast
|
||||
(goto-char (point-min))
|
||||
(let (result)
|
||||
;; Heuristics for 2+ level heading not at bol.
|
||||
(while (re-search-forward (rx (not (any "*\n\r ,")) ;; Not a bol; not escaped ,** heading; not " *** words"
|
||||
"*" (1+ "*") " ") nil t)
|
||||
(push (list (match-beginning 0) "Possibly misplaced heading line") result))
|
||||
result)))
|
||||
|
||||
(defun org-lint-duplicate-custom-id (ast)
|
||||
(org-lint--collect-duplicates
|
||||
ast
|
||||
@ -1452,6 +1463,10 @@ AST is the buffer parse tree."
|
||||
|
||||
;;; Checkers declaration
|
||||
|
||||
(org-lint-add-checker 'misplaced-heading
|
||||
"Report accidentally misplaced heading lines."
|
||||
#'org-lint-misplaced-heading :trust 'low)
|
||||
|
||||
(org-lint-add-checker 'duplicate-custom-id
|
||||
"Report duplicates CUSTOM_ID properties"
|
||||
#'org-lint-duplicate-custom-id
|
||||
|
Loading…
Reference in New Issue
Block a user