From 5d4314ce9e076a22edbcc8586fdb142baee07784 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Wed, 26 Feb 2020 16:34:00 +0100 Subject: [PATCH] ORG-NEWS: Improve suggested fix * etc/ORG-NEWS (Possibly broken internal file links: please check and fix): Improve code. Limit false positives. --- etc/ORG-NEWS | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 523f3fa51..17f3e6a36 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -37,11 +37,14 @@ Go through the buffer and ask for the replacement." (visible-mode 1) (save-excursion (goto-char (point-min)) - (while (re-search-forward - (format "\\[\\[\\*%s\\s-+" (regexp-opt org-todo-keywords-1 t)) - nil t) - (when (y-or-n-p "Fix link (remove TODO keyword)? ") - (replace-match "[[*")))) + (let ((regexp (format "\\[\\[\\*%s\\s-+" + (regexp-opt org-todo-keywords-1 t)))) + (while (re-search-forward regexp nil t) + (when (and (save-excursion + (goto-char (match-beginning 0)) + (looking-at-p org-link-bracket-re)) + (y-or-n-p "Fix link (remove TODO keyword)? ")) + (replace-match "[[*"))))) (visible-mode -1)) #+end_src