From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#20343: csv-mode fails if mode line is customized Date: Wed, 15 Apr 2015 21:29:59 -0400 Message-ID: References: <552EFB97.2080804@eisentraut.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1429147894 24557 80.91.229.3 (16 Apr 2015 01:31:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 16 Apr 2015 01:31:34 +0000 (UTC) Cc: 20343-done@debbugs.gnu.org To: Peter Eisentraut Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Apr 16 03:31:15 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YiYeA-0000E3-4D for geb-bug-gnu-emacs@m.gmane.org; Thu, 16 Apr 2015 03:31:14 +0200 Original-Received: from localhost ([::1]:34872 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YiYe9-0005kV-Jx for geb-bug-gnu-emacs@m.gmane.org; Wed, 15 Apr 2015 21:31:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54328) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YiYe5-0005kQ-K8 for bug-gnu-emacs@gnu.org; Wed, 15 Apr 2015 21:31:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YiYe0-0001Fb-M6 for bug-gnu-emacs@gnu.org; Wed, 15 Apr 2015 21:31:09 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:39567) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YiYe0-0001FX-Ju for bug-gnu-emacs@gnu.org; Wed, 15 Apr 2015 21:31:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YiYe0-0003Zh-7V for bug-gnu-emacs@gnu.org; Wed, 15 Apr 2015 21:31:04 -0400 Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Thu, 16 Apr 2015 01:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 20343 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Mail-Followup-To: 20343@debbugs.gnu.org, monnier@IRO.UMontreal.CA, peter@eisentraut.org Original-Received: via spool by 20343-done@debbugs.gnu.org id=D20343.142914782313632 (code D ref 20343); Thu, 16 Apr 2015 01:31:02 +0000 Original-Received: (at 20343-done) by debbugs.gnu.org; 16 Apr 2015 01:30:23 +0000 Original-Received: from localhost ([127.0.0.1]:57574 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YiYdE-0003Xd-H4 for submit@debbugs.gnu.org; Wed, 15 Apr 2015 21:30:17 -0400 Original-Received: from chene.dit.umontreal.ca ([132.204.246.20]:35142) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YiYd0-0003WS-FE for 20343-done@debbugs.gnu.org; Wed, 15 Apr 2015 21:30:09 -0400 Original-Received: from pastel.home (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id t3G1Txmu016537; Wed, 15 Apr 2015 21:30:00 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id BBABA1F4F; Wed, 15 Apr 2015 21:29:59 -0400 (EDT) In-Reply-To: <552EFB97.2080804@eisentraut.org> (Peter Eisentraut's message of "Wed, 15 Apr 2015 20:00:23 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV5277=0 X-NAI-Spam-Version: 2.3.0.9393 : core <5277> : inlines <2729> : streams <1423165> : uri <1907795> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:101575 Archived-At: > 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):