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.

Full log


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)))





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

Previous Next


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