Subject: bug#79157: [PATCH] Fix recursive load when 'calc-always-load-extensions' is set

From: Sean Devlin <[email-masked]>
Date: Sat, 2 Aug 2025 11:31:53 -0500

Hi folks,

The Calc setting calc-always-load-extensions leads to a recursive load
error if you set it in your init file before loading calc.el. (If you set it after
loading calc.el, e.g. via calc-settings-file, there is no recursive error, but
it also doesn’t load the extensions.)

To reproduce:

1. Emacs -Q
2. Eval: (setq calc-always-load-extensions t)
3. M-x calc RET

You should see a recursive load error.

This is due to this top-level stanza near the bottom of calc.el:

(when calc-always-load-extensions
  (require 'calc-ext)
  (calc-load-everything))

This can never work as written, since calc-ext.el requires calc.el.

I took a stab at correcting this by deleting this stanza and moving the
call to calc-load-everything inside calc-create-buffer. I’m not sure if
this is the best way, so feedback is welcome.

Thanks!

In GNU Emacs 31.0.50 (build 1, aarch64-apple-darwin24.6.0, NS
appkit-2575.70 Version 15.6 (Build 24G84)) of 2025-08-02 built on
beatrix.local
Repository revision: 49e34dede07b2151dadc0e1f71cc4405ba7f42f5
Repository branch: calc-always-load-extensions-fix
Windowing system distributor 'Apple', version 10.3.2575
System Description:  macOS 15.6

Configured using:
'configure --with-ns --with-modules --with-native-compilation
--with-libgmp --with-tree-sitter --with-sqlite3 --with-mps=yes
--without-imagemagick --without-dbus CPPFLAGS=-I/opt/homebrew/include
LDFLAGS=-L/opt/homebrew/lib PKG_CONFIG_PATH=/opt/homebrew/lib/pkgconfig
ac_cv_func_posix_spawn_file_actions_addchdir=no'