Move header @copyright edoc lines above @doc lines.
[erlware-mode.git] / erlang_appwiz.el
blobecbce66f471e1f3ed9974a8acf6164a669a7fbd1
1 ;;; -*- Emacs-Lisp -*-
2 ;;; File: erlang_appwiz.el
3 ;;; Author: Johan Bevermyr
4 ;;; Created: Tue Dec 9 13:14:24 1997
5 ;;; Purpose: Adds a simple application wizard to erlang.el.
7 ;; OBS! Must be loaded before the erlang.el file is loaded.
8 ;; Add the following to your .emacs file before erlang.el is loaded.
9 ;;
10 ;; (load "erlang_appwiz" t nil)
12 ;; Customisation of makefile generation:
14 ;; The templates for generating makefiles are stored in the
15 ;; variables erlang-skel-makefile-src and erlang-skel-makefile-middle.
16 ;;
17 ;; These can be modified by setting the variables before or after this
18 ;; file is loaded.
19 ;;
20 ;; For example, to generate OTP-style make files:
23 ;;(defvar erlang-skel-makefile-src
24 ;; '((erlang-skel-include erlang-skel-nomodule-header)
25 ;; "CC_ROOT := $(shell pwd | sed 's/erts.*$$//')" n
26 ;; "AUTOCONF := $(CC_ROOT)/erts/autoconf" n
27 ;; "TARGET := $(shell $(AUTOCONF)/config.guess)"
28 ;; "include $(CC_ROOT)/internal_tools/make/$(TARGET)/otp.mk" n
29 ;; n
30 ;; "# ----------------------------------------------------" n
31 ;; "# Application version " n
32 ;; "# ----------------------------------------------------" n
33 ;; "include ../vsn.mk" n
34 ;; "VSN=$(KERNEL_VSN)" n
35 ;; n
36 ;; "# ----------------------------------------------------" n
37 ;; "# Release directory specification" n
38 ;; "# ----------------------------------------------------" n
39 ;; "RELEASE_PATH= ../../../release/$(TARGET)" n
40 ;; "RELSYSDIR = $(RELEASE_PATH)/lib/kernel-$(VSN)" n
41 ;; n
42 ;; "# ----------------------------------------------------" n
43 ;; "# Target Specs" n
44 ;; "# ----------------------------------------------------" n
45 ;; n
46 ;; "MODULES= " appwiz-erlang-modulename n
47 ;; n
48 ;; "HRL_FILES="
49 ;; n
50 ;; INTERNAL_HRL_FILES= appwiz-erlang-modulename "_sup.hrl" n
51 ;; n
52 ;; "ERL_FILES= $(MODULES:%=%.erl)" n
53 ;; n
54 ;; "TARGET_FILES= $(MODULES:%=$(EBIN)/%.$(EMULATOR)) $(APP_TARGET)" n
55 ;; n
56 ;; "APP_FILE= " appwiz-erlang-modulename ".app" n
57 ;; n
58 ;; "APP_SRC= $(APP_FILE).src" n
59 ;; "APP_TARGET= ../ebin/$(APP_FILE)" n
60 ;; n
61 ;; "# ----------------------------------------------------" n
62 ;; "# FLAGS " n
63 ;; "# ----------------------------------------------------" n
64 ;; "ERL_FLAGS += " n
65 ;; "ERL_COMPILE_FLAGS += -I../include" n
66 ;; n
67 ;; "# ----------------------------------------------------" n
68 ;; "# Targets" n
69 ;; "# ----------------------------------------------------" n
70 ;; n
71 ;; "debug opt: $(TARGET_FILES)" n
72 ;; n
73 ;; "clean:" n
74 ;; " rm -f $(TARGET_FILES) $(GEN_FILES)" n
75 ;; " rm -f core" n
76 ;; n
77 ;; "docs:" n
78 ;; n
79 ;; "# ----------------------------------------------------" n
80 ;; "# Special Build Targets " n
81 ;; "# ----------------------------------------------------" n
82 ;; " " n
83 ;; "$(APP_TARGET): $(APP_SRC) " n
84 ;; " sed -e 's;%VSN%;$(VSN);' $(APP_SRC) > $(APP_TARGET)" n
85 ;; " " n
86 ;; "# ----------------------------------------------------" n
87 ;; "# Release Target " n
88 ;; "# ----------------------------------------------------" n
89 ;; "include $(CC_ROOT)/internal_tools/make/otp_release_targets.mk" n
90 ;; n
91 ;; "release_spec: opt" n
92 ;; " $(INSTALL_DIR) $(RELSYSDIR)/src " n
93 ;; " $(INSTALL_DATA) $(ERL_FILES) $(RELSYSDIR)/src " n
94 ;; " $(INSTALL_DATA) $(INTERNAL_HRL_FILES) $(RELSYSDIR)/src " n
95 ;; " $(INSTALL_DIR) $(RELSYSDIR)/include " n
96 ;; " $(INSTALL_DATA) $(HRL_FILES) $(RELSYSDIR)/include " n
97 ;; " $(INSTALL_DIR) $(RELSYSDIR)/ebin " n
98 ;; " $(INSTALL_DATA) $(TARGET_FILES) $(RELSYSDIR)/ebin " n
99 ;; n
100 ;; "release_docs_spec:" n
101 ;; ))
106 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
108 ;; Erlang application wizard
111 (defun erlang-application-wizard (directory name)
112 "Creates all files and directories needed for an application.
113 The top-level directory is placed in DIRECTORY. NAME is used when
114 creating the root directory and for naming application files."
116 (interactive "DApplication root directory: \nsName of application: ")
117 (let ((dir nil)
118 (lastchar (substring directory (- (length directory) 1)))
119 (apptype (completing-read "Type of application: "
120 '(("gen_server" 1)
121 ("gen_event" 2)
122 ("gen_fsm" 3)
123 ("other" 4))
124 nil t "gen_server"))
125 (appname nil)
126 (apptemplate nil)
127 (apitemplate nil)
128 (extension nil))
130 (if (string= lastchar "/")
131 (setq dir directory)
132 (setq dir (concat directory "/")))
134 ;; determine type of application
135 (cond ((string= apptype "gen_server")
136 (setq extension "_server")
137 (setq appname (concat name extension))
138 (setq apptemplate 'tempo-template-erlang-generic-server)
139 (setq apitemplate 'tempo-template-erlang-large-header))
140 ((string= apptype "gen_event")
141 (setq extension "_event")
142 (setq appname (concat name extension))
143 (setq apptemplate 'tempo-template-erlang-gen-event)
144 (setq apitemplate 'tempo-template-erlang-large-header))
145 ((string= apptype "gen_fsm")
146 (setq extension "_fsm")
147 (setq appname (concat name extension))
148 (setq apptemplate 'tempo-template-erlang-gen-fsm)
149 (setq apitemplate 'tempo-template-large-header))
151 ;; use defaults _work
152 (setq extension "_work")
153 (setq appname (concat name extension))
154 (setq apptemplate 'tempo-template-erlang-large-header)
155 (setq apitemplate 'tempo-template-erlang-large-header)))
157 (setq appwiz-erlang-modulename appname)
158 (setq appwiz-erlang-ext extension)
160 ;; create directories
161 (make-directory (concat dir name "/" "src") t)
162 (make-directory (concat dir name "/" "ebin") t)
163 (make-directory (concat dir name "/" "include") t)
165 ;; create directory content
166 ;;;;;;;;; .erl
167 (find-file (concat dir name "/" "src/" name ".erl"))
168 (funcall apitemplate)
169 (insert "API module for the application " name ".")
170 (save-buffer)
172 ;;;;;;;;; _app.erl
173 (find-file (concat dir name "/" "src/" name "_app.erl"))
174 (tempo-template-erlang-application)
175 (insert "Application callback module for the application " name ".")
177 (let ((quotedname (erlang-add-quotes-if-needed
178 (concat name "_sup")))
179 (start (point)))
180 (while (search-forward "'TopSupervisor':start_link" nil t)
181 (replace-match (concat quotedname ":start_link") nil t))
182 (goto-char start))
184 (save-buffer)
186 ;;;;;;;;; _sup.erl
187 (find-file (concat dir name "/" "src/" name "_sup.erl"))
188 (tempo-template-erlang-supervisor)
189 (insert "Top level supervisor for the application " name ".")
192 (let ((quotedname (erlang-add-quotes-if-needed appname))
193 (start (point)))
194 (while (search-forward "'AName'" nil t)
195 (replace-match quotedname nil t))
196 (goto-char start))
198 (let ((quotedname (erlang-add-quotes-if-needed appname))
199 (start (point)))
200 (goto-char 0)
201 (while (search-forward "'AMODULE'" nil t)
202 (replace-match quotedname nil t))
203 (goto-char start))
205 (save-buffer)
207 ;;;;;;;;; _sup.hrl
208 (find-file (concat dir name "/" "src/" name "_sup.hrl"))
209 (tempo-template-erlang-nomodule-header)
210 (save-buffer)
212 ;;;;;;;;; _(application).erl
213 (find-file (concat dir name "/" "src/" appname ".erl"))
214 (funcall apptemplate)
215 (save-buffer)
217 ;;;;;;;;; makefile (src)
218 (find-file (concat dir name "/" "src/makefile"))
219 (setq appwiz-erlang-modulename name)
220 (setq appwiz-erlang-ext extension)
221 (tempo-template-erlang-makefile-src)
222 (insert "Makefile for application " name ".")
223 (let ((start (point)))
224 (goto-char 0)
225 (while (search-forward "%" nil t)
226 (replace-match "#" nil t))
227 (goto-char start))
228 (save-buffer)
230 ;;;;;;;;; makefile (middle)
231 (find-file (concat dir name "/" "makefile"))
232 (tempo-template-erlang-makefile-middle)
233 (insert "Makefile for application " name ".")
234 (let ((start (point)))
235 (goto-char 0)
236 (while (search-forward "%" nil t)
237 (replace-match "#" nil t))
238 (goto-char start))
239 (save-buffer)
241 ;;;;;;;;; .app
242 (find-file (concat dir name "/" "ebin/" name ".app"))
243 (erlang-mode)
244 (tempo-template-erlang-app)
245 (insert "Application specification file for " name ".")
246 (save-buffer)))
248 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
250 ;; These are setq:ed
253 (defvar appwiz-erlang-modulename "foo")
254 (defvar appwiz-erlang-ext "_work")
256 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
258 ;; Skeletons.
259 ;; Skeletons for nomodule header and .app file added by JB.
262 (defvar erlang-skel
263 '(("If" "if" erlang-skel-if)
264 ("Case" "case" erlang-skel-case)
265 ("Receive" "receive" erlang-skel-receive)
266 ("Receive After" "after" erlang-skel-receive-after)
267 ("Receive Loop" "loop" erlang-skel-receive-loop)
268 ("Module" "module" erlang-skel-module)
269 ("Author" "author" erlang-skel-author)
270 ("Query" "query" erlang-skel-query)
272 ("Small Header" "small-header"
273 erlang-skel-small-header erlang-skel-header)
274 ("Normal Header" "normal-header"
275 erlang-skel-normal-header erlang-skel-header)
276 ("Large Header" "large-header"
277 erlang-skel-large-header erlang-skel-header)
278 ("No Moudle Header" "nomodule-header"
279 erlang-skel-nomodule-header erlang-skel-header)
281 ("Small Server" "small-server"
282 erlang-skel-small-server erlang-skel-header)
284 ("application" "application"
285 erlang-skel-application erlang-skel-header)
286 ("app" "app"
287 erlang-skel-app erlang-skel-header)
288 ("supervisor" "supervisor"
289 erlang-skel-supervisor erlang-skel-header)
290 ("supervisor_bridge" "supervisor-bridge"
291 erlang-skel-supervisor-bridge erlang-skel-header)
292 ("gen_server" "generic-server"
293 erlang-skel-generic-server erlang-skel-header)
294 ("gen_event" "gen-event"
295 erlang-skel-gen-event erlang-skel-header)
296 ("gen_fsm" "gen-fsm"
297 erlang-skel-gen-fsm erlang-skel-header))
298 "*Description of all skeletons templates.
299 Both functions and menu entries will be created.
301 Each entry in `erlang-skel' should be a list with three or four
302 elements, or the empty list.
304 The first element is the name which shows up in the menu. The second
305 is the `tempo' identfier (The string \"erlang-\" will be added in
306 front of it). The third is the skeleton descriptor, a variable
307 containing `tempo' attributes as described in the function
308 `tempo-define-template'. The optinal fourth elements denotes a
309 function which should be called when the menu is selected.
311 Functions corresponding to every template will be created. The name
312 of the function will be `tempo-template-erlang-X' where `X' is the
313 tempo identifier as specified in the second argument of the elements
314 in this list.
316 A list with zero elemets means that the a horisontal line should
317 be placed in the menu.")
319 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
321 ;; Template for .app file skeleton
324 (defvar erlang-skel-app
325 '((erlang-skel-include erlang-skel-nomodule-header)
326 "{application, "
327 (erlang-add-quotes-if-needed (erlang-get-module-from-file-name)) "," n>
328 "[{description, \"" (erlang-get-module-from-file-name) "\"}," n>
329 "{vsn, \"0.1\"}," n>
330 "{modules, ["
331 (erlang-add-quotes-if-needed (erlang-get-module-from-file-name)) "," n>
332 (erlang-add-quotes-if-needed
333 (concat (erlang-get-module-from-file-name) "_app")) "," n>
334 (erlang-add-quotes-if-needed
335 (concat (erlang-get-module-from-file-name) "_sup")) "," n>
336 (erlang-add-quotes-if-needed
337 (concat (erlang-get-module-from-file-name) appwiz-erlang-ext)) "]}," n>
338 "{registered, ["
339 (erlang-add-quotes-if-needed
340 (concat (erlang-get-module-from-file-name) appwiz-erlang-ext)) ","
341 (erlang-add-quotes-if-needed
342 (concat (erlang-get-module-from-file-name) "_sup")) "]}," n>
343 "{applications, [kernel," n>
344 "stdlib," n>
345 "sasl," n>
346 "mnesia]}," n>
347 "{env, []}," n>
348 "{mod, {"
349 (erlang-add-quotes-if-needed
350 (concat (erlang-get-module-from-file-name) "_app"))
351 ", []}}]}." n
353 "*The template of an application file
354 Please see the function `tempo-define-template'.")
356 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
358 ;; Template for no-module header skeleton.
361 (defvar erlang-skel-nomodule-header
362 '(o (erlang-skel-separator)
363 (erlang-skel-include erlang-skel-copyright-comment
364 erlang-skel-file-comment
365 erlang-skel-author-comment)
366 "%%% Purpose : " p n
367 (erlang-skel-include erlang-skel-created-comment)
368 (erlang-skel-separator) n)
369 "*The template of a normal header.
370 Please see the function `tempo-define-template'.")
372 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
374 ;; .app extension added.
377 (defvar erlang-file-name-extension-regexp "\\.\\(erl\\|hrl\\|app\\)$"
378 "*Regexp which should match an erlang file name.
380 This regexp is used when an Erlang module name is extracted from the
381 name of an Erlang source file.
383 The regexp should only match the section of the file name which should
384 be excluded from the module name.
386 To match all files set this variable to \"\\\\(\\\\..*\\\\|\\\\)$\".
387 The matches all except the extension. This is useful if the Erlang
388 tags system should interpretate tags on the form `module:tag' for
389 files written in other languages than Erlang.")
391 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
393 ;; Wizard menu added.
396 (defvar erlang-menu-items
397 '(("Indent"
398 (("Indent Line" erlang-indent-command)
399 ("Indent Region " erlang-indent-region
400 (if erlang-xemacs-p (mark) mark-active))
401 ("Indent Clause" erlang-indent-caluse)
402 ("Indent Function" erlang-indent-function)
403 ("Indent Buffer" erlang-indent-current-buffer)))
404 ("Edit"
405 (("Fill Comment" erlang-fill-paragraph)
406 ("Comment Region" comment-region
407 (if erlang-xemacs-p (mark) mark-active))
408 ("Uncomment Region" erlang-uncomment-region
409 (if erlang-xemacs-p (mark) mark-active))
411 ("beginning of Function" erlang-beginning-of-function)
412 ("End of Function" erlang-end-of-function)
413 ("Mark Function" erlang-mark-function)
415 ("beginning of Clause" erlang-beginning-of-clause)
416 ("End of Clause" erlang-end-of-clause)
417 ("Mark Clause" erlang-mark-clause)
419 ("New Clause" erlang-generate-new-clause)
420 ("Clone Arguments" erlang-clone-arguments)))
421 ("Font Lock Mode"
422 (("Level 3" erlang-font-lock-level-3)
423 ("Level 2" erlang-font-lock-level-2)
424 ("Level 1" erlang-font-lock-level-1)
425 ("Off" erlang-font-lock-level-0)))
426 ("TAGS"
427 (("Find Tag" find-tag)
428 ("Find Next Tag" erlang-find-next-tag)
429 ;("Find Regexp" find-tag-regexp)
430 ("Complete Word" erlang-complete-tag)
431 ("Tags Apropos" tags-apropos)
432 ("Search Files" tags-search)))
434 ("Erlang Shell" inferior-erlang-run-or-select)
435 ("Compile" erlang-compile)
436 ("Next Error" inferior-erlang-next-error)
438 ("Version" erlang-version)
440 ("Wizards"
441 (("Application Wizard" erlang-application-wizard))))
442 "*Description of menu used in Erlang mode.
444 This variable must be a list. The elements are either nil representing
445 a horisontal line or a list with two or three elements. The first is
446 the name of the menu item, the second is the function to call, or a
447 submenu, on the same same form as ITEMS. The third optional argument
448 is an expression which is evaluated every time the menu is displayed.
449 Should the expression evaluate to nil the menu item is ghosted.
451 Example:
452 '((\"Func1\" function-one)
453 (\"SubItem\"
454 ((\"Yellow\" function-yellow)
455 (\"Blue\" function-blue)))
457 (\"Region Funtion\" spook-function midnight-variable))
459 Call the function `erlang-menu-init' after modifying this variable.")
461 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
463 ;; Prefixing space removed from date string
466 (defun erlang-skel-d-mmm-yyyy ()
467 "Return the current date as a string in \"DD Mon YYYY\" form.
468 The first character of DD is *not* space if the value is less than 10."
469 (let ((date (current-time-string)))
470 (format "%d %s %s"
471 (string-to-int (substring date 8 10))
472 (substring date 4 7)
473 (substring date -4))))
475 (defvar erlang-skel-date-function 'erlang-skel-d-mmm-yyyy
476 "*Function which returns date string.
477 Look in the module `time-stamp' for a battery of functions.")
480 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
482 ;; Fixed skeletons. erlang-add-quotes-if-needed introduced where needed.
484 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
486 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
487 ;; Server templates.
489 (defvar erlang-skel-small-server
490 '((erlang-skel-include erlang-skel-large-header)
491 "-export([start/0,init/1])." n n n
492 "start() ->" n> "spawn("
493 (erlang-add-quotes-if-needed (erlang-get-module-from-file-name))
494 ", init, [self()])." n n
495 "init(From) ->" n>
496 "loop(From)." n n
497 "loop(From) ->" n>
498 "receive" n>
499 p "_ ->" n>
500 "loop(From)" n>
501 "end."
503 "*Template of a small server.
504 Please see the function `tempo-define-template'.")
506 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
507 ;; Behaviour templates.
509 (defvar erlang-skel-application
510 '((erlang-skel-include erlang-skel-large-header)
511 "-behaviour(application)." n
513 "%% application callbacks" n
514 "-export([start/2, stop/1])." n n
515 (erlang-skel-separator)
516 "%%% Callback functions from application" n
517 (erlang-skel-separator)
519 (erlang-skel-separator 2)
520 "%% Func: start/2" n
521 "%% Returns: {ok, Pid} |" n
522 "%% {ok, Pid, State} |" n
523 "%% {error, Reason} " n
524 (erlang-skel-separator 2)
525 "start(Type, StartArgs) ->" n>
526 "case 'TopSupervisor':start_link(StartArgs) of" n>
527 "{ok, Pid} -> " n>
528 "{ok, Pid};" n>
529 "Error ->" n>
530 "Error" n>
531 "end." n
533 (erlang-skel-separator 2)
534 "%% Func: stop/1" n
535 "%% Returns: any "n
536 (erlang-skel-separator 2)
537 "stop(State) ->" n>
538 "ok." n
540 (erlang-skel-separator)
541 "%%% Internal functions" n
542 (erlang-skel-separator)
544 "*The template of an application behaviour.
545 Please see the function `tempo-define-template'.")
547 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
549 (defvar erlang-skel-supervisor
550 '((erlang-skel-include erlang-skel-large-header)
551 "-behaviour(supervisor)." n
553 "%% External exports" n
554 "-export([start_link/1])." n
556 "%% supervisor callbacks" n
557 "-export([init/1])." n n
558 (erlang-skel-separator)
559 "%%% API" n
560 (erlang-skel-separator)
561 "start_link(StartArgs) ->" n>
562 "supervisor:start_link({local, "
563 (erlang-add-quotes-if-needed (erlang-get-module-from-file-name)) "}, "
564 (erlang-add-quotes-if-needed (erlang-get-module-from-file-name))
565 ", StartArgs)." n
567 (erlang-skel-separator)
568 "%%% Callback functions from supervisor" n
569 (erlang-skel-separator)
571 (erlang-skel-separator 2)
572 "%% Func: init/1" n
573 "%% Returns: {ok, {SupFlags, [ChildSpec]}} |" n
574 "%% ignore |" n
575 "%% {error, Reason} " n
576 (erlang-skel-separator 2)
577 "init(StartArgs) ->" n>
578 "AChild = {'AName',{'AModule',start_link,[]}," n>
579 "permanent,2000,worker,['AModule']}," n>
580 "{ok,{{one_for_all,4,3600}, [AChild]}}." n
582 (erlang-skel-separator)
583 "%%% Internal functions" n
584 (erlang-skel-separator)
586 "*The template of an supervisor behaviour.
587 Please see the function `tempo-define-template'.")
589 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
591 (defvar erlang-skel-supervisor-bridge
592 '((erlang-skel-include erlang-skel-large-header)
593 "-behaviour(supervisor_bridge)." n
595 "%% External exports" n
596 "-export([start_link/0])." n
598 "%% supervisor callbacks" n
599 "-export([init/1, terminate/2])." n n
600 "-record(state, {})." n
602 (erlang-skel-separator)
603 "%%% API" n
604 (erlang-skel-separator)
605 "start_link() -> " n>
606 "supervisor_bridge:start_link({local, "
607 (erlang-add-quotes-if-needed (erlang-get-module-from-file-name)) "}, "
608 (erlang-add-quotes-if-needed (erlang-get-module-from-file-name))
609 ", [])." n
611 (erlang-skel-separator)
612 "%%% Callback functions from supervisor_bridge" n
613 (erlang-skel-separator)
615 (erlang-skel-separator 2)
616 "%% Func: init/1" n
617 "%% Returns: {ok, Pid, State} |" n
618 "%% ignore |" n
619 "%% {error, Reason} " n
620 (erlang-skel-separator 2)
621 "init([]) ->" n>
622 "case 'AModule':start_link() of" n>
623 "{ok, Pid} ->" n>
624 "{ok, Pid, #state{}};" n>
625 "Error ->" n>
626 "Error" n>
627 "end." n
629 (erlang-skel-separator 2)
630 "%% Func: terminate/2" n
631 "%% Purpose: Synchronized shutdown of the underlying sub system." n
632 "%% Returns: any" n
633 (erlang-skel-separator 2)
634 "terminate(Reason, State) ->" n>
635 "'AModule':stop()," n>
636 "ok." n
638 (erlang-skel-separator)
639 "%%% Internal functions" n
640 (erlang-skel-separator)
642 "*The template of an supervisor_bridge behaviour.
643 Please see the function `tempo-define-template'.")
645 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
647 (defvar erlang-skel-generic-server
648 '((erlang-skel-include erlang-skel-large-header)
649 "-behaviour(gen_server)." n
651 "%% External exports" n
652 "-export([start_link/0])." n
654 "%% gen_server callbacks" n
655 "-export([init/1, handle_call/3, handle_cast/2, "
656 "handle_info/2, terminate/2])." n n
657 "-record(state, {})." n
659 (erlang-skel-separator)
660 "%%% API" n
661 (erlang-skel-separator)
662 "start_link() -> " n>
663 "gen_server:start_link({local, "
664 (erlang-add-quotes-if-needed (erlang-get-module-from-file-name)) "}, "
665 (erlang-add-quotes-if-needed (erlang-get-module-from-file-name))
666 ", [], [])." n
668 (erlang-skel-separator)
669 "%%% Callback functions from gen_server" n
670 (erlang-skel-separator)
672 (erlang-skel-separator 2)
673 "%% Func: init/1" n
674 "%% Returns: {ok, State} |" n
675 "%% {ok, State, Timeout} |" n
676 "%% ignore |" n
677 "%% {stop, Reason}" n
678 (erlang-skel-separator 2)
679 "init([]) ->" n>
680 "{ok, #state{}}." n
682 (erlang-skel-separator 2)
683 "%% Func: handle_call/3" n
684 "%% Returns: {reply, Reply, State} |" n
685 "%% {reply, Reply, State, Timeout} |" n
686 "%% {noreply, State} |" n
687 "%% {noreply, State, Timeout} |" n
688 "%% {stop, Reason, Reply, State} | (terminate/2 is called)" n
689 "%% {stop, Reason, State} (terminate/2 is called)" n
690 (erlang-skel-separator 2)
691 "handle_call(Request, From, State) ->" n>
692 "Reply = ok," n>
693 "{reply, Reply, State}." n
695 (erlang-skel-separator 2)
696 "%% Func: handle_cast/2" n
697 "%% Returns: {noreply, State} |" n
698 "%% {noreply, State, Timeout} |" n
699 "%% {stop, Reason, State} (terminate/2 is called)" n
700 (erlang-skel-separator 2)
701 "handle_cast(Msg, State) ->" n>
702 "{noreply, State}." n
704 (erlang-skel-separator 2)
705 "%% Func: handle_info/2" n
706 "%% Returns: {noreply, State} |" n
707 "%% {noreply, State, Timeout} |" n
708 "%% {stop, Reason, State} (terminate/2 is called)" n
709 (erlang-skel-separator 2)
710 "handle_info(Info, State) ->" n>
711 "{noreply, State}." n
713 (erlang-skel-separator 2)
714 "%% Func: terminate/2" n
715 "%% Purpose: Shutdown the server" n
716 "%% Returns: any (ignored by gen_server)" n
717 (erlang-skel-separator 2)
718 "terminate(Reason, State) ->" n>
719 "ok." n
721 (erlang-skel-separator)
722 "%%% Internal functions" n
723 (erlang-skel-separator)
725 "*The template of a generic server.
726 Please see the function `tempo-define-template'.")
728 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
730 (defvar erlang-skel-gen-event
731 '((erlang-skel-include erlang-skel-large-header)
732 "-behaviour(gen_event)." n
734 "%% External exports" n
735 "-export([start_link/0, add_handler/0])." n
737 "%% gen_event callbacks" n
738 "-export([init/1, handle_event/2, handle_call/2, "
739 "handle_info/2, terminate/2])." n n
740 "-record(state, {})." n
742 (erlang-skel-separator)
743 "%%% API" n
744 (erlang-skel-separator)
745 "start_link() ->" n>
746 "gen_event:start_link({local, "
747 (erlang-add-quotes-if-needed (erlang-get-module-from-file-name)) "}). " n
749 "add_handler() ->" n>
750 "gen_event:add_handler("
751 (erlang-add-quotes-if-needed (erlang-get-module-from-file-name)) ", "
752 (erlang-add-quotes-if-needed (erlang-get-module-from-file-name))
753 ", [])." n
755 (erlang-skel-separator)
756 "%%% Callback functions from gen_event" n
757 (erlang-skel-separator)
759 (erlang-skel-separator 2)
760 "%% Func: init/1" n
761 "%% Returns: {ok, State} |" n
762 "%% Other" n
763 (erlang-skel-separator 2)
764 "init([]) ->" n>
765 "{ok, #state{}}." n
767 (erlang-skel-separator 2)
768 "%% Func: handle_event/2" n
769 "%% Returns: {ok, State} |" n
770 "%% {swap_handler, Args1, State1, Mod2, Args2} |" n
771 "%% remove_handler " n
772 (erlang-skel-separator 2)
773 "handle_event(Event, State) ->" n>
774 "{ok, State}." n
776 (erlang-skel-separator 2)
777 "%% Func: handle_call/2" n
778 "%% Returns: {ok, Reply, State} |" n
779 "%% {swap_handler, Reply, Args1, State1, Mod2, Args2} |" n
780 "%% {remove_handler, Reply} " n
781 (erlang-skel-separator 2)
782 "handle_call(Request, State) ->" n>
783 "Reply = ok," n>
784 "{ok, Reply, State}." n
786 (erlang-skel-separator 2)
787 "%% Func: handle_info/2" n
788 "%% Returns: {ok, State} |" n
789 "%% {swap_handler, Args1, State1, Mod2, Args2} |" n
790 "%% remove_handler " n
791 (erlang-skel-separator 2)
792 "handle_info(Info, State) ->" n>
793 "{ok, State}." n
795 (erlang-skel-separator 2)
796 "%% Func: terminate/2" n
797 "%% Purpose: Shutdown the server" n
798 "%% Returns: any" n
799 (erlang-skel-separator 2)
800 "terminate(Reason, State) ->" n>
801 "ok." n
803 (erlang-skel-separator)
804 "%%% Internal functions" n
805 (erlang-skel-separator)
807 "*The template of a gen_event.
808 Please see the function `tempo-define-template'.")
810 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
812 (defvar erlang-skel-gen-fsm
813 '((erlang-skel-include erlang-skel-large-header)
814 "-behaviour(gen_fsm)." n
816 "%% External exports" n
817 "-export([start_link/0])." n
819 "%% gen_fsm callbacks" n
820 "-export([init/1, state_name/2, state_name/3, handle_event/3," n>
821 "handle_sync_event/4, handle_info/3, terminate/3])." n n
822 "-record(state, {})." n
824 (erlang-skel-separator)
825 "%%% API" n
826 (erlang-skel-separator)
827 "start_link() ->" n>
828 "gen_fsm:start_link({local, "
829 (erlang-add-quotes-if-needed (erlang-get-module-from-file-name)) "}, "
830 (erlang-add-quotes-if-needed (erlang-get-module-from-file-name))
831 ", [], [])." n
833 (erlang-skel-separator)
834 "%%% Callback functions from gen_fsm" n
835 (erlang-skel-separator)
837 (erlang-skel-separator 2)
838 "%% Func: init/1" n
839 "%% Returns: {ok, StateName, StateData} |" n
840 "%% {ok, StateName, StateData, Timeout} |" n
841 "%% ignore |" n
842 "%% {stop, StopReason} " n
843 (erlang-skel-separator 2)
844 "init([]) ->" n>
845 "{ok, state_name, #state{}}." n
847 (erlang-skel-separator 2)
848 "%% Func: StateName/2" n
849 "%% Returns: {next_state, NextStateName, NextStateData} |" n
850 "%% {next_state, NextStateName, NextStateData, Timeout} |" n
851 "%% {stop, Reason, NewStateData} " n
852 (erlang-skel-separator 2)
853 "state_name(Event, StateData) ->" n>
854 "{nextstate, state_name, StateData}." n
856 (erlang-skel-separator 2)
857 "%% Func: StateName/3" n
858 "%% Returns: {next_state, NextStateName, NextStateData} |" n
859 "%% {next_state, NextStateName, NextStateData, Timeout} |" n
860 "%% {reply, Reply, NextStateName, NextStateData} |" n
861 "%% {reply, Reply, NextStateName, NextStateData, Timeout} |" n
862 "%% {stop, Reason, NewStateData} |" n
863 "%% {stop, Reason, Reply, NewStateData} " n
864 (erlang-skel-separator 2)
865 "state_name(Event, From, StateData) ->" n>
866 "Reply = ok," n>
867 "{reply, Reply, state_name, StateData}." n
869 (erlang-skel-separator 2)
870 "%% Func: handle_event/3" n
871 "%% Returns: {next_state, NextStateName, NextStateData} |" n
872 "%% {next_state, NextStateName, NextStateData, Timeout} |" n
873 "%% {stop, Reason, NewStateData} " n
874 (erlang-skel-separator 2)
875 "handle_event(Event, StateName, StateData) ->" n>
876 "{nextstate, StateName, StateData}." n
878 (erlang-skel-separator 2)
879 "%% Func: handle_sync_event/4" n
880 "%% Returns: {next_state, NextStateName, NextStateData} |" n
881 "%% {next_state, NextStateName, NextStateData, Timeout} |" n
882 "%% {reply, Reply, NextStateName, NextStateData} |" n
883 "%% {reply, Reply, NextStateName, NextStateData, Timeout} |" n
884 "%% {stop, Reason, NewStateData} |" n
885 "%% {stop, Reason, Reply, NewStateData} " n
886 (erlang-skel-separator 2)
887 "handle_sync_event(Event, From, StateName, StateData) ->" n>
888 "Reply = ok," n>
889 "{reply, Reply, StateName, StateData}." n
891 (erlang-skel-separator 2)
892 "%% Func: handle_info/3" n
893 "%% Returns: {next_state, NextStateName, NextStateData} |" n
894 "%% {next_state, NextStateName, NextStateData, Timeout} |" n
895 "%% {stop, Reason, NewStateData} " n
896 (erlang-skel-separator 2)
897 "handle_info(Info, StateName, StateData) ->" n>
898 "{nextstate, StateName, StateData}." n
900 (erlang-skel-separator 2)
901 "%% Func: terminate/3" n
902 "%% Purpose: Shutdown the fsm" n
903 "%% Returns: any" n
904 (erlang-skel-separator 2)
905 "terminate(Reason, StateName, StatData) ->" n>
906 "ok." n
908 (erlang-skel-separator)
909 "%%% Internal functions" n
910 (erlang-skel-separator)
912 "*The template of a gen_fsm.
913 Please see the function `tempo-define-template'.")
916 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
918 ;; Original erlang-add-quotes-if-needed is broken, we install a
919 ;; new version.
922 (add-hook 'erlang-load-hook 'my-erlang-load-mods)
924 (defun fixed-erlang-add-quotes-if-needed (str)
925 "Return STR, possibly with quotes."
926 (let ((saved-case-fold-search case-fold-search)
927 (result nil))
928 (setq case-fold-search nil)
929 (setq result (if (string-match (concat "\\`" erlang-atom-regexp "\\'") str)
931 (concat "'" str "'")))
932 (setq case-fold-search saved-case-fold-search)
933 result))
935 (defun my-erlang-load-mods ()
936 (fset 'erlang-add-quotes-if-needed
937 (symbol-function 'fixed-erlang-add-quotes-if-needed))
938 (appwiz-skel-init))
940 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
942 ;; Additional skeletons which are not shown in the Erlang menu.
945 (defvar appwiz-skel
947 ; ("generic-server-no-api" erlang-skel-generic-server-no-api)
948 ; ("generic-server-api" erlang-skel-generic-server-api)
949 ; ("gen-event-no-api" erlang-skel-gen-event-no-api)
950 ; ("gen-event-api" erlang-skel-gen-event-api)
951 ; ("gen-fsm-no-api" erlang-skel-gen-fsm-no-api)
952 ; ("gen-fsm-api" erlang-skel-gen-fsm-api)
953 ("makefile-middle" erlang-skel-makefile-middle)
954 ("makefile-src" erlang-skel-makefile-src)))
956 (defun appwiz-skel-init ()
957 "Generate the skeleton functions."
958 (interactive)
959 (condition-case nil
960 (require 'tempo)
961 (error t))
962 (if (featurep 'tempo)
963 (let ((skel appwiz-skel))
964 (while skel
965 (funcall (symbol-function 'tempo-define-template)
966 (concat "erlang-" (nth 0 (car skel)))
967 ;; The tempo template used contains an `include'
968 ;; function call only, hence changes to the
969 ;; variables describing the templates take effect
970 ;; immdiately.
971 (list (list 'erlang-skel-include (nth 1 (car skel))))
972 (nth 0 (car skel)))
973 (setq skel (cdr skel))))))
976 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
977 ;;;;
978 ;;;;
980 ;;(defvar erlang-skel-generic-server-no-api
981 ;; '((erlang-skel-include erlang-skel-large-header)
982 ;; "-behaviour(gen_server)." n
983 ;; n
984 ;; "%% gen_server callbacks" n
985 ;; "-export([init/1, handle_call/3, handle_cast/2, "
986 ;; "handle_info/2, terminate/2])." n n
987 ;; "-record(state, {})." n
988 ;; n
989 ;; (erlang-skel-separator)
990 ;; "%%% Callback functions from gen_server" n
991 ;; (erlang-skel-separator)
992 ;; n
993 ;; (erlang-skel-separator 2)
994 ;; "%% Func: init/1" n
995 ;; "%% Returns: {ok, State} |" n
996 ;; "%% {ok, State, Timeout} |" n
997 ;; "%% ignore |" n
998 ;; "%% {stop, Reason}" n
999 ;; (erlang-skel-separator 2)
1000 ;; "init([]) ->" n>
1001 ;; "{ok, #state{}}." n
1002 ;; n
1003 ;; (erlang-skel-separator 2)
1004 ;; "%% Func: handle_call/3" n
1005 ;; "%% Returns: {reply, Reply, State} |" n
1006 ;; "%% {reply, Reply, State, Timeout} |" n
1007 ;; "%% {noreply, State} |" n
1008 ;; "%% {noreply, State, Timeout} |" n
1009 ;; "%% {stop, Reason, Reply, State} | (terminate/2 is called)" n
1010 ;; "%% {stop, Reason, State} (terminate/2 is called)" n
1011 ;; (erlang-skel-separator 2)
1012 ;; "handle_call(Request, From, State) ->" n>
1013 ;; "Reply = ok," n>
1014 ;; "{reply, Reply, State}." n
1015 ;; n
1016 ;; (erlang-skel-separator 2)
1017 ;; "%% Func: handle_cast/2" n
1018 ;; "%% Returns: {noreply, State} |" n
1019 ;; "%% {noreply, State, Timeout} |" n
1020 ;; "%% {stop, Reason, State} (terminate/2 is called)" n
1021 ;; (erlang-skel-separator 2)
1022 ;; "handle_cast(Msg, State) ->" n>
1023 ;; "{noreply, State}." n
1024 ;; n
1025 ;; (erlang-skel-separator 2)
1026 ;; "%% Func: handle_info/2" n
1027 ;; "%% Returns: {noreply, State} |" n
1028 ;; "%% {noreply, State, Timeout} |" n
1029 ;; "%% {stop, Reason, State} (terminate/2 is called)" n
1030 ;; (erlang-skel-separator 2)
1031 ;; "handle_info(Info, State) ->" n>
1032 ;; "{noreply, State}." n
1033 ;; n
1034 ;; (erlang-skel-separator 2)
1035 ;; "%% Func: terminate/2" n
1036 ;; "%% Purpose: Shutdown the server" n
1037 ;; "%% Returns: any (ignored by gen_server)" n
1038 ;; (erlang-skel-separator 2)
1039 ;; "terminate(Reason, State) ->" n>
1040 ;; "ok." n
1041 ;; n
1042 ;; (erlang-skel-separator)
1043 ;; "%%% Internal functions" n
1044 ;; (erlang-skel-separator)
1045 ;; )
1046 ;; "*The template of a generic server.
1047 ;;Please see the function `tempo-define-template'.")
1049 ;;(defvar erlang-skel-generic-server-api
1050 ;; '((erlang-skel-include erlang-skel-large-header)
1051 ;; "%% External exports" n
1052 ;; "-export([start_link/0])." n
1053 ;; n
1054 ;; (erlang-skel-separator)
1055 ;; "%%% API" n
1056 ;; (erlang-skel-separator)
1057 ;; "start_link() ->" n>
1058 ;; "gen_server:start_link({local, "
1059 ;; (erlang-add-quotes-if-needed
1060 ;; (concat (erlang-get-module-from-file-name) "_server")) "}, "
1061 ;; (erlang-add-quotes-if-needed
1062 ;; (concat (erlang-get-module-from-file-name) "_server")) ", [], [])." n
1063 ;; n
1064 ;; ))
1066 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1067 ;;;;
1068 ;;;;
1070 ;;(defvar erlang-skel-gen-event-no-api
1071 ;; '((erlang-skel-include erlang-skel-large-header)
1072 ;; "-behaviour(gen_event)." n
1073 ;; n
1074 ;; "%% gen_event callbacks" n
1075 ;; "-export([init/1, handle_event/2, handle_call/2, "
1076 ;; "handle_info/2, terminate/2])." n n
1077 ;; "-record(state, {})." n
1078 ;; n
1079 ;; (erlang-skel-separator)
1080 ;; "%%% Callback functions from gen_event" n
1081 ;; (erlang-skel-separator)
1082 ;; n
1083 ;; (erlang-skel-separator 2)
1084 ;; "%% Func: init/1" n
1085 ;; "%% Returns: {ok, State} |" n
1086 ;; "%% Other" n
1087 ;; (erlang-skel-separator 2)
1088 ;; "init([]) ->" n>
1089 ;; "{ok, #state{}}." n
1090 ;; n
1091 ;; (erlang-skel-separator 2)
1092 ;; "%% Func: handle_event/2" n
1093 ;; "%% Returns: {ok, State} |" n
1094 ;; "%% {swap_handler, Args1, State1, Mod2, Args2} |" n
1095 ;; "%% remove_handler " n
1096 ;; (erlang-skel-separator 2)
1097 ;; "handle_event(Event, State) ->" n>
1098 ;; "{ok, State}." n
1099 ;; n
1100 ;; (erlang-skel-separator 2)
1101 ;; "%% Func: handle_call/2" n
1102 ;; "%% Returns: {ok, Reply, State} |" n
1103 ;; "%% {swap_handler, Reply, Args1, State1, Mod2, Args2} |" n
1104 ;; "%% {remove_handler, Reply} " n
1105 ;; (erlang-skel-separator 2)
1106 ;; "handle_call(Request, State) ->" n>
1107 ;; "Reply = ok," n>
1108 ;; "{ok, Reply, State}." n
1109 ;; n
1110 ;; (erlang-skel-separator 2)
1111 ;; "%% Func: handle_info/2" n
1112 ;; "%% Returns: {ok, State} |" n
1113 ;; "%% {swap_handler, Args1, State1, Mod2, Args2} |" n
1114 ;; "%% remove_handler " n
1115 ;; (erlang-skel-separator 2)
1116 ;; "handle_info(Info, State) ->" n>
1117 ;; "{ok, State}." n
1118 ;; n
1119 ;; (erlang-skel-separator 2)
1120 ;; "%% Func: terminate/2" n
1121 ;; "%% Purpose: Shutdown the server" n
1122 ;; "%% Returns: any" n
1123 ;; (erlang-skel-separator 2)
1124 ;; "terminate(Reason, State) ->" n>
1125 ;; "ok." n
1126 ;; n
1127 ;; (erlang-skel-separator)
1128 ;; "%%% Internal functions" n
1129 ;; (erlang-skel-separator)
1130 ;; )
1131 ;; "*The template of a gen_event.
1132 ;;Please see the function `tempo-define-template'.")
1134 ;;(defvar erlang-skel-gen-event-api
1135 ;; '((erlang-skel-include erlang-skel-large-header)
1136 ;; "%% External exports" n
1137 ;; "-export([start_link/0, add_handler/0])." n
1138 ;; n
1139 ;; (erlang-skel-separator)
1140 ;; "%%% API" n
1141 ;; (erlang-skel-separator)
1142 ;; "start_link() ->" n>
1143 ;; "gen_event:start_link({local, "
1144 ;; (erlang-add-quotes-if-needed
1145 ;; (concat (erlang-get-module-from-file-name) "_event")) "}). " n
1146 ;; n
1147 ;; "add_handler() ->" n>
1148 ;; "gen_event:add_handler("
1149 ;; (erlang-add-quotes-if-needed
1150 ;; (concat (erlang-get-module-from-file-name) "_event")) ", "
1151 ;; (erlang-add-quotes-if-needed
1152 ;; (concat (erlang-get-module-from-file-name) "_event")) ", [])." n
1153 ;; n))
1155 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1156 ;;;;
1157 ;;;;
1159 ;;(defvar erlang-skel-gen-fsm
1160 ;; '((erlang-skel-include erlang-skel-large-header)
1161 ;; "-behaviour(gen_fsm)." n
1162 ;; n
1163 ;; "%% gen_fsm callbacks" n
1164 ;; "-export([init/1, state_name/2, state_name/3, handle_event/3," n>
1165 ;; "handle_sync_event/4, handle_info/3, terminate/3])." n n
1166 ;; "-record(state, {})." n
1167 ;; n
1168 ;; (erlang-skel-separator)
1169 ;; "%%% Callback functions from gen_fsm" n
1170 ;; (erlang-skel-separator)
1171 ;; n
1172 ;; (erlang-skel-separator 2)
1173 ;; "%% Func: init/1" n
1174 ;; "%% Returns: {ok, StateName, StateData} |" n
1175 ;; "%% {ok, StateName, StateData, Timeout} |" n
1176 ;; "%% ignore |" n
1177 ;; "%% {stop, StopReason} " n
1178 ;; (erlang-skel-separator 2)
1179 ;; "init([]) ->" n>
1180 ;; "{ok, state_name, #state{}}." n
1181 ;; n
1182 ;; (erlang-skel-separator 2)
1183 ;; "%% Func: StateName/2" n
1184 ;; "%% Returns: {next_state, NextStateName, NextStateData} |" n
1185 ;; "%% {next_state, NextStateName, NextStateData, Timeout} |" n
1186 ;; "%% {stop, Reason, NewStateData} " n
1187 ;; (erlang-skel-separator 2)
1188 ;; "state_name(Event, StateData) ->" n>
1189 ;; "{nextstate, state_name, StateData}." n
1190 ;; n
1191 ;; (erlang-skel-separator 2)
1192 ;; "%% Func: StateName/3" n
1193 ;; "%% Returns: {next_state, NextStateName, NextStateData} |" n
1194 ;; "%% {next_state, NextStateName, NextStateData, Timeout} |" n
1195 ;; "%% {reply, Reply, NextStateName, NextStateData} |" n
1196 ;; "%% {reply, Reply, NextStateName, NextStateData, Timeout} |" n
1197 ;; "%% {stop, Reason, NewStateData} |" n
1198 ;; "%% {stop, Reason, Reply, NewStateData} " n
1199 ;; (erlang-skel-separator 2)
1200 ;; "state_name(Event, From, StateData) ->" n>
1201 ;; "Reply = ok," n>
1202 ;; "{reply, Reply, state_name, StateData}." n
1203 ;; n
1204 ;; (erlang-skel-separator 2)
1205 ;; "%% Func: handle_event/3" n
1206 ;; "%% Returns: {next_state, NextStateName, NextStateData} |" n
1207 ;; "%% {next_state, NextStateName, NextStateData, Timeout} |" n
1208 ;; "%% {stop, Reason, NewStateData} " n
1209 ;; (erlang-skel-separator 2)
1210 ;; "handle_event(Event, StateName, StateData) ->" n>
1211 ;; "{nextstate, StateName, StateData}." n
1212 ;; n
1213 ;; (erlang-skel-separator 2)
1214 ;; "%% Func: handle_sync_event/4" n
1215 ;; "%% Returns: {next_state, NextStateName, NextStateData} |" n
1216 ;; "%% {next_state, NextStateName, NextStateData, Timeout} |" n
1217 ;; "%% {reply, Reply, NextStateName, NextStateData} |" n
1218 ;; "%% {reply, Reply, NextStateName, NextStateData, Timeout} |" n
1219 ;; "%% {stop, Reason, NewStateData} |" n
1220 ;; "%% {stop, Reason, Reply, NewStateData} " n
1221 ;; (erlang-skel-separator 2)
1222 ;; "handle_sync_event(Event, From, StateName, StateData) ->" n>
1223 ;; "Reply = ok," n>
1224 ;; "{reply, Reply, StateName, StateData}." n
1225 ;; n
1226 ;; (erlang-skel-separator 2)
1227 ;; "%% Func: handle_info/3" n
1228 ;; "%% Returns: {next_state, NextStateName, NextStateData} |" n
1229 ;; "%% {next_state, NextStateName, NextStateData, Timeout} |" n
1230 ;; "%% {stop, Reason, NewStateData} " n
1231 ;; (erlang-skel-separator 2)
1232 ;; "handle_info(Info, StateName, StateData) ->" n>
1233 ;; "{nextstate, StateName, StateData}." n
1234 ;; n
1235 ;; (erlang-skel-separator 2)
1236 ;; "%% Func: terminate/3" n
1237 ;; "%% Purpose: Shutdown the fsm" n
1238 ;; "%% Returns: any" n
1239 ;; (erlang-skel-separator 2)
1240 ;; "terminate(Reason, StateName, StatData) ->" n>
1241 ;; "ok." n
1242 ;; n
1243 ;; (erlang-skel-separator)
1244 ;; "%%% Internal functions" n
1245 ;; (erlang-skel-separator)
1246 ;; )
1247 ;; "*The template of a gen_fsm.
1248 ;;Please see the function `tempo-define-template'.")
1250 ;;(defvar erlang-skel-gen-fsm-no-api
1251 ;; '((erlang-skel-include erlang-skel-large-header)
1252 ;; "%% External exports" n
1253 ;; "-export([start_link/0])." n
1254 ;; n
1255 ;; (erlang-skel-separator)
1256 ;; "%%% API" n
1257 ;; (erlang-skel-separator)
1258 ;; "start_link() ->" n>
1259 ;; "gen_fsm:start_link({local, "
1260 ;; (erlang-add-quotes-if-needed
1261 ;; (concat (erlang-get-module-from-file-name) "_fsm")) "}, "
1262 ;; (erlang-add-quotes-if-needed
1263 ;; (concat (erlang-get-module-from-file-name) "_fsm")) ", [], [])." n
1264 ;; n
1265 ;; ))
1268 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1270 ;; requires that the variables appwiz-erlang-modulename and
1271 ;; appwiz-erlang-ext are defined.
1274 (defvar erlang-skel-makefile-src
1275 '((erlang-skel-include erlang-skel-nomodule-header)
1276 "MAKE = make" n
1278 "ERL = erlc" n
1280 "EBIN = ../ebin" n
1282 (erlang-skel-makefile-separator)
1284 (upcase appwiz-erlang-modulename) "_HEADER_FILES = "
1285 appwiz-erlang-modulename "_sup.hrl" n
1287 (upcase appwiz-erlang-modulename) "_SOURCE_FILES = \\" n
1288 " " appwiz-erlang-modulename ".erl" " "
1289 appwiz-erlang-modulename "_sup.erl \\" n
1290 " " appwiz-erlang-modulename "_app.erl" " "
1291 appwiz-erlang-modulename appwiz-erlang-ext ".erl" n
1293 (upcase appwiz-erlang-modulename) "_OBJECT_FILES = $("
1294 (upcase appwiz-erlang-modulename) "_SOURCE_FILES:.erl=.jam)" n
1297 (erlang-skel-makefile-separator)
1298 "#" n
1299 "# Transformations " n
1300 "#" n
1302 ".erl.jam:" n
1303 " $(ERL) $<" n
1305 (erlang-skel-makefile-separator) n
1308 "def : "
1309 appwiz-erlang-modulename n
1311 appwiz-erlang-modulename ": $("
1312 (upcase appwiz-erlang-modulename) "_OBJECT_FILES)" n
1313 " cp $(" (upcase appwiz-erlang-modulename) "_OBJECT_FILES) "
1314 "$(EBIN)" n
1316 "clean :" n
1317 " /bin/rm -f $(" (upcase appwiz-erlang-modulename)
1318 "_OBJECT_FILES)" n
1320 "$(" (upcase appwiz-erlang-modulename) "_OBJECT_FILES): $("
1321 (upcase appwiz-erlang-modulename) "_HEADER_FILES)" n
1323 ".SUFFIXES : .erl .jam" n
1327 (defvar erlang-skel-makefile-middle
1328 '((erlang-skel-include erlang-skel-nomodule-header)
1329 "MAKE = make" n
1331 (erlang-skel-makefile-separator)
1333 "def:" n
1334 " (cd src ; $(MAKE))" n
1336 "clean:" n
1337 " (cd src ; $(MAKE) clean)" n
1341 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1343 (defun erlang-skel-makefile-separator ()
1344 "Return a comment separator."
1345 (concat (make-string 70 ?\#) "\n"))