From [Geany #1959](https://github.com/geany/geany/issues/1959):
I think it's not Geany’s task: adding this additional functionality to the plugin is more logical. And we can use existing plugins, in this case we have all power of Lua or Python (GeanyLua, GeanyPy, Peasy). "Open selected file" (Ctrl+Shift+O) is a function ```src/document.c:on_menu_open_selected_file1_activate()```, I wrote a Lua script https://pastebin.com/JuvRhRRu (last version), but it's too big :)
Well, I decided that it is logical to hang this task on the plugin, entirely: https://pastebin.com/TiL8wMeH But one problem: function ```src/utils.c:utils_tidy_path()``` is not available for plugins. Yes, I can just copy this function to plugin, but it's somehow stupid, I think that function ```utils_tidy_path()``` can be to add to list of functions when available for plugins. Or maybe not (bump ABI and other) :)
Function like as ```glspi_selfile()``` would be useful in other non-specific (i.e. for general purpose) plugins too - GeanyPy, Peasy. Or maybe writing Lua- or Python-script as a separate module is the best solution. I don't know now.
Any opinions? Ideas?
I think that function utils_tidy_path() can be to add to list of functions when available for plugins. Or maybe not (bump ABI and other)
Would bump the API but not the ABI, so wouldn't affect existing plugins.
There was [a utils library](https://github.com/geany/geany-plugins/tree/master/utils) added to Geany-Plugins for this kind of non-Geany-specific, but useful-to-multiple-plugins type of function.
@elextr good, thanks.
@codebrainz what do you mean? Add function like ```glspi_selfile()``` to utils library? It's not "non-Geany-specific" function. And it requires adding ```utils_tidy_path()``` to list of functions when available for plugins. Both functions or ```utils_tidy_path()``` only? It's strange, because we already have ```libgeany.so```/```libgeany-0.dll```.
@Skif-off the library is to hold stuff that is to be shared between several plugins but is not needed by Geany itself.
What @codebrainz meant is that before that library the only way to share stuff was to put it in Geany itself even if Geany didn't use it.
Unfortunately since `glspi_selfile()` depends on a new version of Geany with `utils_tidy_path()` exported, adding `glspi_selfile()` to the library would mean the library and all plugins that used the library (not many so far) would depend on the Geany version. But I am not sure that the library checks the Geany version anyway.
So in general its probably not a good idea to add it to the library until thats fixed.
I updated Lua-script in first message: missing symbol "\" and returning default list of wordchars. ___ I wrote a Lua script as module https://pastebin.com/6v5xft6R List of functions: ``` get_sel_filename() file_is_exists(path) path_is_absolute(path) tidy_path(path) ``` How to use: Save as ```getselfile.lua``` in ```~/.config/geany/plugins/geanylua/support``` (default on Linux). Example: ```lua -- Get the user's plugin directory and add folder "support" in "package.path" local gi = geany.appinfo() package.path = package.path .. ";" .. gi.scriptdir .. geany.dirsep .. "support" .. geany.dirsep .. "?.lua"; -- Load our module local gsfn = require "getselfile" -- Get selected filename local f = gsfn.get_sel_filename(); if (f ~= nil) then geany.message(f) end; ```
github-comments@lists.geany.org