~ubuntu-branches/ubuntu/trusty/erlang/trusty

« back to all changes in this revision

Viewing changes to lib/tools/emacs/erlang.el

  • Committer: Bazaar Package Importer
  • Author(s): Clint Byrum
  • Date: 2011-05-05 15:48:43 UTC
  • mfrom: (3.5.13 sid)
  • Revision ID: james.westby@ubuntu.com-20110505154843-0om6ekzg6m7ugj27
Tags: 1:14.b.2-dfsg-3ubuntu1
* Merge from debian unstable.  Remaining changes:
  - Drop libwxgtk2.8-dev build dependency. Wx isn't in main, and not
    supposed to.
  - Drop erlang-wx binary.
  - Drop erlang-wx dependency from -megaco, -common-test, and -reltool, they
    do not really need wx. Also drop it from -debugger; the GUI needs wx,
    but it apparently has CLI bits as well, and is also needed by -megaco,
    so let's keep the package for now.
  - debian/patches/series: Do what I meant, and enable build-options.patch
    instead.
* Additional changes:
  - Drop erlang-wx from -et
* Dropped Changes:
  - patches/pcre-crash.patch: CVE-2008-2371: outer level option with
    alternatives caused crash. (Applied Upstream)
  - fix for ssl certificate verification in newSSL: 
    ssl_cacertfile_fix.patch (Applied Upstream)
  - debian/patches/series: Enable native.patch again, to get stripped beam
    files and reduce the package size again. (build-options is what
    actually accomplished this)
  - Remove build-options.patch on advice from upstream and because it caused
    odd build failures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
;; erlang.el --- Major modes for editing and running Erlang
2
2
;; %CopyrightBegin%
3
 
;; 
4
 
;; Copyright Ericsson AB 1996-2009. All Rights Reserved.
5
 
;; 
 
3
;;
 
4
;; Copyright Ericsson AB 1996-2011. All Rights Reserved.
 
5
;;
6
6
;; The contents of this file are subject to the Erlang Public License,
7
7
;; Version 1.1, (the "License"); you may not use this file except in
8
8
;; compliance with the License. You should have received a copy of the
9
9
;; Erlang Public License along with this software. If not, it can be
10
10
;; retrieved online at http://www.erlang.org/.
11
 
;; 
 
11
;;
12
12
;; Software distributed under the License is distributed on an "AS IS"
13
13
;; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
14
;; the License for the specific language governing rights and limitations
15
15
;; under the License.
16
 
;; 
 
16
;;
17
17
;; %CopyrightEnd%
18
18
;; 
19
19
;; Copyright (C) 2004  Free Software Foundation, Inc.
72
72
 
73
73
;; Variables:
74
74
 
75
 
(defconst erlang-version "2.6.1"
 
75
(defconst erlang-version "2.7"
76
76
  "The version number of Erlang mode.")
77
77
 
78
78
(defvar erlang-root-dir nil
466
466
 
467
467
(defvar erlang-indent-level 4
468
468
  "*Indentation of Erlang calls/clauses within blocks.")
 
469
(put 'erlang-indent-level 'safe-local-variable 'integerp)
469
470
 
470
471
(defvar erlang-indent-guard 2
471
472
  "*Indentation of Erlang guards.")
 
473
(put 'erlang-indent-guard 'safe-local-variable 'integerp)
472
474
 
473
475
(defvar erlang-argument-indent 2
474
476
  "*Indentation of the first argument in a function call.
475
477
When nil, indent to the column after the `(' of the
476
478
function.")
 
479
(put 'erlang-argument-indent 'safe-local-variable '(lambda (val) (or (null val) (integerp val))))
477
480
 
478
481
(defvar erlang-tab-always-indent t
479
482
  "*Non-nil means TAB in Erlang mode should always re-indent the current line,
659
662
(eval-and-compile
660
663
  (defconst erlang-guards-regexp (erlang-regexp-opt erlang-guards 'symbols)))
661
664
 
662
 
 
663
665
(eval-and-compile
664
666
  (defvar erlang-predefined-types
665
667
    '("any"
666
668
      "arity"
 
669
      "boolean"
667
670
      "byte"
668
671
      "char"
669
672
      "cons"
670
673
      "deep_string"
 
674
      "iolist"
671
675
      "maybe_improper_list"
 
676
      "module"
672
677
      "mfa"
673
678
      "nil"
 
679
      "neg_integer"
674
680
      "none"
675
681
      "non_neg_integer"
676
682
      "nonempty_list"
677
683
      "nonempty_improper_list"
678
684
      "nonempty_maybe_improper_list"
 
685
      "no_return"
 
686
      "pos_integer"
679
687
      "string"
 
688
      "term"
680
689
      "timeout")
681
690
    "Erlang type specs types"))
682
691
 
885
894
If nil, the inferior shell replaces the window. This is the traditional
886
895
behaviour.")
887
896
 
888
 
(defvar erlang-mode-map nil
 
897
(defconst inferior-erlang-use-cmm (boundp 'minor-mode-overriding-map-alist)
 
898
  "Non-nil means use `compilation-minor-mode' in Erlang shell.")
 
899
 
 
900
(defvar erlang-mode-map
 
901
  (let ((map (make-sparse-keymap)))
 
902
    (unless (boundp 'indent-line-function)
 
903
      (define-key map "\t"        'erlang-indent-command))
 
904
    (define-key map ";"       'erlang-electric-semicolon)
 
905
    (define-key map ","       'erlang-electric-comma)
 
906
    (define-key map "<"         'erlang-electric-lt)
 
907
    (define-key map ">"         'erlang-electric-gt)
 
908
    (define-key map "\C-m"      'erlang-electric-newline)
 
909
    (if (not (boundp 'delete-key-deletes-forward))
 
910
        (define-key map "\177" 'backward-delete-char-untabify)
 
911
      (define-key map [(backspace)] 'backward-delete-char-untabify))
 
912
    ;;(unless (boundp 'fill-paragraph-function)
 
913
    (define-key map "\M-q"      'erlang-fill-paragraph)
 
914
    (unless (boundp 'beginning-of-defun-function)
 
915
      (define-key map "\M-\C-a"   'erlang-beginning-of-function)
 
916
      (define-key map "\M-\C-e"   'erlang-end-of-function)
 
917
      (define-key map '(meta control h)   'erlang-mark-function))       ; Xemacs
 
918
    (define-key map "\M-\t"     'erlang-complete-tag)
 
919
    (define-key map "\C-c\M-\t" 'tempo-complete-tag)
 
920
    (define-key map "\M-+"      'erlang-find-next-tag)
 
921
    (define-key map "\C-c\M-a"  'erlang-beginning-of-clause)
 
922
    (define-key map "\C-c\M-b"  'tempo-backward-mark)
 
923
    (define-key map "\C-c\M-e"  'erlang-end-of-clause)
 
924
    (define-key map "\C-c\M-f"  'tempo-forward-mark)
 
925
    (define-key map "\C-c\M-h"  'erlang-mark-clause)
 
926
    (define-key map "\C-c\C-c"  'comment-region)
 
927
    (define-key map "\C-c\C-j"  'erlang-generate-new-clause)
 
928
    (define-key map "\C-c\C-k"  'erlang-compile)
 
929
    (define-key map "\C-c\C-l"  'erlang-compile-display)
 
930
    (define-key map "\C-c\C-s"  'erlang-show-syntactic-information)
 
931
    (define-key map "\C-c\C-q"  'erlang-indent-function)
 
932
    (define-key map "\C-c\C-u"  'erlang-uncomment-region)
 
933
    (define-key map "\C-c\C-y"  'erlang-clone-arguments)
 
934
    (define-key map "\C-c\C-a"  'erlang-align-arrows)
 
935
    (define-key map "\C-c\C-z"  'erlang-shell-display)
 
936
    (unless inferior-erlang-use-cmm
 
937
      (define-key map "\C-x`"    'erlang-next-error))
 
938
    map)
889
939
  "*Keymap used in Erlang mode.")
890
940
(defvar erlang-mode-abbrev-table nil
891
941
  "Abbrev table in use in Erlang-mode buffers.")
892
942
(defvar erlang-mode-syntax-table nil
893
943
  "Syntax table in use in Erlang-mode buffers.")
894
944
 
895
 
(defconst inferior-erlang-use-cmm (boundp 'minor-mode-overriding-map-alist)
896
 
  "Non-nil means use `compilation-minor-mode' in Erlang shell.")
897
945
 
 
946
 
 
947
(defvar erlang-skel-file "erlang-skels"
 
948
  "The type of erlang-skeletons that should be used, default
 
949
   uses edoc type, for the old type, standard comments,
 
950
   set \"erlang-skels-old\" in your .emacs and restart.
 
951
 
 
952
   Or define your own and set the variable to that file.")
 
953
 
898
954
;; Tempo skeleton templates:
899
 
 
900
 
(defvar erlang-tempo-tags nil
901
 
  "Tempo tags for erlang mode")
902
 
 
903
 
(defvar erlang-skel
904
 
  '(("If"            "if"            erlang-skel-if)
905
 
    ("Case"          "case"          erlang-skel-case)
906
 
    ("Receive"       "receive"       erlang-skel-receive)
907
 
    ("Receive After" "after"         erlang-skel-receive-after)
908
 
    ("Receive Loop"  "loop"          erlang-skel-receive-loop)
909
 
    ("Module"        "module"        erlang-skel-module)
910
 
    ("Author"        "author"        erlang-skel-author)
911
 
    ()
912
 
    ("Small Header"  "small-header"
913
 
     erlang-skel-small-header erlang-skel-header)
914
 
    ("Normal Header" "normal-header"
915
 
     erlang-skel-normal-header erlang-skel-header)
916
 
    ("Large Header"  "large-header"
917
 
     erlang-skel-large-header erlang-skel-header)
918
 
    ()
919
 
    ("Small Server"   "small-server"
920
 
     erlang-skel-small-server erlang-skel-header)
921
 
    ()
922
 
    ("Application" "application"
923
 
     erlang-skel-application erlang-skel-header)
924
 
    ("Supervisor" "supervisor"
925
 
     erlang-skel-supervisor erlang-skel-header)
926
 
    ("supervisor_bridge" "supervisor-bridge"
927
 
     erlang-skel-supervisor-bridge erlang-skel-header)
928
 
    ("gen_server" "generic-server"
929
 
     erlang-skel-generic-server erlang-skel-header)
930
 
    ("gen_event" "gen-event"
931
 
     erlang-skel-gen-event erlang-skel-header)
932
 
    ("gen_fsm" "gen-fsm"
933
 
     erlang-skel-gen-fsm erlang-skel-header)
934
 
    ("Library module" "gen-lib"
935
 
     erlang-skel-lib erlang-skel-header)
936
 
    ("Corba callback" "gen-corba-cb"
937
 
     erlang-skel-corba-callback erlang-skel-header)
938
 
    ("Small Common Test suite" "ct-test-suite-s"
939
 
     erlang-skel-ct-test-suite-s erlang-skel-header)
940
 
    ("Large Common Test suite" "ct-test-suite-l"
941
 
     erlang-skel-ct-test-suite-l erlang-skel-header)
942
 
    ("Erlang TS test suite" "ts-test-suite"
943
 
     erlang-skel-ts-test-suite erlang-skel-header)
944
 
  )
945
 
  "*Description of all skeleton templates.
946
 
Both functions and menu entries will be created.
947
 
 
948
 
Each entry in `erlang-skel' should be a list with three or four
949
 
elements, or the empty list.
950
 
 
951
 
The first element is the name which shows up in the menu.  The second
952
 
is the `tempo' identifier (The string \"erlang-\" will be added in
953
 
front of it).  The third is the skeleton descriptor, a variable
954
 
containing `tempo' attributes as described in the function
955
 
`tempo-define-template'.  The optional fourth elements denotes a
956
 
function which should be called when the menu is selected.
957
 
 
958
 
Functions corresponding to every template will be created.  The name
959
 
of the function will be `tempo-template-erlang-X' where `X' is the
960
 
tempo identifier as specified in the second argument of the elements
961
 
in this list.
962
 
 
963
 
A list with zero elements means that the a horizontal line should
964
 
be placed in the menu.")
965
 
 
966
 
;; In XEmacs `user-mail-address' returns "x@y.z (Foo Bar)" ARGH!
967
 
;; What's wrong with that? RFC 822 says it's legal.   [sverkerw]
968
 
;; This needs to use the customized value.  If that's not sane, things like
969
 
;; add-log will lose anyhow.  Avoid it if there _is_ a paren.
970
 
(defvar erlang-skel-mail-address
971
 
  (if (or (not user-mail-address) (string-match "(" user-mail-address))
972
 
      (concat (user-login-name) "@"
973
 
              (or (and (boundp 'mail-host-address)
974
 
                       mail-host-address)
975
 
                  (system-name)))
976
 
    user-mail-address)
977
 
  "Mail address of the user.")
978
 
 
979
 
;; Expression templates:
980
 
(defvar erlang-skel-case
981
 
  '((erlang-skel-skip-blank) o >
982
 
    "case " p " of" n> p "_ ->" n> p "ok" n> "end" p)
983
 
  "*The skeleton of a `case' expression.
984
 
Please see the function `tempo-define-template'.")
985
 
 
986
 
(defvar erlang-skel-if
987
 
  '((erlang-skel-skip-blank) o >
988
 
    "if"  n> p " ->" n> p "ok" n> "end" p)
989
 
  "The skeleton of an `if' expression.
990
 
Please see the function `tempo-define-template'.")
991
 
 
992
 
(defvar erlang-skel-receive
993
 
  '((erlang-skel-skip-blank) o >
994
 
    "receive" n> p "_ ->" n> p "ok" n> "end" p)
995
 
  "*The skeleton of a `receive' expression.
996
 
Please see the function `tempo-define-template'.")
997
 
 
998
 
(defvar erlang-skel-receive-after
999
 
  '((erlang-skel-skip-blank) o >
1000
 
    "receive" n> p "_ ->" n> p "ok" n> "after " p "T ->" n>
1001
 
    p "ok" n> "end" p)
1002
 
  "*The skeleton of a `receive' expression with an `after' clause.
1003
 
Please see the function `tempo-define-template'.")
1004
 
 
1005
 
(defvar erlang-skel-receive-loop
1006
 
  '(& o "loop(" p ") ->" n> "receive" n> p "_ ->" n>
1007
 
      "loop(" p ")" n> "end.")
1008
 
  "*The skeleton of a simple `receive' loop.
1009
 
Please see the function `tempo-define-template'.")
1010
 
 
1011
 
 
1012
 
;; Attribute templates
1013
 
 
1014
 
(defvar erlang-skel-module
1015
 
  '(& "-module("
1016
 
      (erlang-add-quotes-if-needed (erlang-get-module-from-file-name))
1017
 
      ")." n)
1018
 
  "*The skeleton of a `module' attribute.
1019
 
Please see the function `tempo-define-template'.")
1020
 
 
1021
 
(defvar erlang-skel-author
1022
 
  '(& "-author('" erlang-skel-mail-address "')." n)
1023
 
  "*The skeleton of a `author' attribute.
1024
 
Please see the function `tempo-define-template'.")
1025
 
 
1026
 
(defvar erlang-skel-vc nil
1027
 
  "*The skeleton template to generate a version control attribute.
1028
 
The default is to insert nothing.  Example of usage:
1029
 
 
1030
 
    (setq erlang-skel-vc '(& \"-rcs(\\\"$\Id: $ \\\").\") n)
1031
 
 
1032
 
Please see the function `tempo-define-template'.")
1033
 
 
1034
 
(defvar erlang-skel-export
1035
 
  '(& "-export([" n> "])." n)
1036
 
  "*The skeleton of an `export' attribute.
1037
 
Please see the function `tempo-define-template'.")
1038
 
 
1039
 
(defvar erlang-skel-import
1040
 
  '(& "%%-import(Module, [Function/Arity, ...])." n)
1041
 
  "*The skeleton of an `import' attribute.
1042
 
Please see the function `tempo-define-template'.")
1043
 
 
1044
 
(defvar erlang-skel-compile nil
1045
 
  ;;  '(& "%%-compile(export_all)." n)
1046
 
  "*The skeleton of a `compile' attribute.
1047
 
Please see the function `tempo-define-template'.")
1048
 
 
1049
 
 
1050
 
;; Comment templates.
1051
 
 
1052
 
(defvar erlang-skel-date-function 'erlang-skel-dd-mmm-yyyy
1053
 
  "*Function which returns date string.
1054
 
Look in the module `time-stamp' for a battery of functions.")
1055
 
 
1056
 
(defvar erlang-skel-copyright-comment '()
1057
 
  "*The template for a copyright line in the header, normally empty.
1058
 
This variable should be bound to a `tempo' template, for example:
1059
 
  '(& \"%%% Copyright (C) 2000, Yoyodyne, Inc.\" n)
1060
 
 
1061
 
Please see the function `tempo-define-template'.")
1062
 
 
1063
 
(defvar erlang-skel-created-comment
1064
 
  '(& "%%% Created : " (funcall erlang-skel-date-function) " by "
1065
 
      (user-full-name) " <" erlang-skel-mail-address ">" n)
1066
 
  "*The template for the \"Created:\" comment line.")
1067
 
 
1068
 
(defvar erlang-skel-author-comment
1069
 
  '(& "%%% Author  : " (user-full-name) " <" erlang-skel-mail-address ">" n)
1070
 
  "*The template for creating the \"Author:\" line in the header.
1071
 
Please see the function `tempo-define-template'.")
1072
 
 
1073
 
(defvar erlang-skel-file-comment
1074
 
  '(& "%%% File    : " (file-name-nondirectory buffer-file-name) n)
1075
 
"*The template for creating the \"Module:\" line in the header.
1076
 
Please see the function `tempo-define-template'.")
1077
 
 
1078
 
(defvar erlang-skel-small-header
1079
 
  '(o (erlang-skel-include erlang-skel-module)
1080
 
      ;;                           erlang-skel-author)
1081
 
      n
1082
 
      (erlang-skel-include erlang-skel-compile
1083
 
                           ;;                      erlang-skel-export
1084
 
                           erlang-skel-vc))
1085
 
  "*The template of a small header without any comments.
1086
 
Please see the function `tempo-define-template'.")
1087
 
 
1088
 
(defvar erlang-skel-normal-header
1089
 
  '(o (erlang-skel-include erlang-skel-copyright-comment
1090
 
                           erlang-skel-file-comment
1091
 
                           erlang-skel-author-comment)
1092
 
      "%%% Description : " p n
1093
 
      (erlang-skel-include erlang-skel-created-comment) n
1094
 
      (erlang-skel-include erlang-skel-small-header) n)
1095
 
  "*The template of a normal header.
1096
 
Please see the function `tempo-define-template'.")
1097
 
 
1098
 
(defvar erlang-skel-large-header
1099
 
  '(o (erlang-skel-separator)
1100
 
      (erlang-skel-include erlang-skel-copyright-comment
1101
 
                           erlang-skel-file-comment
1102
 
                           erlang-skel-author-comment)
1103
 
      "%%% Description : " p n 
1104
 
      "%%%" n
1105
 
      (erlang-skel-include erlang-skel-created-comment)
1106
 
      (erlang-skel-separator) 
1107
 
      (erlang-skel-include erlang-skel-small-header) )
1108
 
  "*The template of a large header.
1109
 
Please see the function `tempo-define-template'.")
1110
 
 
1111
 
 
1112
 
;; Server templates.
1113
 
 
1114
 
(defvar erlang-skel-small-server
1115
 
  '((erlang-skel-include erlang-skel-large-header)
1116
 
    "-export([start/0,init/1])." n n n
1117
 
    "start() ->" n> "spawn(" (erlang-get-module-from-file-name)
1118
 
    ", init, [self()])." n n
1119
 
    "init(From) ->" n>
1120
 
    "loop(From)." n n
1121
 
    "loop(From) ->" n>
1122
 
    "receive" n>
1123
 
    p "_ ->" n>
1124
 
    "loop(From)" n>
1125
 
    "end."
1126
 
    )
1127
 
  "*Template of a small server.
1128
 
Please see the function `tempo-define-template'.")
1129
 
 
1130
 
;; Behaviour templates.
1131
 
 
1132
 
(defvar erlang-skel-application
1133
 
  '((erlang-skel-include erlang-skel-large-header)
1134
 
    "-behaviour(application)." n n
1135
 
    "%% Application callbacks" n
1136
 
    "-export([start/2, stop/1])." n n
1137
 
    (erlang-skel-double-separator 2)
1138
 
    "%% Application callbacks" n
1139
 
    (erlang-skel-double-separator 2)
1140
 
    (erlang-skel-separator 2)
1141
 
    "%% Function: start(Type, StartArgs) -> {ok, Pid} |" n
1142
 
    "%%                                     {ok, Pid, State} |" n
1143
 
    "%%                                     {error, Reason}" n
1144
 
    "%% Description: This function is called whenever an application " n
1145
 
    "%% is started using application:start/1,2, and should start the processes" n
1146
 
    "%% of the application. If the application is structured according to the" n
1147
 
    "%% OTP design principles as a supervision tree, this means starting the" n
1148
 
    "%% top supervisor of the tree." n
1149
 
    (erlang-skel-separator 2)
1150
 
    "start(_Type, StartArgs) ->" n>
1151
 
    "case 'TopSupervisor':start_link(StartArgs) of" n>
1152
 
    "{ok, Pid} -> " n>
1153
 
    "{ok, Pid};" n>
1154
 
    "Error ->" n>
1155
 
    "Error" n>
1156
 
    "end." n
1157
 
    n
1158
 
    (erlang-skel-separator 2)
1159
 
    "%% Function: stop(State) -> void()" n
1160
 
    "%% Description: This function is called whenever an application" n
1161
 
    "%% has stopped. It is intended to be the opposite of Module:start/2 and" n
1162
 
    "%% should do any necessary cleaning up. The return value is ignored. "n
1163
 
    (erlang-skel-separator 2)
1164
 
    "stop(_State) ->" n>
1165
 
    "ok." n
1166
 
    n
1167
 
    (erlang-skel-double-separator 2)
1168
 
    "%% Internal functions" n
1169
 
    (erlang-skel-double-separator 2)
1170
 
    )
1171
 
  "*The template of an application behaviour.
1172
 
Please see the function `tempo-define-template'.")
1173
 
 
1174
 
(defvar erlang-skel-supervisor
1175
 
  '((erlang-skel-include erlang-skel-large-header)
1176
 
    "-behaviour(supervisor)." n n
1177
 
 
1178
 
    "%% API" n
1179
 
    "-export([start_link/0])." n n 
1180
 
 
1181
 
    "%% Supervisor callbacks" n
1182
 
    "-export([init/1])." n n
1183
 
 
1184
 
    "-define(SERVER, ?MODULE)." n n
1185
 
    
1186
 
    (erlang-skel-double-separator 2)
1187
 
    "%% API functions" n
1188
 
    (erlang-skel-double-separator 2)
1189
 
    (erlang-skel-separator 2)
1190
 
    "%% Function: start_link() -> {ok,Pid} | ignore | {error,Error}" n
1191
 
    "%% Description: Starts the supervisor" n
1192
 
    (erlang-skel-separator 2)
1193
 
    "start_link() ->" n>
1194
 
    "supervisor:start_link({local, ?SERVER}, ?MODULE, [])." n 
1195
 
    n
1196
 
    (erlang-skel-double-separator 2)
1197
 
    "%% Supervisor callbacks" n
1198
 
    (erlang-skel-double-separator 2)
1199
 
    (erlang-skel-separator 2)
1200
 
    "%% Func: init(Args) -> {ok,  {SupFlags,  [ChildSpec]}} |" n
1201
 
    "%%                     ignore                          |" n
1202
 
    "%%                     {error, Reason}" n
1203
 
    "%% Description: Whenever a supervisor is started using "n
1204
 
    "%% supervisor:start_link/[2,3], this function is called by the new process "n
1205
 
    "%% to find out about restart strategy, maximum restart frequency and child "n
1206
 
    "%% specifications." n
1207
 
    (erlang-skel-separator 2)
1208
 
    "init([]) ->" n>
1209
 
    "AChild = {'AName',{'AModule',start_link,[]}," n>
1210
 
    "permanent,2000,worker,['AModule']}," n>
1211
 
    "{ok,{{one_for_all,0,1}, [AChild]}}." n
1212
 
    n
1213
 
    (erlang-skel-double-separator 2)
1214
 
    "%% Internal functions" n
1215
 
    (erlang-skel-double-separator 2)
1216
 
    )
1217
 
  "*The template of an supervisor behaviour.
1218
 
Please see the function `tempo-define-template'.")
1219
 
 
1220
 
(defvar erlang-skel-supervisor-bridge
1221
 
  '((erlang-skel-include erlang-skel-large-header)
1222
 
    "-behaviour(supervisor_bridge)." n n
1223
 
 
1224
 
    "%% API" n
1225
 
    "-export([start_link/0])." n n
1226
 
 
1227
 
    "%% supervisor_bridge callbacks" n
1228
 
    "-export([init/1, terminate/2])." n n
1229
 
    
1230
 
    "-define(SERVER, ?MODULE)." n n
1231
 
 
1232
 
    "-record(state, {})." n n
1233
 
     
1234
 
    (erlang-skel-double-separator 2)
1235
 
    "%% API" n
1236
 
    (erlang-skel-double-separator 2)
1237
 
    (erlang-skel-separator 2)
1238
 
    "%% Function: start_link() -> {ok,Pid} | ignore | {error,Error}" n
1239
 
    "%% Description: Starts the supervisor bridge" n
1240
 
    (erlang-skel-separator 2) 
1241
 
    "start_link() ->" n>
1242
 
    "supervisor_bridge:start_link({local, ?SERVER}, ?MODULE, [])." n
1243
 
    n
1244
 
    (erlang-skel-double-separator 2)
1245
 
    "%% supervisor_bridge callbacks" n
1246
 
    (erlang-skel-double-separator 2)
1247
 
    (erlang-skel-separator 2)
1248
 
    "%% Funcion: init(Args) -> {ok,  Pid, State} |" n
1249
 
    "%%                        ignore            |" n
1250
 
    "%%                        {error, Reason}    " n
1251
 
    "%% Description:Creates a supervisor_bridge process, linked to the calling" n
1252
 
    "%% process, which calls Module:init/1 to start the subsystem. To ensure a" n
1253
 
    "%% synchronized start-up procedure, this function does not return until" n
1254
 
    "%% Module:init/1 has returned. "  n
1255
 
    (erlang-skel-separator 2)
1256
 
    "init([]) ->" n>
1257
 
    "case 'AModule':start_link() of" n>
1258
 
    "{ok, Pid} ->" n>
1259
 
    "{ok, Pid, #state{}};" n>
1260
 
    "Error ->" n>
1261
 
    "Error" n>
1262
 
    "end." n
1263
 
    n
1264
 
    (erlang-skel-separator 2)
1265
 
    "%% Func: terminate(Reason, State) -> void()" n
1266
 
    "%% Description:This function is called by the supervisor_bridge when it is"n
1267
 
    "%% about to terminate. It should be the opposite of Module:init/1 and stop"n
1268
 
    "%% the subsystem and do any necessary cleaning up.The return value is ignored."
1269
 
    (erlang-skel-separator 2)
1270
 
    "terminate(Reason, State) ->" n>
1271
 
    "'AModule':stop()," n>
1272
 
    "ok." n
1273
 
    n
1274
 
    (erlang-skel-double-separator 2)
1275
 
    "%% Internal functions" n
1276
 
    (erlang-skel-double-separator 2)
1277
 
    )
1278
 
  "*The template of an supervisor_bridge behaviour.
1279
 
Please see the function `tempo-define-template'.")
1280
 
 
1281
 
(defvar erlang-skel-generic-server
1282
 
  '((erlang-skel-include erlang-skel-large-header)
1283
 
    "-behaviour(gen_server)." n n
1284
 
 
1285
 
    "%% API" n
1286
 
    "-export([start_link/0])." n n
1287
 
    
1288
 
    "%% gen_server callbacks" n
1289
 
    "-export([init/1, handle_call/3, handle_cast/2, "
1290
 
    "handle_info/2," n>
1291
 
    "terminate/2, code_change/3])." n n
1292
 
 
1293
 
    "-record(state, {})." n n
1294
 
    
1295
 
    (erlang-skel-double-separator 2)
1296
 
    "%% API" n
1297
 
    (erlang-skel-double-separator 2)
1298
 
    (erlang-skel-separator 2)
1299
 
    "%% Function: start_link() -> {ok,Pid} | ignore | {error,Error}" n
1300
 
    "%% Description: Starts the server" n
1301
 
    (erlang-skel-separator 2) 
1302
 
    "start_link() ->" n>
1303
 
    "gen_server:start_link({local, ?SERVER}, ?MODULE, [], [])." n
1304
 
    n
1305
 
    (erlang-skel-double-separator 2)
1306
 
    "%% gen_server callbacks" n
1307
 
    (erlang-skel-double-separator 2)
1308
 
    n
1309
 
    (erlang-skel-separator 2)
1310
 
    "%% Function: init(Args) -> {ok, State} |" n
1311
 
    "%%                         {ok, State, Timeout} |" n
1312
 
    "%%                         ignore               |" n
1313
 
    "%%                         {stop, Reason}" n
1314
 
    "%% Description: Initiates the server" n
1315
 
    (erlang-skel-separator 2)
1316
 
    "init([]) ->" n>
1317
 
    "{ok, #state{}}." n
1318
 
    n
1319
 
    (erlang-skel-separator 2)
1320
 
    "%% Function: "
1321
 
    "%% handle_call(Request, From, State) -> {reply, Reply, State} |" n
1322
 
    "%%                                      {reply, Reply, State, Timeout} |" n
1323
 
    "%%                                      {noreply, State} |" n
1324
 
    "%%                                      {noreply, State, Timeout} |" n
1325
 
    "%%                                      {stop, Reason, Reply, State} |" n 
1326
 
    "%%                                      {stop, Reason, State}" n       
1327
 
    "%% Description: Handling call messages" n
1328
 
    (erlang-skel-separator 2)
1329
 
    "handle_call(_Request, _From, State) ->" n>
1330
 
    "Reply = ok," n>
1331
 
    "{reply, Reply, State}." n
1332
 
    n
1333
 
    (erlang-skel-separator 2)
1334
 
    "%% Function: handle_cast(Msg, State) -> {noreply, State} |" n
1335
 
    "%%                                      {noreply, State, Timeout} |" n
1336
 
    "%%                                      {stop, Reason, State}" n
1337
 
    "%% Description: Handling cast messages" n
1338
 
 
1339
 
    (erlang-skel-separator 2)
1340
 
    "handle_cast(_Msg, State) ->" n>
1341
 
    "{noreply, State}." n
1342
 
    n
1343
 
    (erlang-skel-separator 2)
1344
 
    "%% Function: handle_info(Info, State) -> {noreply, State} |" n
1345
 
    "%%                                       {noreply, State, Timeout} |" n
1346
 
    "%%                                       {stop, Reason, State}" n
1347
 
    "%% Description: Handling all non call/cast messages" n
1348
 
    (erlang-skel-separator 2)
1349
 
    "handle_info(_Info, State) ->" n>
1350
 
    "{noreply, State}." n
1351
 
    n
1352
 
    (erlang-skel-separator 2)
1353
 
    "%% Function: terminate(Reason, State) -> void()" n
1354
 
    "%% Description: This function is called by a gen_server when it is about to"n
1355
 
    "%% terminate. It should be the opposite of Module:init/1 and do any necessary"n
1356
 
    "%% cleaning up. When it returns, the gen_server terminates with Reason." n
1357
 
    "%% The return value is ignored." n 
1358
 
    
1359
 
    (erlang-skel-separator 2)
1360
 
    "terminate(_Reason, _State) ->" n>
1361
 
    "ok." n
1362
 
    n
1363
 
    (erlang-skel-separator 2)
1364
 
    "%% Func: code_change(OldVsn, State, Extra) -> {ok, NewState}" n
1365
 
    "%% Description: Convert process state when code is changed" n
1366
 
    (erlang-skel-separator 2)
1367
 
    "code_change(_OldVsn, State, _Extra) ->" n>
1368
 
    "{ok, State}." n
1369
 
    n
1370
 
    (erlang-skel-separator 2)
1371
 
    "%%% Internal functions" n
1372
 
    (erlang-skel-separator 2)
1373
 
    )
1374
 
  "*The template of a generic server.
1375
 
Please see the function `tempo-define-template'.")
1376
 
 
1377
 
(defvar erlang-skel-gen-event
1378
 
  '((erlang-skel-include erlang-skel-large-header)
1379
 
    "-behaviour(gen_event)." n
1380
 
 
1381
 
    "%% API" n
1382
 
    "-export([start_link/0, add_handler/0])." n n
1383
 
 
1384
 
    "%% gen_event callbacks" n
1385
 
    "-export([init/1, handle_event/2, handle_call/2, " n>
1386
 
    "handle_info/2, terminate/2, code_change/3])." n n
1387
 
 
1388
 
    "-record(state, {})." n n
1389
 
 
1390
 
    (erlang-skel-double-separator 2)
1391
 
    "%% gen_event callbacks" n
1392
 
    (erlang-skel-double-separator 2)
1393
 
    (erlang-skel-separator 2)
1394
 
    "%% Function: start_link() -> {ok,Pid} | {error,Error} " n
1395
 
    "%% Description: Creates an event manager." n
1396
 
    (erlang-skel-separator 2) 
1397
 
    "start_link() ->" n>
1398
 
    "gen_event:start_link({local, ?SERVER}). " n
1399
 
    n
1400
 
    (erlang-skel-separator 2)
1401
 
    "%% Function: add_handler() -> ok | {'EXIT',Reason} | term()" n
1402
 
    "%% Description: Adds an event handler" n
1403
 
    (erlang-skel-separator 2) 
1404
 
    "add_handler() ->" n>
1405
 
    "gen_event:add_handler(?SERVER, ?MODULE, [])." n 
1406
 
    n
1407
 
    (erlang-skel-double-separator 2)
1408
 
    "%% gen_event callbacks" n
1409
 
    (erlang-skel-double-separator 2)
1410
 
    (erlang-skel-separator 2)
1411
 
    "%% Function: init(Args) -> {ok, State}" n
1412
 
    "%% Description: Whenever a new event handler is added to an event manager,"n
1413
 
    "%% this function is called to initialize the event handler." n
1414
 
    (erlang-skel-separator 2)
1415
 
    "init([]) ->" n>
1416
 
    "{ok, #state{}}." n
1417
 
    n
1418
 
    (erlang-skel-separator 2)
1419
 
    "%% Function:  "n
1420
 
    "%% handle_event(Event, State) -> {ok, State} |" n
1421
 
    "%%                               {swap_handler, Args1, State1, Mod2, Args2} |"n
1422
 
    "%%                               remove_handler" n
1423
 
    "%% Description:Whenever an event manager receives an event sent using"n
1424
 
    "%% gen_event:notify/2 or gen_event:sync_notify/2, this function is called for"n
1425
 
    "%% each installed event handler to handle the event. "n
1426
 
    (erlang-skel-separator 2)
1427
 
    "handle_event(_Event, State) ->" n>
1428
 
    "{ok, State}." n
1429
 
    n
1430
 
    (erlang-skel-separator 2)
1431
 
    "%% Function: " n
1432
 
    "%% handle_call(Request, State) -> {ok, Reply, State} |" n
1433
 
    "%%                                {swap_handler, Reply, Args1, State1, "n
1434
 
    "%%                                  Mod2, Args2} |" n
1435
 
    "%%                                {remove_handler, Reply}" n
1436
 
    "%% Description: Whenever an event manager receives a request sent using"n
1437
 
    "%% gen_event:call/3,4, this function is called for the specified event "n
1438
 
    "%% handler to handle the request."n
1439
 
    (erlang-skel-separator 2)
1440
 
    "handle_call(_Request, State) ->" n>
1441
 
    "Reply = ok," n>
1442
 
    "{ok, Reply, State}." n
1443
 
    n
1444
 
    (erlang-skel-separator 2)
1445
 
    "%% Function: " n
1446
 
    "%% handle_info(Info, State) -> {ok, State} |" n
1447
 
    "%%                             {swap_handler, Args1, State1, Mod2, Args2} |" n
1448
 
    "%%                              remove_handler" n
1449
 
    "%% Description: This function is called for each installed event handler when"n
1450
 
    "%% an event manager receives any other message than an event or a synchronous"n
1451
 
    "%% request (or a system message)."n
1452
 
    (erlang-skel-separator 2)
1453
 
    "handle_info(_Info, State) ->" n>
1454
 
    "{ok, State}." n
1455
 
    n
1456
 
    (erlang-skel-separator 2)
1457
 
    "%% Function: terminate(Reason, State) -> void()" n
1458
 
    "%% Description:Whenever an event handler is deleted from an event manager,"n
1459
 
    "%% this function is called. It should be the opposite of Module:init/1 and "n
1460
 
    "%% do any necessary cleaning up. " n
1461
 
    (erlang-skel-separator 2)
1462
 
    "terminate(_Reason, _State) ->" n>
1463
 
    "ok." n
1464
 
    n
1465
 
    (erlang-skel-separator 2)
1466
 
    "%% Function: code_change(OldVsn, State, Extra) -> {ok, NewState} " n
1467
 
    "%% Description: Convert process state when code is changed" n
1468
 
    (erlang-skel-separator 2)
1469
 
    "code_change(_OldVsn, State, _Extra) ->" n>
1470
 
    "{ok, State}." n
1471
 
    n
1472
 
    (erlang-skel-separator 2)
1473
 
    "%%% Internal functions" n
1474
 
    (erlang-skel-separator 2)
1475
 
    )
1476
 
  "*The template of a gen_event.
1477
 
Please see the function `tempo-define-template'.")
1478
 
 
1479
 
(defvar erlang-skel-gen-fsm
1480
 
  '((erlang-skel-include erlang-skel-large-header)
1481
 
    "-behaviour(gen_fsm)." n n
1482
 
 
1483
 
    "%% API" n
1484
 
    "-export([start_link/0])." n n
1485
 
    
1486
 
    "%% gen_fsm callbacks" n
1487
 
    "-export([init/1, state_name/2, state_name/3, handle_event/3," n>
1488
 
    "handle_sync_event/4, handle_info/3, terminate/3, code_change/4])." n n
1489
 
 
1490
 
    "-record(state, {})." n n
1491
 
 
1492
 
    (erlang-skel-double-separator 2)
1493
 
    "%% API" n
1494
 
    (erlang-skel-double-separator 2)
1495
 
    (erlang-skel-separator 2)
1496
 
    "%% Function: start_link() -> ok,Pid} | ignore | {error,Error}" n
1497
 
    "%% Description:Creates a gen_fsm process which calls Module:init/1 to"n
1498
 
    "%% initialize. To ensure a synchronized start-up procedure, this function" n
1499
 
    "%% does not return until Module:init/1 has returned.  " n
1500
 
    (erlang-skel-separator 2) 
1501
 
    "start_link() ->" n>
1502
 
    "gen_fsm:start_link({local, ?SERVER}, ?MODULE, [], [])." n 
1503
 
    n
1504
 
    (erlang-skel-double-separator 2)
1505
 
    "%% gen_fsm callbacks" n
1506
 
    (erlang-skel-double-separator 2)
1507
 
    (erlang-skel-separator 2)
1508
 
    "%% Function: init(Args) -> {ok, StateName, State} |" n
1509
 
    "%%                         {ok, StateName, State, Timeout} |" n
1510
 
    "%%                         ignore                              |" n
1511
 
    "%%                         {stop, StopReason}                   " n
1512
 
    "%% Description:Whenever a gen_fsm is started using gen_fsm:start/[3,4] or"n
1513
 
    "%% gen_fsm:start_link/3,4, this function is called by the new process to "n
1514
 
    "%% initialize. " n
1515
 
    (erlang-skel-separator 2)
1516
 
    "init([]) ->" n>
1517
 
    "{ok, state_name, #state{}}." n
1518
 
    n
1519
 
    (erlang-skel-separator 2)
1520
 
    "%% Function: "n
1521
 
    "%% state_name(Event, State) -> {next_state, NextStateName, NextState}|" n
1522
 
    "%%                             {next_state, NextStateName, " n
1523
 
    "%%                                NextState, Timeout} |" n
1524
 
    "%%                             {stop, Reason, NewState}" n
1525
 
    "%% Description:There should be one instance of this function for each possible"n
1526
 
    "%% state name. Whenever a gen_fsm receives an event sent using" n
1527
 
    "%% gen_fsm:send_event/2, the instance of this function with the same name as"n
1528
 
    "%% the current state name StateName is called to handle the event. It is also "n
1529
 
    "%% called if a timeout occurs. " n
1530
 
    (erlang-skel-separator 2)
1531
 
    "state_name(_Event, State) ->" n>
1532
 
    "{next_state, state_name, State}." n
1533
 
    n
1534
 
    (erlang-skel-separator 2)
1535
 
    "%% Function:" n
1536
 
    "%% state_name(Event, From, State) -> {next_state, NextStateName, NextState} |"n
1537
 
    "%%                                   {next_state, NextStateName, " n
1538
 
    "%%                                     NextState, Timeout} |" n
1539
 
    "%%                                   {reply, Reply, NextStateName, NextState}|"n
1540
 
    "%%                                   {reply, Reply, NextStateName, " n
1541
 
    "%%                                    NextState, Timeout} |" n
1542
 
    "%%                                   {stop, Reason, NewState}|" n
1543
 
    "%%                                   {stop, Reason, Reply, NewState}" n
1544
 
    "%% Description: There should be one instance of this function for each" n
1545
 
    "%% possible state name. Whenever a gen_fsm receives an event sent using" n
1546
 
    "%% gen_fsm:sync_send_event/2,3, the instance of this function with the same"n
1547
 
    "%% name as the current state name StateName is called to handle the event." n
1548
 
    (erlang-skel-separator 2)
1549
 
    "state_name(_Event, _From, State) ->" n>
1550
 
    "Reply = ok," n>
1551
 
    "{reply, Reply, state_name, State}." n
1552
 
    n
1553
 
    (erlang-skel-separator 2)
1554
 
    "%% Function: " n
1555
 
    "%% handle_event(Event, StateName, State) -> {next_state, NextStateName, "n
1556
 
    "%%                                           NextState} |" n
1557
 
    "%%                                          {next_state, NextStateName, "n
1558
 
    "%%                                           NextState, Timeout} |" n
1559
 
    "%%                                          {stop, Reason, NewState}" n
1560
 
    "%% Description: Whenever a gen_fsm receives an event sent using"n
1561
 
    "%% gen_fsm:send_all_state_event/2, this function is called to handle"n
1562
 
    "%% the event." n
1563
 
    (erlang-skel-separator 2)
1564
 
    "handle_event(_Event, StateName, State) ->" n>
1565
 
    "{next_state, StateName, State}." n
1566
 
    n
1567
 
    (erlang-skel-separator 2)
1568
 
    "%% Function: " n
1569
 
    "%% handle_sync_event(Event, From, StateName, "n
1570
 
    "%%                   State) -> {next_state, NextStateName, NextState} |" n
1571
 
    "%%                             {next_state, NextStateName, NextState, " n
1572
 
    "%%                              Timeout} |" n
1573
 
    "%%                             {reply, Reply, NextStateName, NextState}|" n
1574
 
    "%%                             {reply, Reply, NextStateName, NextState, " n
1575
 
    "%%                              Timeout} |" n
1576
 
    "%%                             {stop, Reason, NewState} |" n
1577
 
    "%%                             {stop, Reason, Reply, NewState}" n
1578
 
    "%% Description: Whenever a gen_fsm receives an event sent using"n
1579
 
    "%% gen_fsm:sync_send_all_state_event/2,3, this function is called to handle"n
1580
 
    "%% the event."n
1581
 
    (erlang-skel-separator 2)
1582
 
    "handle_sync_event(Event, From, StateName, State) ->" n>
1583
 
    "Reply = ok," n>
1584
 
    "{reply, Reply, StateName, State}." n
1585
 
    n
1586
 
    (erlang-skel-separator 2)
1587
 
    "%% Function: " n
1588
 
    "%% handle_info(Info,StateName,State)-> {next_state, NextStateName, NextState}|" n
1589
 
    "%%                                     {next_state, NextStateName, NextState, "n
1590
 
    "%%                                       Timeout} |" n
1591
 
    "%%                                     {stop, Reason, NewState}" n
1592
 
    "%% Description: This function is called by a gen_fsm when it receives any"n
1593
 
    "%% other message than a synchronous or asynchronous event"n
1594
 
    "%% (or a system message)." n
1595
 
    (erlang-skel-separator 2)
1596
 
    "handle_info(_Info, StateName, State) ->" n>
1597
 
    "{next_state, StateName, State}." n
1598
 
    n
1599
 
    (erlang-skel-separator 2)
1600
 
    "%% Function: terminate(Reason, StateName, State) -> void()" n
1601
 
    "%% Description:This function is called by a gen_fsm when it is about"n
1602
 
    "%% to terminate. It should be the opposite of Module:init/1 and do any"n
1603
 
    "%% necessary cleaning up. When it returns, the gen_fsm terminates with"n
1604
 
    "%% Reason. The return value is ignored." n
1605
 
    (erlang-skel-separator 2)
1606
 
    "terminate(_Reason, _StateName, _State) ->" n>
1607
 
    "ok." n
1608
 
    n
1609
 
    (erlang-skel-separator 2)
1610
 
    "%% Function:" n
1611
 
    "%% code_change(OldVsn, StateName, State, Extra) -> {ok, StateName, NewState}" n
1612
 
    "%% Description: Convert process state when code is changed" n
1613
 
    (erlang-skel-separator 2)
1614
 
    "code_change(_OldVsn, StateName, State, _Extra) ->" n>
1615
 
    "{ok, StateName, State}." n
1616
 
    n
1617
 
    (erlang-skel-separator 2)
1618
 
    "%%% Internal functions" n
1619
 
    (erlang-skel-separator 2)
1620
 
    )
1621
 
  "*The template of a gen_fsm.
1622
 
Please see the function `tempo-define-template'.")
1623
 
 
1624
 
(defvar erlang-skel-lib
1625
 
  '((erlang-skel-include erlang-skel-large-header)
1626
 
 
1627
 
    "%% API" n
1628
 
    "-export([])." n n
1629
 
    
1630
 
    (erlang-skel-double-separator 2)
1631
 
    "%% API" n
1632
 
    (erlang-skel-double-separator 2)
1633
 
    (erlang-skel-separator 2)
1634
 
    "%% Function: " n
1635
 
    "%% Description:" n
1636
 
    (erlang-skel-separator 2) 
1637
 
    n
1638
 
    (erlang-skel-double-separator 2)
1639
 
    "%% Internal functions" n
1640
 
    (erlang-skel-double-separator 2)
1641
 
    )
1642
 
  "*The template of a library module.
1643
 
Please see the function `tempo-define-template'.")
1644
 
 
1645
 
(defvar erlang-skel-corba-callback
1646
 
  '((erlang-skel-include erlang-skel-large-header)
1647
 
    "%% Include files" n n
1648
 
 
1649
 
    "%% API" n
1650
 
    "-export([])." n n
1651
 
 
1652
 
    "%% Corba callbacks" n
1653
 
    "-export([init/1, terminate/2, code_change/3])." n n
1654
 
 
1655
 
    "-record(state, {})." n n
1656
 
    
1657
 
    (erlang-skel-double-separator 2)
1658
 
    "%% Corba callbacks" n
1659
 
    (erlang-skel-double-separator 2)
1660
 
    (erlang-skel-separator 2)
1661
 
    "%% Function: init(Args) -> {ok, State} |" n
1662
 
    "%%                         {ok, State, Timeout} |" n
1663
 
    "%%                         ignore               |" n
1664
 
    "%%                         {stop, Reason}" n
1665
 
    "%% Description: Initiates the server" n
1666
 
    (erlang-skel-separator 2)
1667
 
    "init([]) ->" n>
1668
 
    "{ok, #state{}}." n
1669
 
    n
1670
 
    (erlang-skel-separator 2)
1671
 
    "%% Function: terminate(Reason, State) -> void()" n
1672
 
    "%% Description: Shutdown the server" n
1673
 
    (erlang-skel-separator 2)
1674
 
    "terminate(_Reason, _State) ->" n>
1675
 
    "ok." n
1676
 
    n
1677
 
    (erlang-skel-separator 2)
1678
 
    "%% Function: code_change(OldVsn, State, Extra) -> {ok, NewState} " n
1679
 
    "%% Description: Convert process state when code is changed" n
1680
 
    (erlang-skel-separator 2)
1681
 
    "code_change(_OldVsn, State, _Extra) ->" n>
1682
 
    "{ok, State}." n
1683
 
    n
1684
 
    (erlang-skel-double-separator 2)
1685
 
    "%% Internal functions" n
1686
 
    (erlang-skel-double-separator 2)
1687
 
    )
1688
 
  "*The template of a library module.
1689
 
Please see the function `tempo-define-template'.")
1690
 
 
1691
 
(defvar erlang-skel-ts-test-suite
1692
 
 '((erlang-skel-include erlang-skel-large-header)
1693
 
   "%% Note: This directive should only be used in test suites." n
1694
 
    "-compile(export_all)." n n
1695
 
 
1696
 
    "-include(\"test_server.hrl\")." n n
1697
 
 
1698
 
    (erlang-skel-separator 2)    
1699
 
    "%% TEST SERVER CALLBACK FUNCTIONS" n
1700
 
    (erlang-skel-separator 2)
1701
 
    n
1702
 
    (erlang-skel-separator 2)
1703
 
    "%% Function: init_per_suite(Config0) -> Config1 | {skip,Reason}" n
1704
 
    "%%" n
1705
 
    "%% Config0 = Config1 = [tuple()]" n
1706
 
    "%%   A list of key/value pairs, holding the test case configuration." n
1707
 
    "%% Reason = term()" n
1708
 
    "%%   The reason for skipping the suite." n
1709
 
    "%%" n
1710
 
    "%% Description: Initialization before the suite." n
1711
 
    "%%" n
1712
 
    "%% Note: This function is free to add any key/value pairs to the Config" n
1713
 
    "%% variable, but should NOT alter/remove any existing entries." n
1714
 
    (erlang-skel-separator 2) 
1715
 
    "init_per_suite(Config) ->" n >
1716
 
    "Config." n n
1717
 
 
1718
 
    (erlang-skel-separator 2)
1719
 
    "%% Function: end_per_suite(Config) -> void()" n
1720
 
    "%%" n
1721
 
    "%% Config = [tuple()]" n
1722
 
    "%%   A list of key/value pairs, holding the test case configuration." n
1723
 
    "%%" n
1724
 
    "%% Description: Cleanup after the suite." n
1725
 
    (erlang-skel-separator 2)
1726
 
    "end_per_suite(_Config) ->" n >
1727
 
    "ok." n n
1728
 
 
1729
 
    (erlang-skel-separator 2)
1730
 
    "%% Function: init_per_testcase(TestCase, Config0) -> Config1 |" n 
1731
 
    "%%                                                   {skip,Reason}" n
1732
 
    "%% TestCase = atom()" n
1733
 
    "%%   Name of the test case that is about to run." n
1734
 
    "%% Config0 = Config1 = [tuple()]" n
1735
 
    "%%   A list of key/value pairs, holding the test case configuration." n
1736
 
    "%% Reason = term()" n
1737
 
    "%%   The reason for skipping the test case." n
1738
 
    "%%" n
1739
 
    "%% Description: Initialization before each test case." n
1740
 
    "%%" n
1741
 
    "%% Note: This function is free to add any key/value pairs to the Config" n
1742
 
    "%% variable, but should NOT alter/remove any existing entries." n
1743
 
    (erlang-skel-separator 2)
1744
 
    "init_per_testcase(_TestCase, Config) ->" n >
1745
 
    "Config." n n
1746
 
 
1747
 
    (erlang-skel-separator 2)
1748
 
    "%% Function: end_per_testcase(TestCase, Config) -> void()" n
1749
 
    "%%" n
1750
 
    "%% TestCase = atom()" n
1751
 
    "%%   Name of the test case that is finished." n
1752
 
    "%% Config = [tuple()]" n
1753
 
    "%%   A list of key/value pairs, holding the test case configuration." n
1754
 
    "%%" n
1755
 
    "%% Description: Cleanup after each test case." n
1756
 
    (erlang-skel-separator 2)
1757
 
    "end_per_testcase(_TestCase, _Config) ->" n >
1758
 
    "ok."n n
1759
 
 
1760
 
    (erlang-skel-separator 2)
1761
 
    "%% Function: all(Clause) -> Descr | Spec | {skip,Reason}" n
1762
 
    "%%" n
1763
 
    "%% Clause = doc | suite" n
1764
 
    "%%   Indicates expected return value." n
1765
 
    "%% Descr = [string()] | []" n
1766
 
    "%%   String that describes the test suite." n
1767
 
    "%% Spec = [TestCase]" n
1768
 
    "%%   A test specification." n
1769
 
    "%% TestCase = ConfCase | atom()" n
1770
 
    "%%   Configuration case, or the name of a test case function." n
1771
 
    "%% ConfCase = {conf,Init,Spec,End} |" n
1772
 
    "%%            {conf,Properties,Init,Spec,End}" n
1773
 
    "%% Init = End = {Mod,Func} | Func" n
1774
 
    "%%   Initialization and cleanup function." n
1775
 
    "%% Mod = Func = atom()" n
1776
 
    "%% Properties = [parallel | sequence | Shuffle | {RepeatType,N}]" n
1777
 
    "%%   Execution properties of the test cases (may be combined)." n
1778
 
    "%% Shuffle = shuffle | {shuffle,Seed}" n
1779
 
    "%%   To get cases executed in random order." n
1780
 
    "%% Seed = {integer(),integer(),integer()}" n
1781
 
    "%% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail |" n
1782
 
    "%%              repeat_until_any_ok | repeat_until_any_fail" n
1783
 
    "%%   To get execution of cases repeated." n
1784
 
    "%% N = integer() | forever" n
1785
 
    "%% Reason = term()" n
1786
 
    "%%   The reason for skipping the test suite." n
1787
 
    "%%" n
1788
 
    "%% Description: Returns a description of the test suite when" n
1789
 
    "%%              Clause == doc, and a test specification (list" n
1790
 
    "%%              of the conf and test cases in the suite) when" n
1791
 
    "%%              Clause == suite." n
1792
 
    (erlang-skel-separator 2)
1793
 
    "all(doc) -> " n >
1794
 
    "[\"Describe the main purpose of this suite\"];" n n
1795
 
    "all(suite) -> " n >
1796
 
    "[a_test_case]." n n
1797
 
    n
1798
 
    (erlang-skel-separator 2)
1799
 
    "%% TEST CASES" n
1800
 
    (erlang-skel-separator 2)
1801
 
    n
1802
 
    (erlang-skel-separator 2)
1803
 
    "%% Function: TestCase(Arg) -> Descr | Spec | ok | exit() | {skip,Reason}" n
1804
 
    "%%" n
1805
 
    "%% Arg = doc | suite | Config" n
1806
 
    "%%   Indicates expected behaviour and return value." n
1807
 
    "%% Config = [tuple()]" n
1808
 
    "%%   A list of key/value pairs, holding the test case configuration." n
1809
 
    "%% Descr = [string()] | []" n
1810
 
    "%%   String that describes the test case." n 
1811
 
    "%% Spec = [tuple()] | []" n
1812
 
    "%%   A test specification, see all/1." n
1813
 
    "%% Reason = term()" n
1814
 
    "%%   The reason for skipping the test case." n
1815
 
    "%%" n
1816
 
    "%% Description: Test case function. Returns a description of the test" n
1817
 
    "%%              case (doc), then returns a test specification (suite)," n
1818
 
    "%%              or performs the actual test (Config)." n
1819
 
    (erlang-skel-separator 2)
1820
 
    "a_test_case(doc) -> " n >
1821
 
    "[\"Describe the main purpose of this test case\"];" n n
1822
 
    "a_test_case(suite) -> " n >
1823
 
    "[];" n n
1824
 
    "a_test_case(Config) when is_list(Config) -> " n >
1825
 
    "ok." n
1826
 
   )
1827
 
 "*The template of a library module.
1828
 
Please see the function `tempo-define-template'.")
1829
 
 
1830
 
(defvar erlang-skel-ct-test-suite-l
1831
 
 '((erlang-skel-include erlang-skel-large-header)
1832
 
   "%% Note: This directive should only be used in test suites." n
1833
 
    "-compile(export_all)." n n
1834
 
 
1835
 
    "-include(\"ct.hrl\")." n n
1836
 
 
1837
 
    (erlang-skel-separator 2)
1838
 
    "%% COMMON TEST CALLBACK FUNCTIONS" n
1839
 
    (erlang-skel-separator 2)
1840
 
    n
1841
 
    (erlang-skel-separator 2)
1842
 
    "%% Function: suite() -> Info" n
1843
 
    "%%" n
1844
 
    "%% Info = [tuple()]" n
1845
 
    "%%   List of key/value pairs." n
1846
 
    "%%" n
1847
 
    "%% Description: Returns list of tuples to set default properties" n
1848
 
    "%%              for the suite." n
1849
 
    "%%" n
1850
 
    "%% Note: The suite/0 function is only meant to be used to return" n
1851
 
    "%% default data values, not perform any other operations." n  
1852
 
    (erlang-skel-separator 2) 
1853
 
    "suite() ->" n >
1854
 
    "[{timetrap,{minutes,10}}]." n n
1855
 
 
1856
 
    (erlang-skel-separator 2)
1857
 
    "%% Function: init_per_suite(Config0) ->" n
1858
 
    "%%               Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n
1859
 
    "%%" n
1860
 
    "%% Config0 = Config1 = [tuple()]" n
1861
 
    "%%   A list of key/value pairs, holding the test case configuration." n
1862
 
    "%% Reason = term()" n
1863
 
    "%%   The reason for skipping the suite." n
1864
 
    "%%" n
1865
 
    "%% Description: Initialization before the suite." n
1866
 
    "%%" n
1867
 
    "%% Note: This function is free to add any key/value pairs to the Config" n
1868
 
    "%% variable, but should NOT alter/remove any existing entries." n
1869
 
    (erlang-skel-separator 2) 
1870
 
    "init_per_suite(Config) ->" n >
1871
 
    "Config." n n
1872
 
 
1873
 
    (erlang-skel-separator 2)
1874
 
    "%% Function: end_per_suite(Config0) -> void() | {save_config,Config1}" n
1875
 
    "%%" n
1876
 
    "%% Config0 = Config1 = [tuple()]" n
1877
 
    "%%   A list of key/value pairs, holding the test case configuration." n
1878
 
    "%%" n
1879
 
    "%% Description: Cleanup after the suite." n
1880
 
    (erlang-skel-separator 2)
1881
 
    "end_per_suite(_Config) ->" n >
1882
 
    "ok." n n
1883
 
 
1884
 
    (erlang-skel-separator 2)
1885
 
    "%% Function: init_per_group(GroupName, Config0) ->" n
1886
 
    "%%               Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n
1887
 
    "%%" n
1888
 
    "%% GroupName = atom()" n
1889
 
    "%%   Name of the test case group that is about to run." n
1890
 
    "%% Config0 = Config1 = [tuple()]" n
1891
 
    "%%   A list of key/value pairs, holding configuration data for the group." n
1892
 
    "%% Reason = term()" n
1893
 
    "%%   The reason for skipping all test cases and subgroups in the group." n
1894
 
    "%%" n
1895
 
    "%% Description: Initialization before each test case group." n
1896
 
    (erlang-skel-separator 2)
1897
 
    "init_per_group(_GroupName, Config) ->" n >
1898
 
    "Config." n n
1899
 
 
1900
 
    (erlang-skel-separator 2)
1901
 
    "%% Function: end_per_group(GroupName, Config0) ->" n
1902
 
    "%%               void() | {save_config,Config1}" n
1903
 
    "%%" n
1904
 
    "%% GroupName = atom()" n
1905
 
    "%%   Name of the test case group that is finished." n
1906
 
    "%% Config0 = Config1 = [tuple()]" n
1907
 
    "%%   A list of key/value pairs, holding configuration data for the group." n
1908
 
    "%%" n
1909
 
    "%% Description: Cleanup after each test case group." n
1910
 
    (erlang-skel-separator 2)
1911
 
    "end_per_group(_GroupName, _Config) ->" n >
1912
 
    "ok." n n
1913
 
 
1914
 
    (erlang-skel-separator 2)
1915
 
    "%% Function: init_per_testcase(TestCase, Config0) ->" n
1916
 
    "%%               Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n
1917
 
    "%%" n
1918
 
    "%% TestCase = atom()" n
1919
 
    "%%   Name of the test case that is about to run." n
1920
 
    "%% Config0 = Config1 = [tuple()]" n
1921
 
    "%%   A list of key/value pairs, holding the test case configuration." n
1922
 
    "%% Reason = term()" n
1923
 
    "%%   The reason for skipping the test case." n
1924
 
    "%%" n
1925
 
    "%% Description: Initialization before each test case." n
1926
 
    "%%" n
1927
 
    "%% Note: This function is free to add any key/value pairs to the Config" n
1928
 
    "%% variable, but should NOT alter/remove any existing entries." n
1929
 
    (erlang-skel-separator 2)
1930
 
    "init_per_testcase(_TestCase, Config) ->" n >
1931
 
    "Config." n n
1932
 
 
1933
 
    (erlang-skel-separator 2)
1934
 
    "%% Function: end_per_testcase(TestCase, Config0) ->" n 
1935
 
    "%%               void() | {save_config,Config1} | {fail,Reason}" n
1936
 
    "%%" n
1937
 
    "%% TestCase = atom()" n
1938
 
    "%%   Name of the test case that is finished." n
1939
 
    "%% Config0 = Config1 = [tuple()]" n
1940
 
    "%%   A list of key/value pairs, holding the test case configuration." n
1941
 
    "%% Reason = term()" n
1942
 
    "%%   The reason for failing the test case." n
1943
 
    "%%" n
1944
 
    "%% Description: Cleanup after each test case." n
1945
 
    (erlang-skel-separator 2)
1946
 
    "end_per_testcase(_TestCase, _Config) ->" n >
1947
 
    "ok." n n
1948
 
 
1949
 
    (erlang-skel-separator 2)
1950
 
    "%% Function: groups() -> [Group]" n
1951
 
    "%%" n
1952
 
    "%% Group = {GroupName,Properties,GroupsAndTestCases}" n
1953
 
    "%% GroupName = atom()" n
1954
 
    "%%   The name of the group." n
1955
 
    "%% Properties = [parallel | sequence | Shuffle | {RepeatType,N}]" n
1956
 
    "%%   Group properties that may be combined." n
1957
 
    "%% GroupsAndTestCases = [Group | {group,GroupName} | TestCase]" n
1958
 
    "%% TestCase = atom()" n
1959
 
    "%%   The name of a test case." n
1960
 
    "%% Shuffle = shuffle | {shuffle,Seed}" n
1961
 
    "%%   To get cases executed in random order." n
1962
 
    "%% Seed = {integer(),integer(),integer()}" n
1963
 
    "%% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail |" n
1964
 
    "%%              repeat_until_any_ok | repeat_until_any_fail" n
1965
 
    "%%   To get execution of cases repeated." n
1966
 
    "%% N = integer() | forever" n
1967
 
    "%%" n
1968
 
    "%% Description: Returns a list of test case group definitions." n
1969
 
    (erlang-skel-separator 2)
1970
 
    "groups() ->" n >
1971
 
    "[]." n n
1972
 
 
1973
 
    (erlang-skel-separator 2)
1974
 
    "%% Function: all() -> GroupsAndTestCases | {skip,Reason}" n
1975
 
    "%%" n
1976
 
    "%% GroupsAndTestCases = [{group,GroupName} | TestCase]" n
1977
 
    "%% GroupName = atom()" n
1978
 
    "%%   Name of a test case group." n
1979
 
    "%% TestCase = atom()" n
1980
 
    "%%   Name of a test case." n
1981
 
    "%% Reason = term()" n
1982
 
    "%%   The reason for skipping all groups and test cases." n
1983
 
    "%%" n
1984
 
    "%% Description: Returns the list of groups and test cases that" n 
1985
 
    "%%              are to be executed." n
1986
 
    (erlang-skel-separator 2)
1987
 
    "all() -> " n >
1988
 
    "[my_test_case]." n n
1989
 
    
1990
 
    n
1991
 
    (erlang-skel-separator 2)
1992
 
    "%% TEST CASES" n
1993
 
    (erlang-skel-separator 2)
1994
 
    n
1995
 
 
1996
 
    (erlang-skel-separator 2)
1997
 
    "%% Function: TestCase() -> Info" n
1998
 
    "%%" n
1999
 
    "%% Info = [tuple()]" n
2000
 
    "%%   List of key/value pairs." n
2001
 
    "%%" n
2002
 
    "%% Description: Test case info function - returns list of tuples to set" n
2003
 
    "%%              properties for the test case." n
2004
 
    "%%" n
2005
 
    "%% Note: This function is only meant to be used to return a list of" n
2006
 
    "%% values, not perform any other operations." n  
2007
 
    (erlang-skel-separator 2)
2008
 
    "my_test_case() -> " n >
2009
 
    "[]." n n
2010
 
 
2011
 
    (erlang-skel-separator 2)
2012
 
    "%% Function: TestCase(Config0) ->" n
2013
 
    "%%               ok | exit() | {skip,Reason} | {comment,Comment} |" n
2014
 
    "%%               {save_config,Config1} | {skip_and_save,Reason,Config1}" n
2015
 
    "%%" n
2016
 
    "%% Config0 = Config1 = [tuple()]" n
2017
 
    "%%   A list of key/value pairs, holding the test case configuration." n
2018
 
    "%% Reason = term()" n
2019
 
    "%%   The reason for skipping the test case." n
2020
 
    "%% Comment = term()" n
2021
 
    "%%   A comment about the test case that will be printed in the html log." n
2022
 
    "%%" n
2023
 
    "%% Description: Test case function. (The name of it must be specified in" n
2024
 
    "%%              the all/0 list or in a test case group for the test case" n
2025
 
    "%%              to be executed)." n
2026
 
    (erlang-skel-separator 2)
2027
 
    "my_test_case(_Config) -> " n >
2028
 
    "ok." n
2029
 
    )
2030
 
 "*The template of a library module.
2031
 
Please see the function `tempo-define-template'.")
2032
 
 
2033
 
(defvar erlang-skel-ct-test-suite-s
2034
 
 '((erlang-skel-include erlang-skel-large-header)
2035
 
    "-compile(export_all)." n n
2036
 
 
2037
 
    "-include(\"ct.hrl\")." n n
2038
 
 
2039
 
    (erlang-skel-separator 2)
2040
 
    "%% Function: suite() -> Info" n
2041
 
    "%% Info = [tuple()]" n
2042
 
    (erlang-skel-separator 2) 
2043
 
    "suite() ->" n >
2044
 
    "[{timetrap,{seconds,30}}]." n n
2045
 
 
2046
 
    (erlang-skel-separator 2)
2047
 
    "%% Function: init_per_suite(Config0) ->" n
2048
 
    "%%               Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n
2049
 
    "%% Config0 = Config1 = [tuple()]" n
2050
 
    "%% Reason = term()" n
2051
 
    (erlang-skel-separator 2) 
2052
 
    "init_per_suite(Config) ->" n >
2053
 
    "Config." n n
2054
 
 
2055
 
    (erlang-skel-separator 2)
2056
 
    "%% Function: end_per_suite(Config0) -> void() | {save_config,Config1}" n
2057
 
    "%% Config0 = Config1 = [tuple()]" n
2058
 
    (erlang-skel-separator 2)
2059
 
    "end_per_suite(_Config) ->" n >
2060
 
    "ok." n n
2061
 
 
2062
 
    (erlang-skel-separator 2)
2063
 
    "%% Function: init_per_group(GroupName, Config0) ->" n
2064
 
    "%%               Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n
2065
 
    "%% GroupName = atom()" n
2066
 
    "%% Config0 = Config1 = [tuple()]" n
2067
 
    "%% Reason = term()" n
2068
 
    (erlang-skel-separator 2)
2069
 
    "init_per_group(_GroupName, Config) ->" n >
2070
 
    "Config." n n
2071
 
 
2072
 
    (erlang-skel-separator 2)
2073
 
    "%% Function: end_per_group(GroupName, Config0) ->" n
2074
 
    "%%               void() | {save_config,Config1}" n
2075
 
    "%% GroupName = atom()" n
2076
 
    "%% Config0 = Config1 = [tuple()]" n
2077
 
    (erlang-skel-separator 2)
2078
 
    "end_per_group(_GroupName, _Config) ->" n >
2079
 
    "ok." n n
2080
 
 
2081
 
    (erlang-skel-separator 2)
2082
 
    "%% Function: init_per_testcase(TestCase, Config0) ->" n
2083
 
    "%%               Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n
2084
 
    "%% TestCase = atom()" n
2085
 
    "%% Config0 = Config1 = [tuple()]" n
2086
 
    "%% Reason = term()" n
2087
 
    (erlang-skel-separator 2)
2088
 
    "init_per_testcase(_TestCase, Config) ->" n >
2089
 
    "Config." n n
2090
 
 
2091
 
    (erlang-skel-separator 2)
2092
 
    "%% Function: end_per_testcase(TestCase, Config0) ->" n 
2093
 
    "%%               void() | {save_config,Config1} | {fail,Reason}" n
2094
 
    "%% TestCase = atom()" n
2095
 
    "%% Config0 = Config1 = [tuple()]" n
2096
 
    "%% Reason = term()" n
2097
 
    (erlang-skel-separator 2)
2098
 
    "end_per_testcase(_TestCase, _Config) ->" n >
2099
 
    "ok." n n
2100
 
 
2101
 
    (erlang-skel-separator 2)
2102
 
    "%% Function: groups() -> [Group]" n
2103
 
    "%% Group = {GroupName,Properties,GroupsAndTestCases}" n
2104
 
    "%% GroupName = atom()" n
2105
 
    "%% Properties = [parallel | sequence | Shuffle | {RepeatType,N}]" n
2106
 
    "%% GroupsAndTestCases = [Group | {group,GroupName} | TestCase]" n
2107
 
    "%% TestCase = atom()" n
2108
 
    "%% Shuffle = shuffle | {shuffle,{integer(),integer(),integer()}}" n
2109
 
    "%% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail |" n
2110
 
    "%%              repeat_until_any_ok | repeat_until_any_fail" n
2111
 
    "%% N = integer() | forever" n
2112
 
    (erlang-skel-separator 2)
2113
 
    "groups() ->" n >
2114
 
    "[]." n n
2115
 
 
2116
 
    (erlang-skel-separator 2)
2117
 
    "%% Function: all() -> GroupsAndTestCases | {skip,Reason}" n
2118
 
    "%% GroupsAndTestCases = [{group,GroupName} | TestCase]" n
2119
 
    "%% GroupName = atom()" n
2120
 
    "%% TestCase = atom()" n
2121
 
    "%% Reason = term()" n
2122
 
    (erlang-skel-separator 2)
2123
 
    "all() -> " n >
2124
 
    "[my_test_case]." n n
2125
 
    
2126
 
    (erlang-skel-separator 2)
2127
 
    "%% Function: TestCase() -> Info" n
2128
 
    "%% Info = [tuple()]" n
2129
 
    (erlang-skel-separator 2)
2130
 
    "my_test_case() -> " n >
2131
 
    "[]." n n
2132
 
 
2133
 
    (erlang-skel-separator 2)
2134
 
    "%% Function: TestCase(Config0) ->" n
2135
 
    "%%               ok | exit() | {skip,Reason} | {comment,Comment} |" n
2136
 
    "%%               {save_config,Config1} | {skip_and_save,Reason,Config1}" n
2137
 
    "%% Config0 = Config1 = [tuple()]" n
2138
 
    "%% Reason = term()" n
2139
 
    "%% Comment = term()" n
2140
 
    (erlang-skel-separator 2)
2141
 
    "my_test_case(_Config) -> " n >
2142
 
    "ok." n
2143
 
    )
2144
 
 "*The template of a library module.
2145
 
Please see the function `tempo-define-template'.")
 
955
(load erlang-skel-file)
2146
956
 
2147
957
;; Font-lock variables
2148
958
 
2226
1036
   (list (concat "^\\(-" erlang-atom-regexp "\\)\\(\\s-\\|\\.\\|(\\)")   
2227
1037
         1 (if (boundp 'font-lock-preprocessor-face)
2228
1038
               'font-lock-preprocessor-face
2229
 
             'font-lock-function-name-face)))
 
1039
             'font-lock-constant-face)))
2230
1040
  "Font lock keyword highlighting attributes.")
2231
1041
 
2232
1042
(defvar erlang-font-lock-keywords-quotes
2257
1067
  (list
2258
1068
   (list (concat "?\\s-*\\(" erlang-atom-regexp
2259
1069
                 "\\|" erlang-variable-regexp "\\)")
2260
 
         1 'font-lock-type-face)
 
1070
         1 'font-lock-constant-face)
2261
1071
   (list (concat "^\\(-\\(?:define\\|ifn?def\\)\\)\\s-*(\\s-*\\(" erlang-atom-regexp
2262
1072
                 "\\|" erlang-variable-regexp "\\)")
2263
 
         (list 1 'font-lock-preprocessor-face t)
 
1073
         (if (boundp 'font-lock-preprocessor-face)
 
1074
             (list 1 'font-lock-preprocessor-face t)
 
1075
           (list 1 'font-lock-constant-face t))
2264
1076
         (list 3 'font-lock-type-face t t))
2265
1077
   (list "^-e\\(lse\\|ndif\\)\\>" 0 'font-lock-preprocessor-face t))
2266
1078
  "Font lock keyword highlighting macros.
2483
1295
  (setq major-mode 'erlang-mode)
2484
1296
  (setq mode-name "Erlang")
2485
1297
  (erlang-syntax-table-init)
2486
 
  (erlang-keymap-init)
 
1298
  (use-local-map erlang-mode-map)
2487
1299
  (erlang-electric-init)
2488
1300
  (erlang-menu-init)
2489
1301
  (erlang-mode-variables)
2538
1350
  (set-syntax-table erlang-mode-syntax-table))
2539
1351
 
2540
1352
 
2541
 
(defun erlang-keymap-init ()
2542
 
  (if erlang-mode-map
2543
 
      nil
2544
 
    (setq erlang-mode-map (make-sparse-keymap))
2545
 
    (erlang-mode-commands erlang-mode-map))
2546
 
  (use-local-map erlang-mode-map))
2547
 
 
2548
 
 
2549
 
(defun erlang-mode-commands (map)
2550
 
  (unless (boundp 'indent-line-function)
2551
 
    (define-key map "\t"        'erlang-indent-command))
2552
 
  (define-key map ";"         'erlang-electric-semicolon)
2553
 
  (define-key map ","         'erlang-electric-comma)
2554
 
  (define-key map "<"         'erlang-electric-lt)
2555
 
  (define-key map ">"         'erlang-electric-gt)
2556
 
  (define-key map "\C-m"      'erlang-electric-newline)
2557
 
  (if (not (boundp 'delete-key-deletes-forward))
2558
 
      (define-key map "\177" 'backward-delete-char-untabify)
2559
 
    (define-key map [(backspace)] 'backward-delete-char-untabify))
2560
 
  ;;(unless (boundp 'fill-paragraph-function)
2561
 
  (define-key map "\M-q"      'erlang-fill-paragraph)
2562
 
  (unless (boundp 'beginning-of-defun-function)
2563
 
    (define-key map "\M-\C-a"   'erlang-beginning-of-function)
2564
 
    (define-key map "\M-\C-e"   'erlang-end-of-function)
2565
 
    (define-key map '(meta control h)   'erlang-mark-function)) ; Xemacs
2566
 
  (define-key map "\M-\t"     'erlang-complete-tag)
2567
 
  (define-key map "\C-c\M-\t" 'tempo-complete-tag)
2568
 
  (define-key map "\M-+"      'erlang-find-next-tag)  
2569
 
  (define-key map "\C-c\M-a"  'erlang-beginning-of-clause)
2570
 
  (define-key map "\C-c\M-b"  'tempo-backward-mark)
2571
 
  (define-key map "\C-c\M-e"  'erlang-end-of-clause)
2572
 
  (define-key map "\C-c\M-f"  'tempo-forward-mark)
2573
 
  (define-key map "\C-c\M-h"  'erlang-mark-clause)
2574
 
  (define-key map "\C-c\C-c"  'comment-region)
2575
 
  (define-key map "\C-c\C-j"  'erlang-generate-new-clause)
2576
 
  (define-key map "\C-c\C-k"  'erlang-compile)
2577
 
  (define-key map "\C-c\C-l"  'erlang-compile-display)
2578
 
  (define-key map "\C-c\C-s"  'erlang-show-syntactic-information)
2579
 
  (define-key map "\C-c\C-q"  'erlang-indent-function)
2580
 
  (define-key map "\C-c\C-u"  'erlang-uncomment-region)
2581
 
  (define-key map "\C-c\C-y"  'erlang-clone-arguments)
2582
 
  (define-key map "\C-c\C-a"  'erlang-align-arrows)
2583
 
  (define-key map "\C-c\C-z"  'erlang-shell-display)
2584
 
  (unless inferior-erlang-use-cmm
2585
 
    (define-key map "\C-x`"    'erlang-next-error)))
2586
 
 
2587
 
 
2588
1353
(defun erlang-electric-init ()
2589
1354
  ;; Set up electric character functions to work with
2590
1355
  ;; delsel/pending-del mode. Also, set up text properties for bit
2638
1403
  (set (make-local-variable 'imenu-prev-index-position-function)
2639
1404
       'erlang-beginning-of-function)
2640
1405
  (set (make-local-variable 'imenu-extract-index-name-function)
2641
 
       'erlang-get-function-name)
 
1406
       'erlang-get-function-name-and-arity)
2642
1407
  (set (make-local-variable 'tempo-match-finder)
2643
1408
       "[^-a-zA-Z0-9_]\\([-a-zA-Z0-9_]*\\)\\=")
2644
1409
  (set (make-local-variable 'beginning-of-defun-function)
2719
1484
                                    erlang-font-lock-keywords-3 
2720
1485
                                    erlang-font-lock-keywords-4)
2721
1486
         nil nil ((?_ . "w")) erlang-beginning-of-clause
2722
 
         (font-lock-mark-block-function . erlang-mark-clause))))
 
1487
         (font-lock-mark-block-function . erlang-mark-clause)
 
1488
         (font-lock-syntactic-keywords
 
1489
          ;; A dollar sign right before the double quote that ends a
 
1490
          ;; string is not a character escape.
 
1491
          ;;
 
1492
          ;; And a "string" has with a double quote not escaped by a
 
1493
          ;; dollar sign, any number of non-backslash non-newline
 
1494
          ;; characters or escaped backslashes, a dollar sign
 
1495
          ;; (otherwise we wouldn't care) and a double quote.  This
 
1496
          ;; doesn't match multi-line strings, but this is probably
 
1497
          ;; the best we can get, since while font-locking we don't
 
1498
          ;; know whether matching started inside a string: limiting
 
1499
          ;; search to a single line keeps things sane.
 
1500
          . (("\\(?:^\\|[^$]\\)\"\\(?:[^\"\n]\\|\\\\\"\\)*\\(\\$\\)\"" 1 "w")
 
1501
             ;; And the dollar sign in $\" escapes two characters, not
 
1502
             ;; just one.
 
1503
             ("\\(\\$\\)\\\\\\\"" 1 "'"))))))
2723
1504
 
2724
1505
 
2725
1506
 
3728
2509
            ((looking-at "\\(of\\)[^_a-zA-Z0-9]")
3729
2510
             ;; Must handle separately, try X of -> catch
3730
2511
             (if (and stack (eq (car (car stack)) 'try))
3731
 
                 (let ((try-column (nth 2 (car stack))))
 
2512
                 (let ((try-column (nth 2 (car stack)))
 
2513
                       (try-pos (nth 1 (car stack))))
3732
2514
                   (erlang-pop stack)
3733
 
                   (erlang-push (list 'icr token try-column) stack))))
 
2515
                   (erlang-push (list 'icr try-pos try-column) stack))))
3734
2516
            
3735
2517
            ((looking-at "\\(fun\\)[^_a-zA-Z0-9]")
3736
2518
             ;; Push a new layer if we are defining a `fun'
3792
2574
       
3793
2575
       ;; Clause end
3794
2576
       ((= (following-char) ?\;)
3795
 
        (if (and stack (and (eq (car (car stack)) 'when) 
3796
 
                            (eq (car (car (cdr (cdr stack)))) 'spec)))
3797
 
            (erlang-pop stack))
 
2577
        (if (eq (car (car (last stack))) 'spec)
 
2578
            (while (memq (car (car stack)) '(when ::))
 
2579
              (erlang-pop stack)))
3798
2580
        (if (and stack (eq (car (car stack)) '->))
3799
2581
            (erlang-pop stack))
3800
2582
        (forward-char 1))
3891
2673
      (cond ((eq (car (car stack)) '\()
3892
2674
             (erlang-pop stack)
3893
2675
             (if (and (eq (car (car stack)) 'fun) 
3894
 
                      (eq (car (car (cdr stack))) '::))
 
2676
                      (or (eq (car (car (last stack))) 'spec)
 
2677
                          (eq (car (car (cdr stack))) '::))) ;; -type()
3895
2678
                 ;; Inside fun type def ') closes fun definition
3896
2679
                 (erlang-pop stack)))
3897
2680
            ((eq (car (car stack)) 'icr)
3955
2738
                         (nth 2 stack-top))))
3956
2739
                 (t 
3957
2740
                  (goto-char (nth 1 stack-top))
3958
 
                  (cond ((looking-at "[({]\\s *\\($\\|%\\)")
3959
 
                         ;; Line ends with parenthesis.
3960
 
                         (erlang-indent-parenthesis (nth 2 stack-top)))
3961
 
                        (t
3962
 
                         ;; Indent to the same column as the first
3963
 
                         ;; argument.
3964
 
                         (goto-char (1+ (nth 1 stack-top)))
3965
 
                         (skip-chars-forward " \t")
3966
 
                         (current-column))))))
 
2741
                  (let ((base (cond ((looking-at "[({]\\s *\\($\\|%\\)")
 
2742
                                     ;; Line ends with parenthesis.
 
2743
                                     (erlang-indent-parenthesis (nth 2 stack-top)))
 
2744
                                    (t
 
2745
                                     ;; Indent to the same column as the first
 
2746
                                     ;; argument.
 
2747
                                     (goto-char (1+ (nth 1 stack-top)))
 
2748
                                     (skip-chars-forward " \t")
 
2749
                                     (current-column)))))
 
2750
                    (erlang-indent-standard indent-point token base 't)))))
3967
2751
          ;;
3968
2752
          ((eq (car stack-top) '<<)
3969
2753
           ;; Element of binary (possible comprehension) expression,
3989
2773
           ;;
3990
2774
           ;; `after' should be indented to the same level as the
3991
2775
           ;; corresponding receive.
3992
 
           (cond ((looking-at "\\(after\\|catch\\|of\\)\\($\\|[^_a-zA-Z0-9]\\)")
 
2776
           (cond ((looking-at "\\(after\\|of\\)\\($\\|[^_a-zA-Z0-9]\\)")
3993
2777
                  (nth 2 stack-top))
3994
2778
                 ((looking-at "when[^_a-zA-Z0-9]")
3995
2779
                  ;; Handling one when part
4008
2792
          ((and (eq (car stack-top) '||) (looking-at "\\(]\\|>>\\)[^_a-zA-Z0-9]"))
4009
2793
           (nth 2 (car (cdr stack))))
4010
2794
          ;; Real indentation, where operators create extra indentation etc.
4011
 
          ((memq (car stack-top) '(-> || begin try))
 
2795
          ((memq (car stack-top) '(-> || try begin))
4012
2796
           (if (looking-at "\\(of\\)[^_a-zA-Z0-9]")
4013
2797
               (nth 2 stack-top)
4014
2798
             (goto-char (nth 1 stack-top))
4037
2821
                            (erlang-caddr (car stack))
4038
2822
                          0))
4039
2823
                       ((looking-at "catch\\($\\|[^_a-zA-Z0-9]\\)")
4040
 
                        (if (or (eq (car stack-top) 'try)
4041
 
                                (eq (car (car (cdr stack))) 'icr))
4042
 
                            (progn 
4043
 
                              (if (eq (car stack-top) '->)
4044
 
                                  (erlang-pop stack))
4045
 
                              (if stack
4046
 
                                  (erlang-caddr (car stack))
4047
 
                                0))
4048
 
                          base)) ;; old catch 
 
2824
                        ;; Are we in a try
 
2825
                        (let ((start (if (eq (car stack-top) '->)
 
2826
                                         (car (cdr stack))
 
2827
                                       stack-top)))
 
2828
                          (if (null start) nil
 
2829
                            (goto-char (nth 1 start)))
 
2830
                          (cond ((looking-at "try\\($\\|[^_a-zA-Z0-9]\\)")
 
2831
                                 (progn
 
2832
                                   (if (eq (car stack-top) '->)
 
2833
                                       (erlang-pop stack))
 
2834
                                   (if stack
 
2835
                                       (erlang-caddr (car stack))
 
2836
                                     0)))
 
2837
                                (t (erlang-indent-standard indent-point token base 'nil))))) ;; old catch
4049
2838
                       (t 
4050
 
                        ;; Look at last thing to see how we are to move relative
4051
 
                        ;; to the base.
4052
 
                        (goto-char token)
4053
 
                        (cond ((looking-at "||\\|,\\|->")
4054
 
                               base)
4055
 
                              ((erlang-at-keyword)
4056
 
                               (+ (current-column) erlang-indent-level))
4057
 
                              ((or (= (char-syntax (following-char)) ?.)
4058
 
                                   (erlang-at-operator))
4059
 
                               (+ base erlang-indent-level))
4060
 
                              (t
4061
 
                               (goto-char indent-point)
4062
 
                               (cond ((memq (following-char) '(?\( ?{))
4063
 
                                      ;; Function application or record.
4064
 
                                      (+ (erlang-indent-find-preceding-expr)
4065
 
                                         erlang-argument-indent))
4066
 
                                     ;; Empty line, or end; treat it as the end of
4067
 
                                     ;; the block.  (Here we have a choice: should
4068
 
                                     ;; the user be forced to reindent continued
4069
 
                                     ;; lines, or should the "end" be reindented?)
4070
 
                                     
4071
 
                                     ;; Avoid treating comments a continued line.
4072
 
                                     ((= (following-char) ?%)
4073
 
                                      base)
4074
 
                                     ;; Continued line (e.g. line beginning
4075
 
                                     ;; with an operator.)
4076
 
                                     (t (+ base erlang-indent-level)))))))))
4077
 
               ))
 
2839
                        (erlang-indent-standard indent-point token base 'nil)
 
2840
                        ))))
 
2841
             ))
4078
2842
          ((eq (car stack-top) 'when)
4079
2843
           (goto-char (nth 1 stack-top))
4080
2844
           (if (looking-at "when\\s *\\($\\|%\\)")
4100
2864
             (current-column)))
4101
2865
          ;; Type and Spec indentation
4102
2866
          ((eq (car stack-top) '::)
4103
 
           (cond ((null erlang-argument-indent)
4104
 
                  ;; indent to next column.
4105
 
                  (+ 2 (nth 2 stack-top)))
4106
 
                 ((looking-at "::[^_a-zA-Z0-9]")
4107
 
                  (nth 2 stack-top))
4108
 
                 (t 
4109
 
                  (goto-char (nth 1 stack-top))
4110
 
                  (cond ((looking-at "::\\s *\\($\\|%\\)")
4111
 
                         ;; Line ends with ::
4112
 
                         (+ (erlang-indent-find-preceding-expr 2)
4113
 
                            erlang-argument-indent))
4114
 
                        ;; (* 2 erlang-indent-level))
4115
 
                        (t
4116
 
                         ;; Indent to the same column as the first
4117
 
                         ;; argument.
4118
 
                         (goto-char (+ 2 (nth 1 stack-top)))
4119
 
                         (skip-chars-forward " \t")
4120
 
                         (current-column))))))
 
2867
           (if (looking-at "}")
 
2868
               ;; Closing record definition with types
 
2869
               ;; pop stack and recurse
 
2870
               (erlang-calculate-stack-indent indent-point
 
2871
                                              (cons (erlang-pop stack) (cdr state)))
 
2872
             (cond ((null erlang-argument-indent)
 
2873
                    ;; indent to next column.
 
2874
                    (+ 2 (nth 2 stack-top)))
 
2875
                   ((looking-at "::[^_a-zA-Z0-9]")
 
2876
                    (nth 2 stack-top))
 
2877
                   (t
 
2878
                    (let ((start-alternativ (if (looking-at "|") 2 0)))
 
2879
                      (goto-char (nth 1 stack-top))
 
2880
                      (- (cond ((looking-at "::\\s *\\($\\|%\\)")
 
2881
                                ;; Line ends with ::
 
2882
                                (if (eq (car (car (last stack))) 'spec)
 
2883
                                  (+ (erlang-indent-find-preceding-expr 1)
 
2884
                                     erlang-argument-indent)
 
2885
                                  (+ (erlang-indent-find-preceding-expr 2)
 
2886
                                     erlang-argument-indent)))
 
2887
                               (t
 
2888
                                ;; Indent to the same column as the first
 
2889
                                ;; argument.
 
2890
                                (goto-char (+ 2 (nth 1 stack-top)))
 
2891
                                (skip-chars-forward " \t")
 
2892
                                (current-column))) start-alternativ))))))
4121
2893
          )))
4122
2894
 
 
2895
(defun erlang-indent-standard (indent-point token base inside-parenthesis)
 
2896
  "Standard indent when in blocks or tuple or arguments.
 
2897
   Look at last thing to see in what state we are, move relative to the base."
 
2898
  (goto-char token)  
 
2899
  (cond ((looking-at "||\\|,\\|->\\||")
 
2900
         base)
 
2901
        ((erlang-at-keyword)
 
2902
         (+ (current-column) erlang-indent-level))
 
2903
        ((or (= (char-syntax (following-char)) ?.)
 
2904
             (erlang-at-operator))
 
2905
         (+ base erlang-indent-level))
 
2906
        (t
 
2907
         (goto-char indent-point)
 
2908
         (cond ((memq (following-char) '(?\( ))
 
2909
                ;; Function application.
 
2910
                (+ (erlang-indent-find-preceding-expr)
 
2911
                   erlang-argument-indent))
 
2912
               ;; Empty line, or end; treat it as the end of
 
2913
               ;; the block.  (Here we have a choice: should
 
2914
               ;; the user be forced to reindent continued
 
2915
               ;; lines, or should the "end" be reindented?)
 
2916
               
 
2917
               ;; Avoid treating comments a continued line.
 
2918
               ((= (following-char) ?%)
 
2919
                base)
 
2920
               ;; Continued line (e.g. line beginning
 
2921
               ;; with an operator.)
 
2922
               (t 
 
2923
                (if (or (erlang-at-operator) (not inside-parenthesis)) 
 
2924
                    (+ base erlang-indent-level)
 
2925
                  base))))))
4123
2926
 
4124
2927
(defun erlang-indent-find-base (stack indent-point &optional offset skip)
4125
2928
  "Find the base column for current stack."
4158
2961
      (skip-chars-backward " \t")
4159
2962
      ;; Needed to match the colon in "'foo':'bar'".
4160
2963
      (if (not (memq (preceding-char) '(?# ?:)))
4161
 
          col
4162
 
        (backward-char 1)
4163
 
        (forward-sexp -1)
4164
 
        (current-column)))))
 
2964
          col
 
2965
        ;; Special hack to handle: (note line break)
 
2966
        ;; [#myrecord{
 
2967
        ;;  foo = foo}]
 
2968
        (or
 
2969
         (ignore-errors
 
2970
           (backward-char 1)
 
2971
           (forward-sexp -1)
 
2972
           (current-column))
 
2973
         col)))))
4165
2974
 
4166
2975
(defun erlang-indent-parenthesis (stack-position) 
4167
2976
  (let ((previous (erlang-indent-find-preceding-expr)))
4700
3509
                     (erlang-get-function-arrow)))"
4701
3510
  (and 
4702
3511
   (save-excursion
4703
 
     (re-search-forward "[^-:]*-\\|:" (point-max) t)
4704
 
     (erlang-buffer-substring (- (point) 1) (+ (point) 1)))))
 
3512
     (re-search-forward "->" (point-max) t)
 
3513
     (erlang-buffer-substring (- (point) 2) (+ (point) 1)))))
4705
3514
 
4706
3515
(defun erlang-get-function-arity ()
4707
3516
  "Return the number of arguments of function at point, or nil."
4730
3539
               res)
4731
3540
           (error nil)))))
4732
3541
 
 
3542
(defun erlang-get-function-name-and-arity ()
 
3543
  "Return the name and arity of the function at point, or nil.
 
3544
The return value is a string of the form \"foo/1\"."
 
3545
  (let ((name (erlang-get-function-name))
 
3546
        (arity (erlang-get-function-arity)))
 
3547
    (and name arity (format "%s/%d" name arity))))
 
3548
 
4733
3549
(defun erlang-get-function-arguments ()
4734
3550
  "Return arguments of current function, or nil."
4735
3551
  (if (not (looking-at (eval-when-compile
4905
3721
      (setq erlang-electric-newline-inhibit nil)
4906
3722
    (setq erlang-electric-newline-inhibit t)
4907
3723
    (undo-boundary)
 
3724
    (erlang-indent-line)
4908
3725
    (end-of-line)
4909
3726
    (newline)
4910
3727
    (if (condition-case nil
4946
3763
      (setq erlang-electric-newline-inhibit nil)
4947
3764
    (setq erlang-electric-newline-inhibit t)
4948
3765
    (undo-boundary)
 
3766
    (erlang-indent-line)
4949
3767
    (end-of-line)
4950
3768
    (newline)
4951
3769
    (condition-case nil
6124
4942
(defvar inferior-erlang-buffer nil
6125
4943
  "Buffer of last invoked inferior Erlang, or nil.")
6126
4944
 
 
4945
;; Enable uniquifying Erlang shell buffers based on directory name.
 
4946
(eval-after-load "uniquify"
 
4947
  '(add-to-list 'uniquify-list-buffers-directory-modes 'erlang-shell-mode))
 
4948
 
6127
4949
;;;###autoload
6128
 
(defun inferior-erlang ()
 
4950
(defun inferior-erlang (&optional command)
6129
4951
  "Run an inferior Erlang.
 
4952
With prefix command, prompt for command to start Erlang with.
6130
4953
 
6131
4954
This is just like running Erlang in a normal shell, except that
6132
4955
an Emacs buffer is used for input and output.
6140
4963
The following commands imitate the usual Unix interrupt and
6141
4964
editing control characters:
6142
4965
\\{erlang-shell-mode-map}"
6143
 
  (interactive)
 
4966
  (interactive
 
4967
   (when current-prefix-arg
 
4968
     (list (if (fboundp 'read-shell-command)
 
4969
               ;; `read-shell-command' is a new function in Emacs 23.
 
4970
               (read-shell-command "Erlang command: ")
 
4971
             (read-string "Erlang command: ")))))
6144
4972
  (require 'comint)
6145
 
  (let ((opts inferior-erlang-machine-options))
6146
 
    (cond ((eq inferior-erlang-shell-type 'oldshell)
6147
 
           (setq opts (cons "-oldshell" opts)))
6148
 
          ((eq inferior-erlang-shell-type 'newshell)
6149
 
           (setq opts (append '("-newshell" "-env" "TERM" "vt100") opts))))
6150
 
    (setq inferior-erlang-buffer
6151
 
          (apply 'make-comint
6152
 
                 inferior-erlang-process-name inferior-erlang-machine
6153
 
                 nil opts)))
 
4973
  (let (cmd opts)
 
4974
    (if command
 
4975
        (setq cmd "sh"
 
4976
              opts (list "-c" command))
 
4977
      (setq cmd inferior-erlang-machine
 
4978
            opts inferior-erlang-machine-options)
 
4979
      (cond ((eq inferior-erlang-shell-type 'oldshell)
 
4980
             (setq opts (cons "-oldshell" opts)))
 
4981
            ((eq inferior-erlang-shell-type 'newshell)
 
4982
             (setq opts (append '("-newshell" "-env" "TERM" "vt100") opts)))))
 
4983
 
 
4984
    ;; Using create-file-buffer and list-buffers-directory in this way
 
4985
    ;; makes uniquify give each buffer a unique name based on the
 
4986
    ;; directory.
 
4987
    (let ((fake-file-name (expand-file-name inferior-erlang-buffer-name default-directory)))
 
4988
      (setq inferior-erlang-buffer (create-file-buffer fake-file-name))
 
4989
      (apply 'make-comint-in-buffer
 
4990
             inferior-erlang-process-name
 
4991
             inferior-erlang-buffer
 
4992
             cmd
 
4993
             nil opts)
 
4994
      (with-current-buffer inferior-erlang-buffer
 
4995
        (setq list-buffers-directory fake-file-name))))
 
4996
 
6154
4997
  (setq inferior-erlang-process
6155
4998
        (get-buffer-process inferior-erlang-buffer))
6156
4999
  (if (> 21 erlang-emacs-major-version) ; funcalls to avoid compiler warnings
6163
5006
  (if (and (not (eq system-type 'windows-nt))
6164
5007
           (eq inferior-erlang-shell-type 'newshell))
6165
5008
      (setq comint-process-echoes t))
6166
 
  ;; `rename-buffer' takes only one argument in Emacs 18.
6167
 
  (condition-case nil
6168
 
      (rename-buffer inferior-erlang-buffer-name t)
6169
 
    (error (rename-buffer inferior-erlang-buffer-name)))
6170
5009
  (erlang-shell-mode))
6171
5010
 
6172
5011