branch: externals/csv-mode
commit af8c6b7aa96bbfc40b457694927535a4482f7f75
Author: Lars Ingebrigtsen <[email protected]>
Commit: Lars Ingebrigtsen <[email protected]>

    Make the field indicator in csv-mode correct
    
    * csv-mode.el (csv--field-index): Count fields correctly
    (bug#41427).  The previous code would do the wrong thing with
    quoted fields that contains commas.
---
 csv-mode.el | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/csv-mode.el b/csv-mode.el
index 8df9b8e..eaea881 100644
--- a/csv-mode.el
+++ b/csv-mode.el
@@ -4,7 +4,7 @@
 
 ;; Author: "Francis J. Wright" <[email protected]>
 ;; Maintainer: [email protected]
-;; Version: 1.13
+;; Version: 1.14
 ;; Package-Requires: ((emacs "24.1") (cl-lib "0.5"))
 ;; Keywords: convenience
 
@@ -830,11 +830,15 @@ the mode line after `csv-field-index-delay' seconds of 
Emacs idle time."
 
 (defun csv--field-index ()
   (save-excursion
-    (let ((lbp (line-beginning-position)) (field 1))
-      (while (re-search-backward csv-separator-regexp lbp 'move)
-       ;; Move as far as possible, i.e. to beginning of line.
+    (let ((start (point))
+         (field 0))
+      (beginning-of-line)
+      (while (< (point) start)
+       (csv-end-of-field)
+       (unless (eolp)
+         (forward-char 1))
        (setq field (1+ field)))
-      (unless (csv-not-looking-at-record) field))))
+      field)))
 
 (defun csv-field-index ()
   "Construct `csv-field-index-string' to display in mode line.

Reply via email to