Subject: bug#78637: 30.1.90; Calling setopt during init loads cus-start over and over

From: Stefan Monnier <[email-masked]>
Date: Sat, 31 May 2025 12:37:54 -0400

> This dates back to
>
>     commit 4883633e7b4416a0da1a63bc7fd0c4081bdc7837
>     Author: Richard M. Stallman <[email-masked]>
>     Date:   Sat May 31 00:54:10 1997 +0000
>     
>         Arrange to load it once during dumping,
>         and again if needed by cus-edit.el.
[...]
> I have no idea why, but it's not a new problem.

The why is a bit further up in the file:

      (unless dump-mode
	;; Add it to the right group(s).
	(if (listp group)
	    (dolist (g group)
	      (custom-add-to-group g symbol 'custom-variable))
	  (custom-add-to-group group symbol 'custom-variable))
	;; Set the type.
	(put symbol 'custom-type type)
	(while rest
	  (setq prop (car rest)
		propval (cadr rest)
		rest (nthcdr 2 rest))
	  (cond ((memq prop '(:standard :risky :safe :set))) ; handled above
		((eq prop :tag)
		 (put symbol 'custom-tag propval))))))))

IOW, the dump-time load of `cus-start.el` only sets up part of the info
(to try and keep the dumped executable a bit smaller), which is why we
need to *re*load it later.

So the remaining question is why/when it may be reloaded multiple times
rather than once.  I personally don't see this behavior here, so I think
we need a more detailed recipe to investigate the origin.

        Stefan