Subject: Re: bug#66742: 30.0.50; transient-mark-mode is not enabled after re-dumping Emacs

From: Gerd Möllmann <[email-masked]>
Date: Thu, 26 Oct 2023 11:11:38 +0200

Ihor Radchenko <[email-masked]> writes:

> Steps to reproduce:
>
> 1. ./src/emacs -Q --batch -l ~/Downloads/dump.el 
> With dump.el:
>
> (dump-emacs-portable "/tmp/emacs-dumped.dmp")
>
> 2. ./src/emacs -Q --dump-file="/tmp/emacs-dumped.dmp"
>
> 3. C-<SPC> C-p C-p
>
> Expected: active region is highlighted
> Observed: Transient mark mode is not enabled and thus active region is
>           not highlighted.

Just an analyis.

AFAICS, this one comes from a special handling of some custom variables.
In function command-line, we have

  ;; Re-evaluate predefined variables whose initial value depends on
  ;; the runtime context.  But delay the warning about
  ;; `user-emacs-directory' being inaccessible until after processing
  ;; the init file and the command-line arguments, in case the user
  ;; customized `user-emacs-directory-warning' to nil via those.
  (let ((user-emacs-directory-warning nil))
    (when (listp custom-delayed-init-variables)
      (mapc #'custom-reevaluate-setting
            ;; Initialize them in the same order they were loaded, in
            ;; case there are dependencies between them.
            (reverse custom-delayed-init-variables))))
  (setq custom-delayed-init-variables t)

The list of custom-delayed-init-variables is built by function
custom-initialize-delay. If you grep for that, you'll finds a number of
declarations containing an :initialize with the delaying function.

In a re-dumped Emacs, the variable is not a list, so nothing is done. In
the particular case of transient-mark-mode, the default value, which is
set in C, is nil, so it keeps that value.