From: "Mattias Engdegård" <mattiase@acm.org>
To: "Simen Heggestøyl" <simenheg@runbox.com>
Cc: 55315@debbugs.gnu.org
Subject: bug#55315: [elpa/csv-mode] [PATCH] CSV separator guessing
Date: Sun, 8 May 2022 19:56:00 +0200 [thread overview]
Message-ID: <07E204D4-5FE4-4122-BB82-EBB2107C09E8@acm.org> (raw)
In-Reply-To: <87h760jeq7.fsf@simenheg@gmail.com>
> + (setq csv-separator-chars (mapcar #'string-to-char value))
> + (let ((quoted-value (mapcar #'regexp-quote value)))
> + (setq csv--skip-chars (apply #'concat "^\n" quoted-value))
> + (setq csv-separator-regexp
> + (apply #'concat `("[" ,@quoted-value "]"))))
`regexp-quote` produces a regexp from a string literal, but what goes inside the square brackets is not a regexp -- the syntax rules are different. More specifically, other characters are special, and backslash does not quote anything.
To produce a regexp that matches one in a set of characters, try rx-to-string or regexp-opt. For example,
(setq csv-separator-regexp (rx-to-string `(or ,@csv-separator-chars) t))
The same applies to csv--skip-chars: this isn't a regexp either, but uses yet another syntax so regexp-quote is inappropriate here too. Easiest is to precede each char with a backslash since that always yields a correctly quoted character: "ABC" -> "\\A\\B\\C".
This is not a judgement on the rest of the patch which may be fine for all I know.
next parent reply other threads:[~2022-05-08 17:56 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <87h760jeq7.fsf@simenheg@gmail.com>
2022-05-08 17:56 ` Mattias Engdegård [this message]
2022-05-08 19:31 ` bug#55315: [elpa/csv-mode] [PATCH] CSV separator guessing Simen Heggestøyl
[not found] ` <87mtfryg73.fsf@simenheg@gmail.com>
2022-05-09 9:37 ` Mattias Engdegård
2022-05-09 11:03 ` Simen Heggestøyl
2022-05-09 11:28 ` Mattias Engdegård
2022-05-12 19:59 ` Simen Heggestøyl
2022-05-08 14:12 Simen Heggestøyl
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=07E204D4-5FE4-4122-BB82-EBB2107C09E8@acm.org \
--to=mattiase@acm.org \
--cc=55315@debbugs.gnu.org \
--cc=simenheg@runbox.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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.