An asynchronous web server written in Emacs LISP

Elnode is an asynchronous web server written in Emacs LISP.
Emacs has had asynchronous socket programming facilities for some time and a few years ago asynchronous TCP server sockets were introduced. I couldn’t quite believe that no one had written an asynchronous webserver with EmacsLISP before. So now I have.
When I started looking at actually doing this I intended to knock up just a silly demo. But the more I got into it the more it seemed to me that this could be an important addition to Emacs and that, sometimes, an Emacs LISP async web server could actually be useful.

(via nic)

Managing bibliography references with JabRef

JabRef is an open source bibliography reference manager. The native file format used by JabRef is BibTeX, the standard LaTeX bibliography format. JabRef runs on the Java VM (version 1.5 or newer), and should work equally well on Windows, Linux and Mac OS X.

Addendum: 2019-09-24

JabRef continues to be an excellent bibliography manager.

Using BibTeX as the master database and JabRef to populate, manage, and export from it has been really nice. The key has been letting Emacs manage the keys and sorting.

Clipped fonts in Emacs

The awesome pretty-mode for Emacs displays symbols of your choosing rather than text for specified patterns. For example if you have a lot of Greek letter names in your MATLAB code you might just have the symbol show up instead.
After upgrading to Emacs version 23 on Windows (GNU Emacs 23.3.1 (i386-mingw-nt6.1.7600) of 2011-03-10 on 3249CTO) though the symbols get clipped off. Here is what I mean:

When I place the cursor on the lambda in this case, it renders correctly:

However, when I modify the buffer, the characters again renders incorrectly.
When I type in the Unicode characters directly; they render just fine.
My current approach for figuring out what is going on has been to read the code and the Elisp API. From what I can see, it “looks right”. Right now I’m just documenting it here to try to get a pointer on where to look next.

Enabling PNG, JPG, and GIF in Emacs on Windows

Today I installed graphviz mode for Emacs. One of its features is that it will show you the rendered image in a buffer. When I tried it out, the image was opened as text. This is of course not what I wanted :).
The Emacs user guide says here that to enable support on Windows you should check “Other useful ports”.
This post was particularly helpful because it explained that the contents of the ‘image-library-alist’ variable tell us everything we need to know. When you view its contents, it tells you which DLLs that it is looking for in order to view each particular format of image file. Just get the Windows version of those DLLs and throw them in the Emacs bin directory and restart Emacs for image support to be enabled.
I got zlib1.dll, jpeg62.dll, and giflib4.dll from GetGnuWin32 and libpng14-14.dll from Gnome.

Calling Java Under Cygwin

While trying to set up Clojure under Cygwin I found that doing mixed-mode between Cygwin and Java isn’t very happy due to the ‘;’ vs ‘:’ in the classpath.
This post (via this post) provided an obfuscated Ruby program to take care of that for you… thanks!

#!/bin/ruby
# Slightly obfuscated cygwin + windows java wrapper, automate cygpath
cpi = ARGV.index("-cp") + 1
cp = ARGV[cpi] if cpi
XBCP = "-Xbootclasspath/a:"
xbcpi = ARGV.index{|i|i=~/^#{XBCP}.*/}
xbcp = ARGV[xbcpi] if xbcpi
if cp or xbcpi
  def convert_paths(paths)
    paths = paths.gsub(':', ';').split(';')
    paths.map{|p|`cygpath -aw #{p}`.strip}.join ';'
  end
  ARGV[cpi] = convert_paths(cp) if cp
  ARGV[xbcpi] = XBCP + convert_paths(xbcp.sub(XBCP, '')) if xbcp
end
java = '/cygdrive/c/Program Files/Java/jdk1.6.0_18/bin/java'
cmd = .concat ARGV
def e(s); "\"#{s.strip.gsub('"','\"')}\""; end
exec(cmd.map{|a|e a}.join(' '))

DrScheme Style Buffer Evaluation for OCaml in Emacs

When you want to evaluate code inside of DrScheme, you hit the F5 key and the entire editor buffer gets evaluated inside of a new REPL. Unlike Emacs, the ability to send the current expression, region, or buffer to the REPL isn’t available. It might sound constricting, but in practice it is very nice because you are always working with the most up-to-date versions of your definitions. It might sound slow to start a new REPL on each run, but it isn’t; on my older desktop the new REPL comes up before my finger even comes off of the F5 key. This approach seemed like a nice to have for working with OCaml in Tuareg mode on Emacs, so I pieced together a function to do so against Tuareg 1.45.6:

(defun tuareg-eval-buffer-drscheme-style ()
  "Send the buffer to a brand new Tuareg Interactive process."
  (interactive)
  (tuareg-kill-caml)
  (sleep-for 0.25)
  (if (get-buffer tuareg-interactive-buffer-name)
      (kill-buffer tuareg-interactive-buffer-name))
  (tuareg-eval-buffer)
  (switch-to-buffer tuareg-interactive-buffer-name))

Out of the box Tuareg mode will ask you what program name to run to start OCaml each and every time you evaluate the buffer, even when the variable storing that name is defined. I didn’t find a way to avoid this prompt so I patched Tuareg such that it will not ask you if a value is already defined for the program name. Here is the patch.
Thus far it has been nice to have the option of evaluating the whole buffer in a new REPL in addition to the existing incremental evaluation options.