GNU bug report logs - #20343
csv-mode fails if mode line is customized

Previous Next

Package: emacs;

Reported by: Peter Eisentraut <peter <at> eisentraut.org>

Date: Thu, 16 Apr 2015 00:18:02 UTC

Severity: normal

Done: Stefan Monnier <monnier <at> IRO.UMontreal.CA>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 20343 in the body.
You can then email your comments to 20343 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#20343; Package emacs. (Thu, 16 Apr 2015 00:18:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Peter Eisentraut <peter <at> eisentraut.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 16 Apr 2015 00:18:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Peter Eisentraut <peter <at> eisentraut.org>
To: bug-gnu-emacs <at> gnu.org
Subject: csv-mode fails if mode line is customized
Date: Wed, 15 Apr 2015 20:00:23 -0400
This is about csv-mode.el version 1.2 from elpa.gnu.org.

If the mode line has been customized in a certain way, calling csv-mode
will fail.

Example:

in ~/emacs.d/init.el

(setq-default mode-line-format '("%e"))

Install csv-mode.el.

Then run

emacs test.csv

This will produce a message like

(wrong-type-argument number-or-marker-p ("%e"))


The reason is that in the definition of csv-mode-line-format, the
arguments of the `last' function are flipped:

(defconst csv-mode-line-format
  ;; See bindings.el for details of `mode-line-format' construction.
  (let* ((ml (copy-sequence (default-value 'mode-line-format)))
         (x (or (memq 'mode-line-position ml) (last 3 ml))))  ;; wrong


(I doubt that messing around with the mode line like that is current
practice, but that might be a separate discussion.)




Reply sent to Stefan Monnier <monnier <at> IRO.UMontreal.CA>:
You have taken responsibility. (Thu, 16 Apr 2015 01:31:03 GMT) Full text and rfc822 format available.

Notification sent to Peter Eisentraut <peter <at> eisentraut.org>:
bug acknowledged by developer. (Thu, 16 Apr 2015 01:31:04 GMT) Full text and rfc822 format available.

Message #10 received at 20343-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Peter Eisentraut <peter <at> eisentraut.org>
Cc: 20343-done <at> debbugs.gnu.org
Subject: Re: bug#20343: csv-mode fails if mode line is customized
Date: Wed, 15 Apr 2015 21:29:59 -0400
> The reason is that in the definition of csv-mode-line-format, the
> arguments of the `last' function are flipped:

> (defconst csv-mode-line-format
>   ;; See bindings.el for details of `mode-line-format' construction.
>   (let* ((ml (copy-sequence (default-value 'mode-line-format)))
>          (x (or (memq 'mode-line-position ml) (last 3 ml))))  ;; wrong

Oops, indeed.

> (I doubt that messing around with the mode line like that is current
> practice, but that might be a separate discussion.)

I've changed the code to make fewer assumptions.  See patch below,


        Stefan


diff --git a/packages/csv-mode/csv-mode.el b/packages/csv-mode/csv-mode.el
index a8ae4e4..e727027 100644
--- a/packages/csv-mode/csv-mode.el
+++ b/packages/csv-mode/csv-mode.el
@@ -249,16 +249,7 @@ Number of spaces used by `csv-align-fields' after separators."
 
 
 (defconst csv-mode-line-format
-  ;; See bindings.el for details of `mode-line-format' construction.
-  (let* ((ml (copy-sequence (default-value 'mode-line-format)))
-         (x (or (memq 'mode-line-position ml) (last 3 ml))))
-    (when x
-      (setcdr x (cons
-                 `(csv-field-index-string
-                   ("" csv-field-index-string
-                    ))
-                 (cdr x))))
-    ml)
+  '(csv-field-index-string ("" csv-field-index-string))
   "Mode line format string for CSV mode.")
 
 (defvar csv-mode-map
@@ -322,9 +313,13 @@ CSV mode provides the following specific keyboard key bindings:
   (setq
    ;; Font locking -- separator plus syntactic:
    font-lock-defaults '(csv-font-lock-keywords)
-   buffer-invisibility-spec csv-invisibility-default
-   ;; Mode line to support `csv-field-index-mode':
-   mode-line-format csv-mode-line-format)
+   buffer-invisibility-spec csv-invisibility-default)
+  ;; Mode line to support `csv-field-index-mode':
+  (set (make-local-variable 'mode-line-position)
+       (pcase mode-line-position
+         (`(,(or (pred consp) (pred stringp)) . ,_)
+          `(,@mode-line-position ,csv-mode-line-format))
+         (_ `("" ,mode-line-position ,csv-mode-line-format))))
   (set (make-local-variable 'truncate-lines) t)
   ;; Enable or disable `csv-field-index-mode' (could probably do this
   ;; a bit more efficiently):




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 14 May 2015 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 43 days ago.

Previous Next


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