From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [RFC] Org version of the Org manual Date: Fri, 22 Mar 2013 15:22:19 +0100 Message-ID: <87ip4j5xb8.fsf@gmail.com> References: <87r4jeqq0i.fsf@Rainer.invalid> <87620k79fo.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([208.118.235.92]:35597) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UJ2rX-0001BK-4q for emacs-orgmode@gnu.org; Fri, 22 Mar 2013 10:22:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UJ2rV-0006jx-Bn for emacs-orgmode@gnu.org; Fri, 22 Mar 2013 10:22:31 -0400 Received: from mail-wg0-f49.google.com ([74.125.82.49]:57585) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UJ2rV-0006jg-5m for emacs-orgmode@gnu.org; Fri, 22 Mar 2013 10:22:29 -0400 Received: by mail-wg0-f49.google.com with SMTP id gg9so2905474wgb.16 for ; Fri, 22 Mar 2013 07:22:28 -0700 (PDT) In-Reply-To: (Achim Gratz's message of "Fri, 22 Mar 2013 08:50:57 +0100") 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Achim Gratz Cc: emacs-orgmode@gnu.org Hello, Achim Gratz 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=C4=A5-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, --=20 Nicolas Goaziou