diff --git a/lisp/org-element.el b/lisp/org-element.el index eacdb6519..36141c02e 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -1609,8 +1609,7 @@ Assume point is at comment beginning." (point))) (end (progn (goto-char com-end) (skip-chars-forward " \r\t\n" limit) - (skip-chars-backward " \t") - (if (bolp) (point) (line-end-position))))) + (if (eobp) (point) (line-beginning-position))))) (list 'comment (nconc (list :begin begin diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el index e1fd7f4cd..a526c046d 100644 --- a/testing/lisp/test-org-element.el +++ b/testing/lisp/test-org-element.el @@ -360,15 +360,20 @@ Some other text (should (eq 1 (org-test-with-temp-text "#+keyword: value\n# comment\n#+keyword: value" - (length (org-element-map - (org-element-parse-buffer) 'comment 'identity))))) + (length (org-element-map (org-element-parse-buffer) 'comment + 'identity))))) (should (equal "comment" (org-test-with-temp-text "#+keyword: value\n# comment\n#+keyword: value" (org-element-property :value - (org-element-map - (org-element-parse-buffer) 'comment 'identity nil t)))))) + (org-element-map (org-element-parse-buffer) 'comment + 'identity nil t))))) + ;; Correctly handle non-empty blank lines at the end of buffer. + (should + (org-test-with-temp-text "# A\n " + (goto-char (org-element-property :end (org-element-at-point))) + (eobp)))) ;;;; Comment Block