domingo, 24 de junio de 2018

emacs-like browsing in firefox and chrome

In this post we'll see how to make ctrl-n work as "next-line" in chrome, firefox, or any other app in your linux box.

Browsing is my only daily computing activity I can't do inside emacs. There are browser extensions that make your browser behave like vim or emacs to a certain extent, which is very useful but they don't give a complete experience to the user (often because of limitations in the browse extension system).

Bear in mind that myself being an evil user and heavy hjkl fan, my configs use j and k sometimes to mean down and up.


Long time ago, there was conkeror. which gave a very emacsy browsing experience, but after the whole change on browser extensions, conkeror is a feasible option anymore.  The same happened to keysnail. There were also some nifty hacks using mozrepl, which are long gone now.


The plugin is originally thought to give vim-like experience to chrome/firefox, but there's no reason you can't add shortcuts like "m-<" for "beginning-of-buffer" command.

Here's my config. Custom mappings:

Btw, pay attention to c-j and c-k. that's basically to be able to use j and k somehow in sites that override them (github, gmail). Also, note that we have a custom mapping for c-n and another for c-p, but unfortunately they do not work because those shortcuts are catched by the browser application before it arrives to the plugin.


This should be in your ~/.config/gtk-3.0/settings.ini :
With this you're allowing basic movements in address bar, search boxes, and input forms and text areas.


Yep, this is the tricky one. Both firefox and chrome take over ctrl-n, so you can't remap them and they always open a new window. Same happens with c-p showing the printing dialog. The trick then is to take over it ourselves going at Window manager level :).

In my case, I'm using ratpoison wm, so some of the commands used here won't work in your window manager, but you can find your way around using xdotool Look at this link for more info.

So we need 3 things:
  • - A way to guess which window is active (ratpoison -c "info") 
  • - A way to capture a keystroke (ratpoison's "definekey top" ) 
  • - A way to send an arbitrary keystroke to the active window. (ratpoison's "meta")
With these 3 capabilities, easy peasy:
It's dead simple, but I didn't write this till this week, and it's already made a huge difference in removing friction using firefox for me.


If you write long texts in text areas, you probably want to check atomic-chrome with ghost-text.

Also, mooz, the author of keysnail is now working in a generalized solution for what I just explained for C-n, using python (and requires root privileges) called xkeysnail. It appears to be very powerful and super customizable. Also, windowmanager agnostic, so you should probably give xkeysnail a try.

Also, /u/attrigh suggests giving next browser a try. Written in Common Lisp, built using webkit, and with a much richer experience than all those hacks put together.  I haven't tried it yet, but it's worth looking at in the near future.

sábado, 12 de mayo de 2018

Lisp recent threads

Lately, some articles on Lisp appeared in my usual websites.

Here's a HN thread where you can see the usual lispers enlightening other people about why Common Lisp is a very special beast.  DR Christian Shafmeister (CLASP) gives masterclasses in every post. Don't miss any :). There's some mention to those charts, where lisp shows as one of the both fastest and cheapest languages (after the ones that are specifically built to be superfast or efficient, while being more flexible than both)

Beautiful Racket, another hn post about the book.

Cloe lang. Apparently a heavily concurrent lisp.

extramaze, is built with racket, and the post shows some tricks used there.

Some CL macros?

Insightful post about starting a project in CL (going from repl to a project). Specially cool comment on tooling.

And as a bonus, RMS talking about his story with lisps. Very nice read also

I think I miss CL ... (...said while installing sbcl....)

bitmasking basic readings

So lately I've been exposed to using bitmasking for several tasks, and it's a cool and niche enough topic so that I delved a bit into it.

Appart from datastructures that depend on bit indexing like persistent datastructures, bit trees, bloom/cuckoo filters or others,  there's the concept of "plain" bit masking to optimize bookkeeping of a set of numbers (they can be indices of an array) in one big number.

Here are some examples of them:

martes, 8 de mayo de 2018

an advanced jq slideshow

So I found this advanced slideshow about jq (a tool you wanna have in your toolbox), and felt like sharing it here.