Subject: Re: bug#42887: 28.0.50; Customize Group doesn't show/hide option on repeated clicking

From: Stefan Kangas <[email-masked]>
Date: Tue, 17 Nov 2020 03:48:30 -0800

Mauro Aranda <[email-masked]> writes:

> Stefan Kangas <[email-masked]> writes:
>
>> Mauro Aranda <[email-masked]> writes:
>>
>>> Only when I click "too fast" the option doesn't expand,
>>
>> That's different from what I'm seeing.  I can wait several seconds
>> between clicks, and as long as I don't move the mouse cursor the option
>> won't expand.
>
> I think I misunderstood your recipe.  Does an option that starts as hidden
> never expand for you in the recipe?

No, it does expand on the first click.

It will not expand on repeated clicks unless I move the mouse cursor
between clicks.  The delay does not matter (except if I click too fast I
see double-click events).

So I had a quick look, and the defun `custom-toggle-hide-variable' is
called on the first click.  The option then correctly expands.

But that function is not called on subsequent clicks.  After moving the
mouse cursor and clicking, it seems to register again and
`custom-toggle-hide-variable' is called.

This is what I used to test this:

diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el
index d1077d367d..86235f9fc0 100644
--- a/lisp/cus-edit.el
+++ b/lisp/cus-edit.el
@@ -2796,11 +2796,14 @@ custom-variable-value-create
 	  (custom-add-parent-links widget))
 	(custom-add-see-also widget)))))

+(defvar count 0)
 (defun custom-toggle-hide-variable (visibility-widget &rest _ignore)
   "Toggle the visibility of a `custom-variable' parent widget.
 By default, this signals an error if the parent has unsaved
 changes.  If the parent has a `simple' :custom-style property,
 the present value is saved to its :shown-value property instead."
+  (message "Click %s" count)
+  (setq count (1+ count))
   (let ((widget (widget-get visibility-widget :parent)))
     (unless (eq (widget-type widget) 'custom-variable)
       (error "Invalid widget type"))