Thursday 8 April 2010

Simple File Renaming in Emacs

I stumbled across this tip while browsing reddit/emacs. In summary, it allows for the possibility of having a 'write file' (C-x C-w) variant that deletes the original file, essentially performing a simple rename without having to invoke dired or fire up a shell.

Putting on my Emacs cap, I came up with something similar, shorter and (debatably) more 'emacs-y':

(defadvice write-file (around write-file-possibly-rename activate)
(let ((old-filename (buffer-file-name)))
(and current-prefix-arg
(not (string-equal old-filename (buffer-file-name)))
(delete-file old-filename))))

defadvice allows you to hook a new function up to an existing one, to be invoked either before, after or around it (around advice invokes the original function with its original arguments with ad-do-it, and can do that zero or more times). This form of advice is what hits the spot for this task. Subsequently, when write-file is called, this advice intercepts it, captures the current filename and then invokes the old behaviour. After the write has happened, it checks to see whether or not it should delete the old file, and does so if the preconditions are met.

This preserves the existing C-x C-w behaviour, creating a completely new copy of your file if you choose a different name. Invoked as C-u C-x C-w, however, it deletes the old filename, performing the same rename with less code and less duplication of the existing file-writing plumbing.

Gordon's Pledges?

Gordon Brown pledges 'five more years' as Prime Minister if Labour wins.

That's not a pledge, Gordon. That's a threat.

Sunday 4 April 2010

Institutional Abuse is not "Petty Gossip"

Cardinal Angelo Sodano has said the Roman Catholic faithful will not be swayed by "petty gossip" about child sex-abuse allegations.

I find myself stunned.

The church faces far more than "petty gossip", at least as far as Giuseppe dalla Torre, head of the Vatican's tribunal, seems to be concerned, compelled as he was to remind us that the pope cannot be called to trial because he enjoys immunity as head of state. And yet here we have one of the most senior members of the Catholic church dismissing repeated charges of the most disgusting violations of trust and abuse as "petty".

Nothing quite reveals a man-made god as much as the dismissal of "petty" concerns.

Saturday 3 April 2010

PS3 System Update 3.21

Sony appear to be breaking new ground with the PS3: the only games console that loses features with firmware 'upgrades'. Yes, that's right: version 3.21 drops support for the 'Install Other OS' feature. This is almost on-par with the decision to drop software emulation of the Playstation 2, cutting off those large libraries of games that long-time users of Sony's console series have built up.

The best part of it is being held hostage: you can't use the Playstation Network with anything but the latest firmware, so those who stubbornly refuse to upgrade will find themselves stuck with local-only access.

Way to go, Sony! Really making your customers feel valued here.

Thankfully, George Hotz, who is similarly bemused has some advice: don't update. He's already hacked the PS3, and is looking to get a 3.21 firmware that doesn't lose the feature.

The strange thing is, he's the one that Sony will think is out of order.