From 5dfd6afdf03f3e541ca7b47800607f5bf09df08d Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Mon, 18 Oct 2021 21:50:40 +0300 Subject: [PATCH] guile: fix user script path detection Fixes: #2159. --- man/mu-script.1 | 9 +++++---- mu/mu-cmd-script.cc | 12 ++++++++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/man/mu-script.1 b/man/mu-script.1 index aa4159b8..ec3f0324 100644 --- a/man/mu-script.1 +++ b/man/mu-script.1 @@ -1,8 +1,8 @@ -.TH MU SCRIPT 1 "June 2013" "User Manuals" +.TH MU SCRIPT 1 "October 2021" "User Manuals" .SH NAME -mu script\- show the available mu scripts, and run them. +mu script\- show the available mu scripts, and/or run them. .SH SYNOPSIS @@ -58,8 +58,9 @@ code when this is not the case. .SH FILES You can make your own Scheme scripts accessible through \fBmu script\fR by -putting them in \fI/scripts\fR (which is typically -\fI~/.mu/scripts\fR). It is a good idea to document the scripts by using some +putting them in either \fI/mu/scripts\fR (e.g., \fI~/.local/share/mu/scripts\fR) or, if \fImuhome\fR is specified, in + +It is a good idea to document the scripts by using some special comments in the source code: .nf ;; INFO: this is my script -- one-line description diff --git a/mu/mu-cmd-script.cc b/mu/mu-cmd-script.cc index 48170ee7..b4285c36 100644 --- a/mu/mu-cmd-script.cc +++ b/mu/mu-cmd-script.cc @@ -102,6 +102,15 @@ print_scripts (GSList *scripts, gboolean color, return TRUE; } +static char* +get_userpath (const char *muhome) +{ + if (muhome) + return g_build_path (G_DIR_SEPARATOR_S, muhome, "scripts", NULL); + else + return g_build_path (G_DIR_SEPARATOR_S, g_get_user_data_dir(), + "mu", "scripts", NULL); +} static GSList* get_script_info_list (const char *muhome, GError **err) @@ -117,8 +126,7 @@ get_script_info_list (const char *muhome, GError **err) if (err && *err) return NULL; - userpath = g_strdup_printf ("%s%c%s", - muhome, G_DIR_SEPARATOR, "scripts"); + userpath = get_userpath(muhome); /* is there are userdir for scripts? */ if (!mu_util_check_dir (userpath, TRUE, FALSE)) {