GNU bug report logs -
#55315
[elpa/csv-mode] [PATCH] CSV separator guessing
Previous Next
Reported by: Simen Heggestøyl <simenheg <at> runbox.com>
Date: Sun, 8 May 2022 14:13:02 UTC
Severity: normal
Tags: patch
Done: Simen Heggestøyl <simenheg <at> runbox.com>
Bug is archived. No further changes may be made.
Full log
Message #8 received at 55315 <at> debbugs.gnu.org (full text, mbox):
> + (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.
This bug report was last modified 3 years and 14 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.