Re: [O] [ANN] Changes to link syntax
stardiviner writes: > After finished this upgrading, I will write a blog post about this for > helping user migration. As I said, I wrote a simple blog post about how to upgrade to new link syntax. https://stardiviner.github.io/Blog/upgrade-Org-link-syntax-to-new.html -- [ 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
Re: [O] [ANN] Changes to link syntax
Hello, stardiviner writes: > I found a simple and better solution to replace those. I use =rg (ripgrep)= to > search you mentioned escape characters "%20 %25 %5B %5D". I then use =wgrep= > on > results. I spend pretty long time to processing all links. There are about > 4 > links matched. And about 2 links processed. Still there are some links > matched but not process (or ignored) by your upper function. > > Here I picked some typical cases: > > #+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]] > > - [ ] > [[file:Data/Books/%E7%89%9B%E6%B4%A5%E9%80%9A%E8%AF%86%E8%AF%BB%E6%9C%AC:%20%E7%A7%91%E5%AD%A6%E5%93%B2%E5%AD%A6.azw3][牛津通识读本: > 科学哲学 (azw3)]] -- by 萨米尔·奥卡沙 > > [[file:~/Org/Wiki/Computer%20Technology/Programming/Data%20Structure/Data/Books/%E5%A4%A7%E8%AF%9D%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84.pdf::%25PDF-1.4][数据结构起源 > -- 《大话数据结构》]] > > [[file:~/Org/Wiki/Computer Technology/Programming/Emacs/Data/Emacs > Packages/Org mode/Org mode.org::*Write Online Book of Programming Data > Structures and Algorithms][Write Online Book of Programming Data Structures > and Algorithms]] > > - > [[file:Data/Videos/%E8%B5%8C%E5%8D%9A%E9%BB%98%E7%A4%BA%E5%BD%95/%5B%E8%B5%8C%E5%8D%9A%E9%BB%98%E7%A4%BA%E5%BD%95%5D%20Ultimate_Survivor_Kaiji%20-%2015.rmvb][Ultimate > Survivor Kaiji 15]] > #+end_src I added a less conservative function in ORG-NEWS. You may want to try it. Regards, -- Nicolas Goaziou
Re: [O] [ANN] Changes to link syntax
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 found a simple and better solution to replace those. I use =rg (ripgrep)= to search you mentioned escape characters "%20 %25 %5B %5D". I then use =wgrep= on results. I spend pretty long time to processing all links. There are about 4 links matched. And about 2 links processed. Still there are some links matched but not process (or ignored) by your upper function. Here I picked some typical cases: #+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]] - [ ] [[file:Data/Books/%E7%89%9B%E6%B4%A5%E9%80%9A%E8%AF%86%E8%AF%BB%E6%9C%AC:%20%E7%A7%91%E5%AD%A6%E5%93%B2%E5%AD%A6.azw3][牛津通识读本: 科学哲学 (azw3)]] -- by 萨米尔·奥卡沙 [[file:~/Org/Wiki/Computer%20Technology/Programming/Data%20Structure/Data/Books/%E5%A4%A7%E8%AF%9D%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84.pdf::%25PDF-1.4][数据结构起源 -- 《大话数据结构》]] [[file:~/Org/Wiki/Computer Technology/Programming/Emacs/Data/Emacs Packages/Org mode/Org mode.org::*Write Online Book of Programming Data Structures and Algorithms][Write Online Book of Programming Data Structures and Algorithms]] - [[file:Data/Videos/%E8%B5%8C%E5%8D%9A%E9%BB%98%E7%A4%BA%E5%BD%95/%5B%E8%B5%8C%E5%8D%9A%E9%BB%98%E7%A4%BA%E5%BD%95%5D%20Ultimate_Survivor_Kaiji%20-%2015.rmvb][Ultimate Survivor Kaiji 15]] #+end_src After finished this upgrading, I will write a blog post about this for helping user migration. -- [ 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
Re: [O] [ANN] Changes to link syntax
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
Re: [O] [ANN] Changes to link syntax
Nicolas Goaziou writes: > Hello, > > stardiviner writes: > >> So I have to consider a safer and larger method to upgrade link. I can't >> manually open every Org files and run linter on them. > > I already offered a function for replacing it in a file. You can wrap it > within a `dolist' on `directory-files-recursively'. Hmm, I will randomly copy some files on my disk to do a separate test out. > >> (Maybe linter can run on Org files automatically in programtically >> way?) > > When not called interactively, it returns a non-nil value if any error > is found. And you can call it on a limited set of checkers. Though, > I think the function I provided is better. I see. you're right. > >> Seems I can wait for better solution now. > > I don't see any other solution. Hm.. Let me go back to check out your commit. So that I can settle my heart down. :) > > Regards, -- [ 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
Re: [O] [ANN] Changes to link syntax
Hello, stardiviner writes: > So I have to consider a safer and larger method to upgrade link. I can't > manually open every Org files and run linter on them. I already offered a function for replacing it in a file. You can wrap it within a `dolist' on `directory-files-recursively'. > (Maybe linter can run on Org files automatically in programtically > way?) When not called interactively, it returns a non-nil value if any error is found. And you can call it on a limited set of checkers. Though, I think the function I provided is better. > Seems I can wait for better solution now. I don't see any other solution. Regards, -- Nicolas Goaziou
Re: [O] [ANN] Changes to link syntax
Nicolas Goaziou writes: > Hello, > > stardiviner writes: > >> Hi, @Nicolas, will you release a method to update all existing Org >> file links? > > This is not limited to file links. > > There is no method that can, with certainty, convert old syntax into the > new one. More accurately, it is possible to convert them with: > > (org-link-escape (org-link-decode URI)) > > but in some cases, it may be difficult to tell when the URI should be > decoded in the first place. > > I suggest to first try the linter on a document. Once we know it detects > with a good ratio links to convert, we can write a wrapper to also > convert them. I agree, but I have so many Org files. #+begin_src sh :async find ~/Org/ -iname "*.org" -print | wc -l #+end_src #+RESULTS[<2019-03-16 16:34:21> d5afbee25c7529c23db70bb758b4bb1e7bdad9a3]: : 9872 So I have to consider a safer and larger method to upgrade link. I can't manually open every Org files and run linter on them. (Maybe linter can run on Org files automatically in programtically way?) Seems I can wait for better solution now. > >> I don't know which special escaped characters need to be converted. > > %20, %25, %5B and %5D. This is helpful, I will try to use external command-line tools to search and replace them. Like ripgrep.el wapper, etc. Then use wgrep mode to query-replace. This might be more safely. I'm wandering whether is it possible to extract my Org links out for testing before I really apply upgrade solution on my mess Org files. Because once I applied method, I will lose original data. Of course I can backup all files. I did backup them regularly about 1 week repeatedly. Also this upgrade experience can help Org Mode figure out a flow about how to do backward compatibility broken steps. That will reduce other user's damage. :) Seems this will keep me spin on before new link syntax commit for a while. I always catch up the latest Org Mode code as I like it so much. > > Regards, Thanks for your working :) -- [ 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
Re: [O] [ANN] Changes to link syntax
Hello, stardiviner writes: > Hi, @Nicolas, will you release a method to update all existing Org > file links? This is not limited to file links. There is no method that can, with certainty, convert old syntax into the new one. More accurately, it is possible to convert them with: (org-link-escape (org-link-decode URI)) but in some cases, it may be difficult to tell when the URI should be decoded in the first place. I suggest to first try the linter on a document. Once we know it detects with a good ratio links to convert, we can write a wrapper to also convert them. > I don't know which special escaped characters need to be converted. %20, %25, %5B and %5D. Regards, -- Nicolas Goaziou
Re: [O] [ANN] Changes to link syntax
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)))
Re: [O] [ANN] Changes to link syntax
Nicolas Goaziou writes: > Hello, > > I finally pushed changed about escape syntax in bracket links. Here is > the excerpt from ORG-NEWS: > > Org used to percent-encode sensitive characters in the URI part of the > bracket links. > > Now, escaping mechanism uses the usual backslash character, according > to the following rules, applied in order: > > 1. All consecutive =\= characters at the end of the link must be >escaped; > 2. Any =]= character at the very end of the link must be escaped; > 3. Any =]= character followed by either =[= or =]= must be escaped; > 4. Other =]= and =\= characters need not be escaped. > > When in doubt, use the function ~org-link-escape~ in order to turn > a link string into its properly escaped form. > > The old ~org-link-escape~ and ~org-link-unescape~ functions have > been renamed into ~org-link-encode~ and ~org-link-decode~. > > I added a checker in "org-lint.el" to detect old percent-encoding escape > syntax in links. > > Internally, I also moved all link related code from "org.el" to "ol.el", > and renamed libraries defining a new link type with "ol-" prefix. (e.g. > "org-bbdb.el" to "ol-bbdb.el"), much like "ox-" prefix. > > Feedback is welcome. > > Regards, Hi, @Nicolas, will you release a method to update all existing Org file links? (Sorry for second time asking this, you have not mentioned it, so I asked again, it's important for me, or people who want to upgrade to new link syntax). I don't know which special escaped characters need to be converted. If someone already has command to do this. Can you share it? I'm still using a separate local branch which before this commit, so all my Org file links still can work temporarily. -- [ 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
Re: [O] [ANN] Changes to link syntax
Hello, Amin Bandali writes: > On 2019-03-10 1:02 PM, Samuel Wales wrote: >> the org capture firefox extensions, and similar extensions, or >> org-protocol, might need changing. >> >> > > [...] > > Also seems like there are a couple more internal Org functions that need > changing: when opening a new empty org file using latest Org master, I > get the following error: > > File mode specification error: (void-function org-element-restriction) > > Also, calling org-insert-last-stored-link seems to cause error(s) like > this one: > > Error during redisplay: (jit-lock-function 1) signaled (void-function > org-element-link-parser) Fixed. Thank you. This was unrelated to link syntax change, tho. Regards, -- Nicolas Goaziou
Re: [O] [ANN] Changes to link syntax
Thanks! It works again :) On Tue, Mar 12, 2019 at 12:07 AM Nicolas Goaziou wrote: > Hello, > > Diego Zamboni writes: > > > I can confirm this behavior. After updating to latest org from master and > > restarting Emacs, my documents now show the link destinations instead of > > their descriptions (nothing changed in my configuration). > > > > Best, > > --Diego > > > > > > On Mon, Mar 11, 2019 at 6:52 PM Marco Wahl > wrote: > > > >> Hi Nicolas and all, > >> > >> Is it just me or does > >> > >> [[https://duckduckgo.com][DDG]] > >> > >> show up now as > >> > >> https://duckduckgo.com > >> > >> with `org-link-descriptive' set to t? > >> > >> I would instead expect > >> > >> DDG > >> > >> to appear. Wild guess: this is an issue in `org-activate-links'? > > Oops. Fixed. Thank you. > > Regards, > > -- > Nicolas Goaziou >
Re: [O] [ANN] Changes to link syntax
Hello, Diego Zamboni writes: > I can confirm this behavior. After updating to latest org from master and > restarting Emacs, my documents now show the link destinations instead of > their descriptions (nothing changed in my configuration). > > Best, > --Diego > > > On Mon, Mar 11, 2019 at 6:52 PM Marco Wahl wrote: > >> Hi Nicolas and all, >> >> Is it just me or does >> >> [[https://duckduckgo.com][DDG]] >> >> show up now as >> >> https://duckduckgo.com >> >> with `org-link-descriptive' set to t? >> >> I would instead expect >> >> DDG >> >> to appear. Wild guess: this is an issue in `org-activate-links'? Oops. Fixed. Thank you. Regards, -- Nicolas Goaziou
Re: [O] [ANN] Changes to link syntax
I can confirm this behavior. After updating to latest org from master and restarting Emacs, my documents now show the link destinations instead of their descriptions (nothing changed in my configuration). Best, --Diego On Mon, Mar 11, 2019 at 6:52 PM Marco Wahl wrote: > Hi Nicolas and all, > > Is it just me or does > > [[https://duckduckgo.com][DDG]] > > show up now as > > https://duckduckgo.com > > with `org-link-descriptive' set to t? > > I would instead expect > > DDG > > to appear. Wild guess: this is an issue in `org-activate-links'? > > > Ciao > -- > Marco > >
Re: [O] [ANN] Changes to link syntax
Hi Nicolas and all, Is it just me or does [[https://duckduckgo.com][DDG]] show up now as https://duckduckgo.com with `org-link-descriptive' set to t? I would instead expect DDG to appear. Wild guess: this is an issue in `org-activate-links'? Ciao -- Marco
Re: [O] [ANN] Changes to link syntax
On 11-03-2019 10:35, Nicolas Goaziou wrote: > Hello, > > Daniele Nicolodi writes: > >> On 10/03/2019 11:19, Nicolas Goaziou wrote: >>> When in doubt, use the function ~org-link-escape~ in order to turn >>> a link string into its properly escaped form. >>> >>> The old ~org-link-escape~ and ~org-link-unescape~ functions have >>> been renamed into ~org-link-encode~ and ~org-link-decode~. >> >> Aren't those two sentences slightly contradictory? If ~org-link-escape~ >> has been renamed ~org-link-encode~ I think that the later should be >> mentioned in the first sentence. > > The first paragraph is about the new `org-link-escape'. The second one > is about the old `org-link-escape', which has become `org-link-encode'. > Is that clearer? I may have understood what you mean now. At the first read I understood that org-link-escape should be used to turn strings into link form, and that it has been renamed into org-link-encode, thus the function that should be used to turn strings into valid links is org-link-encode. What you meant is that the old org-link-escape is now org-link-encode and a new function with the same name has been introduced. Cheers, Dan
Re: [O] [ANN] Changes to link syntax
Hello Nicolas, With the new syntax, are link descriptions meant to be displayed instead of the actual links? I only seem to have the actual links displayed. Have I missed some setting? Thanks, eric -- Eric S Fraga via Emacs 27.0.50, Org release_9.2.2-286-gc020e9
Re: [O] [ANN] Changes to link syntax
Hello, Daniele Nicolodi writes: > On 10/03/2019 11:19, Nicolas Goaziou wrote: >> When in doubt, use the function ~org-link-escape~ in order to turn >> a link string into its properly escaped form. >> >> The old ~org-link-escape~ and ~org-link-unescape~ functions have >> been renamed into ~org-link-encode~ and ~org-link-decode~. > > Aren't those two sentences slightly contradictory? If ~org-link-escape~ > has been renamed ~org-link-encode~ I think that the later should be > mentioned in the first sentence. The first paragraph is about the new `org-link-escape'. The second one is about the old `org-link-escape', which has become `org-link-encode'. Is that clearer? Regards, -- Nicolas Goaziou
Re: [O] [ANN] Changes to link syntax
On 10/03/2019 11:19, Nicolas Goaziou wrote: > When in doubt, use the function ~org-link-escape~ in order to turn > a link string into its properly escaped form. > > The old ~org-link-escape~ and ~org-link-unescape~ functions have > been renamed into ~org-link-encode~ and ~org-link-decode~. Aren't those two sentences slightly contradictory? If ~org-link-escape~ has been renamed ~org-link-encode~ I think that the later should be mentioned in the first sentence. Cheers, Dan
Re: [O] [ANN] Changes to link syntax
On 2019-03-10 1:02 PM, Samuel Wales wrote: > the org capture firefox extensions, and similar extensions, or > org-protocol, might need changing. > > [...] Also seems like there are a couple more internal Org functions that need changing: when opening a new empty org file using latest Org master, I get the following error: File mode specification error: (void-function org-element-restriction) Also, calling org-insert-last-stored-link seems to cause error(s) like this one: Error during redisplay: (jit-lock-function 1) signaled (void-function org-element-link-parser) Best, -- Amin Bandali https://aminb.org
Re: [O] [ANN] Changes to link syntax
the org capture firefox extensions, and similar extensions, or org-protocol, might need changing. On 3/10/19, Nicolas Goaziou wrote: > Hello, > > I finally pushed changed about escape syntax in bracket links. Here is > the excerpt from ORG-NEWS: > > Org used to percent-encode sensitive characters in the URI part of the > bracket links. > > Now, escaping mechanism uses the usual backslash character, according > to the following rules, applied in order: > > 1. All consecutive =\= characters at the end of the link must be >escaped; > 2. Any =]= character at the very end of the link must be escaped; > 3. Any =]= character followed by either =[= or =]= must be escaped; > 4. Other =]= and =\= characters need not be escaped. > > When in doubt, use the function ~org-link-escape~ in order to turn > a link string into its properly escaped form. > > The old ~org-link-escape~ and ~org-link-unescape~ functions have > been renamed into ~org-link-encode~ and ~org-link-decode~. > > I added a checker in "org-lint.el" to detect old percent-encoding escape > syntax in links. > > Internally, I also moved all link related code from "org.el" to "ol.el", > and renamed libraries defining a new link type with "ol-" prefix. (e.g. > "org-bbdb.el" to "ol-bbdb.el"), much like "ox-" prefix. > > Feedback is welcome. > > Regards, > > -- > Nicolas Goaziou > > -- The Kafka Pandemic What is misopathy? https://thekafkapandemic.blogspot.com/2013/10/why-some-diseases-are-wronged.html The disease DOES progress. MANY people have died from it. And ANYBODY can get it at any time.