Monthly Archives: June 2008

Yet another post from someone admiring an Emacs feature

I’ve been using Emacs for some time now, and I’ve grown to really appreciate it. One of the nifty features introduced in Emacs 22 is the ability to execute arbitrary elisp when replacing text using regular expressions (elisp is the Lisp dialect in which Emacs itself is written and through which it can be extended). I had reason today to use the feature for a silly little problem, and I was impressed, so here’s why.

I had a set of data where I had to replace a placeholder on each line with an integer, which incremented every four lines, starting at 2. i.e:

x line 1
x line 2
x line 3
x line 4
x line 5
x line 6

should become:

2 line 1 
2 line 2 
2 line 3 
2 line 4 
3 line 5 
3 line 6

This would be quite tricky to solve with a normal regexp replace operation, but under Emacs I simply defined a new function to do the hard work:

(setq mod_id 1)

(defun four_inc (y)
        (if (eq 0 (% y 4)) (setq mod_id (1+ mod_id)) mod_id)

I evaluated those two pieces of elisp in place in the scratchpad I was working in (another massively nifty Emacs capacity) and then ran a regular expression replacement, replacing x with \,(four_inc \#)). The \, tells Emacs to insert the result of calling the four_inc function into the replacement text, and \# is the number of replacements already done.

This is hardly earth-shattering stuff, but it’s the ability both to extend Emacs however one desires (by writing an increment-every-4-times function in this case) and the heaps of nifty features other people have already provided (executing arbitrary elisp code in a regexp replacement for example) that explains to a large degree why I like Emacs so much.

Leave a Comment

Filed under computers, elisp, emacs, programming, Uncategorized

Jabber: the IM of choice of 9/10 evil maniacal geniuses

pkeike, jerith, voyager42 (Voyager below) and myself had a very amusing conversation over Jabber IM a little while ago: here it is in marked up glory. Let this be a lesson to you: never forget the duck…

Voyager: FOOLS! Now I can take over the world! mmmuahahahaha!!!
***Kim makes a note to contact the specialist and see about having voyager's medication adjusted, yet again
***Jerith plants a small explosive device somewhere in Johan's dirigible.
***Pkeike makes a note to contact the surveillance team and see that voyager is actually having his medication
***Kim makes another note to politely decline future offered lifts in Johan's dirigible
Jerith: Oh, I replaced the dried frogs with sugar pills. Far more interesting that way.
Jerith: I'm thinking of adding caffeine and the merest hint of LSD.
***Voyager makes a note to remind the specialist, surveilance team and bomb squad who they work for
Pkeike: jerith: I was just wondering if his paranoia meds need to be adjusted or forcibly administered
Kim:  I already added the LSD
***Pkeike makes a note to remind the surveillance team of their cover story
Jerith: Tri: They are being correctly taken, it's just that he's on different (and more interesting) meds.
Pkeike: fair enough, social experimentation ftw!
Voyager: But who is experimenting on whom?
Voyager: twitch
Jerith: Everyone on everyone.
Jerith: It's more exciting that way.
Kim:  excellent - the twitching has begun
Kim:  we can proceed to stage 5
Jerith: Umm, I did that last week.
Kim:  prepare the generator and the clamps
Jerith: The twitching should have cleared up by now...
Kim:  you did?
Pkeike: dammit jerith, communicate!
Jerith: Unless you were continuing with stage 3 procedures...
Pkeike: or at least put it on the damned wiki!
Jerith: I left a message in the secondary dead-drop.
Kim:  yes, but you used last months cipher
Kim:  so the message was disregarded, as per agreed protocol
Jerith: Oh, blast. My autoupdate script failed on the encryption module.
Kim:  now we have to "reset" the subject for the umpteenth time
***Kim prepares the mind scrubber
Voyager: You guys are crazy
Pkeike: Good. Standard response received. We may proceed.
Pkeike: Good work Kim
***Voyager notices nothing strange.  crazy==normal, after all
Kim:  excellent
Kim:  I so hate it when the scrubbing fails and a new subject is required
Kim:  subject-acquisition is such a tedious process
Jerith: Especially when you forget the duck.
Kim:  that's why the wiki's HOW-TO page specifically specifies the mallard

Leave a Comment

Filed under humour, internet, Uncategorized

A plaintive cry to the developers of Delphi 7

To the developers of Delphi 7:

What is wrong with you!?! Why did you choose to ignore the behaviour of roughly a gazillion Windows apps which provide an encapsulating frame to keep all the little bits of your application together and nicely bundled? Why did you instead choose to provide 6 floating boxes and expose whatever it is my screen was previously displaying on the bits those boxes aren’t occupying?

Do you have any idea how frustratingly annoying this is? Why do you hate your poor users so? Is it not bad enough that they have to write in Delphi, that you feel the need to punish them further?

After all, I’ve been using Delphi for two days and I already hate it for its tedious and overwhelmingly pointless verbosity – and this from a guy that writes C for a living! Why do you seek to make the pain so much worse?


Filed under delphi, rants, Uncategorized

Big Walks

I did the Spar Ladies 10km run yesterday with Vicki and some friends. Before I continue, a few points:

  • Yes, men are also permitted.
  • No, I did not dress up.
  • We walked it all, “run” notwithstanding.

I also did the East Coast Radio Big Walk three weekends ago (also roughly 10km, and also walked). Both were quite fun, although I must say I preferred the ECR event – it’s limited to 8000 people versus Spar’s 12000 odd, which made for a less compressed field. The organisation was much better at the ECR one as well – the Spar event had water stations that were either unreachable due to the crowds or woefully under supplied, and a distinct dearth of medical personnel on hand for people who may have developed problems or who wanted to pull out.

While both events were good fun, I also got up last week Sunday at 3AM to assist the Cowies Hill Lions Club at their Comrades watering station (the first station the runners reach). That’s three really early Sundays in a row – next week I intend to rise at 1pm 🙂

Of course, things would also be slightly better if I had the use of my left leg today…

Leave a Comment

Filed under Uncategorized