* What's up with widgets?
@ 2022-01-28 15:37 Derek Davies
0 siblings, 0 replies; 2+ messages in thread
From: Derek Davies @ 2022-01-28 15:37 UTC (permalink / raw)
To: Emacs Devel
Hello!
I keep running into issues using widgets (wid-edit.el, etc) in my projects.
I give one example, involving the toggle widget, but it seems like I
run into unexpected behavior very often, depending on the widget I'm
trying to use. It feels to me like there is inconsistency around the
use of at lease some keywords that are shared between widget types.
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.
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?
Is it just me or do others experience this too? Wondering how much
inconsistency/missing doc there might be, or if it's ignorance on my part.
Thanks very much!
Derek
If it's not just me, I would like to work on the doc or widget code so that it's easier to use the widget library in user projects. Otherwise, would just apprechiate knowing what I'm missing :)
;; -*- 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")))
(defvar tog-buffer "*TOG*")
(defun tog-form ()
(interactive)
(switch-to-buffer tog-buffer)
(kill-all-local-variables)
(let ((inhibit-read-only t))
(erase-buffer)
(remove-overlays))
(widget-create 'tog-wid)
(use-local-map widget-keymap)
(widget-setup))
;; End
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: What's up with widgets?
@ 2022-01-28 18:15 Mauro Aranda
0 siblings, 0 replies; 2+ messages in thread
From: Mauro Aranda @ 2022-01-28 18:15 UTC (permalink / raw)
To: ddavies; +Cc: Emacs-Devel List
[-- Attachment #1: Type: text/plain, Size: 1302 bytes --]
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.
[-- Attachment #2: Type: text/html, Size: 1821 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-01-28 18:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-28 18:15 What's up with widgets? Mauro Aranda
-- strict thread matches above, loose matches on Subject: below --
2022-01-28 15:37 Derek Davies
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.