unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#14122: csv-mode: can't kill column from single-column file
@ 2013-04-02  8:00 Dan
  2013-04-24 19:29 ` Stefan Monnier
  0 siblings, 1 reply; 2+ messages in thread
From: Dan @ 2013-04-02  8:00 UTC (permalink / raw)
  To: 14122

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)





^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#14122: csv-mode: can't kill column from single-column file
  2013-04-02  8:00 bug#14122: csv-mode: can't kill column from single-column file Dan
@ 2013-04-24 19:29 ` Stefan Monnier
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2013-04-24 19:29 UTC (permalink / raw)
  To: Dan; +Cc: 14122

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






^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-04-24 19:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-02  8:00 bug#14122: csv-mode: can't kill column from single-column file Dan
2013-04-24 19:29 ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).