Lua Extension Plugin
Posted by: 307
Date: October 30, 2005 02:39PM

I wrote yet another macro plugin. It uses Lua for macro language.
But it's in alpha stage. If you have interest, please try it.

http://rapidshare.de/files/6960717/luamacros.zip.html

Sorry, I weak in English. Thank you for your reading.

Re: Lua Extension Plugin
Posted by: guenter
Date: October 31, 2005 12:55PM

thank You for work -
i will try to use ( experiment with it)
Your English is good - better than mine!

p. s. many here are not English - & all here are open minded and try to understand.
greetings from Germany

Re: Lua Extension Plugin
Posted by: rmn
Date: November 10, 2005 12:59AM

Hey, this is really interesting.. K-Meleon's macro language is a bit limited (albeit quite enough for most common tasks), and I've heard that Lua is very powerful.

Re: Lua Extension Plugin
Posted by: Hao Jiang
Date: November 10, 2005 02:54AM

Great to see a new plugin coming out for K-Meleon. I will dig through it a little. Thanks.

Hao

Re: Lua Extension Plugin
Posted by: 307
Date: November 13, 2005 04:36AM

Thank you for testing and comments.
This plugin has worked well with mine.

I know K-Meleon's macro language is superior (simple, small, efficient, effective, and more). But it is weak on modularity. Understanding and managing a large macros.cfg is hard for me. I think that to reuse macros or to update customized macros.cfg is troublesome.

I aimed to offer the choices and to have discussion on macro language.

Thanks for reading.

Re: Lua Extension Plugin
Posted by: Hao Jiang
Date: November 13, 2005 04:52AM

@307

Can you provide more examples on how to use this Lua plugin in K-Meleon?

Hao

Re: Lua Extension Plugin
Posted by: 307
Date: November 14, 2005 01:16PM

Dear Hao

Sorry, I have no idea for good example.
I have some snippets for debug or testing. But they are useless.

However I made up a few tiny scripts, and I added some explanations to manual.
I hope they are useful for you and others.

]http://rapidshare.de/files/7618895/luamacros.zip.html

I appreciate your interest in this plugin.
Thanks for reading.

Re: Lua Extension Plugin
Posted by: guenter
Date: November 14, 2005 01:51PM

thx 307

- the big macro files are a problem to me too.
it takes much time to sort them and to learn to sort them.


i agree good to have it a little more modular.

but most of all i think it is good that you added a little more choice.
greetz

p. s. thanks for posting

Re: Lua Extension Plugin
Posted by: rmn
Date: November 15, 2005 02:51AM

@307:

Haha, you're truly brilliant! Hook + multiple files = plug-n-play macros!

@Hao:

I've created a simple Group-like macro; I'll post it sometime this week.

Re: Lua Extension Plugin
Posted by: rmn
Date: November 15, 2005 11:54PM

OK, I changed my mind. The Groups macro is not a good example at all. It's too complicated, made worse by my less-than-one-week-old experience with Lua smiling smiley .

I've uploaded a simple "search" macro which is a much better starting point. The sample "proxy" macro (in proxy.lua and a bit of macros.lua) is also good for starters; it's very well written.

Suggestion: use an editor which can do syntax highlighting for Lua. Don't use Notepad!

Re: Lua Extension Plugin
Posted by: rmn
Date: November 15, 2005 11:55PM

Oops, wrong link. The right one

Re: Lua Extension Plugin
Posted by: bst82551
Date: November 16, 2005 01:43AM

Wow, judging by some of the work done by rmn, it looks like Lua is exactly what K-Meleon needs in a macro language.

Brian

Re: Lua Extension Plugin
Posted by: rmn
Date: November 16, 2005 01:58AM

What we don't know yet is Lua's performance in a slow machine compared to macros.dll .

Re: Lua Extension Plugin
Posted by: Hao Jiang
Date: November 16, 2005 04:22AM

@rmn,
Thank you very much for your lua macros. It's a good starting point to learn those things from scratch. I'm trying to figure out more things lua could do in K-Meleon. Thanks again.

Hao

Re: Lua Extension Plugin
Posted by: 307
Date: November 16, 2005 02:20PM

@rmn

That's great. I see you are more skilled in Lua than me. I'll study Lua with your scripts. Thank you.

@All

Do you have complaints about this plugin?
I feel that Lua scripts tends to be verbosity. And hwnd is ugly.

Thank you for reading.

Re: Lua Extension Plugin
Posted by: kko
Date: November 16, 2005 10:08PM

Thank you very much for your work, 307! It will take me some time to get into it. I guess the benefits are really worth this effort! Thank you again!

For those interested in the Lua programming language:

Reference manuals can be found at the official web site http://www.lua.org/. Another location is http://lua-users.org/.

If you are looking for a Lua capable editor, try http://www.scintilla.org/SciTE.html. SciTE supports syntax-highlighting for Lua and can even use Lua internally.

Re: Lua Extension Plugin
Posted by: bst82551
Date: November 17, 2005 01:24AM

http://scintilla.sourceforge.net/SciTE.html

The period at the end of it made it act funny.

Brian

Re: Lua Extension Plugin
Posted by: rmn
Date: November 17, 2005 04:59AM

> @rmn
That's great. I see you are more skilled in Lua than me. I'll study Lua with your scripts. Thank you.


Uh, no way, I didn't know any Lua before last week... your scripts are better written; and thanks a lot for the plugin! (And I'm pretty sure there are a few bugs in that groups script because I didn't know that the scripts only receive hwnd + 1 string param from K-Meleon. :-)

> @All
Do you have complaints about this plugin?
I feel that Lua scripts tends to be verbosity. And hwnd is ugly.


I can't think of any complaints right now, but I'm really curious about how it preforms in a slow machine. I'm just thinking, if this plugin is fast enough, it can replace macros.dll.... And the fact that we can add/remove scripts anytime means we don't have to load the ones that we don't need.

I think the verbosity isn't that bad (also, I don't really mind that hwnd thingy), and it's a very nice scripting language. By the way, does this mean we can manipulate other windows using their window handles?

Re: Lua Extension Plugin
Posted by: 307
Date: November 17, 2005 02:04PM

@rmn

By the way, does this mean we can manipulate other windows using their window handles?

Yes. That's possible. But I don't recomend using it. Because this plugin doesn't check whether handle is valid.

Thanks for reading.

P.S. I began to learn Lua language at last month. I'm beginner too.

Re: Lua Extension Plugin
Posted by: alain aupeix chez wanadoo fr
Date: November 17, 2005 07:54PM

Hmm, it's perhaps a way to close the loader when needed (for example after a modification which needed to close K-Meleon) ...

Re: Lua Extension Plugin
Posted by: jsnj
Date: November 17, 2005 08:01PM

Hook + multiple files = plug-n-play macros!

Only just started reading this thread. The above got my attention and would be great. Of course we still run into the copy & pasting annoyance for the menu & accelerator files. It would be great if a user could just drop a file into his/her profile, restart and tada!...there it is revving to go :-)


The Groups macro is not a good example at all. It's too complicated

Wait 'til you see the convoluted mess of the Switch Proxy macro script I'm almost finished with :-). It'll make the Groups macro script look nice & clean....lol. As far as the lua group script's compatibilty with the direct macros group script, some adjustments would have to be made besides the pref changes. I sampled yours and I believe your groups are saved to prefs with an underscore preceding the name IINM? Little things like that would have to be changed. But there really is no reason for them to be compatible yet until we decided that lua scripts should replace direct macro scripts and therefore users' migrating to lua files wouldn't have to adjust their prefs.

Re: Lua Extension Plugin
Posted by: rmn
Date: November 17, 2005 11:01PM

I've just realised that it isn't really plug-and-play, because we still need to add 'require "scriptfile"' to macros.lua, but at least that's only one line, and doesn't make your macros.cfg grow uncontrollably smiling smiley .

> your groups are saved to prefs with an underscore preceding the name IINM?

Yep, and that's what the groups.pref.GROUPS variable does (it's the prefix for the group prefs; should've named it "prefix" or something). Anyway, it wasn't my intention to create a usable script; I did it just as an exercise.

Re: Lua Extension Plugin
Posted by: bst82551
Date: November 17, 2005 11:54PM

It may be just a step more user-friendly than the current macros plugin, but i think the main advantage of this is that it's easier to manage (more organized because different macros each have their own file) and more powerful, but mostly that it's more powerful.

Brian

Re: Lua Extension Plugin
Posted by: 307
Date: November 19, 2005 05:42AM

I become to think that it's also complicated to separate macros to some files. Anyway, I have worked about this plugin.

http://rapidshare.de/files/7837300/luamacros-0.0.4.zip.html

Add: OnQuit
Add: Plugin command 'Eval'
Add: Popup menu and select dialog.
Add: New samples. search, viewlinks.
Add: Include pre-compiled standalone interpreter and byte compiler.
They don't link K-Meleon API, ant yet the compiler can compile
scripts. Then the interpreter is maybe useful to study Lua.
Fix: Instructions

Plan: Add anoother path to 'LUA_PATH'.
Plan: Agreements with naming and structure.

If you have idea, please tell me.
Thanks for reading. Have a nice weekend.

Re: Lua Extension Plugin
Posted by: bst82551
Date: November 19, 2005 02:15PM

I don't know how the lua plugin calls functions, but if it calls them the way I think it does (ex: "lua(TogglePref)"), then do you think that it'd be better to find a way to specify the filename of the script, then colon, then the lua macro... something like:
lua(FILENAME:TogglePref)

Of course, you wouldn't need to include the .lua extension... just the filename.
Can this even be done? Is it necessary to prevent macros with the same name from different scripts from clashing?

Brian

Re: Lua Extension Plugin
Posted by: bst82551
Date: November 19, 2005 02:17PM

Oh yes, and if you needed to call a function from a different file, you could use the same format.

Brian

Re: Lua Extension Plugin
Posted by: 307
Date: November 20, 2005 03:59AM

@Brian

Sorry, I cannot get you mean. Which do you mean to extend "luamacros(...)" syntax for "require" less, or to create namespace by file as python does?

If you mean the latter, Lua has done it. Lua loads file as block, so variables declared as "local" in module isn't visible from other modules.

Lua: technical note 7 Modules & Packages
http://www.lua.org/notes/ltn007.html

In the fact, I didn't know it. I thought we need to classify public or private functions by name. But I get it is needless. Thank you for your question. However I think that we must have a consensus about a foundation structure such as hook mechanism or filesystem structure.

If you mean the former, I will think to do. But it is probably difficult, because to do needs to solve dependency of modules.

The limitation of filename extension comes from require Lua function, and it can omit by changing LUA_PATH gloval variable. But if this plugin can load all files, this would load non-lua files.

Thanks for reading.

Re: Lua Extension Plugin
Posted by: 307
Date: November 20, 2005 07:13AM

Oh, I mistake. orz
We don't need a consensus about LUA_PATH. If you want to put Lua scripts (except macros.lua) into other folder, you may modify LUA_PATH before calling "require" such below:

LUA_PATH=PREFPATH.."/lua/?.lua;"..PREFPATH.."/lua/?.lc"

(typically it's on head of "macros.lua"). It means you put Lua scripts into "lua" subfolder in your profile folder. Filename extension have to be specified yet. But I think good that Lua scripts are named with ".lua" extention.
Thanks.

Re: Lua Extension Plugin
Posted by: rmn
Date: November 28, 2005 04:19AM

Hey, that select() function is quite handy. I've updated my Groups script to use it.

I've also been playing around with the naming to see how I can separate KM-callable functions from the 'private' functions. Now I put them in different tables and make one of them local. That seems to make the code look nicer.

Re: Lua Extension Plugin
Posted by: 307
Date: November 29, 2005 01:39PM

I'm very happy that someone is interested in this plugin. Then I release new version of this plugin.

http://rapidshare.de/files/8328236/luamacros-0.1.0.zip.html

Change: Lua 5.1 beta
Change: "select" function is renamed to "choose", because Lua 5.1 has "select" function.
Fix: Memory leak on EncodeUTF8 and DecodeUTF8 function.
Fix: "id" function couldn't handle number ID correctly.
Improve: More detailed error message.
Improve: "SetCheck" function can handle string ID.
Remove: Pre compiled Lua binaries.

I hope this plugin is useful for you. Thanks.

K-Meleon forum is powered by Phorum.