HowTo Change camelCase() to camel_case() with Emacs

Go to the top of your file, unless you want to do regexp replace in many files, then press Meta-Ctrl-% to enter regexp-replace mode. Then enter the following:

   \([a-z]+\)\([A-Z]\)
Then press <CR> and enter the replacement text:
   \1_\,(downcase \2)

The trick to use Emacs lisp was found here.

Update: For an even better ways of dealing with CamelCase, see the EmacsWiki topic. :-)

Wednesday, 10 February 2010 at 08:50 | /emacs | permanent link to this entry

Emacs Again

It's now over a year since my first post on and about Enterprise Emacs and, believe it or not, lots have happened in the world of Emacs!

Some of the development is detailed here in my blog. The biggest news is that Emacs-23 now has been released!

In terms of usability I must say a lot has happened in only one year. Let's have a look at the items of my most wanted list:

OK, not bad. Now, what's left and how can we work around it in the interim? I'll start off by presenting the quirks and then finish off with a minimal .emacs file that will become our first Enterprise Emacs setup!

I really recommend using the Options menu to set the bulk of these, see the bullets below for pointers, the rest still needs to be set manually in the ~/.emacs file. That link points to a version controlled file that I will update for each new blog post on Enterprise Emacs.

As you can see, the Options does contain a lot of useful settings. Try them out, they take effect immediately. Click Save Options so your settings are saved to your ~/.emacs file. I have included some of my own personal settings already in the above ~/.emacs file.

Emacs vs. de facto standard terminology
Emacs De Facto
buffer file
frame window
window frame

Sunday, 09 August 2009 at 12:20 | /emacs | permanent link to this entry

Emacs regexp replace in many files

  1. M-x find-dired
  2. Run find in directory: 'top directory to recurse'
  3. Run find (with args): -name *.[ch]
  4. A dired listing pops up
  5. Select/Mark all files, type: % m and press enter
  6. M-x dired-do-query-replace-regexp
  7. Query replace regexp in marked files: 'seach regexp'
  8. Query replace 'NNN' with: 'replacement text'
  9. You will now be prompted for each file with a math to do replace, just like you would a regual M-C-% search.

Note: regexp back references are allowed in the replacement text.

Tuesday, 02 June 2009 at 14:44 | /emacs | permanent link to this entry

HowTo build GNU Emacs from CVS

Why would you want to do this? Well, considering all the neat new things that have been added lately it should be tempting for any old Emacs fan.

The Emacs Wiki has all the info you need, but here is a quick run-down of the bare necessities:

  1. Check out your working copy of the source: cvs -z3 -d:pserver:anonymous@cvs.savannah.gnu.org:/cvsroot/emacs co emacs
  2. cd emacs/
  3. ./configure
  4. make bootstrap
  5. Done!

Start with ./src/emacs or symlink the binary to your ~/bin/ directory. I.e., you don't have to run make install to use it.

Users of emacsclient should symlink that to their ~/bin as well.

The above assumes; a) that you have the appropriate -dev packages installed in Debian/Ubuntu, and b) that your .bashrc does indeed add ~/bin to your search PATH environment variable.

Monday, 28 July 2008 at 01:38 | /emacs | permanent link to this entry

More Emacs Progress!

Wow, I'm almost starting to feel like a Windows user. The latest builds of GNU Emacs has a lot of new features:

Here's a screen shot of my main editor window in Ubuntu 8.10.

Here is another, debugging a program.

I think it is quite impressive how far this little editor has come. OK, so it is perhaps not just an editor anymore. Some people claim it is a fully sufficient operating system and other refer to it as a kitchen sink. Nevertheless, today you do not need to know any Lisp to configure it or grab the scroll bar with the middle mouse button or any other archaic method to get around.

Still interested? Be sure to take the tour and then proceed to explore the wonderful world of Emacs.

Tuesday, 22 July 2008 at 23:56 | /emacs | permanent link to this entry

Enterprise Emacs

Many years ago I discovered the beauty in a beast called Emacs. I am actually a frequent user of both Emacs and VIM, but I firmly belive in the notion of learning one editor well. It took me several years to get to know it well, but it was all worth it!

This is the first tale in a series of entries about my thoughts and ideas about something I would like to call Enterprise Emacs. Enterprise? Yes, everything these days is enterprise this and enterprise that, stick some glue on it and you are enterprise ready! Let me give you some glue...

At many jobs I have had people have looked over my shoulder and said; "Oh, Emacs. Yeah I used that ages ago when I was working on UNIX, is it still C-x M-v...?". Of course, I say, because it still is. They usually continue; "Well, I left it because it was too hard to use...".

Until now I have not really had a good reply — because I understand these people. Emacs can be really counter intuitive and an outright pain in the **** to use. That is my gripe and I will use this blog to present the small things I have done to make Emacs more user friendly.

I find it a shame that still today, after so many decades (literally!) there are no sane defaults setup — I have seen something in Win32-Emacs that resembled what I would like to have — a sort of use cases possible to chose from. Why not have that on the GNU/Linux versions as well?

OK, so what is it that I want by default? Well, to me it is, at the very least, the following really obvious things:

Most of these settings today have a graphical menu called "Options", where you can actually click and save. So those tiny things are fixed in the latest Emacs versions. Wow...

In the coming months I will present some useful tips from my bag of tricks. Including, but not limited to:

Plus the usual Emacs features that users of Microsoft products may not have ever known. To mention a few: complete indentation engine, with several predefined indentation modes. Built-in calculator (converts between bases!)

The first tip is Emacs-23 with, grab on to something, font anti-aliasing! Yes, it's still an experimental feature, and if you did not already know this, "experimental" in free/open source is often quite stable. I have used it daily for >6 months and it has crashed on me only once.

Start off by installing it and discover the Options menu. Then return to this blog and I will have the next installment ready.

Sunday, 24 February 2008 at 10:59 | /emacs | permanent link to this entry