Tuesday, 7 June 2011

Emacs user at work

Despite being designed by a Vim user, and despite its implied criticism of Emacs, I still enjoyed this image:

ashawley in the comments below points out the similarity with the 1981 cover of the EMACS Manual:

Saturday, 21 May 2011

rms on apple and brain scans

Some Apple addicts truly worship that company, suggest brain scans.
That must be why they allow it to abuse them so much and don't care.
I know a number of Apple fans, and they do tend to have strongly favourable attitudes towards Apple products. (Apple things generally seem to be superior to Microsoft things, but the Apple company doesn't seem any less evil than Microsoft, and Linux is generally superior to both anyway.)

But I question whether this is a reaction which is actually specific to Apple fans. I imagine my brain scans might show similar reactions to GNU/Linux and Emacs.... (Most Windows/Microsoft users probably wouldn't show similar results, given that it's really just the "default" nowadays.)

Wednesday, 6 April 2011

Emacs in Tron

JT Nimoy discusses the creation of software art for creating visual effects in the film Tron: Legacy. Additionally, he mentions that:
In Tron, the hacker was not supposed to be snooping around on a network; he was supposed to kill a process. So we went with posix kill and also had him pipe ps into grep. I also ended up using emacs eshell to make the terminal more l33t. The team was delighted to see my emacs performance -- splitting the editor into nested panes and running different modes. I was tickled that I got emacs into a block buster movie. I actually do use emacs irl, and although I do not subscribe to alt.religion.emacs, I think that's all incredibly relevant to the world of Tron.

(1) The original article/post by JT Nimoy
(2) On jwz's blog
(3) On boingboing
(4) On reddit

Tip: Showing blocked syntactic movement in LaTeX with tikz(-qtree)

Minimal example showing how to indicate blocked/illegal syntactic movement in LaTeX using the tikz and tikz-qtree packages.

\begin{tikzpicture}[baseline,description/.style={fill=white,inner sep=2pt}]
  \Tree [.A [.B \node(b){b}; ] [.C c [.D d [.E e [.F f [.G g [.H \node(h){h}; ]]]]]]]
  \draw [dashed, ->, bend left] (h) to node [description] {\LARGE $\times$} (b);

Thanks to Andy L├╝cking and Alexis Dimitriadis from the Ling-TeX mailing list.

Saturday, 19 March 2011

Tip: let Synaptic handle updates to Buuf icon set

If you want the synaptic package manager to keep your Buuf icons up-to-date, you can do so by using the Ubuntu Satanic Edition repository, as follows:

1) add the secure key; in terminal enter:
wget -q http://ubuntusatanic.org/ubuntu-se-key.gpg -O- | sudo apt-key add -

2) add the following repository to your system (you could go to Go System->Administration->Software Sources->Other Software->Add and enter the following APT line:), choose the appropriate version (the following assumes you're using Ubuntu Maverick 10.10):
deb http://ubuntusatanic.org/hell maverick main

3) then in the terminal add the Buuf package by entering:
sudo apt-get update && sudo apt-get install buuf-icon-theme

Thursday, 3 February 2011

Tunes from an alternative Victorian era: Sunday Driver

Sunday Driver were formed in the summer of 2000, though lead singer Chandrika "Chandy" Nath had earlier composed some of the songs whilst monitoring ice floes near the South Pole, during a field trip in Antarctica, collecting data for the British Antarctic Survey.

Chandy has a Ph.D. (in physics, I think), and the band's name "Sunday Driver" derives from the moniker of a gene (SYD) commonly found in mice; and the music mixes Indian (Carnatic) and English folk music, along with early 20th century classical music (Ravel, Glass, etc.) and West End musicals, topped off with a (originally unintentional, I believe) steampunky twist.

Their first album, "In the City of Dreadful Night", is available here: www.sundaydriver.co.uk. From their own description: "...inspiration from Victorian London and Raj-era Calcutta, the tracks range from hypnotic to bittersweet."

In any case, here's...

A nice sampler:

A few interviews:

And a few promotion photos suitable for wallpaper:

Monday, 31 January 2011

The Indifference Engine - Victorianesque Hiphop

Prof Elemental : a steampunk mad professor with a fondness for adventure, strange animals and the pursuit of a good cuppa.  He has a new album out, the delightfully titled Indifference Engine.

Here's a taste:

Cup of Brown Joy:

Fighting Trousers (The beginning of a battle with Mr B?):

Tuesday, 25 January 2011

CPUs (+ALUs) in Minecraft

Some people have managed to create working CPUs (or ALUs) in Minecraft. They're slow and have little computing power or memory, but I still think it's an interesting case of recursion. Minecraft simulates a physical world, and these are computers created within the confines, and conforming to the rules of that world.

In any case, some links to information/videos about creating CPUs (and ALUs) in Minecraft follow.

An 8-bit CPU:

And a webpage about it: http://lazcraft.info/tagged/CPU

(This is the project with most information.)

A 16-bit CPU:

Here's the Youtube channel connected with this project: http://www.youtube.com/user/theinternetftw

A 32-bit ALU:

And, finally, it's not a computer, but a pretty cool implementation of Conway's Game of Life in Minecraft:

Conway's Game of Life in Minecraft:

Let me know about other CPUs/ALUs etc. in the comments.

Saturday, 22 January 2011

Clockworks: explanations and videos

Some interesting/educational videos on the workings of mechanical watches.

First, from 1949, a video produced by the Hamilton Watch Company:

Source: http://www.archive.org/details/HowaWatc1949

A simple demonstration of the basic design and operation of a watch. The inside "works" are shown in stop-motion animation using giant 7.5 foot, in-line movement, exact and to scale in every detail. [See the source for higher resolution versions.]

Second, a beautiful video showing some high resolution video shots of a mechanical pocket watch:

Source: http://theb-roll.com/day-186-time/

[See the source for a description.]

(More bits on clockworks here: http://blekko.com/ws/+/beslayed/clockworks .)

Thursday, 20 January 2011

2D Goggles, Or, The Thrilling Adventures of Lovelace & Babbage: a webcomic

Something which, for some reason, I only came across just now:

A webcomic consisting of the chronicles of Charles Babbage (the inventor of the first computer, which, alas, was never built---but it might be soon: see here!) and Ada Lovelace (the first computer programmer) in an alternative world where Ada Lovelace didn't die at age of 36, and where Babbage and Lovelace successfully developed the first computer (giving humanity the necessary technological advantage to repel the alien invasion of 1898) and went on to use their combined powers to fight crime and have thrilling adventures.

Here's a taste:

See more here.

Part of what I really like about this comic is its footnotes. Yes, it has footnotes, references to various primary (and secondary) sources relevant to the comic, like Babbage's autobiography.

Saturday, 15 January 2011

LaTeX table manipulation using Emacs/AUCTeX+align.el+rectangular selection

Tables in LaTeX are sometimes somewhat difficult to manage; in particular doing anything with columns---in contrast to most word processors, which allow for the manipulation of columns in certain environments (e.g. tables). However, the text editor Emacs in fact allows for rectangular selections anywhere, which means that using Emacs as an editor for (La)TeX files makes working with tables easier.

The AUCTeX package for Emacs adds a vast number of useful features; however, it does not automatically format tabular environments. Here I  offer some notes on how to deal with LaTeX tables in a Emacs/AUCTeX environment.

So let's say we have a LaTeX document containing a (big) table, like this:

And let's say we want to switch the third and fourth columns. Easily done in a typical word processor, but not necessarily so for a LaTeX document. Let's look at the LaTex .tex source for this table:

A rectangular selection will work only if we have  our columns aligned in our source .tex file. The align.el package for Emacs is needed here (as of Emacs 22, this functionality is built in).

Place the cursor at the beginning of the tabular environment (in our current example, right below the first \hline command will work), and use the align-current function (press M-x and then type align-current RET):


[Make sure there are no blank lines in your tabular environment; "align-current" will stop when it hits a blank line.]

If you're working with a large table, as in this example, you still won't be able to see the entire width of the table, so hold down SHIFT and left-click the mouse and choose "Decrease Buffer Text Size" repeatedly until the entire width of the table is visible on your screen (maximizing the Emacs frame to the maximum width of your desktop will be helpful as well...). You should then  be able to view the table as so:

All of our columns are now aligned. Now we need simply to select a rectangular region. There are (at least) two ways of going about doing so. Firstly, the ability to select rectangular regions is a built-in feature of Emacs (see the relevant section of the Emacs manual). Simply select the columnar area (mark it using C-SPC) and press either C-x r r to copy the rectangular area to the register or C-x r k to cut ("kill") the rectangular area and place it in the register. And then use C-x r y to paste ("yank") the copied/cut rectangle into the position you want it (with the cursor in the position of its upper left-hand corner).

However, if your Emacs has the visible selection turned on (as is the default as of Emacs 23), then it is nicer and easier to be able to see the selected area as a rectangle. One nice option is to use the rectangular selection features of the CUA package (a built-in default as of Emacs 22). One of the main functions of the CUA-mode is to change Emacs' copy, kill/cut, and yank/paste keybindings (M-w, C-w, C-y) to the "common" C-c, C-x, C-v. If you, like me, don't want to change the default Emacs keybindings, then include the following in your .emacs configuration file:

(cua-selection-mode t)
(setq cua-auto-tabify-rectangles nil) 

[If you do want the "common" keybindings, then use (cua-mode t) in place of (cua-selection-mode t).]

With this configuration in place, we can now visibly select rectangular areas, and use the normal copy/kill/yank keybindings to copy, cut, and paste the rectangular selections. In CUA-mode rectangular selections are made using C-RET rather than C-SPC. Here is the rectangular selection in our example:

I then kill ("cut") this rectangular area with C-w. And then position the cursor at the point where I want the upper left-hand corner of this rectangular area to be inserted:

And then yank ("paste") the column in its new position with C-y:

That's it. Here is the resulting table (with columns 3 and 4 switched):

Oh, and here is a nice video demonstration of the use of rectangular selection cut-and-pasting (with CUA-mode): Emacs Column Editing by Mark Mansour. It doesn't deal with LaTeX, but rather HTML; however, it illustrates the general use.

Wednesday, 12 January 2011

Conkeror - browsing the web, emacs-style

As noted below, I've switched from Icecat/Firefox+Pentadactyl/Vimperator to Conkeror. Trying to retool the essentially vi-ish shortcuts to emacs-like shortcuts is rather difficult, and in the end I wasn't able to change some of the shortcuts I wanted to change.  Anyway, Conkeror is simply more interesting: more of a from-the-ground-up approach than an add-on approach.

This post isn't intending as a general intro to Conkeror; if that's what you're looking for, see here or here, or, if you're running Conkeror, press C-h t (that's Ctrl and h at the same time, release, then t) for a tutorial.

Rather like Emacs, Conkeror gets much better than more one personalises/configures it. Some good places to start are on the Conkeror site itself, on Tips from Users page and also the emacs-fu article "conkeror web browsing the emacs way".

In the same spirit, I offer a number of useful customisations I've adopted, some from the two above-mentioned sources, some from other places (including from suggestions on the Conkeror mailling list), and some of my own.

Some initial things:
//allow for 'contrib' stuff

// Mode-line

// auto completion in the minibuffer
minibuffer_auto_complete_default = true;
url_completion_use_history = true; // should work since bf05c87405
url_completion_use_bookmarks = true;

// display the url before going to it in hints mode
hints_display_url_panel = true;

These are settings taken from here and there. Turning on the mode-line, allowing the url completion (very handy) to access history and bookmarks, and displaying the url of a link (in hints mode).

Customising the mode-line:
add_hook("mode_line_hook", mode_line_adder(buffer_icon_widget), true);
read_buffer_show_icons = true;

// we'd like to see the # of buffers being loaded 
add_hook("mode_line_hook", mode_line_adder(loading_count_widget), true);

// but really we'd also like to know how many buffers are present and which is the current
add_hook("mode_line_hook", mode_line_adder(buffer_count_widget), true);

// remove the clock
remove_hook("mode_line_hook", mode_line_adder(clock_widget));

The first allows for favicons in both mode-line and the C-x b buffer list, the second shows how many buffers are currently still loading, the third shows how many buffers are present and which buffer is the current buffer, the last simply disables the clock. The order of the first three is actually important; this order puts the buffer count on the far left, then the "loading buffer" count, then the favicon, (and then the url of the current buffer).

Tabs & Mouse:
// Tabs

//Open Middle-Clicked Links in New Buffers
clicks_in_new_buffer_target = OPEN_NEW_BUFFER_BACKGROUND; // Now buffers open in background.

//Bind Number Keys to Switch to Buffers 1-10
function define_switch_buffer_key (key, buf_num) {
    define_key(default_global_keymap, key,
               function (I) {
for (let i = 0; i < 10; ++i) {
    define_switch_buffer_key(String((i+1)%10), i);
I like having tabs, and the first bit above turns on the tabs, with numbering (but no favicons). I still find it useful to use the mouse from time to time. What's annoying is having to switch from keyboard to mouse or vice-versa. So if I'm using the mouse, I want it to be effective. The second bit above opens new buffers/tabs on middle-clicked links (in background buffers). The last bit allow for quick switching between tabs (the first 10 anyway) using 1-10 (where 0=10). Other useful things to know (though not dependent on this particular configuration): tabs can be closed directly with right click; you can scroll through your tabs by positioning the mouse pointer on the tab bar and using the mouse wheel.

External editor
//set emacs as external editor
editor_shell_command = "emacsclient -c";

// view source in your editor.
view_source_use_external_editor = true;

Set emacs as an external editor (assuming you're running emacs as a daemon), etc.

Managing/Navigating Tab-Buffers
// redefine C-f as "forwards" and C-b as "backwards"
// using F and B (that is Shift+F, Shift+B is actually rather inconvenient since 
// many other command use Control and so requires shifting fingers)
define_key(content_buffer_normal_keymap, "C-f", "forward");
define_key(content_buffer_normal_keymap, "C-b", "back");

// make M-f and M-b switch to next and previous buffers
define_key(content_buffer_normal_keymap, "M-f", "buffer-next");
define_key(content_buffer_normal_keymap, "M-b", "buffer-previous");

// redefine l as "follow link" (like f)
// (too many of the keys are for the left hand, I like "l" for "link")
define_key(content_buffer_normal_keymap, "l", "follow");

// Use M-l to follow link in new background buffer
define_key(default_global_keymap, "M-l", "follow-new-buffer-background");

// open url in new background buffer  (I can't think of a good keybinding for this)
    "Open a URL in a new background buffer",
    alternates(follow_new_buffer_background, follow_new_window),
    $browser_object = browser_object_url,
    $prompt = "Find url");

The default keys for navigate forwards and navigate backwards are F and B, respectively. I imagine there are historic reasons behind this (it's how W3 does it), but I find it annoying to have to switch from Ctrl to Shift (since most of the other keybindings involve Ctrl), so the initial bit above binds C-f and C-b to forwards and backwards (F and B still work too). And I bound M-f and M-b to "move to next tab-buffer", "move to previous tab-buffer", respectively. These seem to me to make sense as extensions of the normal behaviour of C-f, C-b, M-f, M-b, in Emacs. [Note: These bindings don't affect the how these keys behave in text boxes. All of these keys retain their expected Emacs-ish behaviour in text boxes.]

I prefer using l for following links in hint mode, so that's another binding added above (f still works too). And I added M-l as "follow link in new background buffer" (works like middle-click).

The last bit is a new command for opening URLs in new background buffers, but I haven't thought of a good keybinding for it so far.

// use M-y to google current selection in new buffer
// use M-Y to google current selection in new buffer "double-quoted"

// [ref: http://www.mozdev.org/pipermail/conkeror/2009-February/001334.html ]
// (See also "**c" for selecting text)
interactive("search-clipboard-contents", "Search in Google the content of the X clipboard (the selected text)",
              function(I) {
                  return "g "+ read_from_x_primary_selection();
interactive("search-clipboard-contents-doublequoted", "Search in Google the content of the X clipboard (the selected text) as a fixed string",
              function(I) {
                  return "g \""+ read_from_x_primary_selection()+"\"";

define_key(content_buffer_normal_keymap, "M-y", "search-clipboard-contents");
define_key(content_buffer_normal_keymap, "M-Y", "search-clipboard-contents-doublequoted");

By default, (outside of text boxes, where, again, Conkeror has the expected Emacs-ish behaviour), M-w copies the selected area. And C-y opens whatever's in the clipboard (I would say kill-ring, but it's not) in the current buffer---assuming that what's in the clipboard is a URL. The above code adds two new commands, performing a Google search on the current clipboard contents, and performing a Google search on the current clipboard contents double-quoted. I bound these to M-y, and M-Y, respectively.

Oh, in general, adding a C-u prefix results in the command being executed in a new buffer. So C-u M-y performs a Google search on the clipboard contents in a new (focussed) buffer.

More buffer management/misc. bindings
// make C-c C-c "submit form"
define_key(content_buffer_normal_keymap, "C-c C-c", "submit-form");

// make C-x 0 "kill current buffer"
define_key(default_global_keymap, "C-x 0", "kill-current-buffer");

// make C-x 1 "kill other buffers"
define_key(content_buffer_normal_keymap, "C-x 1", "kill-other-buffers");

// make C-x 2 "duplicate buffer"
interactive("duplicate-buffer", "Duplicate buffer",
            function (I) {
              browser_object_follow(I.buffer, OPEN_NEW_BUFFER, I.buffer.current_uri.spec);
define_key(content_buffer_normal_keymap, "C-x 2", "duplicate-buffer");

Use C-c C-c to submit forms.

Now Conkeror doesn't have "windows" in the Emacs-sense. It has buffers/tabs. So the above commands depart somewhat from being truly parallel with Emacs behaviour, since in Emacs these commands all involve window management. But I still find it useful to have some keybinding for these commands, and these make a sort of sense to me. C-x 0 closes the current tab-buffer (C-x k is the command for "close buffer" in general; it defaults to the current buffer, but requires another keystroke (Enter)); C-x 1 closes all tab-buffers except for the current one; C-x 2 duplicates the current tab-buffer in a new tab.

Set default download directory
// cwd

This sets the default download directory to "~/Downloads". "cwd" is useful, and can be used cross-platform. It gets the "home directory". The last line obviously appends "Downloads" to the home directory location.

// xkcd add mouse-over text
xkcd_add_title = true;

// No new window for downloads

// Make sure I don't close by accident
           function () {
               var w = get_recent_conkeror_window();
               var result = (w == null) ||
                   "y" == (yield w.minibuffer.read_single_character_option(
                       $prompt = "Quit Conkeror? (y/n)",
                       $options = ["y", "n"]));
               yield co_return(result);

can_kill_last_buffer = false;

Show xkcd mouse-over text on the page below the cartoon (it would be nice to have another way of handling mouse-over text though).

The second command handles how the download info buffer is handled; here it opens in a new tab rather than opening a new window ("frame" in the Emacs sense).

The last bits makes sure that if by accident I hit C-x C-c rather than C-x C-v it doesn't close everything without asking me, and then final line disallows killing of the last buffer.

Webjumps are a useful feature of Conkeror. In the mini-buffer, instead of typing a url, one can type a webjump. A number of such webjumps are built-in to Conkeror already. For example, "google emacs" will open a google search for "emacs". Actually, "g emacs" will do the same thing, and that's preferable since it's relatively quick to type. Also, "wikipedia emacs" will open the wikipedia page on "emacs", etc. Conkeror also already has webjumps designed for use with del.icio.us (press C-h i for more info).

And you can define your own webjumps. Here's a good page of some other useful webjumps you can add. Webjumps are not limited simply to site names, but can include javascript code as well. Here are a couple relatively simple ones I wrote for adding favourites to Stumbleupon and adding stories to Digg:

// Define add favourite to Stumbleupon

// Define Digg story

And here's a screenshot: