From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#14122: csv-mode: can't kill column from single-column file Date: Wed, 24 Apr 2013 15:29:47 -0400 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1366831821 17979 80.91.229.3 (24 Apr 2013 19:30:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 24 Apr 2013 19:30:21 +0000 (UTC) Cc: 14122@debbugs.gnu.org To: Dan Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Apr 24 21:30:26 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UV5Oa-0001x0-1m for geb-bug-gnu-emacs@m.gmane.org; Wed, 24 Apr 2013 21:30:24 +0200 Original-Received: from localhost ([::1]:39673 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UV5OZ-0001dZ-Je for geb-bug-gnu-emacs@m.gmane.org; Wed, 24 Apr 2013 15:30:23 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:47659) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UV5OG-0000yA-AY for bug-gnu-emacs@gnu.org; Wed, 24 Apr 2013 15:30:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UV5OB-0001EN-Fl for bug-gnu-emacs@gnu.org; Wed, 24 Apr 2013 15:30:04 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:37375) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UV5OB-0001E7-BI for bug-gnu-emacs@gnu.org; Wed, 24 Apr 2013 15:29:59 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UV5T4-0006uO-2m for bug-gnu-emacs@gnu.org; Wed, 24 Apr 2013 15:35:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 24 Apr 2013 19:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 14122 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 14122-submit@debbugs.gnu.org id=B14122.136683209426539 (code B ref 14122); Wed, 24 Apr 2013 19:35:02 +0000 Original-Received: (at 14122) by debbugs.gnu.org; 24 Apr 2013 19:34:54 +0000 Original-Received: from localhost ([127.0.0.1]:41484 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UV5Sw-0006tz-8C for submit@debbugs.gnu.org; Wed, 24 Apr 2013 15:34:54 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]:50809) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UV5Su-0006tp-Ns for 14122@debbugs.gnu.org; Wed, 24 Apr 2013 15:34:53 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av8EABK/CFFFpYYW/2dsb2JhbAA7Cbs1g1kXc4IeAQEEAVYjBQsLNBIUGA0kiB4GwS2NFoN0A6R6gV6DEw X-IPAS-Result: Av8EABK/CFFFpYYW/2dsb2JhbAA7Cbs1g1kXc4IeAQEEAVYjBQsLNBIUGA0kiB4GwS2NFoN0A6R6gV6DEw X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="8210703" Original-Received: from 69-165-134-22.dsl.teksavvy.com (HELO pastel.home) ([69.165.134.22]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 24 Apr 2013 15:29:44 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id D4BB267A3A; Wed, 24 Apr 2013 15:29:47 -0400 (EDT) In-Reply-To: (Dan's message of "Tue, 2 Apr 2013 11:00:45 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 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.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:73646 Archived-At: > If I try to kill column 1 (the only column) from a single-column csv > file, it correctly guesses the entire buffer as the desired region, > the desired field as 1, then proceeds to only kill the header row > (instead of the entire region). Indeed, thanks for the report. I installed the patch below for csv-mode-1.2, which should fix this problem. Stefan === modified file 'packages/csv-mode/csv-mode.el' --- packages/csv-mode/csv-mode.el 2012-10-22 21:58:24 +0000 +++ packages/csv-mode/csv-mode.el 2013-04-24 19:25:16 +0000 @@ -844,21 +844,18 @@ (csv-kill-one-column (car fields))))) (setq csv-killed-fields (nreverse csv-killed-fields))) -(defmacro csv-kill-one-field (field killed-fields) +(defun csv-kill-one-field (field) "Kill field with index FIELD in current line. -Save killed field by `push'ing onto KILLED-FIELDS. -Assumes point is at beginning of line. -Called by `csv-kill-one-column' and `csv-kill-many-columns'." - `(progn +Return killed text. Assumes point is at beginning of line." ;; Move to start of field to kill: - (csv-sort-skip-fields ,field) + (csv-sort-skip-fields field) ;; Kill to end of field (cf. `kill-region'): - (push (delete-and-extract-region + (prog1 (delete-and-extract-region (point) (progn (csv-end-of-field) (point))) - ,killed-fields) - (if (eolp) (delete-char -1) ; delete trailing separator at eol - (delete-char 1)))) ; or following separator otherwise + (if (eolp) + (unless (bolp) (delete-char -1)) ; Delete trailing separator at eol + (delete-char 1)))) ; or following separator otherwise. (defun csv-kill-one-column (field) "Kill field with index FIELD in all lines in (narrowed) buffer. @@ -867,7 +864,7 @@ Ignore blank and comment lines." (while (not (eobp)) (or (csv-not-looking-at-record) - (csv-kill-one-field field csv-killed-fields)) + (push (csv-kill-one-field field) csv-killed-fields)) (forward-line))) (defun csv-kill-many-columns (fields) @@ -912,7 +909,7 @@ (setq field (car fields) fields (cdr fields)) (beginning-of-line) - (csv-kill-one-field field killed-fields)) + (push (csv-kill-one-field field) killed-fields)) (push (mapconcat 'identity killed-fields (car csv-separators)) csv-killed-fields))) (forward-line)))