Emacs: latest habits: regex-tool and Visible Bookmarks

jplindstrom on 2008-01-21T01:45:15

Using Emacs means constantly acquiring new habits to improve how you do things.

Well, maybe not constantly. It's important to let the good habits slowly grow into reflexes, otherwise it's just too much to think about when you try to get things done. Once it's a reflex you can forget about it, just use it and work on picking up the next useful trick. Fortunately that seems like a renewable resource.

Last week I picked up something I've lacked for a while: Visible bookmarks. I know of putting locations in registers, but I never really started using that for some reason. I think it was ever so slightly too bothersome to use, and so I didn't. We'll see if I have started using these in a week or two, or if I need something else from it.

The second new thing is the Regex Tool which will let you compose a Perl (or Emacs, but we already have re-builder for that, so...) regular expression interactively with matching text highlighed. If you have seen The Regex Coach, this is pretty much it.

This is obviously a very useful thing to have when writing complicated regexes.

I just uploaded the latest release of Devel::PerlySense to PAUSE. Release 0.0141 bundles regex-tool.el and contains a first stab at integrating it with PerlySense. Well, integrate and integrate... The default dialect is set to Perl, and it's got a key binding :) That's about it at the moment.

The next step is to notice if point is on a regex and use that as a default.

The next next step is to notice whether there is a comment block just above the regex. If there is, it will be assumed to be an example of the text to match and used as the default.

I've found that putting the example input next to the regex to be a very good practice; it really helps understanding what the regexp is all about when coming back and reading it three months later. Yeah, yeah, there should be complete sample input in unit tests, but those are in a different file, and you may not know about it (or whether it actually exists) when you come across this piece of code. So it's good to have it right there. The Principle of Proximity in action again.

In the process of incorporating Regex Tool I also upgraded it a bit to support the whole Perl regex syntax with modifiers (including the essential /x). I hope the author will accept a patch.