all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Dan <danmbox@gmail.com>
Cc: 14122@debbugs.gnu.org
Subject: bug#14122: csv-mode: can't kill column from single-column file
Date: Wed, 24 Apr 2013 15:29:47 -0400	[thread overview]
Message-ID: <jwvmwsn20en.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <CAJ6Zc6NvBPHSJT4sC_dhCCXr4o5wQmx2sbqh8ME29QaV7cEjnw@mail.gmail.com> (Dan's message of "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).

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	other threads:[~2013-04-24 19:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvmwsn20en.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=14122@debbugs.gnu.org \
    --cc=danmbox@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.