From: Nicolas Goaziou <n.goaziou@gmail.com>
To: Achim Gratz <Stromeko@Nexgo.DE>
Cc: emacs-orgmode@gnu.org
Subject: Re: [RFC] Org version of the Org manual
Date: Fri, 22 Mar 2013 15:22:19 +0100 [thread overview]
Message-ID: <87ip4j5xb8.fsf@gmail.com> (raw)
In-Reply-To: <kih2gg$6hh$1@ger.gmane.org> (Achim Gratz's message of "Fri, 22 Mar 2013 08:50:57 +0100")
Hello,
Achim Gratz <Stromeko@Nexgo.DE> writes:
> Am 21.03.2013 22:02, schrieb Nicolas Goaziou:
>> I suggest the following code instead, which allows to escape the
>> escaping backslash so the comma is not escaped:
>>
>> (args (mapcar 'org-trim
>> (split-string
>> (replace-regexp-in-string
>> "\\(\\\\+\\)?\\(,\\)"
>> (lambda (str)
>> (let ((slashes (match-string 1 str)))
>> (if (or (not slashes) (evenp (length slashes))) "\\1\000"
>> (concat (make-string (1- (length slashes)) ?\\) ","))))
>> (org-match-string-no-properties 3))
>> "\000")))
>>
>> What do you think about it?
>
> I think this is a lot harder to understand
Actually it is harder to understand because it doesn't make any sense:
the code is wrong. More on this below.
> and I would guess it is also quite a bit slower.
Speed difference is not significant here.
> Also I'm not sure why you are trying to match multiple backslashes.
> The original implementation and the description of the syntax says
> that the only character that can be escaped is a comma, so the new
> implementation changes behaviour in that regard (maybe intentionally,
> I can't tell).
Actually the code I pasted is wrong, I meant:
(split-string
(replace-regexp-in-string
"\\(\\\\+\\)?\\(,\\)"
(lambda (str)
(let ((len (length (match-string 1 str))))
(if (evenp len) (concat (make-string (/ len 2) ?\\) "\000")
(concat (make-string (/ (1- len) 2) ?\\) ","))))
(org-matcĥ-string-no-properties 3) nil t)
"\000")
With the current implementation (and in your refactoring), it is
impossible to have '("a\,b").
If you allow to escape a character, you should also be able to escape
the escaping character. With this patch:
"a,b" -> '("a" "b")
"a\,b" -> '("a,b")
"a\\,b" -> '("a\" "b")
"a\\\,b" -> '("a\,b")
"a\\\\,b" -> '(a"\\" "b")
Note that with the patch, you only need to escape backslashes before
a comma:
"a\\b\,c" -> '("a\\b,c")
If consistency is a matter, a slightly different patch can require to
escape every backslash character. Though, I don't think it is necessary.
Regards,
--
Nicolas Goaziou
next prev parent reply other threads:[~2013-03-22 14:22 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-25 20:21 [RFC] Org version of the Org manual Thomas S. Dye
2013-02-25 21:21 ` Carsten Dominik
2013-03-04 21:28 ` Achim Gratz
2013-03-06 3:14 ` Thomas S. Dye
2013-03-06 7:44 ` Yagnesh Raghava Yakkala
2013-03-06 8:18 ` Achim Gratz
2013-03-06 8:29 ` Bastien
2013-03-06 8:40 ` Nicolas Goaziou
2013-03-06 8:44 ` Achim Gratz
2013-03-06 10:18 ` Jambunathan K
2013-03-07 17:35 ` Thomas S. Dye
2013-03-07 18:22 ` Achim Gratz
2013-03-07 18:49 ` Thomas S. Dye
2013-03-09 23:53 ` Thomas S. Dye
2013-03-10 12:24 ` Achim Gratz
2013-03-10 19:01 ` Jonathan Leech-Pepin
2013-03-10 19:25 ` Achim Gratz
2013-03-10 19:39 ` Jonathan Leech-Pepin
2013-03-10 20:23 ` Nicolas Goaziou
2013-03-10 20:40 ` Jonathan Leech-Pepin
2013-03-11 0:32 ` Thomas S. Dye
2013-03-11 6:43 ` Achim Gratz
2013-03-11 16:18 ` Thomas S. Dye
2013-03-16 16:00 ` Achim Gratz
2013-03-17 1:19 ` Thomas S. Dye
2013-03-17 5:50 ` Carsten Dominik
2013-03-17 6:54 ` Achim Gratz
2013-03-17 12:33 ` Carsten Dominik
2013-03-17 13:34 ` Achim Gratz
2013-03-17 15:37 ` Carsten Dominik
2013-03-17 17:36 ` Achim Gratz
2013-03-17 19:58 ` Carsten Dominik
2013-03-17 7:01 ` Sebastien Vauban
2013-03-17 12:36 ` Carsten Dominik
2013-03-17 10:28 ` Achim Gratz
2013-03-21 21:02 ` Nicolas Goaziou
2013-03-22 7:50 ` Achim Gratz
2013-03-22 14:22 ` Nicolas Goaziou [this message]
2013-03-22 16:46 ` Achim Gratz
2013-03-22 18:17 ` Nicolas Goaziou
2013-03-23 7:32 ` Achim Gratz
2013-03-23 20:17 ` Nicolas Goaziou
2013-04-27 18:16 ` Achim Gratz
2013-04-28 7:29 ` Nicolas Goaziou
2013-04-28 8:28 ` Achim Gratz
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=87ip4j5xb8.fsf@gmail.com \
--to=n.goaziou@gmail.com \
--cc=Stromeko@Nexgo.DE \
--cc=emacs-orgmode@gnu.org \
/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).