From unknown Tue Jun 24 05:10:19 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#20343 <20343@debbugs.gnu.org> To: bug#20343 <20343@debbugs.gnu.org> Subject: Status: csv-mode fails if mode line is customized Reply-To: bug#20343 <20343@debbugs.gnu.org> Date: Tue, 24 Jun 2025 12:10:19 +0000 retitle 20343 csv-mode fails if mode line is customized reassign 20343 emacs submitter 20343 Peter Eisentraut severity 20343 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Wed Apr 15 20:17:23 2015 Received: (at submit) by debbugs.gnu.org; 16 Apr 2015 00:17:23 +0000 Received: from localhost ([127.0.0.1]:57537 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YiXUg-0001b7-Nc for submit@debbugs.gnu.org; Wed, 15 Apr 2015 20:17:23 -0400 Received: from eggs.gnu.org ([208.118.235.92]:49431) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YiXEU-0001AY-3g for submit@debbugs.gnu.org; Wed, 15 Apr 2015 20:00:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YiXEN-0005vh-Rr for submit@debbugs.gnu.org; Wed, 15 Apr 2015 20:00:32 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_05,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:44671) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YiXEN-0005vb-O5 for submit@debbugs.gnu.org; Wed, 15 Apr 2015 20:00:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34704) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YiXEM-0006zn-RP for bug-gnu-emacs@gnu.org; Wed, 15 Apr 2015 20:00:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YiXEI-0005tK-RC for bug-gnu-emacs@gnu.org; Wed, 15 Apr 2015 20:00:30 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:55887) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YiXEI-0005t3-GL for bug-gnu-emacs@gnu.org; Wed, 15 Apr 2015 20:00:26 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id CAFE320F60 for ; Wed, 15 Apr 2015 20:00:24 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Wed, 15 Apr 2015 20:00:24 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=eisentraut.org; h= content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=GlU TRDMbOI7aRuuQ3hz6F9ak2iw=; b=eh61pH8ndw9h5rJFRxXd/pF17o8ajEKgMVQ s6IACWDcipTerDxCcKZooZ/Q/TbkoguXAu4OxVKpNzQI1iMKZiRYotnIjNDNtwRq Q1/SNyqvnjFxVOkvqCSSLjjjIYqvSgypAvcyhXpJQNCX4rN1Ev5vW8Va/to9GIfo t3EaYDgQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-sasl-enc :x-sasl-enc; s=smtpout; bh=GlUTRDMbOI7aRuuQ3hz6F9ak2iw=; b=JGS7M AqXzFOQmxJi7cy1rZLnCMMw2QajiRJsFC8FzBG+vopJu6h5h9nzMgGlVmTHMckxX KoGmU/vj9eQKROFN/7NvJaUJInuMMBXbPyG/7Q+MRhVXWK+2tQwrfKqJ/6ZVZ7Dj kwf9ILM/2WmFml7NyyEnB3o/VPG8yfqcc/GqKs= X-Sasl-enc: ZTULRLr6ZGi6C77aoOckY6iy/KgFACEbaoJsmafjfPf0 1429142424 Received: from [10.0.0.13] (unknown [67.165.24.246]) by mail.messagingengine.com (Postfix) with ESMTPA id 86FEC6801B3 for ; Wed, 15 Apr 2015 20:00:24 -0400 (EDT) Message-ID: <552EFB97.2080804@eisentraut.org> Date: Wed, 15 Apr 2015 20:00:23 -0400 From: Peter Eisentraut User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: bug-gnu-emacs@gnu.org Subject: csv-mode fails if mode line is customized Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Wed, 15 Apr 2015 20:17:21 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) 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.) From debbugs-submit-bounces@debbugs.gnu.org Wed Apr 15 21:30:23 2015 Received: (at 20343-done) by debbugs.gnu.org; 16 Apr 2015 01:30:23 +0000 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 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 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 Received: by pastel.home (Postfix, from userid 20848) id BBABA1F4F; Wed, 15 Apr 2015 21:29:59 -0400 (EDT) From: Stefan Monnier To: Peter Eisentraut Subject: Re: bug#20343: csv-mode fails if mode line is customized Message-ID: References: <552EFB97.2080804@eisentraut.org> Date: Wed, 15 Apr 2015 21:29:59 -0400 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) MIME-Version: 1.0 Content-Type: text/plain 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-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: 20343-done Cc: 20343-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.3 (-) > 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): From unknown Tue Jun 24 05:10:19 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 14 May 2015 11:24:07 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator