Subject: Re: bug#48531: Error on `Apply and Save` when using customize

From: Mikhail P <[email-masked]>
Date: Sat, 22 May 2021 15:53:22 +0700

Hi Mauro

version build from master branch is free of this bug.

Thanks,

-Mikhail

On 5/20/21 5:11 PM, Mauro Aranda wrote:
> Mikhail P <[email-masked]> writes:
>
>> Greetings!
>>
>> I started to see problems with customizing anything using M-x customize.
>>
>> When I change something and then press Apply and Save I get an error. Attached is what
>> I got in the trace when applying and saving debug-on-error .
>>
>> Unfortunately I could not reproduce it with -Q because the feature Apply and Save
>> becomes unavailable. However I could reproduce it without any .emacs file.
>>
>> Below is what report-emacs-bug has generated. Thanks for any help.
>>
>> Debugger entered--Lisp error: (void-function nil)
>>    nil(nil)
>>    widget-apply(nil :value-get)
>>    widget-value(nil)
>>    custom-variable-modified-p((custom-variable :tag "Debug Ignored Errors" :value debug-ignored-errors :custom-form edit :custom-magic (custom-magic :args (nil) :parent #1 :indent 0 :children nil :from #<marker (moves after insertion) at 236 in *Customize Apropos*> :to #<marker at 236 in *Customize Apropos*> :buttons nil :value nil) :buttons ((documentation-string :args nil :value "List of errors for which the debugger should not b..." :indent 3 :visibility-widget custom-visibility :parent #1 :doc-overlay #<overlay from 236 to 299 in *Customize Apropos*> :buttons ((custom-visibility :args nil :value nil :help-echo "Show or hide rest of the documentation." :on "Hide" :off "More" :always-active t :action widget-parent-action :parent #13 :indent 3 :button-overlay #<overlay from 299 to 303 in *Customize Apropos*> :from #<marker (moves after insertion) at 299 in *Customize Apropos*> :to #<marker at 303 in *Customize Apropos*>)) :from #<marker (moves after insertion) at 236 in *Customize Apropos*> :to #<marker at 304 in *Customize Apropos*>) (custom-magic :args (nil) :parent #1 :indent 0 :children nil :from #<marker (moves after insertion) at 236 in *Customize Apropos*> :to #<marker at 236 in *Customize Apropos*> :buttons nil :value nil) (item :format "%{%t%} " :sample-face custom-variable-tag :tag "Debug Ignored Errors" :parent #1 :indent 0 :sample-overlay #<overlay from 214 to 234 in *Customize Apropos*> :from #<marker (moves after insertion) at 214 in *Customize Apropos*> :to #<marker at 235 in *Customize Apropos*>) (custom-visibility :args nil :value nil :help-echo "Show the value of this option." :on-glyph "down" :on "Hide" :off-glyph "right" :off "Show Value" :action custom-toggle-hide-variable :parent #1 :indent 0 :suppress-face t :button-overlay #<overlay from 203 to 213 in *Customize Apropos*> :from #<marker (moves after insertion) at 203 in *Customize Apropos*> :to #<marker at 213 in *Customize Apropos*>)) :documentation-indent 3 :children nil :custom-state hidden :from #<marker (moves after insertion) at 203 in *Customize Apropos*> :to #<marker at 304 in *Customize Apropos*>))
> Thanks for the bug report.  This looks like Bug#40853 (and Bug#42801),
> which was fixed in the development branch with this fix:
>
> commit 5c39f6f1165a33f5714eedd3a413f786dffbb5a2
> Author: Mauro Aranda <[email-masked]>
> Date:   Fri Aug 14 16:40:40 2020 +0200
>
>      Make sure we only act on edited widgets in Custom-save
>      
>      * lisp/cus-edit.el (Custom-save): Only act on edited widgets in the
>      buffer.  If we attempt to redraw all widgets, we confuse
>      custom-variable-modified-p, or we end up drawing State buttons for
>      all options, including the hidden ones (bug#42801).
>
> Would it be possible for you to build Emacs from the master branch and
> see if you can reproduce it?
>
> Alternatively, maybe you can try to redefine Custom-save as below in
> your Emacs session, and see if you can reproduce it.
>
> (defun Custom-save (&rest _ignore)
>    "Set all edited settings, then save all settings that have been set.
> If a setting was edited and set before, this saves it.  If a
> setting was merely edited before, this sets it then saves it."
>    (interactive)
>    (let (edited-widgets)
>      (when (custom-command-apply
> 	   (lambda (child)
> 	     (when (memq (widget-get child :custom-state)
> 		         '(modified set changed rogue))
>                 (push child edited-widgets)
> 	       (widget-apply child :custom-mark-to-save)))
> 	   "Save all settings in this buffer? " t)
>        ;; Save changes to buffer.
>        (custom-save-all)
>        ;; Redraw and recalculate the state when necessary.
>        (dolist (widget edited-widgets)
>          (widget-apply widget :custom-state-set-and-redraw)))))
>