summaryrefslogtreecommitdiff
path: root/src/plugins/scripts/perl
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2010-02-23 10:51:59 +0100
committerSebastien Helleu <flashcode@flashtux.org>2010-02-23 10:51:59 +0100
commit3d3dc1593db988c7649c9f7dc7e4289a576a6c77 (patch)
treed727c01a55c3d9b20852ad6c4fc2609caf60c969 /src/plugins/scripts/perl
parent27bf347e1c1889457e9a7d1b0419cb4d1e03a359 (diff)
downloadweechat-3d3dc1593db988c7649c9f7dc7e4289a576a6c77.zip
Allow script commands to reload only one script
Diffstat (limited to 'src/plugins/scripts/perl')
-rw-r--r--src/plugins/scripts/perl/weechat-perl.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/plugins/scripts/perl/weechat-perl.c b/src/plugins/scripts/perl/weechat-perl.c
index 76b4b9948..50ee2845b 100644
--- a/src/plugins/scripts/perl/weechat-perl.c
+++ b/src/plugins/scripts/perl/weechat-perl.c
@@ -507,6 +507,38 @@ weechat_perl_unload_all ()
}
/*
+ * weechat_perl_reload_name: reload a Perl script by name
+ */
+
+void
+weechat_perl_reload_name (const char *name)
+{
+ struct t_plugin_script *ptr_script;
+ char *filename;
+
+ ptr_script = script_search (weechat_perl_plugin, perl_scripts, name);
+ if (ptr_script)
+ {
+ filename = strdup (ptr_script->filename);
+ if (filename)
+ {
+ weechat_perl_unload (ptr_script);
+ weechat_printf (NULL,
+ weechat_gettext ("%s: script \"%s\" unloaded"),
+ PERL_PLUGIN_NAME, name);
+ weechat_perl_load (filename);
+ free (filename);
+ }
+ }
+ else
+ {
+ weechat_printf (NULL,
+ weechat_gettext ("%s%s: script \"%s\" not loaded"),
+ weechat_prefix ("error"), PERL_PLUGIN_NAME, name);
+ }
+}
+
+/*
* weechat_perl_command_cb: callback for "/perl" command
*/
@@ -572,6 +604,11 @@ weechat_perl_command_cb (void *data, struct t_gui_buffer *buffer,
if (path_script)
free (path_script);
}
+ else if (weechat_strcasecmp (argv[1], "reload") == 0)
+ {
+ /* reload one Perl script */
+ weechat_perl_reload_name (argv_eol[2]);
+ }
else if (weechat_strcasecmp (argv[1], "unload") == 0)
{
/* unload Perl script */