Emacs Weekly Tip #2: Recent Files with recentf

In my daily Emacs activities I open a lot of files. However, during the week I am normally opening the same files as I’m generally working on the same stuff. Emacs’s Recent Files (recentf) feature generates a list of my recently used files and allows me to display that list so I can quickly open any of them.

To enable recentf mode, add the following into your Emacs init file (which you are version controlling right?)

;; recentf stuff
(require 'recentf)
(recentf-mode 1)
(setq recentf-max-menu-items 25)
(global-set-key "C-x C-r" 'recentf-open-files)

If you use Tramp a lot you may want to disable the auto-cleanup command for Recentf. This is simply because every now an then, if enabled, the auto-cleanup feature scans a list of your recent files, and tries to stat them to see if they should remain in the list. Obviously, if it tries to stat any remote files this may cause your system to temporarily hang.

;; recentf stuff
(require 'recentf)
(setq recentf-auto-cleanup 'never) ;; disable before we start recentf!
(recentf-mode 1)
(setq recentf-max-menu-items 25)
(global-set-key "C-x C-r" 'recentf-open-files)

Now use Emacs for a bit to generate a list of your recently used files. Next time you open Emacs, simply hit C-x C-r and you’ll be greeted with a list of your recently used files.

A great time saver.

For more info, visit the Emacs Wiki page.

Awesome WM Clicky Widget

Awesome WM Clicky WidgetAs some of you know, whilst Emacs is my editor (et al.) of choice my favourite window manger is Awesome. Awesome is, according to the website,

.. extremely fast, small, dynamic and heavily extensible using the Lua programming language

I’ve never delved into Lua before, but since using Awesome I’ve had to play around with a bunch of config files. They have always looked very clean and simple so, this weekend, with a spare couple of hours to kill I thought I’d have a play around with Lua and see if Awesome really is as “heavily extensible” as the claims make out.

A couple of weeks ago I set up real time web analytics on a number of sites with Clicky. Clicky have an incredibly simple API which I thought would be perfect to play around with.

I decided to try and build a widget that displays the total visitors and actions for a specified website. Really simple, but also quite useful. I had never written anything in Lua before, or even played around with widgets too much in Awesome. Fortunately both Awesome and Lua made the whole thing fantastically easy and fun. What follows is the code I wrote, use it if you want to, it’s just an example of what I did with my first attempt, so feel free to extend it as you want.

(more…)

Emacs Weekly Tip #1: Version Control Emacs.d

Welcome to the first of my weekly Emacs top tips.

This first tip is something that I’m seeing more and more people do, especially with the excellent Emacs Starter Kit aiming to get Emacs newbies up and running quickly:
Version control your emacs.d directory.

This technique is especially useful if you have a number of development machines that you work from (desktop, laptop, remote server).  This is the reason why I started to version control my .emacs.d directory. Whilst my configuration is still very basic (for now) I find it invaluable.

Whilst it is useful to version control your configuration file, a happy side effect of the increasing prevalence of services like GitHub is that you can see other Emacs users’ setups. It is great to look at these, borrow some ideas and lean some new techniques. After some Googling, I’ve quickly compiled the  list below from GitHub, which is by no means exhaustive:

So what are you waiting for? Put your Emacs config directory into Git, share it on GitHub and post the respoitory URL in the comments below.

Introducing Emacs Weekly Tips

As regular readers of my poor, infrequently updated blog may know my editor of choice is the wondrously magnificent Emacs.  One of the reasons I like Emacs is because there is so much more to learn. I can easily imagine that one could spend every day for a whole year learning a new technique, mode or snippet within Emacs and still not come close to learning all there is to know about it.

Sadly, I’m not dedicated enough to learn a new tip every day.

However,  I am going to try and learn one a week. My aim is to pick up a new Emacs top tip, use it for a week and post about it here on my blog. This should hopefully increase my knowledge of Emacs and server as a repository of this information.

So, tune in every Monday for my Emacs Tip of the Week!

For those that can’t wait, there are loads of great places for all things Emacs out there. Check out:

Testing Tumblr with Berlin Birdbox

I’ve head a lot of stuff about Tumblr recently and how easy it is to update. As you can see from the blog you’re reading right now, I need all the help with keeping things up-to-date so I thought I’d give it a try, so I did.

Obviously, being the lead tech geek at Jabbakam I had to do something involving IP cameras, so I found an old Axis camera we had lying around the office, pointed it at the birdbox we have at home and started recording. BerlinBirdbox was born.

If any of our feathered friends decide to make our little birdbox their home, hopefully the camera will record it, upload it to Jabbakam and then I can post it onto Tumblr. I might even mash up the APIs to get it to auto post…. but possibly another day!

Until then, stay tuned to the BerlinBirdbox.

Fix: Cannot load from mysql.proc. The table is probably corrupted

Following from my dependency hell problems the other day my new version of MySQL seems to have all its stored procedures corrupted, displaying the following message when any of them are executed:

Cannot load from mysql.proc. The table is probably corrupted

After a bit of research, I found the simple fix is to run

mysql_upgrade

Problem solved.

Posting it to my blog as a reminder to me to RTFM, and just in case it is useful to some other poor soul out there.

Please help improve this blog and take a quick survey. Thanks!

NodeJS v0.4.0 on Arch Linux

As NodeJS v0.4.0 is out, I thought I’d have a play around with it (something I haven’t done in a very long time!)

Instantly I ran into problems:

$ ./configure
Traceback (most recent call last):
  File "/Users/greim/nodestuff/node/tools/waf-light", line 157, in
    import Scripting
  File "/Users/greim/nodestuff/node/tools/wafadmin/Scripting.py", line 146
    except Utils.WafError, e:
                         ^
SyntaxError: invalid syntax

I’m trying to install this on my Arch Desktop, which has Python version 3.1.3 installed. After some research I found that it was a compatibility issue between Python 2.x and 3.x.

I didn’t really want to remove Python 3 as I’d had dependency hell recently. Inspired by an answer on StackOverflow, I had a dig about in my /usr/bin directory to see if there was both Python v3 and Python v2 installed. Fortunately there was: /usr/bin/python2

Note: Following a comment by eveningsky below, there is a much easier way to work around the problem.

mkdir /tmp/bin
ln -s /usr/bin/python2 /tmp/bin/python
export PATH=/tmp/bin:$PATH

You can now carry on as normal. I have kept my nasty hack below just in case for some absurd reason the above doesn’t work for you.

Many thanks eveningsky!

Old Version

After some trial and error, all I had to do was to edit 2 files:

/tmp/node-v0.4.0/tools/waf-light

amending the first line to read:

#!/usr/bin/env python2

and once I had run ./configure edit the first line in the Makefile  to read:

WAF=python2 tools/waf-light

Simple!

Now I have Node JS version 0.4.0 running on my Arch box.

WordPress on Android

Testing the wordpress admin Android app.

The text area looks pretty small, I’m not sure that anything lengthy could be written with this app.

End.

Three Useful Emacs Blogs

The past few months I have spent most of my time head down, working on a number of projects. In work, I spend most my time in Emacs, which has been my editor of choice for just over a year. Over the past year, my knowledge of Emacs, and my associated productivity is improving all the time. However, the Emacs universe is so vast there is no possible way to know everything, or every little command (or even every “big” command).

My tactic recently has been to try and learn one new useful tip each day, whether it is switching to ibuffer instead of the normal buffer mode, or trying to use M-^ (delete-indentation) more. Whilst trawling through the Emacs Wiki or a list of command references may be a good way to find some useful stuff, a better way is to let someone else do all the hard work for you!

So here are three blogs that I have found great for general Emacs related tips and tricks:

  • Emacs Fu – Simply put, a fantastic resource.
  • Mastering Emacs – A brand new blog, looks promising.
  • M-x All Things Emacs – Hasn’t been posted to since July 2009, but still has lots of good tips in the archives.

Enjoy.

Long time No See

It has been many months since I last posted. But this is just a quick update to let you know that I haven’t abandoned this blog, it is very much still on my mind. Unfortunately (or fortunately depending on your point of view) I have been really busy these past few months with Jabbakam and LiveUnsigned.

We are now working on a [top secret] new project here at ibrow using some fun new stuff (think MongoDB, Node.JS etc) and hopefully over the next few weeks and months I’ll be able to set aside some time to post about the challenges and successes we will have with these shiny new toys.