From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ihor Radchenko Newsgroups: gmane.emacs.bugs Subject: bug#66742: 30.0.50; transient-mark-mode is not enabled after re-dumping Emacs Date: Thu, 26 Oct 2023 11:42:57 +0000 Message-ID: <874jidd2ym.fsf@localhost> References: <8734xz2guk.fsf@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36753"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 66742@debbugs.gnu.org To: Gerd =?UTF-8?Q?M=C3=B6llmann?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Oct 26 13:41:50 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qvykI-0009Ns-8K for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 26 Oct 2023 13:41:50 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qvyk2-0007kM-8K; Thu, 26 Oct 2023 07:41:34 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qvyjz-0007h0-VS for bug-gnu-emacs@gnu.org; Thu, 26 Oct 2023 07:41:32 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qvyjz-00017j-Gi for bug-gnu-emacs@gnu.org; Thu, 26 Oct 2023 07:41:31 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qvykU-0004nH-6m for bug-gnu-emacs@gnu.org; Thu, 26 Oct 2023 07:42:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ihor Radchenko Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 26 Oct 2023 11:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66742 X-GNU-PR-Package: emacs Original-Received: via spool by 66742-submit@debbugs.gnu.org id=B66742.169832051818417 (code B ref 66742); Thu, 26 Oct 2023 11:42:02 +0000 Original-Received: (at 66742) by debbugs.gnu.org; 26 Oct 2023 11:41:58 +0000 Original-Received: from localhost ([127.0.0.1]:60675 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qvykP-0004mz-Vb for submit@debbugs.gnu.org; Thu, 26 Oct 2023 07:41:58 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:45795) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qvykN-0004mk-5H for 66742@debbugs.gnu.org; Thu, 26 Oct 2023 07:41:56 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id DB6D4240103 for <66742@debbugs.gnu.org>; Thu, 26 Oct 2023 13:41:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1698320477; bh=2vGyuvD9RYT8hlIAYIC5Z2y39ypbn9HFJRT4y47TETc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version: Content-Transfer-Encoding:From; b=ae4577DBZnvw5aFlg4J+QK7W05rP6G239zd3W96iJ7WsaSBaBEPa83sx2A/+RuvWz o92th6+eKy7nA4iLLnlpEoFmk6VE6O1PRf1glKPnyqRSnP+2Zxlq6HVtyiJBLVt6DQ MwEKwkIwt+AJENWwDI5Dva+/HLlOqjaljqh47Xr19AIMV+hXNatA88UWfMrssHA6VZ GBb4ahKybFK1yOblvbqEKvnRHmMxfKKcM6CZSkjZtuRH0wmb/ZjmiPtL6IWaiC/JO1 kGsl7Rf51nNQ7JoCmKmHot/gGRvlBGEDr7xjXii7tRbzrrCJ1utIBYonbdF9n4l+BN Gqd7j14CJNjcg== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4SGP585wcxz9rxB; Thu, 26 Oct 2023 13:41:16 +0200 (CEST) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:273266 Archived-At: Gerd M=C3=B6llmann writes: > 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. Thanks for the analysis. I dag a bit further and it looks like :initialize is used in `define-minor-mode' and `defcustom' with the latter simply deferring :initialize keyword processing to `defcustom'. The :initialize keyword in `defcustom' is implicitly assumed to be evaluated during Emacs startup, in the Emacs sessions that will use the custom definition. Actually, I think that I will not be wrong to say that (defvar foo . ..), (defcustom foo ...), and similar expressions are often assumed to evaluated in the same Emacs session that will use the library. For example, Org mode often calculated default variable values dynamically: (defcustom org-clock-x11idle-program-name (if (executable-find "xprintidle") "xprintidle" "x11idle") ...) Re-dumping such code is prone to subtle bugs when the dumping environment differs from the runtime. Things get worse when loading a library relies on side effects: ----- org-persist.el --------- ;; Point to temp directory when `org-persist--disable-when-emacs-Q' is set. (when (and org-persist--disable-when-emacs-Q ;; FIXME: This is relying on undocumented fact that ;; Emacs sets `user-init-file' to nil when loaded with ;; "-Q" argument. (not user-init-file)) (setq org-persist-directory (make-temp-file "org-persist-" 'dir))) ---------------------------- I suspect that it is only truly safe to re-dump parts of the libraries that do not emit (byte-code ...) in the compiler output. For example, the following is .elc part corresponding to the above defcustom: (defvar org-x11idle-exists-p (byte-code "\302>?\205%17\303\304\305 \"!\306= =3D\205%17\303 !\306=3D\207" [system-type org-clock-x11idle-program-name (w= indows-nt ms-dos) call-process-shell-command format "command -v %s" 0] 4))#= @46 Return the current X11 idle time in seconds.=1F The variable itself can be defined, but its value is (byte-code ...) and thus should be evaluated during startup, and not dumped. And the side-effect clause is a complete (byte-code ...): (byte-code "\203%d \204%d\303\304\305\"%12\306\307\n!!\310%1!\204%%0\211\3= 06\311%3!!\211\262%3\232\203%12\312%1!\2044%0\313\314\n\"\266%2\202D%0\315\= 316\317\"\210\315\316\320\"\210\315\316\321\"\266%2\315\322\323\"\210\324\3= 25!\207" [org-persist--disable-when-emacs-Q user-init-file org-persist-dire= ctory make-temp-file "org-persist-" dir directory-file-name file-name-as-di= rectory file-exists-p file-name-directory file-writable-p message "Missing = write access rights to org-persist-directory: %S" add-hook kill-emacs-hook = org-persist-clear-storage-maybe org-persist-write-all org-persist-gc after-= init-hook org-persist-load-all provide org-persist] 5) --=20 Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at