emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What's up with widgets?


From: Mauro Aranda
Subject: Re: What's up with widgets?
Date: Fri, 28 Jan 2022 15:15:11 -0300

Derek Davies <ddavies@ddavies.net> writes:

> The other thing is that the info page seems categorical and detailed,
> but with many details missing.  It would be fine if there were more examples and/or blog posts
> available at large, but I can't find much when searching the web.

Yes, the docs could be improved.

> The example below does not toggle for me and I get a message about "read only" when I press ret on the toggle value.  If I remove the :format keyword the value appears and is togglable.  How do I display a field label like I do with editable-field or most of the other widgets I've used?
>
[...]
>
> ;; -*-  lexical-binding: t; -*-
>
>
> (require 'subr-x)
> (require 'widget)
> (eval-when-compile
>   (require 'wid-edit))
>
> (define-widget 'tog-wid 'group
>   ""
>   :format " %v"
>   :entry-format " %v"
>   :args '((editable-field
>            :tag "Limit"
>   :format " %t %v\n")
>           (toggle
>            :tag "Threads"
>            :format " %t %v")))

You're missing the "%[" and "%]" around "%v", which tells the widget code
to buttonize the value, so that you can press RET to toggle it.

The toggle default :format has "%[" and "%]", so that's why it works
when you remove your custom format.

I think that:
(toggle :tag "Threads" :format " %t %[%v%]")

should work.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]