bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Stefan Monnier
Subject: bug#14122: csv-mode: can't kill column from single-column file
Date: Wed, 24 Apr 2013 15:29:47 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

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






reply via email to

[Prev in Thread] Current Thread [Next in Thread]