New Stuff in Emacs 24.4

Xah Lee has a nice post on some of the smaller additions to Emacs 24.4. Unless you like reading through NEWS files, this is a quick and easy way to find some nifty new features.

I found a couple of things that significantly reduced my workload in working with the Irreal .htaccess file. I have a script that pulls down the connection log from the hosting provider and calculates how many times each IP has tried to post a comment. Any IP that tried more than 20 times a day gets added to the deny list in the .htaccess file.

Two operations in this process are made considerably easier with the new features in Emacs 24.4. Part of the pipeline that generates the report that gets mailed to me each day, calls uniq -c which generates lines like

132 192.168.1.1

where the 132 is the number of times the IP tried to post a comment. The first thing I need to do is cut the counts from the file so that only the IPs remain. With Emacs 24.4, we have rectangle-mark-mode, which is bound to 【Ctrl+x Space】 for easy use. With it, it’s easy to mark the counts and delete them.

The next thing I do is append the new IPs to the end of the .htaccess file and then use a keyboard macro to add a “Deny from” to the beginning of each IP. For technical reasons the calculations are based on the log from two days ago so the new IPs can already be in the list and I needed to remove duplicates. I handled this by sorting the list and then piping it to uniq with 【Ctrl+u Meta+|】. That worked well but with Emacs 24.4 I can simply call delete-duplicate-lines without bothering with the sorting or using an external process.

Take a look at Lee’s post. Like me, you’re apt to find something to makes your life a little bit easier.

This entry was posted in General and tagged . Bookmark the permalink.