26
Jun 08

Emacs FAIL

Okay, no. I gave it a try for a good week. And by the end of the week, I don’t have any way to change basic stuff like fonts or colours, completion is still a mystery, line numbers are buggy, and I’ve not yet seen one single function that made me say “y’know, it’s a pain, but it’s worth it”. I wound up getting not one extra page added to the RCMS project during the entire week because of emacs configuration hell. Frac that for a game of soldiers.

I’ll stick with vim 7. Completion? Got it. Reformatting code? Got it. Testing code syntax in the editor? Got it.

And now, on with the actual work. Y’know, the thing we’re meant to use the editor for in the first place?


19
Jun 08

Emacs

Hmmm. I started programming on an old ICL OPD (anyone else remember microdrives?). There was some fooling about afterwards with an IBM PS/2 system (woo-hoo, 40Mb of hard disk space!), but the first time I hit what I thought of as a real machine was on a unix account in the first week of college. And that’s when I first hit the biggest question any starting computer engineer hits (or used to hit, back then): Vi or Emacs.

Back then, I chose Vi by default, in that it was the first thing I came across and command/edit mode switching actually made sense to me. And I used vi for a good while afterwards, until I finally found, and immediately switched to, vim. I’ve used vim ever since for any task where I could use it on any platform where I could get it (in fact, not being able to use it for wordpress blogging ticks me off). Being able to run around a source code file in command mode and dd or y lines from here and p them over there, or J them together or call up boxes with an remap to give me a nice easy-to-spot function header, those are things I’ve gotten down to the reflex level at this stage. In short, I like vim. It’s small, fast, uncluttered. And don’t talk to me about tabbed editing and intellisense and debugger integration please, that’s been in vim for quite some time if you want it (and frankly, if you’re using Visual Studio anything and telling me it has a better editor, you seriously need to stop wasting your time). Not to mention the fact that everytime I’ve seen something like intellisense in actual use, it’s been used by some rather lazy programmers. Which isn’t to say that brace completion and the like can’t be used by good programmers, just that my impression so far hasn’t been a good one. Lie down with dogs, get fleas in your keyboard…

Anyway, the thing is, I’m familiar with the claims about the immense customisability and power in Emacs, but by the time I’d started to hear about it, I’d learnt vi, and once you learn an editor and there’s work to be done, it’s hard to justify the effort to relearn another one. Feels too much like faffing about. But right now, work’s in the research phase (ie.  Feck! Why won’t that work? Damn, go read the devel mailing list archives and the code…), and I have my little side project for the rifle club tootling away, and apparently XEmacs/GNU Emacs is now a run race and GNU Emacs is now a full superset of xemacs so there’s an easy install choice, and GNU Emacs 22 supports mercurial (there’s a blog post in there on its own methinks) out of the package, and PHP with a simple apt-get install, and the more tools you can use the better, right?

So I’ve installed a basic GNU Emacs setup on the work and home boxen with a PHP major mode, and over the next week or so, I’m going to try to use it for my side project. If that takes off, I’ll think about using it for the main project and where it fits into my toolbox overall. I suspect vim’s still a winner where another app has to call an editor (VCS commits from a command line and such) or where you’re running round /etc trying to fix something, but we’ll have to see.

First thing I have to figure out is what the emacs equivalent to command mode and edit mode are…


04
Jan 08

Multiple databases in Drupal

Have to say, while MDB2 has the more straightforward way of accessing multiple databases (just create more database objects using MDB2::factory()), drupal’s way of doing things is a long way from horrible.

To initialise:
[ccN lang=”php”]$db_url[‘default’] = ‘mysql://drupal:drupal@localhost/drupal’;
$db_url[‘mydb’] = ‘mysql://user:pwd@localhost/anotherdb’;
$db_url[‘db3’] = ‘mysql://user:pwd@localhost/yetanotherdb’;[/cc]
And then to use:
[ccN lang=”php”]db_set_active(‘mydb’);
db_query(‘SELECT * FROM table_in_anotherdb’);
//Switch back to the default connection when finished.
db_set_active(‘default’);[/cc]

Quite straightfoward looking. Now to see if it actually works! 🙂