branch: externals/org commit 22984a940057dcc70af9a10fc7da7785c0463723 Author: Ihor Radchenko <yanta...@posteo.net> Commit: Ihor Radchenko <yanta...@posteo.net>
org-element-fixed-width-parser: Fix :post-blank property * lisp/org-element.el (org-element-fixed-width-parser): Fix :post-blank parsed as 1 when it should be 0. * testing/lisp/test-org-element.el (test-org-element/fixed-width-parser): Add test. Reported-by: chris <inkbottle...@gmail.com> Link: https://orgmode.org/list/5322763.GXAFRqVoOG@nixos --- lisp/org-element.el | 4 +++- testing/lisp/test-org-element.el | 11 ++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lisp/org-element.el b/lisp/org-element.el index fec90c45fa..dd7ee6b24a 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -2652,11 +2652,13 @@ Assume point is at the beginning of the fixed-width area." (save-excursion (let* ((begin (car affiliated)) (post-affiliated (point)) + pos-before-blank (end-area (progn (while (and (< (point) limit) (looking-at-p "[ \t]*:\\( \\|$\\)")) (forward-line)) + (setq pos-before-blank (point)) (if (bolp) (line-end-position 0) (point)))) (end (progn (skip-chars-forward " \r\t\n" limit) (if (eobp) (point) (line-beginning-position))))) @@ -2669,7 +2671,7 @@ Assume point is at the beginning of the fixed-width area." "^[ \t]*: ?" "" (buffer-substring-no-properties post-affiliated end-area)) - :post-blank (count-lines end-area end) + :post-blank (count-lines pos-before-blank end) :post-affiliated post-affiliated) (cdr affiliated)))))) diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el index 7c4b928119..e36057f5b4 100644 --- a/testing/lisp/test-org-element.el +++ b/testing/lisp/test-org-element.el @@ -1607,7 +1607,16 @@ CLOCK: [2023-10-13 Fri 14:40]--[2023-10-13 Fri 14:51] => 0:11" (should (org-test-with-temp-text ": A\n " (= (org-element-property :end (org-element-at-point)) - (point-max))))) + (point-max)))) + ;; Correctly parse post-blank + (should + (org-test-with-temp-text ": A\n " + (= (org-element-property :post-blank (org-element-at-point)) + 1))) + (should + (org-test-with-temp-text ": A\nB" + (= (org-element-property :post-blank (org-element-at-point)) + 0)))) ;;;; Footnote Definition