Slash Boxes
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)

  (email not shown publicly)

Technorati Profile []

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 <>

package (>>>PACKAGE_NAME<<<);
use strict;
use warnings;
("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)))
                  (if (string-match "\\([^/]+\\)[.]pm$" filename)
                          (match-string 1 filename)

The nice part is that it knows what the name of your module is. If you C-x C-f lib/Foo/Bar/, 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.
More | Login | Reply
Loading... please wait.