From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#55315: [elpa/csv-mode] [PATCH] CSV separator guessing Date: Sun, 8 May 2022 19:56:00 +0200 Message-ID: <07E204D4-5FE4-4122-BB82-EBB2107C09E8@acm.org> References: <87h760jeq7.fsf@simenheg@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11968"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 55315@debbugs.gnu.org To: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun May 08 19:57:14 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nnl9e-0002ro-8s for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 08 May 2022 19:57:14 +0200 Original-Received: from localhost ([::1]:42336 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nnl9c-0008V0-QW for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 08 May 2022 13:57:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53698) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nnl9S-0008Ur-Ml for bug-gnu-emacs@gnu.org; Sun, 08 May 2022 13:57:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33061) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nnl9S-00084S-EM for bug-gnu-emacs@gnu.org; Sun, 08 May 2022 13:57:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nnl9S-0005Ea-CF for bug-gnu-emacs@gnu.org; Sun, 08 May 2022 13:57:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <87h760jeq7.fsf@simenheg@gmail.com> Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 08 May 2022 17:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55315 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 55315-submit@debbugs.gnu.org id=B55315.165203257020051 (code B ref 55315); Sun, 08 May 2022 17:57:02 +0000 Original-Received: (at 55315) by debbugs.gnu.org; 8 May 2022 17:56:10 +0000 Original-Received: from localhost ([127.0.0.1]:55191 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nnl8c-0005DL-18 for submit@debbugs.gnu.org; Sun, 08 May 2022 13:56:10 -0400 Original-Received: from mail18c50.megamailservers.eu ([91.136.10.28]:32776) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nnl8X-0005D7-C8 for 55315@debbugs.gnu.org; Sun, 08 May 2022 13:56:08 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1652032563; bh=wMU4Q1IuvkxqwwIGFht7qJUwvzqZZZYwoW7HOo/E2oI=; h=From:Subject:Date:Cc:To:From; b=KlmmhEN6+w9TdIcBta0S0Gt4cV9m6irqP+HM8x6Zji7FyJ+D3DP7rOYh7FwdOMY6l dKqzbo9Ezmgnm2614fSyV3SIft+S0q4i3z8QVTjAn6FLhXF3EHt+478WVbF5NmbVva FnLToKPeoZk96mRZDkXUwgTkhMfZm2DxZL6xsBrg= Feedback-ID: mattiase@acm.or Original-Received: from smtpclient.apple (c188-150-171-71.bredband.tele2.se [188.150.171.71]) (authenticated bits=0) by mail18c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 248Hu1Wh018310; Sun, 8 May 2022 17:56:02 +0000 X-Mailer: Apple Mail (2.3654.120.0.1.13) X-CTCH-RefID: str=0001.0A742F27.62780433.0011, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-Origin-Country: SE X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:231678 Archived-At: > + (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.