From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mauro Aranda Newsgroups: gmane.emacs.devel Subject: Re: What's up with widgets? Date: Fri, 28 Jan 2022 15:15:11 -0300 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000074764605d6a86087" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9009"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Emacs-Devel List To: ddavies@ddavies.net Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jan 28 19:23:54 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nDVuc-000247-EA for ged-emacs-devel@m.gmane-mx.org; Fri, 28 Jan 2022 19:23:54 +0100 Original-Received: from localhost ([::1]:50138 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDVub-0000kK-Aj for ged-emacs-devel@m.gmane-mx.org; Fri, 28 Jan 2022 13:23:53 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:43096) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDVpI-0003Mg-BN for emacs-devel@gnu.org; Fri, 28 Jan 2022 13:18:24 -0500 Original-Received: from [2607:f8b0:4864:20::42c] (port=35711 helo=mail-pf1-x42c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nDVpG-00071I-Mu for emacs-devel@gnu.org; Fri, 28 Jan 2022 13:18:23 -0500 Original-Received: by mail-pf1-x42c.google.com with SMTP id u130so6898279pfc.2 for ; Fri, 28 Jan 2022 10:18:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to:cc; bh=aDxpdrAuhfYzCLS9XeaEBWNaJaxaSq/S2YEd04EfIRA=; b=Nk906RkWrzuQyjqZgUh2vKVP2/Sly8ljkIep7Xh6LtySAcCfg3pAZr6zVUivmQJQ5d XpBkAPTnO1EMuO1ytFeJ3FIUEDltcYJguuUs/sjHJEXOgpwly1ITO2A+y+bEY2CkDsP3 w/XewE/gyTzXfmQLITVK+bDQ8XKPqT4TbfYt3OzYOTviKeQ0stvte4M/5ANOg66nciSt lM0IqetNpWv0gpe0tAXsPSqUfPErmjOF+c502TTx8gWgOYqE0J8mZ0/IdPyGpcvtcj52 u6lJz+GjutoX3dcu2vuyG9QVGp8DQl4kFUDPyd86CzrO9vqFMT0aea9d+qJl6RS+M4ih g3Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=aDxpdrAuhfYzCLS9XeaEBWNaJaxaSq/S2YEd04EfIRA=; b=cwLeOPApDwKdbY1QlwpOU9V4RnxHrLJq7HiPIQ71XNiEiPIaI+a2hT+xFQBDhPZpg2 t1+WGLz8bfz9cF3geBexvJDi6gvL6puGIBGjJMaPoIzgGuxNvEmJzTAyK+H9izEdFgQJ /bLC8/75BygUqRxLUJEYSH9D4FtoUSrtRC1Wo0FgKC4GkYsBSq8akFcPqEeiFQCckFze ObpH8JB6A/ruujLRn19Lqaf+sdWoHn5z+rZ8xptJtOwDbIjWF1tVQLzwv1WJ4p9k2Ibw 2NZ95rYuzD0h60oZUHBaEP3/rV7P6NlDE1Wy9oak9DbwI+XE+5Nv+N4cWBJzuQ4bC4/y AfVQ== X-Gm-Message-State: AOAM530aQyPpqQORiUva4xkRHbdI9dtm7M17R+NpiKfEMi5MjxrfS2+o Wn5XfdBaEySB+NcMWPLjPNORmvz9Zaqv9DIYie0EKqiFifAr5w== X-Google-Smtp-Source: ABdhPJwBwRd3nn54tOK0ZC7IUALdh8pArxe+G2IurYlt4fp6UIeY13XoKKzWik7Ghzud7qZhzIwQRbJeLsDnUnFqlkU= X-Received: by 2002:a67:fc93:: with SMTP id x19mr4269713vsp.40.1643393544647; Fri, 28 Jan 2022 10:12:24 -0800 (PST) X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::42c (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=maurooaranda@gmail.com; helo=mail-pf1-x42c.google.com X-Spam_score_int: 6 X-Spam_score: 0.6 X-Spam_bar: / X-Spam_report: (0.6 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:285520 Archived-At: --00000000000074764605d6a86087 Content-Type: text/plain; charset="UTF-8" Derek Davies 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. --00000000000074764605d6a86087 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Derek Davies <dd= avies@ddavies.net> writes:

> The other thing is that the i= nfo page seems categorical and detailed,
> but with many details miss= ing.=C2=A0 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.=C2=A0 If I remo= ve the :format keyword the value appears and is togglable.=C2=A0 How do I d= isplay a field label like I do with editable-field or most of the other wid= gets I've used?
>
[...]
>
> ;; -*- =C2=A0lexical-b= inding: t; -*-
>
>
> (require 'subr-x)
> (requi= re 'widget)
> (eval-when-compile
> =C2=A0 (require 'wid= -edit))
>
> (define-widget 'tog-wid 'group
> =C2= =A0 ""
> =C2=A0 :format " %v"
> =C2=A0 :ent= ry-format " %v"
> =C2=A0 :args '((editable-field
>= ; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0:tag "Limit"
> = =C2=A0 :format " %t %v\n")
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 (toggle
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0:tag "= Threads"
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0:format &quo= t; %t %v")))

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

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

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

should work.
--00000000000074764605d6a86087--