Subject: bug#76716: 30.1; Invalid warning related to image-scaling-factor when cus-edit is required

From: Pierre Rouleau <[email-masked]>
Date: Mon, 3 Mar 2025 11:37:10 -0500

Problem Description
===================

I am compiling my Elisp code, controlling it by a GNU make script.
The compilation is done with something like this:

    emacs -Q  --batch -L . -f batch-byte-compile pel-custom.el

For some of these file I get this warning with Emacs 30.1, something I have never
seen with previous versions of Emacs:

    Note, built-in variable ‘image-scaling-factor’ not bound

My code does not refer to ‘image-scaling-factor’.

Discussed in help-gnu-emacs
===========================

See:
- https://lists.gnu.org/archive/html/help-gnu-emacs/2025-03/msg00006.html
- https://lists.gnu.org/archive/html/help-gnu-emacs/2025-03/msg00034.html

More Details
============

This warning shows up when:
- I build, from a shell controlled by GNU Make, my emacs lisp files with:
- GNU Emacs 30.1 (build 1, aarch64-apple-darwin23.6.0) of 2025-02-23
- (display-graphic-p) returns nil.
- system-configuration-features = GMP GNUTLS LIBXML2 MODULES NOTIFY KQUEUE PDUMPER SQLITE3 THREADS TREE_SITTER ZLIB

With my files:
- pel-setup.el having the (require 'cus-edit) at the top
   of the file (outside any defun)
- pel-benchmark.el which (requires pel-setup.el)
- With the Makefile aware of pel-benchmark.elc depending on
  pel-setup.elc with this dependency line:
    pel-benchmark.elc:      pel--base.elc pel-window.elc pel-setup.elc

If I touch pel-setup.el a make, done on a macOS system which uses that
Emacs 30.1, does this:

>0@08:49:54 L1 [~/my/dv/elisp/pel]  git:(master)pel
zsh% make
emacs -Q  --batch -L . -f batch-byte-compile pel-setup.el
Note, built-in variable ‘image-scaling-factor’ not bound
emacs -Q  --batch -L . -f batch-byte-compile pel-benchmark.el
Note, built-in variable ‘image-scaling-factor’ not bound
>0@08:51:18 L1 [~/my/dv/elisp/pel]  git:(master)pel
zsh%    

Also note that when, inside Emacs 30.1 on this system where I get the
warnings when I use (pel-byte-compile-file-and-load) to compile the
setup.el file then I see *no* warning:

Leaving directory ‘~/my/dv/elisp/pel/’
^L
Compiling file /Users/roup/my/dv/elisp/pel/pel-setup.el at Mon Mar  3 08:49:17 2025
Entering directory ‘/Users/roup/my/dv/elisp/pel/’
^L
Compiling internal form(s) at Mon Mar  3 08:49:42 2025

I only see the warning when building from the shell with the
command: emacs -Q  --batch -L . -f batch-byte-compile

On my system I use several scripts to start Emacs.  
One is 'e' which starts the same as emacs above: the terminal mode emacs.  
Another is 'ge' which starts a graphics capable Emacs on that macOS
system.  
The warning shows up only when compiling with the terminal-mode Emacs
but not with the graphics capable Emacs:

>0@08:51:18 L1 [~/my/dv/elisp/pel]  git:(master)pel
zsh% ge -Q  --batch -L . -f batch-byte-compile pel-setup.el
>0@09:11:12 L1 [~/my/dv/elisp/pel]  git:(master)pel
zsh% e -Q  --batch -L . -f batch-byte-compile pel-setup.el
Note, built-in variable ‘image-scaling-factor’ not bound
>0@09:11:25 L1 [~/my/dv/elisp/pel]  git:(master)pel
zsh%    

The graphics capable Emacs on that macOS system is:
- GNU Emacs 30.1 (build 1, aarch64-apple-darwin21.6.0, NS appkit-2113.65 Version 12.7.6 (Build 21H1320)) of 2025-02-24
- (display-graphic-p) returns t.
- system-configuration-features = ACL GLIB GMP GNUTLS JPEG LIBXML2 MODULES NOTIFY KQUEUE NS PDUMPER PNG RSVG SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XIM ZLIB

On Emacs 29.4 running on a Linux hosts I use.
I still have Emacs 29.4:

- GNU Emacs 29.4.50 (build 2, x86_64-pc-linux-gnu) of 2024-08-15
- (display-graphic-p) returns nil.
- system-configuration-features = GMP GNUTLS LIBSELINUX LIBXML2 MODULES NOTIFY INOTIFY PDUMPER SECCOMP SOUND THREADS TREE_SITTER ZLIB

When I build with the same file content and touch setup.el I get no warnings:

> 0,et:0.005s,L2,0j 09:02:13[~/my/dv/elisp/pel]
bash$ make
emacs -Q  --batch -L . -f batch-byte-compile pel-setup.el
emacs -Q  --batch -L . -f batch-byte-compile pel-benchmark.el
> 0,et:0.273s,L2,0j r09:02:16[~/my/dv/elisp/pel]
bash$

The reason I mentioned make and the dependency is that
pel-benchmark.el does *not* have any line that requires 'cus-edit.
It only has a line that require pel-setup.
And yet I get a warning compiling pel-benchmark.el as well.
I get this warning compiling any file that directly or indirectly require 'cus-edit
with the method I described above.

-The-End-
=========

In GNU Emacs 30.1 (build 1, aarch64-apple-darwin23.6.0) of 2025-02-23
built on Sonoma-arm64.local
System Description:  macOS 14.7.3

Configured using:
'configure --disable-acl --disable-silent-rules
--enable-locallisppath=/opt/homebrew/share/emacs/site-lisp
--infodir=/opt/homebrew/Cellar/emacs/30.1/share/info/emacs
--prefix=/opt/homebrew/Cellar/emacs/30.1 --with-gnutls --without-x
--with-xml2 --without-dbus --with-modules --without-ns
--without-imagemagick --without-selinux --with-tree-sitter'

Configured features:
GMP GNUTLS LIBXML2 MODULES NOTIFY KQUEUE PDUMPER SQLITE3 THREADS
TREE_SITTER ZLIB

Important settings:
  value of $LANG: en_CA.UTF-8
  locale-coding-system: utf-8-unix

Major mode: VC dir

Minor modes in effect:
  windmove-mode: t
  which-key-mode: t
  winner-mode: t
  key-chord-mode: t
  display-time-mode: t
  global-anzu-mode: t
  anzu-mode: t
  vc-dir-git-mode: t
  flx-ido-mode: t
  ido-ubiquitous-mode: t
  ido-everywhere: t
  recentf-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  minibuffer-regexp-mode: t
  buffer-read-only: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
/Users/roup/.emacs.d/utils/sr-speedbar hides /Users/roup/.emacs.d/elpa/sr-speedbar-20220705.1231/sr-speedbar
/Users/roup/.emacs.d/elpa/lispy-20230314.1738/elpa hides /Users/roup/.emacs.d/elpa/ivy-20250224.2125/elpa
/Users/roup/.emacs.d/elpa/cmake-mode-20250114.1444/cmake-mode hides /opt/homebrew/share/emacs/site-lisp/cmake/cmake-mode
/Users/roup/.emacs.d/elpa/lfe-mode-20241206.1536/lfe-indent hides /opt/homebrew/share/emacs/site-lisp/lfe/lfe-indent
/Users/roup/.emacs.d/elpa/lfe-mode-20241206.1536/lfe-mode hides /opt/homebrew/share/emacs/site-lisp/lfe/lfe-mode
/Users/roup/.emacs.d/elpa/lfe-mode-20241206.1536/inferior-lfe hides /opt/homebrew/share/emacs/site-lisp/lfe/inferior-lfe
/Users/roup/.emacs.d/elpa/transient-20250228.1901/transient hides /opt/homebrew/Cellar/emacs/30.1/share/emacs/30.1/lisp/transient
/Users/roup/.emacs.d/utils/cperl-mode hides /opt/homebrew/Cellar/emacs/30.1/share/emacs/30.1/lisp/progmodes/cperl-mode

Features:
(shadow sort mail-extr emacsbug smex hippie-exp smerge-mode diff
whitespace elec-pair org-indent oc-basic org-element org-persist org-id
org-refile org-element-ast inline avl-tree ol-eww eww url-queue mm-url
ol-rmail ol-mhe ol-irc ol-info ol-gnus nnselect gnus-art mm-uu mml2015
mm-view mml-smime smime gnutls dig gnus-sum shr pixel-fill kinsoku
url-file svg gnus-group gnus-undo gnus-start gnus-dbus dbus xml
gnus-cloud nnimap nnmail mail-source utf7 nnoo parse-time gnus-spec
gnus-int gnus-range gnus-win gnus nnheader range ol-docview doc-view
filenotify jka-compr image-mode exif ol-bibtex bibtex iso8601 ol-bbdb
ol-w3m ol-doi org-link-doi macrostep compat mule-util pel-ibuffer
ibuf-ext ibuffer ibuffer-loaddefs pel-elisp pel-iedit iedit iedit-lib
mc-hide-unmatched-lines-mode mc-mark-more sgml-mode facemenu dom
mc-cycle-cursors multiple-cursors-core rect pel-whitespace time-stamp
copyright windmove bm pel-mark misearch multi-isearch pel-search
pel-search-regexp pel-numkpad pel-ccp hl-line
display-fill-column-indicator log-edit message sendmail yank-media puny
rfc822 mml mml-sec epa derived epg rfc6068 epg-config gnus-util
mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 mm-util
ietf-drums mail-prsvr mailabbrev mail-utils gmm-utils mailheader add-log
vc-hg vc-bzr vc-src vc-sccs pel-vc vc-svn vc-cvs vc-rcs log-view
pcvs-util vc-dir ewoc vc ace-link pel-skels-generic counsel xdg dired-x
dired dnd dired-loaddefs compile text-property-search swiper cl-extra
ivy ivy-faces ivy-overlay colir color which-key indent-tools yafolding s
indent-tools-indentation-of winner helm-xref helm-utils helm-help helm
helm-global-bindings helm-easymenu edmacro kmacro helm-core helm-source
helm-multi-match helm-lib async key-seq pel-key-chord key-chord time
anzu vc-git diff-mode track-changes easy-mmode vc-dispatcher emacros
term/xterm xterm tempo pel-skels-elisp pel-text-insert pel-tempo
pel-skels lispy delsel lispy-inline avy etags fileloop generator edebug
debug backtrace help-fns radix-tree help-mode lispy-tags mode-local
zoutline org ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro
org-src pel-sh-iedit sh-script smie treesit executable ob-comint
org-pcomplete pcomplete org-list org-footnote org-faces org-entities
time-date org-version ob-emacs-lisp ob-core ob-eval org-cycle org-table
ol org-fold org-fold-core org-keys oc org-loaddefs thingatpt find-func
cal-menu calendar cal-loaddefs org-compat org-macs format-spec noutline
outline pel__hydra hydra lv pel-lispy pel-spell-iedit flyspell ispell
pel-spell imenu+ pel-imenu imenu ido-grid flx-ido flx pel-completion
pel-ido pel-seq ido-completing-read+ memoize cus-edit pp cus-start
cus-load minibuf-eldef ido pel_keys recentf tree-widget wid-edit
two-column pel-erlang xref project pel-xref pel-pathmng
display-line-numbers pel-text-transform pel-read pel-navigate cap-words
superword subword pel-scroll pel-window pel-prompt pel-syntax
pel--syntax-macros pel-fs pel-ffind comint ansi-osc ansi-color ring
pel-cc-linux-kernel cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles
cc-align cc-engine cc-vars cc-defs speedbar ezimage image dframe ls-lisp
delight pel-autoload pel--keys-macros pel--options pel--macros pel--base
pel finder-inf benchmark-init advice ace-link-autoloads
adoc-mode-autoloads ag-autoloads alchemist-autoloads anzu-autoloads
archive-rpm-autoloads ascii-table-autoloads asn1-mode-autoloads
bison-mode-autoloads bm-autoloads browse-kill-ring-autoloads
call-graph-autoloads beacon-autoloads cargo-autoloads cider-autoloads
clojure-mode-autoloads clojure-snippets-autoloads cmake-mode-autoloads
company-erlang-autoloads company-autoloads counsel-osx-app-autoloads
csv-mode-autoloads cwl-mode-autoloads d-mode-autoloads debbugs-autoloads
delight-autoloads desktop+-autoloads diffview-autoloads
dir-treeview-autoloads dired-git-info-autoloads
dired-hide-dotfiles-autoloads dired-narrow-autoloads
dired-sidebar-autoloads dired-subtree-autoloads
dired-hacks-utils-autoloads dockerfile-mode-autoloads
dumb-jump-autoloads easy-escape-autoloads eat-autoloads edts-autoloads
auto-highlight-symbol-autoloads auto-complete-autoloads
elixir-mode-autoloads elmacro-autoloads eopengrok-autoloads
erlstack-mode-autoloads eros-autoloads esup-autoloads
expand-region-autoloads exunit-autoloads flx-ido-autoloads flx-autoloads
flycheck-plantuml-autoloads flycheck-rust-autoloads forth-mode-autoloads
free-keys-autoloads fuel-autoloads geiser-chez-autoloads
geiser-chibi-autoloads geiser-chicken-autoloads geiser-gambit-autoloads
geiser-guile-autoloads geiser-racket-autoloads geiser-autoloads
ggtags-autoloads git-modes-autoloads go-mode-autoloads
go-translate-autoloads golden-ratio-autoloads goto-last-change-autoloads
graphviz-dot-mode-autoloads gxref-autoloads haskell-mode-autoloads
helm-cscope-autoloads helm-descbinds-autoloads helm-lsp-autoloads
helm-xref-autoloads helm-autoloads helm-core-autoloads helpful-autoloads
elisp-refs-autoloads hgignore-mode-autoloads hide-lines-autoloads
highlight-defined-autoloads highlight-indentation-autoloads
hy-mode-autoloads ibuffer-vc-autoloads ido-completing-read+-autoloads
ido-vertical-mode-autoloads idomenu-autoloads iflipb-autoloads
imenu-anywhere-autoloads impatient-showdown-autoloads
impatient-mode-autoloads htmlize-autoloads indent-tools-autoloads
intel-hex-mode-autoloads interaction-log-autoloads ivy-avy-autoloads
ivy-erlang-complete-autoloads erlang-autoloads counsel-autoloads
async-autoloads ivy-hydra-autoloads ivy-xref-autoloads key-seq-autoloads
key-chord-autoloads keycast-autoloads lfe-mode-autoloads lice-autoloads
lispy-autoloads iedit-autoloads lsp-ivy-autoloads lsp-treemacs-autoloads
lsp-mode-autoloads macrostep-autoloads markdown-preview-mode-autoloads
markdown-mode-autoloads memoize-autoloads merlin-autoloads
monky-autoloads multiple-cursors-autoloads neotree-autoloads
nhexl-mode-autoloads nim-mode-autoloads flycheck-nimsuggest-autoloads
flycheck-autoloads commenter-autoloads epc-autoloads ctable-autoloads
concurrent-autoloads deferred-autoloads nix-mode-autoloads
osx-plist-autoloads outshine-autoloads outorg-autoloads
parseedn-autoloads parseclj-autoloads pcre2el-autoloads
pkg-info-autoloads epl-autoloads plantuml-mode-autoloads
popup-kill-ring-autoloads popup-autoloads projectile-speedbar-autoloads
queue-autoloads racer-autoloads pos-tip-autoloads racket-mode-autoloads
rainbow-delimiters-autoloads rainbow-mode-autoloads regex-tool-autoloads
relint-autoloads rfc-mode-autoloads rg-autoloads ripgrep-autoloads
rtags-xref-autoloads rtags-autoloads rust-mode-autoloads
sesman-autoloads simple-httpd-autoloads sly-autoloads
smart-dash-autoloads smart-shift-autoloads smartparens-autoloads
smex-autoloads sr-speedbar-autoloads suggest-autoloads spinner-autoloads
f-autoloads loop-autoloads swift-mode-autoloads swift-ts-mode-autoloads
swiper-autoloads ivy-autoloads toml-autoloads transpose-frame-autoloads
tree-mode-autoloads tree-sitter-langs-autoloads tree-sitter-autoloads
treemacs-magit-autoloads magit-autoloads pcase transient-autoloads
magit-section-autoloads llama-autoloads treemacs-projectile-autoloads
treemacs-autoloads cfrs-autoloads posframe-autoloads ht-autoloads
pfuture-autoloads ace-window-autoloads avy-autoloads s-autoloads
projectile-autoloads treeview-autoloads tsc-autoloads tuareg-autoloads
regexp-opt rx caml-autoloads tzc-autoloads undo-propose-autoloads
v-mode-autoloads hydra-autoloads lv-autoloads
visual-regexp-steroids-autoloads visual-regexp-autoloads
vmd-mode-autoloads web-server-autoloads websocket-autoloads
wfnames-autoloads wgrep-autoloads window-purpose-autoloads
imenu-list-autoloads windresize-autoloads winum-autoloads dash-autoloads
info tool-bar with-editor-autoloads x509-mode-autoloads
xcscope-autoloads xr-autoloads yafolding-autoloads yaml-mode-autoloads
yang-mode-autoloads yasnippet-snippets-autoloads yasnippet-autoloads
zig-mode-autoloads reformatter-autoloads zig-ts-mode-autoloads
zoutline-autoloads ztree-autoloads package browse-url url url-proxy
url-privacy url-expand url-methods url-history url-cookie
generate-lisp-file url-domsuf url-util mailcap url-handlers url-parse
auth-source cl-seq eieio eieio-core cl-macs icons password-cache json
subr-x map byte-opt gv bytecomp byte-compile url-vars cl-loaddefs cl-lib
rmc iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook
vc-hooks lisp-float-type elisp-mode tabulated-list replace newcomment
text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow
isearch easymenu timer select mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads kqueue multi-tty
make-network-process emacs)

Memory information:
((conses 16 1019538 344910) (symbols 48 50914 0) (strings 32 269343 42796)
(string-bytes 1 6688162) (vectors 16 104836) (vector-slots 8 1685004 161834)
(floats 8 672 51339) (intervals 56 24582 3927) (buffers 992 31))