emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/org a8a0a45d24 2/3: lisp/org-lint.el (misplaced-heading


From: ELPA Syncer
Subject: [elpa] externals/org a8a0a45d24 2/3: lisp/org-lint.el (misplaced-heading): New linter
Date: Thu, 7 Dec 2023 09:58:31 -0500 (EST)

branch: externals/org
commit a8a0a45d241d72e174bb72304b25425f7f874c22
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>

    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.
---
 lisp/org-lint.el | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/lisp/org-lint.el b/lisp/org-lint.el
index 5114902942..3f49ca75f6 100644
--- a/lisp/org-lint.el
+++ b/lisp/org-lint.el
@@ -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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]