branch: externals/denote commit 47073aa2a031761982513fc6ad4ad51efb72ca8a Author: Protesilaos Stavrou <i...@protesilaos.com> Commit: Protesilaos Stavrou <i...@protesilaos.com>
Re-implement commit 36440d7 Sorry for the noise... The previous code was incomplete. --- denote-dired.el | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/denote-dired.el b/denote-dired.el index d990169ee4..b6649089a8 100644 --- a/denote-dired.el +++ b/denote-dired.el @@ -282,6 +282,9 @@ replace what isn't there." ;; Heuristic to check if this is one of our notes (string= (expand-file-name default-directory) (denote-directory))))) +;; FIXME 2022-07-25: We should make the underlying regular expressions +;; that `denote-retrieve--value-title' targets more refined, so that we +;; capture eveyrhing at once. (defun denote-dired--rewrite-front-matter (file title keywords) "Rewrite front matter of note after `denote-dired-rename-file'. The FILE, TITLE, and KEYWORDS are passed from the renaming @@ -297,16 +300,18 @@ appropriate." keywords (denote-dired--filetype-heuristics file)))) (with-current-buffer (find-file-noselect file) (when (y-or-n-p (format - "Replace front matter?\n-%s\n+%s\n\n-%s\n+%s" + "Replace front matter?\n-%s\n+%s\n\n-%s\n+%s?" (propertize old-title 'face 'error) (propertize new-title 'face 'success) (propertize old-keywords 'face 'error) (propertize new-keywords 'face 'success))) (save-excursion (goto-char (point-min)) + (re-search-forward denote-retrieve--title-front-matter-key-regexp nil t 1) (search-forward old-title nil t 1) (replace-match (concat "\\1" new-title) t) (goto-char (point-min)) + (re-search-forward denote-retrieve--keywords-front-matter-key-regexp nil t 1) (search-forward old-keywords nil t 1) (replace-match (concat "\\1" new-keywords) t)))))))