On-the-fly jslint validation in emacs

In the hope that someone will come across this trying not to waste time figuring things out, here’s how I managed to have emacs run jslint in my JavaScript buffers in real time. It’s not perfact, but it works where no other method I found online did.

We’ll use the jslint package from node.js1:

1. Install node.js. I use the homebrew package manager on OSX, so I just had to type brew install node.

2. Install the jslint module of node.js: npm install jslint

After this you should have a jslint command which you can test in a terminal (eg, jslint --terse test.js) to see something that looks like:

18n.js(2):Expected 'en' at column 9, not column 3.
i18n.js(3):Expected 'record' at column 13, not column 5.

By default (without --terse) the output is more verbose, but having one line per error is easier in emacs.

3. Add the following to your .emacs file:

(when (load "flymake" t)
  (defun flymake-jslint-init ()
    (let* ((temp-file (flymake-init-create-temp-buffer-copy
           (local-file (file-relative-name
                        (file-name-directory buffer-file-name))))
      (list "jslint" (list "--terse" local-file))))

  (setq flymake-err-line-patterns
	(cons '("^\\(.*\\)(\\([[:digit:]]+\\)):\\(.*\\)$"
		1 2 nil 3)

  (add-to-list 'flymake-allowed-file-name-masks
               '("\\.js\\'" flymake-jslint-init))

  (require 'flymake-cursor)

(add-hook 'js2-mode-hook
	  (lambda ()
      (flymake-mode 1)
      (define-key js2-mode-map "\C-c\C-n" 'flymake-goto-next-error)))

flymake-cursor replaces the default behaviour of popping up a menu with the error message by just putting it in the minibuffer.

Emacs should of course be set up so that it knows where jslint is, in order to invoke it on the javascript buffers3.


1. I also tried jslint4java but it turned out to be too slow for real-time invocation with flymake. Other Java-based methods (using Rhino) are, unsurprisingly, reported to be equally slow, and I failed to get spidermonkey installed.

3. In OS X, applications get their environment variables (like PATH, here) from the environment.plist in ~/.MacOSX. See this emacswiki page for instructions.

[updates 9 Oct 2012]:

  • Step 2 is no longer necessary, as npm is now included in homebrew’s node package
  • At step 3, removed -g
  • With the --terse option, it is no longer necessary to modify files inside the jslint module.
  • The lisp code has been updated to include --terse and match the new jslint error syntax

Thanks to the people who commented, leading to the update.

Posted in General | 8 Comments

Efficient Calendars Redux: Gosper curve

One Mr Scott posted a comment on a previous entry on calendars and plane-filling curves, where he suggests using the Gosper curve as the calendar path. I was intrigued and adapted the code in order to give it a try. But I can’t say it produced great results:

While it looks pretty and shows much compactness (properly analysed in the 2008 article by Herman Haverkort and Freek van Walderveen previously mentioned), it is perhaps too compact in the sense that there’s not much space to scribble anything in the cells or around (not that I expect anybody to use it for that purpose). More importantly, the way the L-system rendering is implemented in SVG doesn’t lend itself to hexagonal cells, as this close-up shows:

The issue is that the way the calendar is rendered is that a single thick polyline is the space-filling curve and is used as a mask through which the cells show. While it masks square cells pretty well, it sort of fails for hex, as it doesn’t follow the edges of the cells but instead cuts right through.

It’s my own fault, and the solution would be to use a custom type of polyline, which means that I’d have to write my own curve-rendering code. While this would have the extra advantage that I could then port the code to HTML5, I’m not really bothered.

I’m not bothered publishing the Gosper code either, but I’ll do it if anybody asks.

Posted in General | Comments Off on Efficient Calendars Redux: Gosper curve

New Textorizer (again)

Jefferson Excoffized

And yet again I’ve rewritten textorizer. Why? Because:

  • There were many reports of incompatible versions of the JVM, which somehow defeated the purpose of using  Java to make textorizer cross-platform. Hopefully browsers will spare everyone of the problem.
  • HTML5’s canvas is now well supported across browsers and has enough features to let me implement the graphical functionalities needed.
  • JQuery-UI makes it easy to design the controls that required not-so-well-supported UI libraries in Processing.
  • It’s no longer necessary to download an application, which was not only a security risk but also created confusion with the different versions out there when a bug was reported. Now everyone has the latest version (as long as they reload the page)

In case you didn’t notice, textorizer is no longer about graphics, but about me experimenting with as many development platforms as I can (I’ve spared you reports on my experimenting with Opera Widgets, Chrome Extensions, Adobe Air and Titanium). Therefore, since I barely touch the code that does the rendering, there is only one change: the text now has a very slight shadow, which I think improves the result. I’ve also merged excoffizer into textorizer, since a lot of the code is shared. Excoffizer never quite got the popularity it deserved. Maybe it’ll change now.

Textorizer lets you use local pictures through a file-upload button. This uses a javascript API called File API, which is not quite standard and is only implemented in Firefox, Chrome and Opera, but not Safari (I’ve not tried IE).

The new textorizer is available at the same address as before, and the old textorizer has been moved elsewhere. It can still be downloaded but I will no longer make changes to it. So if you find that the new version is missing something that the old one had (or if you find any bug), let me know and I’ll fix it.

Posted in General | Comments Off on New Textorizer (again)

New Textorizer

Hello all,
A new version of textorizer is available. What’s new:
– The size of the resulting image can be set in the control. It make it possible to produce images larger than the size of the screen.
– The control panel has been improved
– Textorizer2: better text placement, and smoother transitions of the text

Thanks for everyone who’s sent feedback. Hope you like the new version.

Update (19 May 2010): new new textorizer available! With a brand new interface allowing you to edit the text directly.

Posted in General | Comments Off on New Textorizer


Inpired by Duncan Robertson’s BBC Logo in QR Code, as well as various similar attempts to make QR codes look pretty (I particularly like David Blume’s), and challenged by @danbri I wrote a little QR code (de)generator. It allows changing individual pixels, as well as adding a picture. Screenshots:


Whether the altered QR codes are still scannable is not measured by this tool, let alone guaranteed. You’ll need to scan them separately in order to make sure the message is still readable.

Things to add:
* a way of saving the code as an image file or SVG
* more than one picture
* “undo” functionality
* more complex pixel manipulation tools
* altering pixel shape and colour (using SVG filters, maybe)

This work wouldn’t have been written without Kazuhiko Arase’s QRコード JavaScript library. It is licensed under the MIT License. The source code is available on github.

Update: and here’s the link to qtqr. Doh.

Posted in General | 1 Comment

Textorizer fixed

Since April, there’s been lots of reports of the application starting and only displaying a grey window. Since I couldn’t reproduce it anywhere, I had no idea how to fix it until a bunch of very kind people were able to help me track the bug down. So I am now really happy to announce a new release that fixes the issue. Head to the textorizer page to download the new version.

Posted in General | Tagged | Comments Off on Textorizer fixed

Commemorating the Moon Landing

I’d done it a few months back, but I thought I’d revamp my textorized Moon Landing poster. The text is the transcript of the Apollo XI landing.

This time, the SVG version is available for your printing needs.

Posted in General | 1 Comment

Dutchr: learn any language in 24 hours

For a couple of years, I’ve been trying to learn Dutch, then Norwegian. And Javascript. I’ve failed at Dutch, but I’m still trying the other two. And to help me I wrote a little web application called Dutchr, which is basically a flashcard app: you give it a list of pairs of words or expressions, and a popup pops up at regular intervals, and invites you to guess one random entry on the list.


You can try it right now in your browser, but if you want to customise your cards, then you have to download it first. See the instructions.

Posted in General | Comments Off on Dutchr: learn any language in 24 hours

New textorizer!

arabian nights

There is a new version of textorizer available for download. It’s still the same deal, but it has been greatly improved: new fonts, new scripts, new settings, fewer bugs.

You can find it on the separate textorizer page, with examples and instructions.

Posted in General | Comments Off on New textorizer!

Calendar Poster!

Rik Penny from ripedigital, a long-time supporter of textorizer, has sent me this big glossy-paper poster of the 2009 fractal calendar. Many many thanks!

Posted in General | Tagged | Comments Off on Calendar Poster!