unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stephen Berman <stephen.berman@gmx.net>
To: dalanicolai@gmail.com
Cc: 44229@debbugs.gnu.org
Subject: bug#44229: 27.1; Can not set tabulated-list-format with variable
Date: Mon, 26 Oct 2020 22:23:39 +0100	[thread overview]
Message-ID: <87a6w8smuc.fsf@rub.de> (raw)
In-Reply-To: <6d9d638cf2dbdcbbddf80be8e9845318b0e154cd.camel@gmail.com> (dalanicolai@gmail.com's message of "Mon, 26 Oct 2020 06:52:13 +0100")

On Mon, 26 Oct 2020 06:52:13 +0100 dalanicolai@gmail.com wrote:

> I would like to make the tabulated-list-format customizable, but the
> format (width) can not be set using a variable.
> To reproduce evaluate the following code:
>
> ```
> (defvar col1-width 4)
> (defvar col2-width 10)
>
> (define-derived-mode tabular-bug-demo-mode
>   tabulated-list-mode "tab-bug"
>   "Major mode for Tab-bug."
>   (setq-local tabulated-list-format [("Col1" 4 nil)
>                                      ("Col2" 10 nil)])
>   (tabulated-list-init-header))
>
> (let ((buf (switch-to-buffer "tablist-bug-demo")))
>   (with-current-buffer buf
>     (tabular-bug-demo-mode)
>     (setq-local tabulated-list-entries (list (list nil ["1" "so
> unfortunately this"])
>                                              (list nil ["2" "does not
> work"])
>                                              (list nil ["3" "when using
> variables"])))
>     (tabulated-list-print)))
> ```
>
> The code above should work correctly. However when you try to use the
> variable defined in the first two lines for the width within the
> definition of the tabulated-list-format then no tabular list is printed
> but instead Emacs shows an error that the width is not a number or
> marker (number-or-marker-p).
>
> I guess this is not the desired behavior?

Using the literal vector notation is like using a quoted list.
It works if you use this:

(setq-local tabulated-list-format `[("Col1" ,col1-width nil)
                                    ("Col2" ,col2-width nil)])

or alternatively this:

(setq-local tabulated-list-format (vector (list "Col1" col1-width nil)
					  (list "Col2" col2-width nil)))

Steve Berman





      parent reply	other threads:[~2020-10-26 21:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-26  5:52 bug#44229: 27.1; Can not set tabulated-list-format with variable dalanicolai
2020-10-26 10:45 ` Lars Ingebrigtsen
2020-10-26 21:10   ` dalanicolai
2020-10-26 21:12     ` Lars Ingebrigtsen
2020-10-26 21:20       ` dalanicolai
2020-10-26 21:20         ` dalanicolai
2020-10-26 21:21           ` dalanicolai
2020-10-26 21:26           ` Lars Ingebrigtsen
2020-10-26 23:35             ` dalanicolai
2020-10-26 21:23 ` Stephen Berman [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a6w8smuc.fsf@rub.de \
    --to=stephen.berman@gmx.net \
    --cc=44229@debbugs.gnu.org \
    --cc=dalanicolai@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).