On Thu, Feb 16, 2012 at 08:45:45PM +0000, Miciah Dashiel Butler Masters wrote:
> On Thu, Feb 16, 2012 at 03:35:02PM -0500, scribblemacher wrote:
> >Hello,
> >
> >I'm fiddling around with using Lua hooks to reformat pages. It's trial
> >and error for me to get the results I want (I'm not a programmer and
> >I've never touched Lua before this). It seems that Elinks only reads my
> >hooks.lua file on start-up though, which makes my trial and error
> >experiments a bit slow. Is there a way to get Lua to reload this file
> >after I make changes? Or perhaps there is a better way to perform this
> >type of experimentation other than the pre_format_html function?
> >
> >Advise would be much appreciated!
> [...]
> 
> Yes: Using the default hooks.lua file, you can enter "reload()" at the
> Lua console to reload the hooks file.  Open the console with the ","
> key.
> 
> "reload()" is actually defined in the default hooks.lua file.  Later on
> in hooks.lua, you can see that the Lua console just calls the
> lua_console_hook function, which allows the user to call the reload()
> function or run arbitrary Lua code.
> 
> Best regards,
> 
> -- 
> Miciah Dashiel Butler Masters <miciah.mast...@gmail.com>
> _______________________________________________
> elinks-users mailing list
> elinks-users@linuxfromscratch.org
> http://linuxfromscratch.org/mailman/listinfo/elinks-users

Thanks for your help. That didn't actually work for me, but it pointed me in 
the right direction.

The Lua console actually did nothing at first; I got an error for all commands 
I entered. To fix this, I needed to define the lua_console_hook() in my 
hooks.lua like so:

function lua_console_hook(expr)
  return "eval", expr
end

After this, I could use the console, but reload() gives me the error: "[strong 
"reload()"]:1: attempt to call global `reload' (a nil value)". Using 
dofile("/path/to/hooks.lua"), howver, works with the cavate that I need to use 
the full path to the file;  using ~/.elinks/hooks.lua returns "file not found".

Anyway, the dofile("hooks.lua") works. I look forward to butchering the HTML of 
sites more quickly :)
_______________________________________________
elinks-users mailing list
elinks-users@linuxfromscratch.org
http://linuxfromscratch.org/mailman/listinfo/elinks-users

Reply via email to