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

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

[elpa] externals/org 53c9d91d3c 2/2: org-element: Fix post-blank shared


From: ELPA Syncer
Subject: [elpa] externals/org 53c9d91d3c 2/2: org-element: Fix post-blank shared between items
Date: Tue, 22 Aug 2023 06:58:11 -0400 (EDT)

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

    org-element: Fix post-blank shared between items
    
    * lisp/org-element.el (org-element-item-parser): Do not parse beyond
    LIMIT - they may extend :post-blank beyond parent list contents.
    (org-element-plain-list-parser): Make sure that plain list always owns
    the trailing blank lines.
    (org-element-cache-version): Bump cache version.
    * testing/lisp/test-org-element.el (test-org-element/item-parser): Add
    test.
    
    Reported-by: Tom Alexander <tom@fizz.buzz>
    Link: 
https://orgmode.org/list/1c833eb8-c556-437b-ac5b-be360ebcc869@app.fastmail.com
---
 lisp/org-element.el              | 12 ++++++++----
 testing/lisp/test-org-element.el |  4 ++++
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/lisp/org-element.el b/lisp/org-element.el
index 3597b9d271..596de47f32 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -1518,8 +1518,8 @@ CONTENTS is the contents of inlinetask."
 
 ;;;; Item
 
-(defun org-element-item-parser (_ struct &optional raw-secondary-p)
-  "Parse an item.
+(defun org-element-item-parser (limit struct &optional raw-secondary-p)
+  "Parse an item up to LIMIT.
 
 STRUCT is the structure of the plain list.
 
@@ -1545,7 +1545,8 @@ Assume point is at the beginning of the item."
                             ((equal "[X]" box) 'on)
                             ((equal "[-]" box) 'trans))))
           (end (progn (goto-char (nth 6 (assq (point) struct)))
-                      (if (bolp) (point) (line-beginning-position 2))))
+                      (min limit
+                            (if (bolp) (point) (line-beginning-position 2)))))
           (pre-blank 0)
           (contents-begin
            (progn
@@ -1760,6 +1761,9 @@ Assume point is at the beginning of the list."
                                       (= (nth 1 item) ind))
                             (setq pos (nth 6 item)))
                           pos))
+           (contents-end (progn (goto-char contents-end)
+                                (skip-chars-backward " \r\t\n")
+                                (if (bolp) (point) (line-beginning-position 
2))))
           (end (progn (goto-char contents-end)
                       (skip-chars-forward " \r\t\n" limit)
                       (if (= (point) limit) limit (line-beginning-position)))))
@@ -5419,7 +5423,7 @@ indentation removed from its contents."
 (defvar org-element-cache-persistent t
   "Non-nil when cache should persist between Emacs sessions.")
 
-(defconst org-element-cache-version "2.1"
+(defconst org-element-cache-version "2.2"
   "Version number for Org AST structure.
 Used to avoid loading obsolete AST representation when using
 `org-element-cache-persistent'.")
diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el
index 92047bfd7e..8b3b5aebdd 100644
--- a/testing/lisp/test-org-element.el
+++ b/testing/lisp/test-org-element.el
@@ -2110,6 +2110,10 @@ DEADLINE: <2012-03-29 thu.>"
   (should
    (= 0
       (org-test-with-temp-text "- A\n\n  - B\n\n<point>  - C\n\n  End sub-list"
+       (org-element-property :post-blank (org-element-at-point)))))
+  (should
+   (= 0
+      (org-test-with-temp-text "1. foo\n   1. bar\n  2.<point>  baz\n\n2. 
lorem\nipsum"
        (org-element-property :post-blank (org-element-at-point))))))
 
 



reply via email to

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