emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: Neil Jerram <neiljerram@gmail.com>
Cc: Org Mode List <emacs-orgmode@gnu.org>
Subject: Re: [RFC] Fixing link encoding once and for all
Date: Tue, 05 Mar 2019 01:23:24 +0100	[thread overview]
Message-ID: <87ef7m2mpv.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <CAKuG=vtO-dMkxZ8nTsSUe_NieqVBt9tCnVSeENewuEGnL303iQ@mail.gmail.com> (Neil Jerram's message of "Mon, 4 Mar 2019 23:16:07 +0000")

Hello,

Neil Jerram <neiljerram@gmail.com> writes:

> On Fri, 1 Mar 2019 at 08:14, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:

>> The regexp for bracket links could be, in its simple (!) form:
>>
>>   \[\[\(.*?[^\\]\(?:\\\)*\)\]\(?:\[\([^\000]+?\)\]\)?\]
>
> [then a bit later]
>> Small update, in its string form now:
>>
>>   "\\[\\[\\([^\000]*?[^\\]\\(\\\\\\\\\\)*\\)\\]\\(?:\\[\\([^\000]+?\\)\\]\\)?\\]"
>
> Is [^\000] the only (or best) way of saying "any character, including
> newlines"?

There is also "\(.\|\n\)", or "[[:ascii:][:nonascii:]]".

> Could there be actual NUL characters in the document?

Good question. I used [^\000] out of habit. You are right, "\(.\|\n\)"
is more robust.

So, the new challenger is:

    "\\[\\[\\(\\(?:.\\|\n\\)*?[^\\]\\(\\\\\\\\\\)*\\)\\]\\(?:\\[\\(\\(?:.\\|\n\\)+?\\)\\]\\)?\\]"

Beautiful.

The commented rx equivalent would be:

(seq "["
     ;; URI part: match group 1.
     "["
     (group
      (*? anything)
      ;; Allow an even number of backslashes before the closing bracket.
      (not (any "\\"))
      (zero-or-more (group "\\\\")))
     "]"
     ;; Description (optional): match group 2.
     (opt "[" (group (+? anything)) "]")
     "]")

> \(        # begin group 3
> ?         # don't understand
> :\[       # literal :[

[...]

> but there's at least a ? that I don't understand, and I'm afraid I'm
> not seeing how it's useful.

\(?: ... \) is a shy group.

> If you think it works, I'm happy to defer to your judgement on that!
> Although I suggested the idea, I don't know Org nearly well enough to
> be sure that I haven't missed problems;

We are solving the problem with a regexp. What bad things could happen? ;)

Regards,

-- 
Nicolas Goaziou

  reply	other threads:[~2019-03-05  0:23 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-24  1:16 [RFC] Fixing link encoding once and for all Nicolas Goaziou
2019-02-24 23:04 ` Neil Jerram
2019-02-27 10:48   ` Nicolas Goaziou
2019-02-28 10:24     ` Neil Jerram
2019-03-01  8:14       ` Nicolas Goaziou
2019-03-01  8:30         ` Nicolas Goaziou
2019-03-01  8:40         ` Michael Brand
2019-03-01  8:41         ` Jens Lechtenboerger
2019-03-01  8:56           ` Nicolas Goaziou
2019-03-01  9:40             ` Jens Lechtenboerger
2019-03-03  6:58         ` stardiviner
2019-03-03  8:08           ` Nicolas Goaziou
2019-03-04 23:16         ` Neil Jerram
2019-03-05  0:23           ` Nicolas Goaziou [this message]
2019-03-05 16:27             ` Neil Jerram
2019-03-05 16:36               ` Robert Pluim
2019-02-25  8:54 ` stardiviner
2019-02-27  8:07 ` Jens Lechtenboerger
2019-02-27 11:25   ` Nicolas Goaziou
2019-02-27 12:57     ` Jens Lechtenboerger
2019-02-28 10:51       ` Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ef7m2mpv.fsf@nicolasgoaziou.fr \
    --to=mail@nicolasgoaziou.fr \
    --cc=emacs-orgmode@gnu.org \
    --cc=neiljerram@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).