guile: fix user script path detection

Fixes: #2159.
This commit is contained in:
Dirk-Jan C. Binnema 2021-10-18 21:50:40 +03:00
parent 672d0c7238
commit 5dfd6afdf0
2 changed files with 15 additions and 6 deletions

View File

@ -1,8 +1,8 @@
.TH MU SCRIPT 1 "June 2013" "User Manuals" .TH MU SCRIPT 1 "October 2021" "User Manuals"
.SH NAME .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 .SH SYNOPSIS
@ -58,8 +58,9 @@ code when this is not the case.
.SH FILES .SH FILES
You can make your own Scheme scripts accessible through \fBmu script\fR by You can make your own Scheme scripts accessible through \fBmu script\fR by
putting them in \fI<muhome>/scripts\fR (which is typically putting them in either \fI<XDG_DATA_HOME>/mu/scripts\fR (e.g., \fI~/.local/share/mu/scripts\fR) or, if \fImuhome\fR is specified, in
\fI~/.mu/scripts\fR). It is a good idea to document the scripts by using some
It is a good idea to document the scripts by using some
special comments in the source code: special comments in the source code:
.nf .nf
;; INFO: this is my script -- one-line description ;; INFO: this is my script -- one-line description

View File

@ -102,6 +102,15 @@ print_scripts (GSList *scripts, gboolean color,
return TRUE; 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* static GSList*
get_script_info_list (const char *muhome, GError **err) 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) if (err && *err)
return NULL; return NULL;
userpath = g_strdup_printf ("%s%c%s", userpath = get_userpath(muhome);
muhome, G_DIR_SEPARATOR, "scripts");
/* is there are userdir for scripts? */ /* is there are userdir for scripts? */
if (!mu_util_check_dir (userpath, TRUE, FALSE)) { if (!mu_util_check_dir (userpath, TRUE, FALSE)) {