unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Matt Wette <matt.wette@gmail.com>
To: guile-user@gnu.org
Subject: Re: Quiet compilation for scripting
Date: Fri, 15 Mar 2024 14:09:40 -0700	[thread overview]
Message-ID: <c6270116-715d-43cd-a797-97d63f21d5b1@gmail.com> (raw)
In-Reply-To: <a653e806-851b-4bbd-84d3-2eea08ca4a35@gmail.com>

On 3/15/24 1:52 PM, Matt Wette wrote:
> On 3/15/24 1:47 PM, Marc Chantreux wrote:
>> On Fri, Mar 15, 2024 at 08:00:09PM +0100, tomas@tuxteam.de wrote:
>>>> I think most of Guile user actually want this feature for a long time.
>>>> I can understand.
>>> I agree.
>> so do I.
>
> As mentioned on another topic (start=up message) I had once hacked 
> guile to have a
> info-port, with initial welcome message and compile messages going to 
> (current-info-port).
> Adding a command arg to set that to a file or /dev/null would fix both 
> issues.
>
> Matt
>
>
I think is it.

--- libguile/ports.c-orig	2023-05-29 06:18:05.866508234 -0700
+++ libguile/ports.c	2023-05-29 09:00:54.592316332 -0700
@@ -432,6 +432,7 @@
  static SCM cur_outport_fluid = SCM_BOOL_F;
  static SCM cur_errport_fluid = SCM_BOOL_F;
  static SCM cur_warnport_fluid = SCM_BOOL_F;
+static SCM cur_infoport_fluid = SCM_BOOL_F;
  static SCM cur_loadport_fluid = SCM_BOOL_F;
  
  SCM_DEFINE (scm_current_input_port, "current-input-port", 0, 0, 0,
@@ -488,6 +489,18 @@
  }
  #undef FUNC_NAME
  
+SCM_DEFINE (scm_current_info_port, "current-info-port", 0, 0, 0,
+            (void),
+	    "Return the port to which diagnostic information should be sent.")
+#define FUNC_NAME s_scm_current_info_port
+{
+  if (scm_is_true (cur_infoport_fluid))
+    return scm_fluid_ref (cur_infoport_fluid);
+  else
+    return SCM_BOOL_F;
+}
+#undef FUNC_NAME
+
  SCM_DEFINE (scm_current_load_port, "current-load-port", 0, 0, 0,
  	    (),
  	    "Return the current-load-port.\n"
@@ -545,6 +558,18 @@
  }
  #undef FUNC_NAME
  
+SCM
+scm_set_current_info_port (SCM port)
+#define FUNC_NAME "set-current-info-port"
+{
+  SCM oinfop = scm_fluid_ref (cur_infoport_fluid);
+  port = SCM_COERCE_OUTPORT (port);
+  SCM_VALIDATE_OPOUTPORT (1, port);
+  scm_fluid_set_x (cur_infoport_fluid, port);
+  return oinfop;
+}
+#undef FUNC_NAME
+
  void
  scm_dynwind_current_input_port (SCM port)
  #define FUNC_NAME NULL
@@ -4155,6 +4180,7 @@
    scm_c_define ("%current-output-port-fluid", cur_outport_fluid);
    scm_c_define ("%current-error-port-fluid", cur_errport_fluid);
    scm_c_define ("%current-warning-port-fluid", cur_warnport_fluid);
+  scm_c_define ("%current-info-port-fluid", cur_infoport_fluid);
  }
  
  void
@@ -4189,6 +4215,7 @@
    cur_outport_fluid = scm_make_fluid ();
    cur_errport_fluid = scm_make_fluid ();
    cur_warnport_fluid = scm_make_fluid ();
+  cur_infoport_fluid = scm_make_fluid ();
    cur_loadport_fluid = scm_make_fluid ();
  
    default_port_encoding_var =
@@ -4227,4 +4254,8 @@
                        (scm_t_subr) scm_current_error_port);
    scm_c_define_gsubr (s_scm_current_warning_port, 0, 0, 0,
                        (scm_t_subr) scm_current_warning_port);
+
+  /* Used by welcome and compiler routines. */
+  scm_c_define_gsubr (s_scm_current_info_port, 0, 0, 0,
+                      (scm_t_subr) scm_current_info_port);
  }
--- module/ice-9/command-line.scm-orig	2023-05-29 09:45:37.186157673 -0700
+++ module/ice-9/command-line.scm	2023-05-29 10:36:29.730463604 -0700
@@ -135,6 +135,7 @@
                   files.
    --listen[=P]   listen on a local port or a path for REPL clients;
                   if P is not given, the default is local port 37146
+  --info-file=PORT  set output file for informative diagnostics
    -q             inhibit loading of user init file
    --use-srfi=LS  load SRFI modules for the SRFIs in LS,
                   which is a list of numbers like \"2,13,14\"
@@ -142,6 +143,7 @@
                   R6RS
    --r7rs         change initial Guile environment to better support
                   R7RS
+  -W             don't print welcome message
    -h, --help     display this help and exit
    -v, --version  display version information and exit
    \\              read arguments from following script lines"))
@@ -386,6 +388,14 @@
              (parse args
                     (cons '((@@ (system repl server) spawn-server)) out)))
             
+           ((string=? arg "--info-file")   ; set info port
+            (parse args
+                   (cons `(set-current-info-port
+                           ',(open-file
+                              (substring arg (string-length "--info-port="))
+                              "w"))
+                         out)))
+
             ((string-prefix? "--listen=" arg) ; start a repl server
              (parse
               args
@@ -405,6 +415,12 @@
                    (error "unknown argument to --listen"))))
                out)))
  
+           #|
+           ((string=? "-W" arg)
+            (parse args
+                   (cons '(skip-welcome) out)))
+           |#
+
             ((or (string=? arg "-h") (string=? arg "--help"))
              (shell-usage usage-name #f)
              (exit 0))
--- module/ice-9/boot-9.scm-orig	2023-05-29 10:40:16.405710774 -0700
+++ module/ice-9/boot-9.scm	2023-05-29 09:26:41.743249629 -0700
@@ -190,6 +190,13 @@
    (newline (current-warning-port))
    (car (last-pair stuff)))
  
+(define (info . stuff)
+  (newline (current-info-port))
+  (display ";;; FYI " (current-info-port))
+  (display stuff (current-info-port))
+  (newline (current-info-port))
+  (car (last-pair stuff)))
+
  \f
  
  ;;; {Features}
@@ -4328,15 +4335,15 @@
             (load-thunk-from-file go-file-name)
             (begin
               (when gostat
-               (format (current-warning-port)
+               (format (current-info-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)
+               (format (current-info-port) ";;; compiling ~a\n" name)
                 (let ((cfn (compile name)))
-                 (format (current-warning-port) ";;; compiled ~a\n" cfn)
+                 (format (current-info-port) ";;; compiled ~a\n" cfn)
                   (load-thunk-from-file cfn)))
                (else #f)))))
       #:warning "WARNING: compilation of ~a failed:\n" name))


  reply	other threads:[~2024-03-15 21:09 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-15 17:15 Quiet compilation for scripting ksoft
2024-03-15 17:27 ` Tomas Volf
2024-03-15 17:31 ` Olivier Dion
2024-03-15 17:50   ` tomas
2024-03-15 18:03     ` Olivier Dion
2024-03-15 18:28       ` Keith Wright
2024-03-15 18:51         ` Olivier Dion
2024-03-15 19:00           ` tomas
2024-03-15 20:47             ` Marc Chantreux
2024-03-15 20:52               ` Matt Wette
2024-03-15 21:09                 ` Matt Wette [this message]
2024-03-16  6:08                 ` tomas
2024-03-18  4:09                 ` Kevin Mazzarella
2024-03-18 13:40                 ` Matt Wette
2024-03-18 14:31                   ` Matt Wette

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c6270116-715d-43cd-a797-97d63f21d5b1@gmail.com \
    --to=matt.wette@gmail.com \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).