Use <configdir>/scripts to (auto)load Lua/Perl/Python/Tcl scripts

This commit is contained in:
Berke Viktor
2012-07-21 19:16:31 +02:00
parent 9ea3ac9ddd
commit 2b3e1f46e3
5 changed files with 45 additions and 26 deletions

View File

@ -89,8 +89,10 @@ static char unknown[] = {
"}\n"
};
/* don't pollute the filesystem with script files, this only causes misuse of the folders
* only use ~/.config/hexchat/scripts/ and %APPDATA%\HexChat\scripts */
static char sourcedirs[] = {
"set files [lsort [glob -nocomplain -directory [xchatdir] \"*.tcl\"]]\n"
"set files [lsort [glob -nocomplain -directory [xchatdir] \"/scripts/*.tcl\"]]\n"
"set init [lsearch -glob $files \"*/init.tcl\"]\n"
"if { $init > 0 } {\n"
"set initfile [lindex $files $init]\n"
@ -2037,7 +2039,7 @@ static int Command_Source(char *word[], char *word_eol[], void *userdata)
} else {
if (!strchr(word_eol[2], '/')) {
Tcl_DStringAppend(&ds, xchatdir, strlen(xchatdir));
Tcl_DStringAppend(&ds, "/", 1);
Tcl_DStringAppend(&ds, "/scripts/", 9);
Tcl_DStringAppend(&ds, word_eol[2], strlen(word_eol[2]));
}
}