Hello Tomas, thanks for the reply.

Tomas Volf wrote:

While risking some bike shedding, what about `GUILE_INIT_FILE'?

Yeah I think that's a perfectly sensible name for it; I originally thought to use that name, but was worried it might not have been pedantic enough.

I am unsure about ignoring the user's choice if the file does not exist,
should it not be an error instead?

I agree, I'll amend the patch to error when the variable is defined but doesn't point to a file.

The begin does not seem necessary here.  Also I believe it should be
indented below the `(and' above, not just by two spaces.

Ah, yes. Just a personal habit of mine shining through, I'll correct that.

Here is a revised version of the patch with your advice taken into account:

diff --git a/doc/guile.1 b/doc/guile.1
index 77c8639..84276b6 100644
--- a/doc/guile.1
+++ b/doc/guile.1
@@ -212,6 +212,16 @@ Scheme files (.go files) when loading.
 It should be a colon-separated list of directories,
 which will be prefixed to the default
 .B %load-compiled-path.
+.TP
+.B GUILE_INIT_FILE
+If
+.RB $ GUILE_INIT_FILE
+is set before
+.B guile
+is started and points to a file,
+its contents are executed before any other processing occurs.
+If not set, the default is
+.I ~/.guile
 .
 .SH FILES
 .TP
diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm
index aaa9987..3e114e6 100644
--- a/module/ice-9/boot-9.scm
+++ b/module/ice-9/boot-9.scm
@@ -2200,12 +2200,17 @@ not already present. This helps create file names."
 ;; scm_compile_shell_switches.

 (define (load-user-init)
-  (let* ((home (or (getenv "HOME")
- (false-if-exception (passwd:dir (getpwuid (getuid)))) - file-name-separator-string)) ;; fallback for cygwin etc.
-         (init-file (in-vicinity home ".guile")))
-    (if (file-exists? init-file)
-        (primitive-load init-file))))
+  (let ((env-init-path (getenv "GUILE_INIT_FILE")))
+    (if env-init-path
+        (if (file-exists? env-init-path)
+            (primitive-load env-init-path)
+            (error "file specified by GUILE_INIT_FILE was not found."))
+        (let* ((home (or (getenv "HOME")
+ (false-if-exception (passwd:dir (getpwuid (getuid)))) + file-name-separator-string)) ;; fallback for cygwin etc.
+               (init-file (in-vicinity home ".guile")))
+          (if (file-exists? init-file)
+              (primitive-load init-file))))))

I personally am unsure this needs to be configurable, but that is up to
others. ^_^

I'll give a detailed reason for why I believe the ability to configure its' location would be a good thing.

Many software projects adhere to (or support in some way) a specification from FreeDesktop.org, called the XDG-basedir (see https://specifications.freedesktop.org/basedir-spec/latest) spec. It's the specification behind the use of ~/.config, ~/.cache, ~/.local/share and ~/.local/state, among others at the system level. While I am a firm believer in this specification, some (few) find it irrelevant or simply don't like it for one reason or another. The ideal middle ground where the conflicting sides can coexist, is the allowance of something such as an environment variable, or build/install-time configuration option to change the location of common init and config type files.

Emacs supports the XDG spec; when you launch Emacs for the first time, it will create ~/.emacs.d, but if you create ~/.config/emacs before its first run, it will use that directory instead. This approach is nice, but I think simply allowing an environment variable is a completely sensible solution, especially for something like ~/.guile. Python has `PYTHON_STARTUP', Janet has `JANET_PROFILE', even ice-9 readline has `GUILE_HISTORY' which is a variable I very much appreciate. I think it is a net positive, as it is not necessary, and is not something that would potentially clash with any existing environment variables.

There are entire software projects dedicated to helping users like myself who prefer a less cluttered home directory (including hidden dot files), such as `xdg-ninja' (https://github.com/b3nj5m1n/xdg-ninja) and `antidot' (https://github.com/doron-cohen/antidot).

Overall, I think it is a net positive to give users the option, especially when the option can be implemented in very few non-complicated lines while keeping the `~/.guile' default behavior out of the box.

Thanks.

P.S. I apologize if you received a reply from me other than this; This is my first time attempting to contribute to a project via mailing list, just some little misunderstandings.

Reply via email to