Emacs mode "contribution"? Possibly...

s. n. wight <>
Wed Oct 18 01:23:02 CEST 2000

Here are two VERY simple-minded elisp functions that insert
the "-sname" option into the "inferior-erlang-machine-options" list
which is fed to the erlang-shell function in Emacs when spawning
new Erlang shells. 

The first, (erlang-set-nodename (nodename)) is an interactive (aka,
runs in the mini-buf) method that inserts your "node name" choice
into the current options list for the next (and ONLY the next) invocation
of erlang-shell. The next shell that is spawned (either by compiling
an Erlang buffer with "^C^K" or calling erlang-shell from the menu
or mini-buf) will use that node name (in short form) and spawn a
net_kernel distributed node. 

To prevent later confusion the second function, 
(erlang-clear-nodename ()), removes the node name directive 
from the options list; this is installed as an erlang-shell-mode-hook 
(in the example below). This insures that subsequent shells are 
started in "normal" singleton mode unless, of course, 
erlang-set-nodename is invoked with a new name.

Both functions can be deliberately invoked from the mini-buffer
if desired. 

I've found this to be a useful addition to the wonderful emacs-mode
suite, when developing distributed applications. 

steve wight

;; paste this block into your .emacs init file
;; interactive function, run with M-x prior to shell creation
(defun erlang-set-nodename (nodename)
  "Prompts for distributed Erlang node name"
  (interactive "sNext Erlang node name shall be: ")
  (require 'erlang)
  (require 'cl)
      ((oldtail (member "-sname" inferior-erlang-machine-options)))
    (if oldtail
	(nsubstitute nodename 
		     (cadr oldtail)
      (setq inferior-erlang-machine-options
	    (cons "-sname" 
		  (cons nodename 

;; hook function to clean up after a shell is spawned -
;; may be run in mini-buf with M-x as well
(defun erlang-clear-nodename ()
  "Hook function to delete Erlang node name from options list after use"
      ((oldtail (member "-sname" inferior-erlang-machine-options)))
    (if oldtail
	(setq inferior-erlang-machine-options
	      (remove "-sname" 
		      (remove (cadr oldtail) 

(add-hook 'erlang-shell-mode-hook 'erlang-clear-nodename)


More information about the erlang-questions mailing list