* bug#20343: csv-mode fails if mode line is customized
@ 2015-04-16 0:00 Peter Eisentraut
2015-04-16 1:29 ` Stefan Monnier
0 siblings, 1 reply; 2+ messages in thread
From: Peter Eisentraut @ 2015-04-16 0:00 UTC (permalink / raw)
To: 20343
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.)
^ permalink raw reply [flat|nested] 2+ messages in thread
* bug#20343: csv-mode fails if mode line is customized
2015-04-16 0:00 bug#20343: csv-mode fails if mode line is customized Peter Eisentraut
@ 2015-04-16 1:29 ` Stefan Monnier
0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2015-04-16 1:29 UTC (permalink / raw)
To: Peter Eisentraut; +Cc: 20343-done
> 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):
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-04-16 1:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-16 0:00 bug#20343: csv-mode fails if mode line is customized Peter Eisentraut
2015-04-16 1:29 ` Stefan Monnier
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.