<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">I might be doing this the hard-way, but it works well enough to share and ask for feedback:<br>
<div>having Emacs erlang-shell play nice with multiple components built by rebar (invoked from Makefiles).<br>
<br>
First, the elisp code followed by more explanation.<br>
<br>
;; Add paths to ../../*/deps/ebin for running & compiling:<br>
(add-hook 'erlang-mode-hook<br>
(lambda () <br>
(setq inferior-erlang-machine-options<br>
(append (remove nil<br>
(mapcan (lambda (app-path)<br>
(let ((ebin (concat app-path "/ebin")))<br>
(when (file-readable-p ebin)<br>
(list "-pa" ebin))))<br>
(directory-files "../.." t "[^.]$")))<br>
(remove nil<br>
(mapcan (lambda (dep)<br>
(let ((dep-path (concat dep "/deps")))<br>
(when (file-readable-p dep-path)<br>
(mapcan (lambda (dir)<br>
(list "-pa" (concat dir "/ebin")))<br>
(directory-files dep-path t "[^.]$")))))<br>
(directory-files "../.." t "[^.]$"))))<br>
<br>
erlang-compile-extra-opts<br>
(append (remove nil<br>
(mapcan (lambda (app-path)<br>
(let ((ebin (concat app-path "/ebin")))<br>
(when (file-readable-p ebin)<br>
(list "-pa" ebin))))<br>
(directory-files "../.." t "[^.]$")))<br>
(remove nil<br>
(mapcan (lambda (dep)<br>
(let ((dep-path (concat dep "/deps")))<br>
(when (file-readable-p dep-path)<br>
(mapcar (lambda (dir)<br>
(cons 'i (concat dir "/ebin")))<br>
(directory-files dep-path t "[^.]$")))))<br>
(directory-files "../.." t "[^.]$")))))))<br>
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px"><br>
We have a source tree on disk that roughly looks like the following with names changed to protect the innocent, etc.<br>
<br>
ls <br>
app1/ebin app1/deps app1/src app2/ebin app2/deps app2/src<br>
<br>
Our top-level application relies upon Cowboy & friends, and the division between app1 versus app2 is largely to isolate HTTP-related logic for a future alternate Erlang-specific entry point.<br>
<br>
This division introduces problems for *erlang-shell* within Emacs because default values for erlang-mode.el are such that it can't find dependencies across ../app* boundaries without telling the inferior-shell about paths.<br>
<br>
The 'erlang-mode-hook above relies upon rebar related directory tree and should work for an arbitrary number of sibling apps. (Of course, it will require restarting *erlang-shell* if any new dependencies are added.)<br>
<br>
The beauty of this is that you can compile everything via `make` and then do incremental file compilation from within Emacs and run within *erlang-shell*. The generated .beam files from an Emacs-initiated compilation also appear within ../ebin subdirectories
rather than the src directory. <br>
<br>
There may be subtle interaction issues depending upon which app's source is compiled and possibly depositing the .beam file into the wrong ../ebin, but an occasional 'make clean' is useful during development anyway, I suppose. From my early C days, I tend
to `make clean` at least once daily.<br>
<br>
<br>
Why I believe that there may be a cleaner or more concise way is that this is likely to be a common Erlang idiom if not also shared by other languages for which there are Emacs functions like inferior-erlang-compile. Anyone have suggestions about this?<br>
<br>
Thanks,<br>
-Daniel<br>
<br>
<font color="808080">--<br>
d<font color="808080">pezely</font>@splunk.com<br>
</font>
<div><br>
</div>
</div>
</div>
</div>
</div>
</body>
</html>