tags:

views:

80

answers:

3

I am using a single module a lot in the Erlang shell. Is there any shortcut that will enable me to omit the module: prefix when typing in commands?

+2  A: 

I don't think so.

But you can still use tab completion in the shell to make it easy.

Tab completion for a module can be achieved either by loading it:

> l(foo).

Or by manually calling any function from that module for the first time.

Roberto Aloi
I tried that but the tab completion didn't work
Zubair
I did l(module_name) and then module_name:start_of_function_name but it never fills in the name
Zubair
This sounds very strange to me. Which version of Erlang are you running?
Roberto Aloi
5.7.4 under emacs
Zubair
Zed's way is the way to go for what you asked. For future reference, 5.7.4 is the Erlang "erts" version. The proper "Erlang version" is something like R13B04 or similar. Tab completion doesn't work for me either, under Emacs. Try opening an Erlang shell in a terminal and try tab completion there. You might want to raise a new SO question to understand why tab completion doesn't work in Emacs.
Roberto Aloi
+2  A: 

You can not omit module name, but you can type less, using variables:

1> lists:seq(1,10).
[1,2,3,4,5,6,7,8,9,10]
2> L = lists, S = seq.
seq
3> L:S(1,10).
[1,2,3,4,5,6,7,8,9,10]
probsolver
+4  A: 

You can extend the shell commands by defining a user_default module:

-module(user_default).

-export([seq/2]).

seq(A,B) -> lists:seq(A,B).

Make sure the compiled module is in your code path.

Eshell V5.7.5  (abort with ^G)
1> seq(1,4).
[1,2,3,4]
2>
Zed
+1. I didn't know about this. Simply brilliant! :) I wouldn't use this (or any simple approach, tough, since I consider a good thing to always distinguish among a user defined module and a non user defined one.
Roberto Aloi