From c4c6b0ff0ea06b67b5e9e878db1acf86bbb5d2b4 Mon Sep 17 00:00:00 2001
From: "James K. Lowden" <jklowden@cobolworx.com>
Date: Sat, 21 Mar 2026 13:27:37 -0400
Subject: [PATCH] introduce %quiet-auto-compile

---
 libguile/load.c         | 33 ++++++++++++++++++++++++++-------
 module/ice-9/boot-9.scm |  8 +++++---
 2 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/libguile/load.c b/libguile/load.c
index 7b955a743..e9dd55ecf 100644
--- a/libguile/load.c
+++ b/libguile/load.c
@@ -270,6 +270,9 @@ static SCM *scm_loc_load_should_auto_compile;
 /* Whether to treat all auto-compiled files as stale. */
 static SCM *scm_loc_fresh_auto_compile;
 
+/* Whether we should announce auto-compile. */
+static SCM *scm_loc_quiet_auto_compile;
+
 /* The fallback path for auto-compilation */
 static SCM *scm_loc_compile_fallback_path;
 
@@ -613,7 +616,7 @@ compiled_is_fresh (SCM full_filename, SCM compiled_filename,
       compiled_is_newer = 0;
       scm_puts (";;; note: source file ", scm_current_warning_port ());
       scm_display (full_filename, scm_current_warning_port ());
-      scm_puts ("\n;;;       newer than compiled ", scm_current_warning_port ());
+      scm_puts ("\n;;;   is  newer than compiled ", scm_current_warning_port ());
       scm_display (compiled_filename, scm_current_warning_port ());
       scm_puts ("\n", scm_current_warning_port ());
     }
@@ -1129,17 +1132,27 @@ auto_compile_catch_handler (void *data, SCM tag, SCM throw_args)
   return SCM_BOOL_F;
 }
 
+static bool
+is_quiet_auto_compile() {
+    SCM var = scm_c_public_lookup("guile", "%quiet-auto-compile");
+    SCM value = scm_variable_ref(var);
+
+    return scm_is_true(value);
+}
+
 SCM_DEFINE (scm_sys_warn_auto_compilation_enabled, "%warn-auto-compilation-enabled", 0, 0, 0,
 	    (void), "")
 #define FUNC_NAME s_scm_sys_warn_auto_compilation_enabled
 {
   static int message_shown = 0;
-
   if (!message_shown)
     {
-      scm_puts (";;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0\n"
-                ";;;       or pass the --no-auto-compile argument to disable.\n",
-                scm_current_warning_port ());
+      if( ! is_quiet_auto_compile() )
+        {
+          scm_puts (";;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0\n"
+                    ";;;       or pass the --no-auto-compile argument to disable.\n",
+                    scm_current_warning_port ());
+        }
       message_shown = 1;
     }
 
@@ -1413,6 +1426,8 @@ scm_init_load ()
     = SCM_VARIABLE_LOC (scm_c_define ("%load-should-auto-compile", SCM_BOOL_F));
   scm_loc_fresh_auto_compile
     = SCM_VARIABLE_LOC (scm_c_define ("%fresh-auto-compile", SCM_BOOL_F));
+  scm_loc_quiet_auto_compile
+    = SCM_VARIABLE_LOC (scm_c_define ("%quiet-auto-compile", SCM_BOOL_F));
 
   scm_ellipsis = scm_from_latin1_string ("...");
 
@@ -1431,6 +1446,7 @@ scm_init_load ()
 void
 scm_init_load_should_auto_compile ()
 {
+  static const char fresh[] = "fresh", quiet[] = "quiet";
   char *auto_compile = getenv ("GUILE_AUTO_COMPILE");
 
   if (auto_compile && strcmp (auto_compile, "0") == 0)
@@ -1438,14 +1454,17 @@ scm_init_load_should_auto_compile ()
       *scm_loc_load_should_auto_compile = SCM_BOOL_F;
       *scm_loc_fresh_auto_compile = SCM_BOOL_F;
     }
-  /* Allow "freshen" also.  */
-  else if (auto_compile && strncmp (auto_compile, "fresh", 5) == 0)
+  else if (auto_compile && strcmp (auto_compile, fresh) == 0)
     {
       *scm_loc_load_should_auto_compile = SCM_BOOL_T;
       *scm_loc_fresh_auto_compile = SCM_BOOL_T;
     }
   else
     {
+      if (auto_compile && strcmp (auto_compile, quiet) == 0)
+        {
+          *scm_loc_quiet_auto_compile = SCM_BOOL_T;
+        }
       *scm_loc_load_should_auto_compile = SCM_BOOL_T;
       *scm_loc_fresh_auto_compile = SCM_BOOL_F;
     }
diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm
index 8d230093b..d61e988cd 100644
--- a/module/ice-9/boot-9.scm
+++ b/module/ice-9/boot-9.scm
@@ -4409,16 +4409,18 @@ when none is available, reading FILE-NAME with READER."
        (if (and gostat (more-recent? gostat scmstat))
            (load-thunk-from-file go-file-name)
            (begin
-             (when gostat
+             (unless %quiet-auto-compile ; gostat must be true, per "and" above
                (format (current-warning-port)
                        ";;; note: source file ~a\n;;;       newer than compiled ~a\n"
                        name go-file-name))
              (cond
               (%load-should-auto-compile
                (%warn-auto-compilation-enabled)
-               (format (current-warning-port) ";;; compiling ~a\n" name)
+               (unless %quiet-auto-compile
+                 (format (current-warning-port) ";;; compiling ~a\n" name))
                (let ((cfn (compile name)))
-                 (format (current-warning-port) ";;; compiled ~a\n" cfn)
+                 (unless %quiet-auto-compile
+                   (format (current-warning-port) ";;; compiled ~a\n" cfn))
                  (load-thunk-from-file cfn)))
               (else #f)))))
      #:warning "WARNING: compilation of ~a failed:\n" name))
-- 
2.34.1

