Re: [dev] [surf] eval() not needed?

From: Troels Henriksen <athas_AT_sigkill.dk>
Date: Fri, 06 Jul 2012 12:06:53 +0200

stanio_AT_cs.tu-berlin.de writes:

> * Troels Henriksen <athas_AT_sigkill.dk> [2012-07-06 09:31]:
>> eval() was never needed per se. I put it in because you need it if you
>> want robust keybindings to functions defined in script.js, and you need
>
> Ok. Didn't know. And still don't really get it... Can you give a hint?
>
> search of 'eval' within surf.suckless.org yields the Link hints page.
> The js code invokes eval. Is this the same eval?
>
> some time ago someone shared some js code to extract the important
> textual part of a page based on counting number of paragraphs, called
> simplyread. I use this quite often but to activate it I neeed to go into
> insert mode to let surf not eat the keys, then press the key which the
> script bound itself to (FWIW F3).
>
> I found myself binding some xdotool magic to a regular surf keybinding
> as in
> xdotool key -window $0 i key -window $0 F3 key -window $0 Esc
>
> which is sommewhat ugly. Is eval somehow related to that?

I'm not sure what you mean by insert mode. I use eval() for
Conkeror-style numbered link navigation. The actual logic is defined in
Javascript in my script.js, and I have the following bindings in my
config.h:

{ CTRL, GDK_f, eval, STRING("hintMode()") },
{ CTRL|SHIFT, GDK_f, eval, STRING("hintMode(true)") },
{ CTRL, GDK_c, eval, STRING("removeHints()")
},

Creating the keybindings themselves in Javascript is brittle and bad.

-- 
\  Troels
/\ Henriksen
Received on Fri Jul 06 2012 - 12:06:53 CEST

This archive was generated by hypermail 2.3.0 : Fri Jul 06 2012 - 12:12:04 CEST