From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Peder O. Klingenberg" Newsgroups: gmane.emacs.bugs Subject: bug#71042: 29.3; csv-mode: csv-guess-set-separator chokes on comment lines Date: Fri, 26 Jul 2024 12:07:00 +0200 Message-ID: <87y15opiuz.fsf@klingenberg.no> References: <2b074284-fd61-4742-946a-7c45fb89156c@ieee.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3038"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 71042@debbugs.gnu.org To: Marco Emilio Poleggi Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jul 26 12:08:18 2024 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 1sXHs1-0000bB-O2 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 26 Jul 2024 12:08:17 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sXHri-0006O0-Uz; Fri, 26 Jul 2024 06:07:58 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sXHrg-0006NO-6q for bug-gnu-emacs@gnu.org; Fri, 26 Jul 2024 06:07:56 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sXHre-0002y2-3S for bug-gnu-emacs@gnu.org; Fri, 26 Jul 2024 06:07:55 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sXHrm-00032w-4n for bug-gnu-emacs@gnu.org; Fri, 26 Jul 2024 06:08:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Peder O. Klingenberg" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 26 Jul 2024 10:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71042 X-GNU-PR-Package: emacs Original-Received: via spool by 71042-submit@debbugs.gnu.org id=B71042.172198843711639 (code B ref 71042); Fri, 26 Jul 2024 10:08:02 +0000 Original-Received: (at 71042) by debbugs.gnu.org; 26 Jul 2024 10:07:17 +0000 Original-Received: from localhost ([127.0.0.1]:38814 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sXHr3-00031d-3t for submit@debbugs.gnu.org; Fri, 26 Jul 2024 06:07:17 -0400 Original-Received: from s17612523434.blix.com ([176.125.234.34]:46180 helo=castor.klingenberg.no) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sXHqz-00031Q-AX for 71042@debbugs.gnu.org; Fri, 26 Jul 2024 06:07:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=klingenberg.no; s=20200407; h=Content-Type:MIME-Version:Message-ID:Date: References:In-Reply-To:Subject:Cc:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=HTlSsFfbn5UUzl6D/JSytjHz8NUoLyK5Ad6ScGsw70E=; b=txKg5Ve/n891+pXqw//8I0UiZ dNaxqDWUSMsxFwhd/II/9g3APcHwIIOVpdBQ5q8da2y/qcRk7D4q77WklWikukwZxHIhlG6m428F0 JKT2KFhM6U+XhRHa9MgkmLC5kSYEM/2T4Hx5rbnft9dDcaz0FqbHRMvO0/ParST1j6c+oXSRigpkI QD0GR8qYlKju+VdorQVGy5giHRhnj/wLu+yzsLNY7WAZlSiGNM/8cUooE4MREIKFvOnmX4URLM728 t+HN1aCZCjCJAxegkSFTyYgu1Srt9+bOnS5fD8UE5gpfdv5IU30IyKaB6VHOdyGpd91+s9uF1e+fy HedG1QnWw==; Original-Received: from 77.18.49.139.tmi.telenormobil.no ([77.18.49.139] helo=PedersHP) by castor.klingenberg.no with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sXHqo-0005Yl-GD; Fri, 26 Jul 2024 12:07:03 +0200 In-Reply-To: <2b074284-fd61-4742-946a-7c45fb89156c@ieee.org> (Marco Emilio Poleggi's message of "Sat, 18 May 2024 12:14:21 +0200") 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:289354 Archived-At: --=-=-= Content-Type: text/plain Tags: patch On Sat, 2024-05-18 12:14:21 +0200, Marco Emilio Poleggi wrote: > Comment lines seem well supported by csv-mode. However, function > `csv-guess-set-separator` has troubles with them. Easily fixed, but needs someone with commit privileges to apply the patch --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Disregard-comments-when-guessing-separators.patch >From 6bcdef0ed429dfe88a607478c504eb52186e639e Mon Sep 17 00:00:00 2001 From: "Peder O. Klingenberg" Date: Fri, 26 Jul 2024 10:13:24 +0200 Subject: [PATCH] Disregard comments when guessing separators * csv-mode.el (csv--separator-candidates): Ignore csv-comment-start when looking for potential separators. * csv-mode-tests.el (csv-tests-guess-separator-avoid-comment): Previously failing test case guessing the comment start as separator char. (Bug#71042 fixed) --- csv-mode-tests.el | 10 ++++++++++ csv-mode.el | 7 ++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/csv-mode-tests.el b/csv-mode-tests.el index 12e009ecf9..213fd033b2 100644 --- a/csv-mode-tests.el +++ b/csv-mode-tests.el @@ -170,5 +170,15 @@ (should (equal (csv--unquote-value "|Hello, World|") "|Hello, World|"))) +(ert-deftest csv-tests-guess-separator-avoid-comment () + ;; bug#71042 + (let ((testdata "### +### +Foo;Bar;Quux +123;456;blah, blah +")) + (message "Guessed separator: %c" (csv-guess-separator testdata)) + (should-not (equal (csv-guess-separator testdata) ?#)))) + (provide 'csv-mode-tests) ;;; csv-mode-tests.el ends here diff --git a/csv-mode.el b/csv-mode.el index 1e0f99ef92..6bdfcafbbb 100644 --- a/csv-mode.el +++ b/csv-mode.el @@ -4,7 +4,7 @@ ;; Author: "Francis J. Wright" ;; Maintainer: emacs-devel@gnu.org -;; Version: 1.25 +;; Version: 1.26 ;; Package-Requires: ((emacs "27.1") (cl-lib "0.5")) ;; Keywords: convenience @@ -107,6 +107,10 @@ ;;; News: +;; Since 1.26: +;; - `csv-guess-separator' will no longer guess the comment-start +;; character as a potential separator character. + ;; Since 1.25: ;; - The ASCII control character 31 Unit Separator can now be ;; recognized as a CSV separator by `csv-guess-separator'. @@ -1902,6 +1906,7 @@ When CUTOFF is passed, look only at the first CUTOFF number of characters." (or (= c ?\t) (= c ?\C-_) (and (not (member c '(?. ?/ ?\" ?'))) + (not (= c (string-to-char csv-comment-start))) (not (member (get-char-code-property c 'general-category) '(Lu Ll Lt Lm Lo Nd Nl No Ps Pe Cc Co)))))) (puthash c t chars))) -- 2.25.1 --=-=-=--