Plugins' API for scripts

Here you can discuss about your favorite plug-in.
Post Reply
Shmuel
Posts: 5232
Joined: Thu 23 Mar, 2006 21:36
Location: Israel
Has thanked: 16 times
Been thanked: 152 times

Plugins' API for scripts

Post by Shmuel » Sun 16 Aug, 2015 08:31

pepak wrote: Regarding Plugin.Call, I have no idea how to interface plugins with macros.
- To implement that in the plugin, start with OpenW page (in Russian).
- To see how it looks from macro side, see description of Plugin.Call in macroapi_manual.en.chm (in English).
Ask for help on particular issues if needed.

pepak
Posts: 330
Joined: Sun 13 Jul, 2008 11:18
Has thanked: 3 times
Been thanked: 9 times

Named Folders Lite

Post by pepak » Sun 16 Aug, 2015 09:32

Well, the first issue is, I need some introduction as to why I would want to create such an interface: what it can achieve and why is it better than just programming the desired functionality (whatever it is) into plugin itself. I am sure it sounds like something everyone should know, but I don't - when I wrote, I know "literally nothing about it", I was serious, I really don't know anything about it. My experience with FAR macros is limited to CTRL+dot and to copying other people's macros to my profile directory.

Shmuel
Posts: 5232
Joined: Thu 23 Mar, 2006 21:36
Location: Israel
Has thanked: 16 times
Been thanked: 152 times

Named Folders Lite

Post by Shmuel » Sun 16 Aug, 2015 09:47

In short:
Plugin macro interface makes plugin functionality available from macros. Plugin becomes something like a library providing macros with various functions that can pass arbitrary number of arguments to the plugin and receive arbitrary number of return values from it. Each argument and return value can have its own type and value. (In many cases, no argument and no return value are needed).

pepak
Posts: 330
Joined: Sun 13 Jul, 2008 11:18
Has thanked: 3 times
Been thanked: 9 times

Named Folders Lite

Post by pepak » Sun 16 Aug, 2015 11:11

OK, that makes sense.

Now, how does it apply to Named Folders Lite? I can see that I could expose an interface which would allow you to create a new bookmark - something like Plugin.Call("6073FF5D-703E-4C1E-8182-26400240073A", "New", "root", "C:\") - or delete one Plugin.Call("6073FF5D-703E-4C1E-8182-26400240073A", "Delete", "root"). Fair enough. It is certainly doable. But, what would be the point? Surely there must be some reason why a script would want to bookmark a directory, but I must admit I don't see it. And, assuming that there is such a reason, why would I want to perform a Plugin.Call rather than, say, execute pushd Somedirectory[ENTER]cd::name[ENTER]popd[ENTER] on FAR's command line?

I can see where a scripting interface would be useful for e.g. DirSync3: I could provide a function which would let the caller know which kind of line is the line with the cursor (whether it is a <<== line or a ---> line or maybe it's a description line...) and another function for changing the kind of line to something else. But I have my doubts even there - why spend time on creating a plugin interface when I could spend the same time (perhaps less of it) implementing the required functionality directly within the plugin?

[Note to admin: Perhaps it would be useful to split the posts beginning with viewtopic.php?p=131974#p131974 into a separate thread.]

Shmuel
Posts: 5232
Joined: Thu 23 Mar, 2006 21:36
Location: Israel
Has thanked: 16 times
Been thanked: 152 times

Named Folders Lite

Post by Shmuel » Sun 16 Aug, 2015 11:19

pepak, I've no intention to convince you that you need that thing. If it occurs that you have specific questions on how to do it, I'll gladly answer.

pepak
Posts: 330
Joined: Sun 13 Jul, 2008 11:18
Has thanked: 3 times
Been thanked: 9 times

Named Folders Lite

Post by pepak » Sun 16 Aug, 2015 11:26

I don't consider this as some contest between "me who doesn't want to implement macro interface" and "you who does". I am simply approaching the issue from a position of someone who never worked with FAR scripts and never implemented interfaces for them and wants to learn why it would be worthwhile. If there is a good reason for adding scripting support to Named Folders Lite (or any other of my plugins), surely I can do that. I just don't see that good reason at this moment, but certainly am willing to listen if someone wants to explain where he sees the benefits. The "how" will become important later, after I understand the "why".

User avatar
John Doe
Бюрократ
Posts: 11419
Joined: Wed 27 Apr, 2005 20:42
Has thanked: 17 times
Been thanked: 101 times

Named Folders Lite

Post by John Doe » Sun 16 Aug, 2015 11:34

pepak wrote: execute pushd Somedirectory[ENTER]cd::name[ENTER]popd[ENTER] on FAR's command line
In order to avoid pushd/popd you may provide more advanced commandline interface.

User avatar
HaRT
Moderator
Posts: 8118
Joined: Tue 30 Aug, 2005 17:21
Location: Санкт-Петербург
Has thanked: 68 times
Been thanked: 107 times

Named Folders Lite

Post by HaRT » Sun 16 Aug, 2015 11:37

pepak wrote:[Note to admin: Perhaps it would be useful to split the posts beginning with viewtopic.php?p=131974#p131974 into a separate thread.]
Done
Фар есть инструмент, а не нянька. © 2009 DrKnS

User avatar
John Doe
Бюрократ
Posts: 11419
Joined: Wed 27 Apr, 2005 20:42
Has thanked: 17 times
Been thanked: 101 times

Plugins' API for scripts

Post by John Doe » Sun 16 Aug, 2015 11:42

pepak wrote: The "how" will become important later, after I understand the "why".
You should ask GAAlex "why".
As for me, commandline interface is enough for most purposes of the plugin.
It is accessible from macros via Plugin.Command (but there is one limitation: currently it is available in panels only).

Post Reply

Return to “General Plug-In Discussions”