branch: externals/denote-org commit 03df0d9f3e3680f08a8953c6d3f4b680109d2c1d Author: Protesilaos Stavrou <i...@protesilaos.com> Commit: Protesilaos Stavrou <i...@protesilaos.com>
Make denote-org-dblock--get-file-contents-as-heading region deletion more robust --- denote-org.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/denote-org.el b/denote-org.el index 6a2c38edb9..5368f4971f 100644 --- a/denote-org.el +++ b/denote-org.el @@ -754,7 +754,10 @@ With optional ADD-LINKS, make the title link to the original file." (insert-file-contents file) (setq title (denote-org-dblock--extract-regexp (denote--title-key-regexp file-type))) (setq tags (denote-org-dblock--extract-regexp (denote--keywords-key-regexp file-type))) - (delete-region (1+ (re-search-forward "^$" nil :no-error 1)) beginning-of-contents) + (when-let* ((_ (re-search-forward "^$" nil :no-error 1)) + (match-end (+ (match-end 0) 1)) + (_ (>= (point-max) match-end))) + (delete-region match-end beginning-of-contents)) (goto-char beginning-of-contents) (when (and title tags) (if add-links