Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

jrockway (7171)

jrockway
  (email not shown publicly)

Technorati Profile [technorati.com]

Journal of jrockway (7171)

Thursday May 10, 2007
03:17 PM

emacs template for perl modules

[ #33244 ]

Here's the template.el template I use for .pm files:


# Copyright (c) (>>>YEAR<<<) Jonathan Rockway <jrockway@cpan.org>

package (>>>PACKAGE_NAME<<<);
use strict;
use warnings;
(>>>POINT<<<)
1;
>>>TEMPLATE-DEFINITION-SECTION<<<
("PACKAGE_NAME" (insert-string
(let ((filename (buffer-file-name)))
      (if (string-match "lib/\\(.+\\)[.]pm$" filename)
                      (let ((mod (match-string 1 filename)))
                          (while (string-match "/" mod)
                              (setq mod (replace-match "::" nil nil mod)))
                          mod)
                  (if (string-match "\\([^/]+\\)[.]pm$" filename)
                          (match-string 1 filename)
                      "UNKNOWN")))
))

The nice part is that it knows what the name of your module is. If you C-x C-f lib/Foo/Bar/Baz.pm, then the package declaration at the top will say Foo::Bar::Baz (and will auto-create lib/Foo/Bar for you). I've been using this for a few months and realized that it's too convenient to keep to myself :)

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.