fix some yaml
[bioperl-live.git] / ide / bioperl.lisp
blobbf8014130978192f773a1231e87ffee345d483b1
1 ;;
2 ;; $Id$
3 ;;
4 ;; Perl mode set up
6 (assoc "\\.pl$" auto-mode-alist)
7 (setq auto-mode-alist (cons '("\\.pl$" . perl-mode) auto-mode-alist))
9 (assoc "\\.pm$" auto-mode-alist)
10 (setq auto-mode-alist (cons '("\\.pm$" . perl-mode) auto-mode-alist))
12 (defun perl-insert-start ()
13 "Places #!..perl at the start of the script"
14 (interactive)
15 (goto-char (point-min))
16 (insert "#!/usr/local/bin/perl\n"))
19 (defun bioperl-object-start (perl-object-name perl-caretaker-name caretaker-email)
20 "Places standard bioperl object notation headers and footers"
21 (interactive "sName of Object: \nsName of caretaker: \nsEmail: ")
22 (insert "# $Id$\n#\n# BioPerl module for " perl-object-name "\n#\n# Please direct questions and support issues to <bioperl-l@bioperl.org>\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")
23 (insert "# POD documentation - main docs before the code\n\n")
24 (insert "=head1 NAME\n\n" perl-object-name " - DESCRIPTION of Object\n\n")
25 (insert "=head1 SYNOPSIS\n\nGive standard usage here\n\n")
26 (insert "=head1 DESCRIPTION\n\nDescribe the object here\n\n")
27 (insert "=head1 FEEDBACK\n\n=head2 Mailing Lists\n\n")
28 (insert "User feedback is an integral part of the evolution of this and other\nBioperl modules. Send your comments and suggestions preferably to\nthe Bioperl mailing list. Your participation is much appreciated.\n\n")
29 (insert " bioperl-l@bioperl.org - General discussion\n http://bioperl.org/wiki/Mailing_lists - About the mailing lists\n\n")
30 (insert "=head2 Support\n\nPlease direct usage questions or support issues to the mailing list:\n\nL<bioperl-l@bioperl.org>\n\n")
31 (insert "rather than to the module maintainer directly. Many experienced and\nreponsive experts will be able look at the problem and quickly\naddress it. Please include a thorough description of the problem\nwith code and data examples if at all possible.\n\n")
32 (insert "=head2 Reporting Bugs\n\nReport bugs to the Bioperl bug tracking system to help us keep track\nof the bugs and their resolution. Bug reports can be submitted via\nthe web:\n\n")
33 (insert " https://redmine.open-bio.org/projects/bioperl/\n\n")
34 (insert "=head1 AUTHOR - " perl-caretaker-name "\n\nEmail " caretaker-email "\n\nDescribe contact details here\n\n")
35 (insert "=head1 CONTRIBUTORS\n\nAdditional contributors names and emails here\n\n")
36 (insert "=head1 APPENDIX\n\nThe rest of the documentation details each of the object methods.\nInternal methods are usually preceded with a _\n\n=cut\n\n")
37 (insert "\n# Let the code begin...\n\n")
38 (insert "\npackage " perl-object-name ";\n")
39 (insert "use strict;\n")
40 (insert "\n# Object preamble - inherits from Bio::Root::Root\n")
41 (insert "\nuse Bio::Root::Root;\n\n")
42 (insert "\nuse base qw(Bio::Root::Root );\n\n")
43 (insert "=head2 new\n\n Title : new\n Usage : my $obj = new "
44 perl-object-name "();\n Function: Builds a new "
45 perl-object-name " object \n Returns : an instance of "
46 perl-object-name "\n Args :\n\n=cut\n\n")
47 (insert "sub new {\n my($class,@args) = @_;\n\n my $self = $class->SUPER::new(@args);\n return $self;\n}\n")
48 (insert "\n\n1;")
51 (defun bioperl-interface-start (perl-object-name perl-caretaker-name
52 caretaker-email)
53 "Places standard bioperl object notation headers and footers"
54 (interactive "sName of Object: \nsName of caretaker: \nsEmail: ")
55 (insert "# $Id $\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")
56 (insert "# POD documentation - main docs before the code\n\n")
57 (insert "=head1 NAME\n\n" perl-object-name " - DESCRIPTION of Interface\n\n")
58 (insert "=head1 SYNOPSIS\n\nGive standard usage here\n\n")
59 (insert "=head1 DESCRIPTION\n\nDescribe the interface here\n\n")
60 (insert "=head1 FEEDBACK\n\n=head2 Mailing Lists\n\n")
61 (insert "User feedback is an integral part of the evolution of this and other\nBioperl modules. Send your comments and suggestions preferably to\nthe Bioperl mailing list. Your participation is much appreciated.\n\n")
62 (insert " bioperl-l@bioperl.org - General discussion\n http://bioperl.org/wiki/Mailing_lists - About the mailing lists\n\n")
63 (insert "=head2 Reporting Bugs\n\nReport bugs to the Bioperl bug tracking system to help us keep track\nof the bugs and their resolution. Bug reports can be submitted via\nemail or the web:\n\n")
64 (insert " https://redmine.open-bio.org/projects/bioperl/\n\n")
65 (insert "=head1 AUTHOR - " perl-caretaker-name "\n\nEmail " caretaker-email "\n\nDescribe contact details here\n\n")
66 (insert "=head1 CONTRIBUTORS\n\nAdditional contributors names and emails here\n\n")
67 (insert "=head1 APPENDIX\n\nThe rest of the documentation details each of the object methods.\nInternal methods are usually preceded with a _\n\n=cut\n\n")
68 (insert "\n# Let the code begin...\n\n")
69 (insert "\npackage " perl-object-name ";\n")
70 (insert "use strict;\n\nuse Bio::Root::RootI;\n\n")
71 (insert "use base qw( Bio::Root::RootI );")
72 (insert "\n\n1;")
76 (defun bioperl-method (method-name)
77 "puts in a bioperl method complete with pod boiler-plate"
78 (interactive "smethod name:")
79 (insert "=head2 " method-name "\n\n Title : " method-name "\n Usage :\n Function:\n Example :\n Returns : \n Args :\n\n=cut\n\n")
80 (insert "sub " method-name "{\n my ($self,@args) = @_;\n")
81 (save-excursion
82 (insert "\n\n}\n"))
86 (defun bioperl-getset (field-name)
87 "puts in a bioperl method for a get/set method complete with pod boiler-plate"
88 (interactive "sfield name:")
89 (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 " (a scalar)\n Args : on set, new value (a scalar or undef, optional)\n\n=cut\n\n")
90 (insert "sub " field-name "{\n my $self = shift;\n\n return $self->{'" field-name "'} = shift if @_;\n return $self->{'" field-name "'};")
91 (insert "\n}\n"))
93 (defun bioperl-array-getset (field-name class-name)
94 "puts in a bioperl method for array get/add/remove methods complete with pod boiler-plate"
95 (interactive "sarray base object: \nstype of element: ")
96 (insert "=head2 get_" field-name "s\n\n Title : get_" field-name "s\n Usage : @arr = get_" field-name "s()\n Function: Get the list of " field-name "(s) for this object.\n Example :\n Returns : An array of " class-name " objects\n Args :\n\n=cut\n\n")
97 (insert "sub get_" field-name "s{\n my $self = shift;\n\n return @{$self->{'_" field-name "s'}} if exists($self->{'_" field-name "s'});\n return ();\n}\n\n")
98 (insert "=head2 add_" field-name "\n\n Title : add_" field-name "\n Usage :\n Function: Add one or more " field-name "(s) to this object.\n Example :\n Returns : \n Args : One or more " class-name " objects.\n\n=cut\n\n")
99 (insert "sub add_" field-name "{\n my $self = shift;\n\n $self->{'_" field-name "s'} = [] unless exists($self->{'_" field-name "s'});\n push(@{$self->{'_" field-name "s'}}, @_);\n}\n\n")
100 (insert "=head2 remove_" field-name "s\n\n Title : remove_" field-name "s\n Usage :\n Function: Remove all " field-name "s for this class.\n Example :\n Returns : The list of previous " field-name "s as an array of\n " class-name " objects.\n Args :\n\n=cut\n\n")
101 (insert "sub remove_" field-name "s{\n my $self = shift;\n\n my @arr = $self->get_" field-name "s();\n $self->{'_" field-name "s'} = [];\n return @arr;\n}\n\n"))
104 (defun bioperl-abstract-method (method-name)
105 "puts in a bioperl abstract method for interface classes"
106 (interactive "smethod-name:")
107 (save-excursion
108 (insert "=head2 " method-name "\n\n Title : " method-name "\n Usage :\n Function:\n Example :\n Returns : \n Args :\n\n=cut\n\n")
109 (insert "sub " method-name "{\n my ($self) = @_;\n\n $self->throw(\"Abstract method " method-name " implementing class did not provide method\");\n")
110 (insert "\n\n}\n")
115 ;; bug fix - quoted perl-mode-hook here/maj
116 (add-hook 'perl-mode-hook
117 '(lambda ()
118 (define-key perl-mode-map "\C-c\C-h" 'perl-insert-start)
119 (define-key perl-mode-map "\C-c\C-b" 'bioperl-object-start)
120 (define-key perl-mode-map "\C-c\C-i" 'bioperl-interface-start)
121 (define-key perl-mode-map "\C-c\C-v" 'bioperl-getset)
122 (define-key perl-mode-map "\C-c\C-r" 'bioperl-array-getset)
123 (define-key perl-mode-map "\C-c\C-b" 'bioperl-method)
124 (define-key perl-mode-map "\C-c\C-a\C-m" 'bioperl-abstract-method)
125 (define-key perl-mode-map "\C-c\C-z" 'compile)
126 (define-key perl-mode-map [menu-bar] (make-sparse-keymap))
127 (define-key perl-mode-map [menu-bar p]
128 (cons "BioPerl" (make-sparse-keymap "BioPerl")))
129 (define-key perl-mode-map [menu-bar p perl-script-start]
130 '("Insert script template" . perl-script-start))
131 (define-key perl-mode-map [menu-bar p bioperl-object-start]
132 '("bioperl object template" . bioperl-object-start))
133 (define-key perl-mode-map [menu-bar p bioperl-interface-start]
134 '("bioperl interface template" . bioperl-interface-start))
135 (define-key perl-mode-map [menu-bar p bioperl-getset]
136 '("bioperl field func" . bioperl-getset))
137 (define-key perl-mode-map [menu-bar p bioperl-array-getset]
138 '("bioperl array get/add/remove" . bioperl-array-getset))
139 (define-key perl-mode-map [menu-bar p bioperl-method]
140 '("bioperl method" . bioperl-method))