branch: externals/guess-language
commit 8c8a1616b6a7bc4c10942ee0a1b2591b98fcd493
Author: Titus von der Malsburg <malsb...@posteo.de>
Commit: Titus von der Malsburg <malsb...@posteo.de>

    Treat org lists as one paragraph.
    
    The default in org is that each list item is a paragraph but in many
    cases this won’t give us enough material to detect the language reliably.
---
 guess-language.el | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/guess-language.el b/guess-language.el
index ef2a1a9..a0c5a1e 100644
--- a/guess-language.el
+++ b/guess-language.el
@@ -153,14 +153,24 @@ Uses ISO 639-1 to identify languages.")
   "Uses whatever method for moving to the previous paragraph is
 most appropriate given the buffer mode."
   (if (eq major-mode 'org-mode)
-      (org-backward-paragraph)
+      ;; When in list, go to the beginning of the top-level list:
+      (if (org-in-item-p)
+          (progn
+            (while (org-in-item-p)
+              (org-beginning-of-item-list)
+              (forward-line -1))
+            (forward-line 1))
+        (org-backward-paragraph))
     (backward-paragraph)))
 
 (defun guess-language-forward-paragraph ()
   "Uses whatever method for moving to the previous paragraph is
 most appropriate given the buffer mode."
   (if (eq major-mode 'org-mode)
-      (org-forward-paragraph)
+      (if (org-in-item-p)
+          (while (org-in-item-p)
+            (org-end-of-item-list))
+        (org-forward-paragraph))
     (forward-paragraph)))
 
 (defun guess-language-region (beginning end)

Reply via email to