* [ANN] Changes to link syntax
@ 2019-03-10 17:19 Nicolas Goaziou
2019-03-10 20:02 ` Samuel Wales
` (3 more replies)
0 siblings, 4 replies; 22+ messages in thread
From: Nicolas Goaziou @ 2019-03-10 17:19 UTC (permalink / raw)
To: Org Mode List
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
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [ANN] Changes to link syntax
2019-03-10 17:19 [ANN] Changes to link syntax Nicolas Goaziou
@ 2019-03-10 20:02 ` Samuel Wales
2019-03-10 22:13 ` Amin Bandali
2019-03-10 23:00 ` Daniele Nicolodi
` (2 subsequent siblings)
3 siblings, 1 reply; 22+ messages in thread
From: Samuel Wales @ 2019-03-10 20:02 UTC (permalink / raw)
To: Org Mode List
the org capture firefox extensions, and similar extensions, or
org-protocol, might need changing.
On 3/10/19, Nicolas Goaziou <mail@nicolasgoaziou.fr> 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.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [ANN] Changes to link syntax
2019-03-10 20:02 ` Samuel Wales
@ 2019-03-10 22:13 ` Amin Bandali
2019-03-12 13:44 ` Nicolas Goaziou
0 siblings, 1 reply; 22+ messages in thread
From: Amin Bandali @ 2019-03-10 22:13 UTC (permalink / raw)
To: Org Mode List
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
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [ANN] Changes to link syntax
2019-03-10 22:13 ` Amin Bandali
@ 2019-03-12 13:44 ` Nicolas Goaziou
0 siblings, 0 replies; 22+ messages in thread
From: Nicolas Goaziou @ 2019-03-12 13:44 UTC (permalink / raw)
To: Amin Bandali; +Cc: Org Mode List
Hello,
Amin Bandali <bandali@gnu.org> 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
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [ANN] Changes to link syntax
2019-03-10 17:19 [ANN] Changes to link syntax Nicolas Goaziou
2019-03-10 20:02 ` Samuel Wales
@ 2019-03-10 23:00 ` Daniele Nicolodi
2019-03-11 16:35 ` Nicolas Goaziou
2019-03-11 17:27 ` Marco Wahl
2019-03-15 5:23 ` stardiviner
3 siblings, 1 reply; 22+ messages in thread
From: Daniele Nicolodi @ 2019-03-10 23:00 UTC (permalink / raw)
To: emacs-orgmode
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
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [ANN] Changes to link syntax
2019-03-10 23:00 ` Daniele Nicolodi
@ 2019-03-11 16:35 ` Nicolas Goaziou
2019-03-11 17:06 ` Eric S Fraga
2019-03-11 17:31 ` Daniele Nicolodi
0 siblings, 2 replies; 22+ messages in thread
From: Nicolas Goaziou @ 2019-03-11 16:35 UTC (permalink / raw)
To: Daniele Nicolodi; +Cc: emacs-orgmode
Hello,
Daniele Nicolodi <daniele@grinta.net> 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
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [ANN] Changes to link syntax
2019-03-11 16:35 ` Nicolas Goaziou
@ 2019-03-11 17:06 ` Eric S Fraga
2019-03-11 17:31 ` Daniele Nicolodi
1 sibling, 0 replies; 22+ messages in thread
From: Eric S Fraga @ 2019-03-11 17:06 UTC (permalink / raw)
To: Daniele Nicolodi; +Cc: emacs-orgmode
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
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [ANN] Changes to link syntax
2019-03-11 16:35 ` Nicolas Goaziou
2019-03-11 17:06 ` Eric S Fraga
@ 2019-03-11 17:31 ` Daniele Nicolodi
1 sibling, 0 replies; 22+ messages in thread
From: Daniele Nicolodi @ 2019-03-11 17:31 UTC (permalink / raw)
To: emacs-orgmode
On 11-03-2019 10:35, Nicolas Goaziou wrote:
> Hello,
>
> Daniele Nicolodi <daniele@grinta.net> 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
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [ANN] Changes to link syntax
2019-03-10 17:19 [ANN] Changes to link syntax Nicolas Goaziou
2019-03-10 20:02 ` Samuel Wales
2019-03-10 23:00 ` Daniele Nicolodi
@ 2019-03-11 17:27 ` Marco Wahl
2019-03-11 18:00 ` Diego Zamboni
2019-03-15 5:23 ` stardiviner
3 siblings, 1 reply; 22+ messages in thread
From: Marco Wahl @ 2019-03-11 17:27 UTC (permalink / raw)
To: Org Mode List, Nicolas Goaziou
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
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [ANN] Changes to link syntax
2019-03-11 17:27 ` Marco Wahl
@ 2019-03-11 18:00 ` Diego Zamboni
2019-03-11 23:07 ` Nicolas Goaziou
0 siblings, 1 reply; 22+ messages in thread
From: Diego Zamboni @ 2019-03-11 18:00 UTC (permalink / raw)
To: Marco Wahl; +Cc: Org Mode List, Nicolas Goaziou
[-- Attachment #1: Type: text/plain, Size: 616 bytes --]
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 <marcowahlsoft@gmail.com> 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
>
>
[-- Attachment #2: Type: text/html, Size: 1182 bytes --]
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [ANN] Changes to link syntax
2019-03-11 18:00 ` Diego Zamboni
@ 2019-03-11 23:07 ` Nicolas Goaziou
2019-03-12 5:42 ` Diego Zamboni
0 siblings, 1 reply; 22+ messages in thread
From: Nicolas Goaziou @ 2019-03-11 23:07 UTC (permalink / raw)
To: Diego Zamboni; +Cc: Marco Wahl, Org Mode List
Hello,
Diego Zamboni <diego@zzamboni.org> 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 <marcowahlsoft@gmail.com> 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
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [ANN] Changes to link syntax
2019-03-11 23:07 ` Nicolas Goaziou
@ 2019-03-12 5:42 ` Diego Zamboni
0 siblings, 0 replies; 22+ messages in thread
From: Diego Zamboni @ 2019-03-12 5:42 UTC (permalink / raw)
To: Diego Zamboni, Marco Wahl, Org Mode List
[-- Attachment #1: Type: text/plain, Size: 913 bytes --]
Thanks! It works again :)
On Tue, Mar 12, 2019 at 12:07 AM Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:
> Hello,
>
> Diego Zamboni <diego@zzamboni.org> 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 <marcowahlsoft@gmail.com>
> 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
>
[-- Attachment #2: Type: text/html, Size: 1744 bytes --]
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [ANN] Changes to link syntax
2019-03-10 17:19 [ANN] Changes to link syntax Nicolas Goaziou
` (2 preceding siblings ...)
2019-03-11 17:27 ` Marco Wahl
@ 2019-03-15 5:23 ` stardiviner
2019-03-15 10:55 ` Nicolas Goaziou
2019-03-15 11:55 ` Nicolas Goaziou
3 siblings, 2 replies; 22+ messages in thread
From: stardiviner @ 2019-03-15 5:23 UTC (permalink / raw)
To: emacs-orgmode
Nicolas Goaziou <mail@nicolasgoaziou.fr> 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
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [ANN] Changes to link syntax
2019-03-15 5:23 ` stardiviner
@ 2019-03-15 10:55 ` Nicolas Goaziou
2019-03-18 1:04 ` stardiviner
2019-03-15 11:55 ` Nicolas Goaziou
1 sibling, 1 reply; 22+ messages in thread
From: Nicolas Goaziou @ 2019-03-15 10:55 UTC (permalink / raw)
To: stardiviner; +Cc: emacs-orgmode
Hello,
stardiviner <numbchild@gmail.com> 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
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [ANN] Changes to link syntax
2019-03-15 10:55 ` Nicolas Goaziou
@ 2019-03-18 1:04 ` stardiviner
2019-03-18 21:33 ` Nicolas Goaziou
0 siblings, 1 reply; 22+ messages in thread
From: stardiviner @ 2019-03-18 1:04 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: emacs-orgmode
Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:
> Hello,
>
> stardiviner <numbchild@gmail.com> 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
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [ANN] Changes to link syntax
2019-03-18 1:04 ` stardiviner
@ 2019-03-18 21:33 ` Nicolas Goaziou
2019-03-19 8:06 ` stardiviner
0 siblings, 1 reply; 22+ messages in thread
From: Nicolas Goaziou @ 2019-03-18 21:33 UTC (permalink / raw)
To: stardiviner; +Cc: emacs-orgmode
Hello,
stardiviner <numbchild@gmail.com> 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
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [ANN] Changes to link syntax
2019-03-18 21:33 ` Nicolas Goaziou
@ 2019-03-19 8:06 ` stardiviner
0 siblings, 0 replies; 22+ messages in thread
From: stardiviner @ 2019-03-19 8:06 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: emacs-orgmode
Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:
> Hello,
>
> stardiviner <numbchild@gmail.com> 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.
Hmmmmm......
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
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [ANN] Changes to link syntax
2019-03-15 5:23 ` stardiviner
2019-03-15 10:55 ` Nicolas Goaziou
@ 2019-03-15 11:55 ` Nicolas Goaziou
2019-03-26 9:08 ` stardiviner
2019-03-27 2:00 ` stardiviner
1 sibling, 2 replies; 22+ messages in thread
From: Nicolas Goaziou @ 2019-03-15 11:55 UTC (permalink / raw)
To: stardiviner; +Cc: emacs-orgmode
stardiviner <numbchild@gmail.com> 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)))))))))))
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [ANN] Changes to link syntax
2019-03-15 11:55 ` Nicolas Goaziou
@ 2019-03-26 9:08 ` stardiviner
2019-03-27 2:00 ` stardiviner
1 sibling, 0 replies; 22+ messages in thread
From: stardiviner @ 2019-03-26 9:08 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: emacs-orgmode
Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:
> stardiviner <numbchild@gmail.com> 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
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [ANN] Changes to link syntax
2019-03-15 11:55 ` Nicolas Goaziou
2019-03-26 9:08 ` stardiviner
@ 2019-03-27 2:00 ` stardiviner
2019-04-02 21:16 ` Nicolas Goaziou
2019-04-07 11:20 ` stardiviner
1 sibling, 2 replies; 22+ messages in thread
From: stardiviner @ 2019-03-27 2:00 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: emacs-orgmode
Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:
> stardiviner <numbchild@gmail.com> 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 40000
links matched. And about 20000 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
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [ANN] Changes to link syntax
2019-03-27 2:00 ` stardiviner
@ 2019-04-02 21:16 ` Nicolas Goaziou
2019-04-07 11:20 ` stardiviner
1 sibling, 0 replies; 22+ messages in thread
From: Nicolas Goaziou @ 2019-04-02 21:16 UTC (permalink / raw)
To: stardiviner; +Cc: emacs-orgmode
Hello,
stardiviner <numbchild@gmail.com> 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 40000
> links matched. And about 20000 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
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [ANN] Changes to link syntax
2019-03-27 2:00 ` stardiviner
2019-04-02 21:16 ` Nicolas Goaziou
@ 2019-04-07 11:20 ` stardiviner
1 sibling, 0 replies; 22+ messages in thread
From: stardiviner @ 2019-04-07 11:20 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: emacs-orgmode
stardiviner <numbchild@gmail.com> 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
^ permalink raw reply [flat|nested] 22+ messages in thread
end of thread, other threads:[~2019-04-07 11:21 UTC | newest]
Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-10 17:19 [ANN] Changes to link syntax Nicolas Goaziou
2019-03-10 20:02 ` Samuel Wales
2019-03-10 22:13 ` Amin Bandali
2019-03-12 13:44 ` Nicolas Goaziou
2019-03-10 23:00 ` Daniele Nicolodi
2019-03-11 16:35 ` Nicolas Goaziou
2019-03-11 17:06 ` Eric S Fraga
2019-03-11 17:31 ` Daniele Nicolodi
2019-03-11 17:27 ` Marco Wahl
2019-03-11 18:00 ` Diego Zamboni
2019-03-11 23:07 ` Nicolas Goaziou
2019-03-12 5:42 ` Diego Zamboni
2019-03-15 5:23 ` stardiviner
2019-03-15 10:55 ` Nicolas Goaziou
2019-03-18 1:04 ` stardiviner
2019-03-18 21:33 ` Nicolas Goaziou
2019-03-19 8:06 ` stardiviner
2019-03-15 11:55 ` Nicolas Goaziou
2019-03-26 9:08 ` stardiviner
2019-03-27 2:00 ` stardiviner
2019-04-02 21:16 ` Nicolas Goaziou
2019-04-07 11:20 ` stardiviner
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).