GNU bug report logs - #14122
csv-mode: can't kill column from single-column file

Previous Next

Package: emacs;

Reported by: Dan <danmbox <at> gmail.com>

Date: Tue, 2 Apr 2013 16:06:02 UTC

Severity: normal

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 14122 in the body.
You can then email your comments to 14122 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#14122; Package emacs. (Tue, 02 Apr 2013 16:06:06 GMT) Full text and rfc822 format available.

Acknowledgement sent to Dan <danmbox <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 02 Apr 2013 16:06:06 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Dan <danmbox <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: csv-mode: can't kill column from single-column file
Date: Tue, 2 Apr 2013 11:00:45 +0300
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). Subsequently yank-column doesn't work.

This is emacs=24.1+1-2ubuntu3 with csv-mode=1.1 (latest from ELPA)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14122; Package emacs. (Wed, 24 Apr 2013 19:35:02 GMT) Full text and rfc822 format available.

Message #8 received at 14122 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Dan <danmbox <at> gmail.com>
Cc: 14122 <at> debbugs.gnu.org
Subject: Re: bug#14122: csv-mode: can't kill column from single-column file
Date: Wed, 24 Apr 2013 15:29:47 -0400
> 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)))





bug closed, send any further explanations to 14122 <at> debbugs.gnu.org and Dan <danmbox <at> gmail.com> Request was from Stefan Monnier <monnier <at> iro.umontreal.ca> to control <at> debbugs.gnu.org. (Wed, 24 Apr 2013 19:36:01 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 23 May 2013 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 86 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.