in reply to Perl templates for Emacs?
It seems to me that an Emacs shortcut to avoid the mistake you describe would be significantly complicated by the fact that the LHS of the assignment is quite variable, but maybe this will be enough:
Tweak to taste. It assumes that you are using cperl-mode (and if you aren't I highly recommend it). Also, you can probably modify this example to handle other common coding shortcuts.(add-hook 'cperl-mode-hook (lambda() (local-set-key "\C-cm" 'perl-insert-oo-me +thod))) (defun perl-insert-oo-method (methodname) "Insert Perl OO method" (interactive "MEnter method's name: ") (insert (format "sub %s {\nmy ( $self ) = @_;" methodname)) (backward-char 8) (cperl-indent-command) )
Update:For those less familiar with extending Emacs:
Once the method name is entered (say foo), the following will be inserted at point:Enter method name: foo
and point will be placed right after $self.sub foo { my ( $self ) = @_;
the lowliest monk
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl templates for Emacs?
by loris (Hermit) on Jun 30, 2005 at 13:10 UTC | |
by Fletch (Bishop) on Jun 30, 2005 at 13:17 UTC | |
by tlm (Prior) on Jun 30, 2005 at 13:27 UTC |