Hi Stardiviner,
stardiviner <[email protected]> writes:
>> IMHO we may have several file links such as yours broken: Nicolas,
>> do you think the bugfix should be advertized in ORG-NEWS, along with
>> a helper function to fix file links (ie remove the TODO keyword and
>> priority cookies)?
>
> This broken update might need a little think.
>
> The new org-store-link does not include the TODO keyword. But what if user add
> keyword before, then later does not use it in Org Mode config. This TODO
> keyword
> will caused broken.
You can run something like this command in your org files, it will
prompt you for the fixed link:
(defun org-fix-links ()
"Fix ill-formatted internal links.
E.g. replace [[*TODO Headline][headline]] by [[*Headline][headline]].
Go through the buffer and ask for the replacement."
(interactive)
(visible-mode 1)
(save-excursion
(goto-char (point-min))
(while (re-search-forward org-link-any-re nil t)
(let* ((raw (match-string 2))
(desc (match-string 3))
fix new)
(when (and raw desc
(string-match-p
(concat "^\*" (regexp-opt org-todo-keywords-1)
"\\s-+\\(.+\\)$")
raw))
(setq new (replace-regexp-in-string
(concat (regexp-opt org-todo-keywords-1) "\\s-+")
"" raw))
(set-text-properties 0 (length new) nil new)
(setq fix (completing-read "Replace link at point by: "
nil nil nil new))
(replace-match (format "[[%s][%s]]" fix desc))))))
(visible-mode -1))
HTH,
--
Bastien