added bio::ext support
[bioperl-live.git] / bioperl.lisp
blobc2f9d25dae5d05dcb4b8b4fe368c5e48d9a30dcf
2 ;; Perl mode set up
4 (assoc "\\.pl$" auto-mode-alist)
5 (setq auto-mode-alist (cons '("\\.pl$" . perl-mode) auto-mode-alist))
7 (assoc "\\.pm$" auto-mode-alist)
8 (setq auto-mode-alist (cons '("\\.pm$" . perl-mode) auto-mode-alist))
10 (defun perl-insert-start ()
11 "Places #!..perl at the start of the script"
12 (interactive)
13 (goto-char (point-min))
14 (insert "#!/usr/local/bin/perl\n"))
18 (defun bioperl-object-start (perl-object-name perl-caretaker-name caretaker-email)
19 "Places standard bioperl object notation headers and footers"
20 (interactive "sName of Object: \nsName of caretaker: \nsEmail: ")
21 (insert "\n#\n# BioPerl module for " perl-object-name "\n#\n# Cared for by " perl-caretaker-name " <" caretaker-email ">\n#\n# Copyright " perl-caretaker-name "\n#\n# You may distribute this module under the same terms as perl itself\n\n")
22 (insert "# POD documentation - main docs before the code\n\n")
23 (insert "=head1 NAME\n\n" perl-object-name " - DESCRIPTION of Object\n\n")
24 (insert "=head1 SYNOPSIS\n\nGive standard usage here\n\n")
25 (insert "=head1 DESCRIPTION\n\nDescribe the object here\n\n")
26 (insert "=head1 FEEDBACK\n\n=head2 Mailing Lists\n\n")
27 (insert "User feedback is an integral part of the evolution of this\nand other Bioperl modules. Send your comments and suggestions preferably\n to one of the Bioperl mailing lists.\nYour participation is much appreciated.\n\n")
28 (insert " vsns-bcd-perl@lists.uni-bielefeld.de - General discussion\n vsns-bcd-perl-guts@lists.uni-bielefeld.de - Technically-oriented discussion\n http://bio.perl.org/MailList.html - About the mailing lists\n\n")
29 (insert "=head2 Reporting Bugs\n\nReport bugs to the Bioperl bug tracking system to help us keep track\n the bugs and their resolution.\n Bug reports can be submitted via email or the web:\n\n")
30 (insert " bioperl-bugs@bio.perl.org\n http://bio.perl.org/bioperl-bugs/\n\n")
31 (insert "=head1 AUTHOR - " perl-caretaker-name "\n\nEmail " caretaker-email "\n\nDescribe contact details here\n\n")
32 (insert "=head1 APPENDIX\n\nThe rest of the documentation details each of the object methods. Internal methods are usually preceded with a _\n\n=cut\n\n")
33 (insert "\n# Let the code begin...\n\n")
34 (insert "\npackage " perl-object-name ";\n")
35 (insert "use vars qw($AUTOLOAD @ISA);\n")
36 (insert "use strict;\n")
37 (insert "\n# Object preamble - inherits from Bio::Root::Object\n")
38 (insert "\nuse Bio::Root::Object;\n\n")
39 (insert "\nuse AutoLoader;\n@ISA = qw(Bio::Root::Object Exporter);\n@EXPORT_OK = qw();\n")
40 (insert "# new() is inherited from Bio::Root::Object\n\n")
41 (insert "# _initialize is where the heavy stuff will happen when new is called\n\n")
42 (insert "sub _initialize {\n my($self,@args) = @_;\n\n my $make = $self->SUPER::_initialize;\n\n# set stuff in self from @args\n return $make; # success - we hope!\n}\n")
45 (defun bioperl-method (method-name)
46 "puts in a bioperl method complete with pod boiler-plate"
47 (interactive "smethod name:")
48 (insert "=head2 " method-name "\n\n Title : " method-name "\n Usage :\n Function:\n Example :\n Returns : \n Args :\n\n\n=cut\n\n")
49 (insert "sub " method-name "{\n my ($self,@args) = @_;\n")
50 (save-excursion
51 (insert "\n\n}\n"))
55 (defun bioperl-getset (field-name)
56 "puts in a bioperl method for a get/set method complete with pod boiler-plate"
57 (interactive "sfield name:")
58 (insert "=head2 " field-name "\n\n Title : " field-name "\n Usage : $obj->" field-name "($newval)\n Function: \n Example : \n Returns : value of " field-name "\n Args : newvalue (optional)\n\n\n=cut\n\n")
59 (insert "sub " field-name "{\n my ($obj,$value) = @_;\n if( defined $value) {\n $obj->{'" field-name "'} = $value;\n }\n return $obj->{'" field-name "'};\n")
60 (insert "\n}\n"))
62 (setq perl-mode-hook
63 '(lambda ()
64 (define-key perl-mode-map "\C-c\C-h" 'perl-insert-start)
65 (define-key perl-mode-map "\C-c\C-b" 'bioperl-object-start)
66 (define-key perl-mode-map "\C-c\C-v" 'bioperl-getset)
67 (define-key perl-mode-map "\C-c\C-b" 'bioperl-method)
68 (define-key perl-mode-map "\C-c\C-z" 'compile)
69 (define-key perl-mode-map [menu-bar] (make-sparse-keymap))
70 (define-key perl-mode-map [menu-bar p]
71 (cons "BioPerl" (make-sparse-keymap "BioPerl")))
72 (define-key perl-mode-map [menu-bar p perl-script-start]
73 '("Insert script template" . perl-script-start))
74 (define-key perl-mode-map [menu-bar p bioperl-object-start]
75 '("bioperl object template" . bioperl-object-start))
76 (define-key perl-mode-map [menu-bar p bioperl-getset]
77 '("bioperl field func" . bioperl-getset))
78 (define-key perl-mode-map [menu-bar p bioperl-method]
79 '("bioperl method" . bioperl-method))