summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2021-04-17 20:05:58 +0200
committerSébastien Helleu <flashcode@flashtux.org>2021-05-11 21:06:13 +0200
commitf923524a21fe1b016d1921e576796ea588706563 (patch)
tree1f896a627e335ee3cd563362c64157f665d64929 /src
parente5d18e1221b7f232822f0110d80f042ab3bb708e (diff)
downloadweechat-f923524a21fe1b016d1921e576796ea588706563.zip
core: evaluate option weechat.plugin.path (issue #1285)
Diffstat (limited to 'src')
-rw-r--r--src/core/wee-completion.c24
-rw-r--r--src/core/wee-config.c5
-rw-r--r--src/plugins/plugin.c20
3 files changed, 18 insertions, 31 deletions
diff --git a/src/core/wee-completion.c b/src/core/wee-completion.c
index 6d90d3f55..a13c2c3f3 100644
--- a/src/core/wee-completion.c
+++ b/src/core/wee-completion.c
@@ -982,7 +982,7 @@ completion_list_add_plugins_installed_cb (const void *pointer, void *data,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
- char *plugin_path, *plugin_path2, *dir_name, *extra_libdir;
+ char *plugin_path, *dir_name, *extra_libdir;
int length;
/* make C compiler happy */
@@ -1011,23 +1011,15 @@ completion_list_add_plugins_installed_cb (const void *pointer, void *data,
if (CONFIG_STRING(config_plugin_path)
&& CONFIG_STRING(config_plugin_path)[0])
{
- plugin_path = string_expand_home (CONFIG_STRING(config_plugin_path));
- plugin_path2 = string_replace (
- (plugin_path) ?
- plugin_path : CONFIG_STRING(config_plugin_path),
- "%h", weechat_home);
- util_exec_on_files (
- (plugin_path2) ?
- plugin_path2 : ((plugin_path) ?
- plugin_path : CONFIG_STRING(config_plugin_path)),
- 1,
- 0,
- &completion_list_add_plugins_installed_exec_cb,
- completion);
+ plugin_path = string_eval_path_home (CONFIG_STRING(config_plugin_path),
+ NULL, NULL, NULL);
if (plugin_path)
+ {
+ util_exec_on_files (plugin_path, 1, 0,
+ &completion_list_add_plugins_installed_exec_cb,
+ completion);
free (plugin_path);
- if (plugin_path2)
- free (plugin_path2);
+ }
}
/* plugins in WeeChat global lib dir */
diff --git a/src/core/wee-config.c b/src/core/wee-config.c
index aa7fd4d0d..a9d46123d 100644
--- a/src/core/wee-config.c
+++ b/src/core/wee-config.c
@@ -4564,8 +4564,9 @@ config_weechat_init_options ()
config_plugin_path = config_file_new_option (
weechat_config_file, ptr_section,
"path", "string",
- N_("path for searching plugins (\"%h\" will be replaced by "
- "WeeChat home, \"~/.weechat\" by default)"),
+ N_("path for searching plugins "
+ "(path is evaluated, see function string_eval_path_home in "
+ "plugin API reference)"),
NULL, 0, 0, "%h/plugins", NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_plugin_save_config_on_unload = config_file_new_option (
diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c
index ee5539da8..58dd23ad6 100644
--- a/src/plugins/plugin.c
+++ b/src/plugins/plugin.c
@@ -1011,7 +1011,7 @@ plugin_auto_load (char *force_plugin_autoload,
int load_from_lib_dir,
int argc, char **argv)
{
- char *dir_name, *plugin_path, *plugin_path2, *extra_libdir;
+ char *dir_name, *plugin_path, *extra_libdir;
const char *ptr_plugin_autoload;
struct t_weechat_plugin *ptr_plugin;
struct t_plugin_args plugin_args;
@@ -1045,20 +1045,14 @@ plugin_auto_load (char *force_plugin_autoload,
&& CONFIG_STRING(config_plugin_path)
&& CONFIG_STRING(config_plugin_path)[0])
{
- plugin_path = string_expand_home (CONFIG_STRING(config_plugin_path));
- plugin_path2 = string_replace ((plugin_path) ?
- plugin_path : CONFIG_STRING(config_plugin_path),
- "%h", weechat_home);
- util_exec_on_files ((plugin_path2) ?
- plugin_path2 : ((plugin_path) ?
- plugin_path : CONFIG_STRING(config_plugin_path)),
- 1,
- 0,
- &plugin_auto_load_file, &plugin_args);
+ plugin_path = string_eval_path_home (CONFIG_STRING(config_plugin_path),
+ NULL, NULL, NULL);
if (plugin_path)
+ {
+ util_exec_on_files (plugin_path, 1, 0,
+ &plugin_auto_load_file, &plugin_args);
free (plugin_path);
- if (plugin_path2)
- free (plugin_path2);
+ }
}
/* auto-load plugins in WEECHAT_EXTRA_LIBDIR environment variable */