emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [BUG] Recently master branch commit breaks open file: link


From: Bastien
Subject: Re: [BUG] Recently master branch commit breaks open file: link
Date: Mon, 24 Feb 2020 21:30:45 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Hi Stardiviner,

stardiviner <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]