branch: externals/denote-org commit 8bc637f9fdfc453cbe2f89881a38d633708c8dbb Author: Protesilaos Stavrou <i...@protesilaos.com> Commit: Protesilaos Stavrou <i...@protesilaos.com>
Make denote-org-dblock--extract-regexp more robust --- denote-org.el | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/denote-org.el b/denote-org.el index 80f75f9fe5..6a2c38edb9 100644 --- a/denote-org.el +++ b/denote-org.el @@ -734,10 +734,11 @@ Used by `org-dblock-update' with PARAMS provided by the dynamic block." (defun denote-org-dblock--extract-regexp (regexp) "Extract REGEXP from the buffer and trim it of surrounding spaces." - (string-trim - (save-excursion - (re-search-forward regexp nil :no-error) - (buffer-substring-no-properties (match-end 0) (line-end-position))))) + (when-let* ((_ (save-excursion (re-search-forward regexp nil :no-error))) + (match-end (match-end 0)) + (line-end (line-end-position)) + (text (buffer-substring-no-properties match-end line-end))) + (string-trim text))) (defun denote-org-dblock--get-file-contents-as-heading (file add-links) "Insert the contents of Org FILE, formatting the #+title as a heading.