From c60e41ea194992aaa350f5e02237a0736f11cdc0 Mon Sep 17 00:00:00 2001 From: Chris Barrett Date: Wed, 5 Oct 2022 22:22:19 +1300 Subject: [PATCH] Use builtin blank line deletion command --- lisp/org-format.el | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lisp/org-format.el b/lisp/org-format.el index 448248a..c319880 100644 --- a/lisp/org-format.el +++ b/lisp/org-format.el @@ -54,12 +54,6 @@ Only applies to level-1 headings in the document." - -(defun org-format--delete-empty-lines () - (goto-char (line-beginning-position)) - (while (thing-at-point-looking-at (rx bol (* space) eol)) - (delete-region (line-beginning-position) (1+ (line-end-position))))) - (defun org-format--ensure-empty-lines (n) (save-excursion (goto-char (line-beginning-position)) @@ -106,15 +100,19 @@ Only applies to level-1 headings in the document." (unless (and (fboundp 'org-transclusion-within-transclusion-p) (org-transclusion-within-transclusion-p)) (forward-line 1) - (org-format--delete-empty-lines) + (delete-blank-lines) (org-format--ensure-empty-lines org-format-blank-lines-before-meta) (org-end-of-meta-data t) (org-format--ensure-empty-lines org-format-blank-lines-before-content))) t scope) - ;; Format transcluded headings as if they were really there. (org-with-wide-buffer + ;; Clean up trailing whitespace. + (goto-char (point-max)) + (delete-blank-lines) + + ;; Format transcluded headings as if they were really there. (goto-char (point-min)) (while (search-forward-regexp (rx bol "#+transclude:") nil t) (save-excursion