jueves, 26 de mayo de 2016

keysnail plugin to navigate relations

I'm using keysnail as my emacsy browser. It's heavier than conkeror, but I'd say it's also more compatible with common plugins (adblockers, cookiemanagers, RES,...)

A feature not present in keysnail (until now) was the ability to navigate through a hierarchy of a web without reaching to the actual link (if any).

So I wrote this super simple keysnail-navigate-relations plugin that provides 3 commands (go-next, go-prev, go-up) and 3 keybindings (]], [[, ^) so you can navigate much more easily through structured webs.

Possible uses for it are:

As always, feedback is more than welcome.

martes, 17 de mayo de 2016

spying on lua function calls

Following on lua, there's been some trick I've been using for some time, and it's quite useful and (as usual), doable with tiny piece of code.

If we want to have a trace of function calls with their parameters and results, there's a super easy way to do it in lua.  The functionality is basically inspired by lisp's trace or elisp's trace-function.  The code is ridiculously simple, it's a basic case of rewriting key-values in modules and wrapping functions.

local function make_tracer()
  local indent = ""
  return function (mod, f_name)
    local old = mod[f_name]
    return function (...)
      print( string.format("%sCall: %s: params: ", indent, f_name), ...)
      indent = indent .. "   "
      local ret = {old(...)}
      indent = string.sub(indent, 4)
      print(string.format("%sRetn: %s: ",indent, f_name), unpack(ret))
      return unpack(ret)
    end
  end
end
local trace = make_tracer()
... 
for m,_ in pairs(M) do M[m]=trace(M, m) end

It's great that with so simple code we can have a basic debugging tool like this one (btw, this tool is probably not very robust if we put coroutines in the mix, but for simple cases it works quite well).  All this is possible because lua embraces the Universal Design Pattern.


viernes, 13 de mayo de 2016

Asymmetry on searching

Recently I started using helm-occur as a default for c-s. It has some nice things like searching for the word at point, which many times is what you want to do [1].  But it also has its drawbacks.

  • One of them is speed. For big buffers it can be quite slow [2].  
  • Also,when there's more than one match in a line, you can't easily keep pressing c-s and move along the matches.
  • If the matches far in long lines, you don't see them. Can't decide where to stop when lines are similar at start.
  • It doesn't work as a navigation tool [3].

Try to open a giant xml file (all in one line), and work with it. You'll understand it.


But! it's not all lost yet. I found out that if I keep c-r as isearch-backward, I can then press c-s and be in the good old isearch. So you get both functionalities, and the keybindings are not confusing. you just have to remember that sometimes, the fastest way to move forward is to go backwards.




[1]. that same functionality can be done with '*' in evil (but you'll have to configure syntax tables to make it match the whole word instead of symbol). Also, pressing c-w on isearch-mode will add next word to the searched content.

[2]. Some say ivy is faster, but the times I tried m-x ivy-mode, it takes over the whole emacs input system. Probably I should invest more time on learning how to activate it just for buffer searches.

[3]. And I don't buy the yak shaving 'you should use ace-jump', because its aim is not the same (doesn't work to move where you WANT but don't SEE), and now I have 2 problems.