Archive for May 10th, 2006

Colour Terminals in (X)Emacs

Some Unix command line tools display text in colour, if you run them in the right kind of terminal, of which the Emacs shell isn’t one. So far this had not really bothered me since in most cases the colours do not convey all that much information. However, recently I was playing with Maude, which colours terms for debugging purposes. There is no easy alternative for getting hold of the same information.

A few minutes of googling and experimenting produced the magic Emacs command

(require 'ansi-color)

followed by customisation of the ansi-color-for-comint-mode variable (setting it to t) or calling (ansi-color-for-comint-mode-on). This applies across all comint sessions, not just shell sessions, so it also affects things like the interactive Maude mode.

Under Emacs one can go further with M-x ansi-term, which creates a fully-fledged ansi terminal inside an emacs buffer. Finally we can run Emacs inside Emacs inside Emacs …! Ansi-term is not available for XEmacs, probably because it is some ghastly hack.

2 comments May 10th, 2006 matthias

Exporting Squeak Presentations to HTML+PNG

I’ve been using Squeak’s BookMorph to assemble presentation materials recently, but there’s been no way to export the presentation for the benefit of those without a Smalltalk image - until now. I just implemented a trivial little method on BookMorph that exports all its pages to PNG files, and writes a small HTML index file.

Here’s one I prepared earlier:

http://www.lshift.net/~tonyg/cake-presentation/PresentationBook.html

(the presentation itself isn’t done, and won’t mean much outside LShift at the moment, but it’s enough to demo the idea.)

Here’s the method I wrote:

exportPagesAsPng
  | fileName indexPageStream |
  'Exporting ', pages size printString, ' pages to PNG'
    displayProgressAt: Sensor cursorPoint
    from: 1 to: pages size
    during: [:progressSetter |
      pages doWithIndex: [:page :i |
        progressSetter value: i.
        fileName := self externalName, '_',
                      (i printStringLength: 3 padded: true), '.png'.
        PNGReadWriter putForm: page imageForm onFileNamed: fileName.]].

  indexPageStream _ FileStream newFileNamed: self externalName, '.html'.
  indexPageStream nextPutAll: '<html>...</html>'.
    "html and javascript elided - have a look at the example."
  indexPageStream close.

1 comment May 10th, 2006 tonyg

Adding CAPTCHA

We were getting a large volume of comment-spam, so I’ve added a wee Turing test to the comment form. I hope it doesn’t put anyone out.

It certainly inconvenienced me—the plugin needs a graphics extension for PHP. “No problem,” I thought, “I’ll just apt-get install the package for it.” But apt-get went on a rampage, (seemingly) removing the entire WordPress installation and insisting on installing new versions of everything from gcc up. As a final insult, it not only failed to configure PHP to use the extension, it disabled the database extension!

Yes, I accept that it was probably my misuse of apt-get that provoked it. I’ll be sticking to Gentoo for myself, all the same.

3 comments May 10th, 2006 mikeb

Calendar

May 2006
M T W T F S S
« Apr   Jun »
1234567
891011121314
15161718192021
22232425262728
293031  

Posts by Month

Posts by Category