From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: [BUG] Recently master branch commit breaks open file: link Date: Mon, 24 Feb 2020 21:30:45 +0100 Message-ID: <87r1yj683u.fsf@gnu.org> References: <87o8tofq1b.fsf@gmail.com> <87lfosz8ai.fsf@gnu.org> <87lfosfave.fsf@gmail.com> <87zhd8mba7.fsf@gnu.org> <87imjwf2ee.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:46096) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6KNL-0004a4-H7 for emacs-orgmode@gnu.org; Mon, 24 Feb 2020 15:30:48 -0500 In-Reply-To: <87imjwf2ee.fsf@gmail.com> (stardiviner's message of "Mon, 24 Feb 2020 23:09:13 +0800") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane-mx.org@gnu.org Sender: "Emacs-orgmode" To: stardiviner Cc: Org Mode Hi Stardiviner, stardiviner 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