From mboxrd@z Thu Jan 1 00:00:00 1970 From: stardiviner Subject: Re: [ANN] Changes to link syntax Date: Tue, 26 Mar 2019 17:08:06 +0800 Message-ID: <87k1gmrojt.fsf@gmail.com> References: <87sgvusl43.fsf@nicolasgoaziou.fr> <87h8c490eh.fsf@gmail.com> <87sgvotkrt.fsf@nicolasgoaziou.fr> Reply-To: numbchild@gmail.com Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([209.51.188.92]:40066) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h8i4C-0003qv-4m for emacs-orgmode@gnu.org; Tue, 26 Mar 2019 05:08:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h8i4A-0006oE-IB for emacs-orgmode@gnu.org; Tue, 26 Mar 2019 05:08:19 -0400 Received: from [61.175.244.13] (port=31881 helo=dark.localdomain) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h8i4A-0006iI-0V for emacs-orgmode@gnu.org; Tue, 26 Mar 2019 05:08:18 -0400 In-reply-to: <87sgvotkrt.fsf@nicolasgoaziou.fr> 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.org@gnu.org Sender: "Emacs-orgmode" To: Nicolas Goaziou Cc: emacs-orgmode@gnu.org Nicolas Goaziou writes: > stardiviner writes: > >> Hi, @Nicolas, will you release a method to update all existing Org >> file links? > > On second though, you may want to test the following: > > (defun org-update-link-syntax () > "Update syntax for links in current buffer." > (org-with-point-at 1 > (let ((case-fold-search t)) > (while (re-search-forward "\\[\\[[^]]*?%\\(?:2[05]\\|5[BD]\\)" nil t) > (let ((object (save-match-data (org-element-context)))) > (when (and (eq 'link (org-element-type object)) > (= (match-beginning 0) > (org-element-property :begin object))) > (goto-char (org-element-property :end object)) > (let* ((uri-start (+ 2 (match-beginning 0))) > (uri-end (save-excursion > (goto-char uri-start) > (re-search-forward "\\][][]" nil t) > (match-beginning 0))) > (uri (buffer-substring-no-properties uri-start uri-end)) > (start 0)) > (when (catch :obsolete > (while (string-match "%\\(..\\)?" uri start) > (setq start (match-end 0)) > (unless (member (match-string 1 uri) > '("25" "5B" "5D" "20")) > (throw :obsolete nil))) > (y-or-n-p > (format "Possibly obsolete URI syntax: %S. Update?" > uri))) > (setf (buffer-substring uri-start uri-end) > (org-link-escape (org-link-decode uri))))))))))) > I applied your function in my testing Org file. most links are updated. Except some links. I think this link is not detected. #+begin_src org [[file:~/Org/Wiki/Computer%20Technology/Softwares/%E9%9A%8F%E6%89%8B%E8%AE%B0.org::*Export%20through%20Web%20client][Export through Web client]] #+end_src Also, I might write a command to using your suggested ~dolist~ and ~directory-files-recursively~. -- [ stardiviner ] I try to make every word tell the meaning what I want to express. Blog: https://stardiviner.github.io/ IRC(freenode): stardiviner, Matrix: stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3