I finally started using ELPA

My normal development workflow doesn’t use that many different Emacs packages. With a few exceptions I’ve mainly worked with a “stock” Emacs distribution and augmented that with a few select Emacs packages that I downloaded manually. It worked for me for a decade or so, and it made it reasonable easy to move configurations between machines – zip & copy was my friend for that, although I’ve since changed that to using dropbox.

As we recently switched to git at work, I started looking into Emacs git clients and came across magit. At that point I figured a pre-built package would be nice and started looking into ELPA. I use Emacs 24 pretty much wherever I have an Emacs install so having ELPA in place everywhere came in really handy.

Didn’t take very long for me to switch away from the manual package “management” to get the few minor modes and other helper messages via ELPA. I don’t think I’ll go back to manual management.

Guess I should check if the weblogger package – which I am using to write this blog post – is also available in one of the repositories.

So if you’re still using manual package management, I would recommend looking at ELPA together with the marmalade repository. The default ELPA repo didn’t include several of the packages I needed, but combining ELPA and marmalade covered everything I’ve needed so far.

Setting up the Ghost blogging system on FreeBSD

Ah, a meta blogging post. Sorry, I try to keep these to a minimum…

For those who haven’t been caught up in the hype yet, Ghost is a new blogging system that is much more minimal than WordPress and the other more popular systems. It’s designed to be much smaller and faster (plus it uses a lot of cool tools like node.js, handlebars etc).

I recently tried to set up the 0.3.3 release on FreeBSD and overall it was straight forward. Node.js is available as a port – just make sure that you’re installing the regular node port instead of the node-devel port as the latter will install node 0.11 and Ghost wants to use 0.10.

The only hiccup I encountered was that building the sqlite node module failed, but this post suggested an appropriate workaround by pointing npm at the existing install of sqlite.

First impressions are very good, populating the Ghost blog from this WordPress installation was very easy using the Ghost plugin for WordPress. The contents made it over OK, however Ghost doesn’t support comments, thus the export and re-import loses the existing comments. I’d also have to integrate an external comment system.

Overall I’m pretty excited about Ghost as a blog platform so I’ll be keeping an eye on it. For now though this blog will stay on WordPress.

With Emacs on Windows, make sure you know where your $HOME is

The Gnu Emacs for Windows distribution appears to be pretty good at inferring where a reasonable place for $HOME is, straight out of the box. In my case, said reasonable place was %USERPROFILE%/AppData/Roaming which was an entirely acceptable default.

That is, until several other tools entered the picture and disagreed with Emacs. We’ve recently switched to using git at work and the git ecosystem  needed to have some ideas where its home was. I’m using Git Extensions as the “regular” Windows GUI and TortoiseGit for the Windows Explorer integration, plus the awesome Posh-Git that even made me learn basic PowerShell.

All of this worked fine until I threw magit into the mix. I like being able to interact with the VCS directly from Emacs (who doesn’t?) and magit is probably the greatest VCS integration for Emacs. It worked fine as long as I kept the cheat sheet handy, but a colleague of mine pointed out that my magit commits supposedly came from a really funky user that looked very much like the computer guessed my email address rather than the user configured in my git configuration.

Turns out that both git and Emacs respect and look at the HOME environment variable. After settling on a suitable location and adjusting %HOME%, I moved the various dot files into the correct location and can now commit correctly from Emacs with the correct user details. Phew.

Oh, and for those commits that did have the odd username on them, the following commands came in really handy.

To change the author on the current (well, last) commit:

git commit --amend --author="corrected author"

Or if you just want to update the author on the last commit after updating HOME to point at the correct location:

git commit --amend --reset-author

I know, never install an OS the day it was released

Throwing caution into the wind this morning, I’m having an updatefest only a few hours after the software was released:

win81-upgrade-fest

While I’ve grown accustomed to using Win8 – the Surface RT helped – from using the 8.1 prerelease it really looked like 8.1 would be an improvement, so I bit the bullet and installed the upgrades as soon as they were available.

Well, as soon as I got up the day they were available, that is.

Would I recommend that a happy Win7 user should upgrade? Probably not. I had to upgrade because some of the stuff I do at home for myself (mainly a little Windows Phone development) requires Win8 as the Windows Phone 8 phone emulator does require the Win8 64 bit virtualisation infrastructure.

 

Visual Studio 2012 C++ Variadic Template support in the runtime library

As VS2012’s C++ compiler doesn’t support “true” variadic templates, the new runtime library classes that use variadic templates are implemented using macro magic behind the scenes. In order to get the “variadic” templates to accept more than the default of five parameters, you’ll have to set _VARIADIC_MAX to the desired maximum number of parameters (between five and ten).

For more information, see the “faux variadics” section of this blog post on MSDN.

How I learned about delete-selection-mode

One thing I really like about stackoverflow.com is that you end up learning as much answering questions on there as you do by asking them.

For example, when I saw this question I was sure there would be a way to delete a region by simply starting to type after selecting the region, but I didn’t know how. However given that this is emacs, I seriously doubted the person asking the question would be the first one to want this particular feature.

Sure enough, a quick dig around EmacsWiki brought up delete-selection-mode which does exactly what the poster wanted. And I’ve learned a little bit more about Emacs, again.

At this rate I’ll be reasonably proficient in Emacs in a decade or two :).

Repost – how to get rid of those pesky ^M characters using Emacs

I had another of these annoying mixed-mode DOS/Unix text files that suffered from being edited in text editors that didn’t agree which line ending mode they should use. Unfortunately Emacs defaults to Unix text mode in this case so I had an already ugly file that wasn’t exactly prettified by random ^M characters all over the place.

I also don’t have the cygwin tools on the machine that I was seeing this problem on, I couldn’t just run unix2dos or dos2unix over the file and be done with it, but at least I had emacs on that machine. So, emacs to the rescue again…

First, I used query-replace to get rid of the ^Ms in so the file was turned into a “proper” Unix text file. The trick here is that you need to use control-Q to quote the control character. In my case on a Windows box, the key sequence was M-Shift-% Control-Q Control-M and then use the empty string as a replacement value. Job done, we’ve now got a proper Unix mode text file. Well, after almost wearing out the ‘Y’ key but of course you can use replace-string instead.

In order to turn the Unix mode text file into a Dos mode one, run the command set-buffer-file-coding-system with the parameter undecided-dos and save the resulting file. Job done.

A couple of useful Emacs modes

This is a repost from my old blog – I’m moving some of my older articles over as nobody knows how long the machine that hosts that blog will still be around.

highlight-changes-mode – as the name implies, it highlights changes that you make to a file. I do find it useful for the typical scenario of checking out a file, making a couple of smaller changes to it and then having to diff it to work out what you actually changed. As mentioned over at Emacswiki it doesn’t play too nicely with font-locking but I’ll try out some of the suggestions in the “Taming Highlight-Changes-Mode” section on this page. The one big advantage is that it’s available on an out-of-box GNU Emacs, so you don’t need to install any new modes.

nxml-mode – my preferred mode for editing XML. Of course it would be better if I could be bothered to create schemas for some of the files I’m editing but even without them, it does a pretty good job. As it’s trying to parse the XML that you write, it’s very helpful when it comes to highlighting mismatched tags or auto complete tags.

ido-mode – I’ve only recently started to use it and I’m still trying to work out if it is useful enough for me or if the improved file finding capability does bother me more than it helps. Yes, I know it can do a lot more but so far I’m only using the improved file finding and buffer switching. I really rate the buffer switching which is the main reason I leave it turned on.

Not really a mode, but I like using bm.el for visible bookmarks. I don’t use bookmarks that often but the package is extremely useful when I do need them.