Mounting Windows shares in Linux userspace

A current project has forced me into the clunky world of Windows, to verify that a Python program compiles and runs there just like it runs under Linux. Instead of trying to port my entire development environment to Windows — which includes two decades of customizations and a small empire of tools like Emacs, pyflakes, and Rope — I want to simply mount my Windows home directory under Linux so that I can run my normal editor and version control tools in a more familiar environment.

I have worked out an elegant solution by combining two of the powerful user-space filesystems available through the FUSE mechanism in the Linux kernel. Let me take you through the story of how I put them together!

(more...)

Posted in Computing, Emacs | 2 Comments »

Opening tabs remotely in Google Chrome

Now that I use Google Chrome almost exclusively, I miss the fact that a running Firefox instance could be controlled from the command line so that Emacs could call for a new tab when I clicked on a URL. It would run a command something like this:

firefox -remote 'openURL(http://example.com/, new-tab)'

But after a few months of manually cutting and pasting URLs into Chrome — which wasn't actually that bad, since the address bar in Chrome is such a convenient and large target — I decided that I needed a real solution. After not finding anything like a -remote option, I discovered that Chrome can at least be run with a debugging port open:

google-chrome --remote-shell-port=9222

The protocol that Chrome speaks is primitive enough that it was quick work to implement a small client in Python. Rather than merely cutting and pasting its code here on my blog, or even be satisfied with making it available on bitbucket, I decided to place the code inside of a new Python package and make it generally available on PyPI as chrome_remote_shell.

Thanks to this simple package, a four-line program (not counting the shebang and comment) is now all that I need to ask Google Chrome to open a new tab:

#!/usr/bin/env python
# Name this file "google-chrome-open-url"
import sys
import chrome_remote_shell
shell = chrome_remote_shell.open()
shell.open_url(sys.argv[-1])

To teach Emacs to start using Google Chrome when I clicked on a link, I only needed to supply it with two new settings:

(setq browse-url-browser-function
      'browse-url-generic)
(setq browse-url-generic-program
      "google-chrome-open-url")  

And now everything works. I hope that these notes prove useful to someone else. Enjoy!

Posted in Computing, Emacs, Python | 11 Comments »

Installing Python packages for Emacs with virtualenv

The only rough edge I have found amidst the otherwise exceptional advice on Ryan McGuire’s Enigma Curry blog is that Ryan recommends installing Python packages with:

$ sudo easy_install package_url

This means that his Emacs configuration — which, very generously, he has started maintaining as a project on github so that other people can use it themselves, or branch their own versions — requires root access merely to install.

Like Ryan, I also keep my Emacs configuration under version control, so that improvements I check in from one account are easy to check out into all of my other accounts. Although my setup is probably too simple to be interesting as a public project, there is one aspect of it that I should share: unlike Ryan, I use the advanced technology of a virtualenv to hold the Python packages that Emacs needs. The virtual environment lives under my own account, and is easy to create, access, and rebuild, even in the absence of root privileges on a particular machine. Even better, packages that I install or upgrade inside of the virtual environment cannot interfere with Python programs running elsewhere on the system.

(more…)

Posted in Computing, Emacs, Python | 4 Comments »