GNU bug report logs - #66741
30.0.50; [BUG] pdumper, global-font-lock-mode, and :init-value in define-minor-mode

Previous Next

Package: emacs;

Reported by: Ihor Radchenko <yantar92 <at> posteo.net>

Date: Wed, 25 Oct 2023 09:02:02 UTC

Severity: normal

Found in version 30.0.50

To reply to this bug, email your comments to 66741 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to eliz <at> gnu.org, bug-gnu-emacs <at> gnu.org:
bug#66741; Package emacs. (Wed, 25 Oct 2023 09:02:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ihor Radchenko <yantar92 <at> posteo.net>:
New bug report received and forwarded. Copy sent to eliz <at> gnu.org, bug-gnu-emacs <at> gnu.org. (Wed, 25 Oct 2023 09:02:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ihor Radchenko <yantar92 <at> posteo.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.0.50; [BUG] pdumper, global-font-lock-mode, and :init-value in
 define-minor-mode
Date: Wed, 25 Oct 2023 09:02:25 +0000
X-Debbugs-CC: Eli Zaretskii <eliz <at> gnu.org>

Hi,

This is a followup after emacs-devel thread on using pdumper:
https://yhetil.org/emacs-devel/83msw8kw2f.fsf <at> gnu.org/

I was trying to create a simple Emacs dump via

------ dump.el -------
(dump-emacs-portable "/tmp/emacs-dumped.dmp")
----------------------
./src/emacs -q --batch -l ~/Downloads/dump.el

Similar to the problem described in
https://archive.casouri.cc/note/2020/painless-transition-to-portable-dumper/index.html
I got global-font-lock-mode disabled (and the value is nil) when
starting Emacs with the above dump file.

The first immediate surprise here is that lisp/loadup.el already has
(load "font-lock"). So, it should be pre-loaded already. I do not fully
understand why re-dumping changes Emacs behavior.

Trying to investigate a bit about the possible cause, I found the
following suspicious form in font-core.el:

(define-globalized-minor-mode global-font-lock-mode
  font-lock-mode turn-on-font-lock-if-desired
  ;; What was this :extra-args thingy for?  --Stef
  ;; :extra-args (dummy)
  :initialize 'custom-initialize-delay
  :init-value (not (or noninteractive emacs-basic-display))
  :group 'font-lock
  :version "22.1")

Note how :init-value is set according to `noninteractive', which is t
when creating the dump file.

It looks like either a bug in font-core.el that makes wrong assumptions
about :init-value evaluation time or a bug in `define-minor-mode' that
may need to arrange :init-value calculation to be evaluated at load
time.

-----------

Another (possible) problem appeared when I tried to work around the
above issue.  I attempted

(defun font-lock--enable-after-pdump ()
  "Re-initialize `global-font-lock-mode' after loading Emacs with dump file."
  (setq global-font-lock-mode (not (or noninteractive emacs-basic-display))))
(add-hook 'after-pdump-load-hook #'font-lock--enable-after-pdump)

But, to my surprise, it did not lead to font-lock-mode being active in
*scratch* buffer. Either I miss something important here or
`after-pdump-load-hook' may be evaluated too late in Emacs loading for
the purposes for setting up font-lock.

In GNU Emacs 30.0.50 (build 19, x86_64-pc-linux-gnu, GTK+ Version
 3.24.38, cairo version 1.18.0) of 2023-10-25 built on localhost
Repository revision: 8f00c9c3c6c4e76651c000e41582e002755e598b
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101008
System Description: Gentoo Linux

Configured using:
 'configure --with-native-compilation CFLAGS=-g3 --with-pdumper=yes'

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#66741; Package emacs. (Thu, 26 Oct 2023 09:20:02 GMT) Full text and rfc822 format available.

Message #8 received at 66741 <at> debbugs.gnu.org (full text, mbox):

From: Gerd Möllmann <gerd.moellmann <at> gmail.com>
To: Ihor Radchenko <yantar92 <at> posteo.net>
Cc: 66741 <at> debbugs.gnu.org, eli zaretskii <eliz <at> gnu.org>
Subject: Re: bug#66741: 30.0.50; [BUG] pdumper, global-font-lock-mode, and
 :init-value in define-minor-mode
Date: Thu, 26 Oct 2023 11:18:21 +0200
Ihor Radchenko <yantar92 <at> posteo.net> writes:

> (define-globalized-minor-mode global-font-lock-mode
>   font-lock-mode turn-on-font-lock-if-desired
>   ;; What was this :extra-args thingy for?  --Stef
>   ;; :extra-args (dummy)
>   :initialize 'custom-initialize-delay
                 ^^^^^^^^^^^^^^^^^^^^^^^
                 
This at least is the same problem as for transient-mark-mode.
Don't know about the other things.




This bug report was last modified 191 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.