I think that this is the functionality that I want, if by previous/next option you mean the queries that are entered at the prompt, but I'm not running under emacs. I'm just calling the top-level shell from a bash shell (using 'ciao'), and there don't seem to be any editing facilities apart from backspace. Is there some way of gaining this functionality (cursor movement, history, editing..) without using emacs?
Ciao does not provide that functionality (not at the moment, at least). Not that it cannot be done, but that would imply putting in the toplevel pieces which really do not belong to a compiler/interpreter, and which are probably better handled by an external tool which just hands strings typed by the user to the toplevel's standard input, and presents the interpreter output to the user in a reasonable form.
Quite often, a "reasonable form" means just showing the user whatever the interpreter generates. Sometimes there are presentations better than this one: for example, if you use the Emacs interface for debugging (and if everything works as it should :-), you'll see that the file being debugged pops up in an Emacs buffer and the statements being executed are highlighted. [Note that I am not trying to get credit for the debugger, as it is not my work; I am just describing it].
The bottom line is that while the interpreter/compiler should do its job, there are good reasons to think that its job is just to read and write, and not to make editing easier, because there are other tools whose strong points are precisely in making edition easy. Moreover, trying to interpret special character codes in the toplevel might interfere with these tools or with whatever environment the toplevel is running inside.
This being said, Emacs was chosen to implement a development environment because most of the Ciao developers use Emacs extensively, so it makes sense to build the first environment around the tools we use. Why we think Emacs is a wonderful tool to work with is another question, of course, and a matter of debate (orthogonal to this message).
Having started with (and maintaining the) Emacs environment does not mean at all that we do not want other environments to be developed: after all, the Ciao sources are there, and the behavior of the compiler and toplevel is relatively simple and has remained largely untouched for the last few years. And it can of course be adapted (within the limits of adaptability) to the needs of other environment tools. We are open to collaboration. [Note again that I do not pretend to get credit for the development of the programming environment!]
In any case, we wholeheartedly advice using the Emacs environment, because there are many things which are made simpler by it, such as compiling, loading files into the toplevel, locating errors, debugging, generating documentation, a special buffer to interact with the interpreter, etc. It is, of course, not compulsory. Also, I suppose that there should be graphical tools (other than emacs, that is) which can spawn a subprocess and connect with its standard I/O while keeping track of the lines the user types in and, at the same time, accepting some edition commands to feed the subprocess with previous strings, giving the user the possibility to edit them, etc., without the internal subprocess being aware of this. You get, then, a potentially much more poweful combination with less interaction among the pieces. This is, in many aspects, what the Emacs environment for Ciao Prolog (and for other interpreters) does.
If, for any reason, you prefer not to use the Emacs environment an intermediate solution is just start up an Emacs, type "M-x shell", and then you'll have a shell where the history is saved and can be seen as text. You can access the previously typed strings as David said --- and it does not matter whether these are shell commands, Haskell expressions or Prolog goals. Specialized environments for different languages try to make the range of edition commands available as useful as possible for these languages.