I added curiousprogrammer.wordpress.com to my emacs feed in bloglines after finding a cool tip that helps me out particularly with Django programming in Emacs.
One of the cool things about Emacs is that it's not just a text-editor, it's a whole ecosystem of code (or as the joke goes - a pretty cool operating system with a crappy built-in text editor). In exploring all the extensibility though - the built in major and minor modes, the many external modes available - it's easy to forget how much can be customised by setting a few variables.
I didn't even realise how much it was annoying me but the default way Emacs handles duplicate buffer names is kind of dumb. If you have multiple files with the same names the first buffer gets the filename and subsequent buffers get an index value. This isn't a problem in most editing tasks - you occasionally see a choice of switching between foo.py and foo.py<1> and have to remember which is which.
In most code editing I do I don't have many identically named files. Django, however, makes this a little more annoying - each django app I have open has it's own models.py, views.py and likely a urls.py file. When I'm working simultaneously in several apps at once it's confusing every time I go to switch buffers... Thanks to this post, however, I added the following lines to my .emacs:
(require 'uniquify) (setq uniquify-buffer-name-style 'reverse) (setq uniquify-separator "/") (setq uniquify-after-kill-buffer-p t) (setq uniquify-ignore-buffers-re "^\\*")
And now see a choice between views.py/app1, views.py/app2, and views.py/app3 when switching buffers. Uniquify is comes with Gnu Emacs so there's nothing you need to install to scratch this particular itch.
Update: thanks to commenter Van Gale Van Gale for the catch - I added the necessary require line above. I also should have noted that this is built in on my Emacs 23 packaged by Ubuntu 8.10 - YMMV.
blog comments powered by Disqus