Bugs in the Skies

I was wondering how hard it would be to make the Emacs interface to the Emacs bug tracker offline capable. And it turns out it’s not very hard at all to create a half-assed solution here.

Basically you just have to download the bug list, and then all the bugs (which are just mbox files), and then there you are.  All control messages go via email, and Gnus is already offline capable, so here I am sitting on the plane from Sydney doing some bug triage:

IMG_20160301_1718273Unfortunately, food arrived after I’d done five bugs, and I had some wine, and then I fell asleep.

Darn!

A Big Patch For Emacs, A Small Step For eww

During my summer holiday I’ve mainly been working on making the Emacs networking layer more asynchronous.

To set up a connection, you first have to do DNS resolution, then the TCP three way handshake to set up a socket, and then (if you’re setting up a TLS connection) do the TLS negotiation.  Then you can start talking to the server.  Up until now, only the middle bit (setting up the socket) has been non-blocking, while the two bits at either end have blocked the main Emacs execution thread.

This means that when eww, the Emacs web browser, wants to download and insert an image into the buffer, the user experience got kinda choppy.  The DNS resolution might take a while, and when talking to far away servers, the TLS negotiation certainly took some time.

By adding code based on the glibc getaddrinfo_a library function, the first problem was solved.  By calling the gnutls negotiation code from the Emacs event loop, the final problem was solved.

Behold!  I’m here reloading a Norwegian web page where most of the images are fetched via https (i.e., TLS):

Asynchronous DNS and TLS in Emacs

I’m in Australia, so the networking all the way to Norway is s-l-o-w.  Especially since these are TLS connections.  Lots of chatter back and forth.  As you can see from the cursor movement, there’s no noticable choppiness.  Trying the same on this web page before the async patch went it is pretty horrible.

Yay.  And it was only a 3200 line diff. Ok, ok, most of that was chopping up lots of 700 line functions into slightly less ridiculously long functions, but eek.

Touchy Emacs

I use Emacs as a music playing interface, and I thought it would be nice try to create a pure touch screen interface, just … because.

The only OS that would install on my old Surface Pro 2 was the prerelease version of Ubuntu 16.04, Xenial Xerus.  Apparently kernels between 2013 and a couple of weeks ago dropped support for the wifi card in the Pro 2, so, but Xerus has it.

And everything works fine.  Except the multitouch.  Apparently Unity only has support for four-digit gestures, and it’s apparently impossible to remap these gestures.  (This is what hours of googling told me.)

To make Unity stop doing this crap, you have to build your own version.  This page explains how, but I’m just going to reiterate what it says, because some things have changed slightly.

sudo apt-get build-dep unity
cd /tmp
mkdir unity
cd unity
apt-get source unity

Then edit this file:

unity-7.4.0+16.04.20151218/plugins/unityshell/src/unityshell.cpp.  Comment out this line

//InitGesturesSupport();

And then build.

cd /tmp/unity/unity-6.8.0
dpkg-buildpackage -us -uc -nc
cd ..
sudo dpkg -i *.deb
apt-get remove unity-autopilo

Then install touchegg.  You need to create mappings between gestures and the events that Emacs will respond to.

<touchégg>
 
 <settings>
 <property name="composed_gestures_time">0</property>
 </settings>
 
 <application name="Emacs">

 <gesture type="TAP" fingers="2" direction="">
 <action type="SEND_KEYS">space</action>
 </gesture>
 
 <gesture type="TAP" fingers="3" direction="">
 <action type="SEND_KEYS">p</action>
 </gesture>
 
 <gesture type="DRAG" fingers="2" direction="UP">
 <action type="SEND_KEYS">Control+v</action>
 </gesture>

 <gesture type="DRAG" fingers="2" direction="DOWN">
 <action type="SEND_KEYS">Alt+v</action>
 </gesture>
 </application>

</touchégg>

Etc etc.  And here’s the result: A Surface Pro 2 playing in the kitchen while I’m programming on the patio:

The Touch of Emacs

I kinda really wanted to delve into creating a proper touch interface for Emacs, where you could define gestures as you want with a simple (local-set-key [(swipe up three-fingers]) ‘do-something), but this stuff seems like it’s way immature.  Still.  After all these years.  Or perhaps I’ve just not found the right documentation on dar webs.