Skip to content
Commits on Source (9)
* @diml @rgrinberg
_build/
/utop-*.tar.gz
/setup.data
/setup.log
/setup.exe
/setup-dev.exe
/man/*.gz
/src/lib/uTop_version.ml
.merlin
*.install
*.elc
.*.swp
......@@ -3,9 +3,15 @@ sudo: required
install: wget https://raw.githubusercontent.com/ocaml/ocaml-ci-scripts/master/.travis-opam.sh
script: bash -ex .travis-opam.sh
env:
- OCAML_VERSION=4.01
- OCAML_VERSION=4.02
global:
- PACKAGE=utop
matrix:
- OCAML_VERSION=4.03
- OCAML_VERSION=4.04
- OCAML_VERSION=4.05
- OCAML_VERSION=4.06
- OCAML_VERSION=4.07
- OCAML_VERSION=4.08
os:
- linux
- osx
2.4.2 (2019-09-18)
------------------
* Add support for OCaml 4.09.0 (@octachron @avsm, #299)
2.4.1 (2019-08-09)
------------------
### General
* Remove camlp4 remnants (@XVilka, #290) (@kandu, #293)
* Allow to statically link utop (@diml, #285) (@hongchangwu, #286)
### Misc
* Remove broken elisp (m-plamann, #292)
* Add OCaml 4.08 build in Travis CI (XVilka, #291)
2.4.0 (2019-05-17)
------------------
### General
* Better support for wide and combined glyph (@kandu)
* Added tips for simpe prompt without fancy features (Marshall Abrams, #279)
* Correct quoting for Windows command shell (Dmitry Bely, #272)
### Additions
* 4.08 compatibility (#284)
* module `UTop`: add `get_load_path` and `set_load_path` to manage the include directories (#284)
### Breaking
* module `UTop`: `val load_path : string list ref` is removed (#284)
2.3.0 (2019-01-31)
------------------
The new feature in this release is to automatically install
printers marked with `[@@ocaml.toplevel_printer]` (#269 @diml).
Adding this annotation to your libraries will remove the need
to have a separate `top` package to install the printers.
For example, in the [uri](https://github.com/mirage/ocaml-uri)
library, the old printing function for `Uri.t` was:
```
val pp_hum : Format.formatter -> t -> unit
```
Just adding this annotation results in `Uri.t` values being automatically
pretty printed in this version of utop.
```
val pp_hum : Format.formatter -> t -> unit [@@ocaml.toplevel_printer]
```
* Add cool screenshot to README (#259 @rizo) and update links (#257 @bobot)
* Improve robustness by using more tail-recursive functions (#251 @gpetiot)
* Remove deprecation warnings in newer compilers (#246 @ncihnegn)
* Minimum OCaml version supported is now 4.03.0 (#254 @XVilka)
* Publish API documentation online and add `doc:` entry to opam file (#270 @avsm)
* Port build to dune from jbuilder (#268 @avsm)
* Upgrade local opam metadata to opam 2.0 format (#268 @avsm)
2.2.0 (2018-07-15)
------------------
* 4.07.0 compatibility (#238, @hcarty)
* Fix compatibility with latest tuareg-mode (#241, @Wilfred)
* Do not expand include directories (#242, @sliquister)
2.1.0 (2018-02-28)
------------------
* Add support for company-mode based completion in utop.el (#233)
2.0.2 (2017-11-07)
------------------
* 4.06.0 compatibility (#221)
2.0.1 (2016-05-30)
------------------
* Fix: restore the installation of `utop.el` (#210, Louis Gesbert)
2.0.0 (2016-05-26)
------------------
* Add `-implicit-bindings` option to automatically bind expressions to names
`_0`, `_1` and so on. For example, `3 + 4;;` becomes `let _0 = 3 + 4;;`
(#161, #193, Fabian Hemmer)
* Add tab completion for `#mod_use` (#181, Leonid Rozenberg)
* Mention `#help` in `#utop_help` (#190, Fabian Hemmer)
* Add `#utop_stash` and `#utop_save` to save the session to a file
(#169, #199, Christopher Mcalpine and Fabian Hemmer)
* Add support for reason in the emacs mode (#206, Andrea Richiardi)
* Fix a bug where utop wouldn't apply ppx rewriters when running in
emacs (Bug report: #192, fix: #202, Deokhwan Kim)
* Refactor the use of hooks to support the various OCaml emacs mode
(#201, Andrea Richiardi)
* Drop support for camlp4/camlp5
* Drop support for OCaml <= 4.01
* Switch the build system to jbuilder
* Resurect `UTop_main.interact`
1.19.3 (2016-08-15)
-------------------
......@@ -79,7 +187,7 @@
* don't try to colorize the output when there is too much
* add auto-completion for the `#ppx` directive
* add support for -ppx, -dparsetree and -dsource
* fix compatiblity with OCaml 4.02
* fix compatibility with OCaml 4.02
* update pa_optcomp
* do not display the camlp4 welcome message
......
# Makefile
# --------
# Copyright : (c) 2012, Jeremie Dimino <jeremie@dimino.org>
# Licence : BSD3
#
# Generic Makefile for oasis project
INSTALL_ARGS := $(if $(PREFIX),--prefix $(PREFIX),)
# Set to setup.exe for the release
SETUP := setup.exe
.PHONY: all
all:
dune build
# Default rule
default: build
.PHONY: install
install:
dune install $(INSTALL_ARGS)
# Setup for the development version
setup-dev.exe: _oasis setup.ml
sed '/^#/D' setup.ml > setup_dev.ml
ocamlfind ocamlopt -o $@ -linkpkg -package ocamlbuild,oasis.dynrun setup_dev.ml || \
ocamlfind ocamlc -o $@ -linkpkg -package ocamlbuild,oasis.dynrun setup_dev.ml || true
rm -f setup_dev.*
.PHONY: uninstall
uninstall:
dune uninstall $(INSTALL_ARGS)
# Setup for the release
setup.exe: setup.ml
ocamlopt.opt -w -3 -o $@ $< || ocamlopt -w -3 -o $@ $< || ocamlc -w -3 -o $@ $<
rm -f setup.cmx setup.cmi setup.o setup.obj setup.cmo
.PHONY: reinstall
reinstall:
$(MAKE) uninstall
$(MAKE) install
build: $(SETUP) setup.data
./$(SETUP) -build $(BUILDFLAGS)
doc: $(SETUP) setup.data build
./$(SETUP) -doc $(DOCFLAGS)
cp style.css _build/utop-api.docdir/
.PHONY: examples
examples:
dune build @examples
test: $(SETUP) setup.data build
./$(SETUP) -test $(TESTFLAGS)
.PHONY: test
test:
dune runtest
all: $(SETUP)
./$(SETUP) -all $(ALLFLAGS)
.PHONY: all-supported-ocaml-versions
all-supported-ocaml-versions:
dune build --workspace dune-workspace.dev
install: $(SETUP) setup.data
ocamlfind remove utop 2>/dev/null || true
./$(SETUP) -install $(INSTALLFLAGS)
.PHONY: cinaps
cinaps:
cinaps -styler ocp-indent -i src/migrate_parsetree_versions.ml*
cinaps -styler ocp-indent -i src/migrate_parsetree_40?_40?.ml*
uninstall: $(SETUP) setup.data
./$(SETUP) -uninstall $(UNINSTALLFLAGS)
reinstall: $(SETUP) setup.data
ocamlfind remove utop 2>/dev/null || true
./$(SETUP) -reinstall $(REINSTALLFLAGS)
clean: $(SETUP)
./$(SETUP) -clean $(CLEANFLAGS)
distclean: $(SETUP)
./$(SETUP) -distclean $(DISTCLEANFLAGS)
configure: $(SETUP)
./$(SETUP) -configure $(CONFIGUREFLAGS)
setup.data: $(SETUP)
./$(SETUP) -configure $(CONFIGUREFLAGS)
gh-pages: doc
git clone `git config --get remote.origin.url` .gh-pages --reference .
git -C .gh-pages checkout --orphan gh-pages
git -C .gh-pages reset
git -C .gh-pages clean -dxf
cp -t .gh-pages/ _build/utop-api.docdir/*
git -C .gh-pages add .
git -C .gh-pages commit -m "Update Pages"
git -C .gh-pages push origin gh-pages -f
rm -rf .gh-pages
.PHONY: default build doc test all install uninstall reinstall clean distclean configure gh-pages
.PHONY: clean
clean:
rm -rf _build *.install
find . -name .merlin -delete
utop - a universal toplevel for OCaml
=====================================
utop a universal toplevel (i.e., REPL) for OCaml
==================================================
utop is an improved toplevel for OCaml. It can run in a terminal or
in Emacs. It supports line edition, history, real-time and context
utop is an improved toplevel (i.e., Read-Eval-Print Loop) for
OCaml. It can run in a terminal or
in Emacs. It supports line editing, history, real-time and context
sensitive completion, colors, and more.
It integrates with the tuareg and typerex modes in Emacs.
It integrates with the Tuareg and typerex modes in Emacs.
[![Travis build Status](https://travis-ci.org/diml/utop.svg?branch=master)](https://travis-ci.org/diml/utop)
[![Travis build Status](https://travis-ci.org/ocaml-community/utop.svg?branch=master)](https://travis-ci.org/ocaml-community/utop)
![Screenshot](screenshot.png)
Installation via opam
---------------------
......@@ -23,35 +26,27 @@ dependencies listed in the next section.
Dependencies
------------
* [OCaml](http://caml.inria.fr/ocaml/) (>= 4.01.0)
* [OCaml](http://caml.inria.fr/ocaml/) (>= 4.03.0)
* [Dune](http://github.com/ocaml/dune)
* [findlib](http://projects.camlcity.org/projects/findlib.html) (>= 1.4.0)
* [cppo](http://mjambon.com/cppo.html) (>= 1.0.1)
* [react](http://erratique.ch/software/react)
* [lwt](http://ocsigen.org/lwt/) (>= 2.4.0) built with react support
* [Camomile](http://github.com/yoriyuki/Camomile) (>= 0.8)
* [zed](http://github.com/diml/zed) (>= 1.2)
* [lambda-term](http://github.com/diml/lambda-term) (>= 1.2)
* [camlp4](http://github.com/ocaml/camlp4) (optional)
For building the development version, you also need to install
[oasis](http://oasis.forge.ocamlcore.org/) (>= 0.4.0).
* [zed](http://github.com/diml/zed) (>= 2.0)
* [lambda-term](http://github.com/diml/lambda-term) (>= 2.0)
Installation from sources
-------------------------
To build and install utop:
$ ./configure
$ make
$ make install
If you want to be able to use camlp4, rather use:
$ ./configure --enable-camlp4
### Documentation and manual pages _(optional)_
To build the documentation:
To build the documentation (currently broken):
$ make doc
......@@ -59,9 +54,8 @@ It will then be installed by `make install`.
### Tests _(optional)_
To build and execute tests:
To build and execute tests (currently broken):
$ ./configure --enable-tests
$ make test
Usage
......@@ -91,6 +85,17 @@ terminals with light colors (such as black on white).
You can customize the prompt of utop by setting the reference
`UTop.prompt`.
To turn off all colors and remove the line above the prompt
that lists time, etc., add this to your .ocamlinit file:
```OCaml
#utop_prompt_dummy;;
```
To turn off the line of boxes listing possible completions that appears under
the prompt, add this to .ocamlinit:
```OCaml
UTop.set_show_box false
```
### Key bindings
Key bindings in the terminal can be changed by writing a
......@@ -109,7 +114,7 @@ this file by executing:
### UTop API
UTop exposes several more settings through its API; see
[documentation](http://diml.github.io/utop).
[documentation](http://ocaml-community.github.io/utop).
Integration with emacs
----------------------
......@@ -212,9 +217,88 @@ correctly:
It shall point to the directory `stublibs` inside your ocaml installation.
Automatically installing toplevel printers
------------------------------------------
Utop will automatically install toplevel printers for custom
types if their interface file is marked with an
`[@@ocaml.toplevel_printer]` attribute. Adding this annotation to
your libraries will remove the need to have a separate `top` package
to install the printers.
For example, in the [uri](https://github.com/mirage/ocaml-uri)
library, the old printing function for `Uri.t` was:
```
val pp_hum : Format.formatter -> t -> unit
```
Just adding this annotation results in `Uri.t` values being automatically
pretty printed in this version of utop.
```
val pp_hum : Format.formatter -> t -> unit [@@ocaml.toplevel_printer]
```
There should be no downsides to adding this attribute to your
libraries, so we encourage community library maintainers to
use this attribute to improve the out-of-the-box experience
for users of their libraries within utop.
Creating a custom utop-enabled toplevel
---------------------------------------
### With Dune
The recommended way to build a custom utop toplevel is via
[Dune][dune]. The entry point of the custom utop must call
`UTop_main.main`. For instance write the following `myutop.ml` file:
```ocaml
let () = UTop_main.main ()
```
and the following dune file:
```scheme
(executable
(name myutop)
(link_flags -linkall)
(libraries utop))
```
then to build the toplevel, run:
```
$ dune myutop.bc
```
Note the `-linkall` in the link flags. By default OCaml doesn't link
unused modules, however for a toplevel you don't know in advance what
the user is going to use so you must link everything.
If you want to include more libraries in your custom utop, simply add
them to the `(libraries ...)` field.
Additionally, if you want to install this toplevel, add the two
following fields to the executable stanza:
```scheme
(public_name myutop)
(modes byte)
```
The `(modes ...)` field is to tell dune to install the byte-code
version of the executable, as currently native toplevels are not fully
suported.
[dune]: https://github.com/ocaml/dune
### Manually, with ocamlfind
This section describe methods using ocamlfind. These are no longer
tested, so there is no guarantee they still work.
If you want to create a custom toplevel with utop instead of the
classic one you need to link it with utop and its dependencies and
call `UTop_main.main` in the last linked unit. You also need to pass
......
# +-------------------------------------------------------------------+
# | Package parameters |
# +-------------------------------------------------------------------+
OASISFormat: 0.4
OCamlVersion: >= 4.01
Name: utop
Version: 1.19.3
LicenseFile: LICENSE
License: BSD-3-clause
Authors: Jeremie Dimino
Maintainers: Jeremie Dimino <jeremie@dimino.org>
Homepage: https://github.com/diml/utop
BuildTools: ocamlbuild
Plugins: DevFiles (0.3), META (0.3)
XDevFilesEnableMakefile: false
FilesAB: src/lib/uTop_version.ml.ab
AlphaFeatures: ocamlbuild_more_args
XOCamlbuildPluginTags: package(cppo_ocamlbuild)
Synopsis: Universal toplevel for OCaml
Description:
utop is an improved toplevel for OCaml. It can run in a terminal or
in Emacs. It supports line edition, history, real-time and context
sensitive completion, colors, and more.
.
It integrates with the tuareg mode in Emacs.
# +-------------------------------------------------------------------+
# | The toplevel |
# +-------------------------------------------------------------------+
Flag camlp4
Description: camlp4 support
Default: false
Flag interact
Description: enable UTop_main.interact (requires ppx_tools)
Default: false
Library utop
Path: src/lib
Modules:
UTop,
UTop_main
InternalModules:
UTop_private,
UTop_version,
UTop_lexer,
UTop_token,
UTop_complete,
UTop_styles,
UTop_cmt_lifter
BuildDepends: threads, findlib, lambda-term (>= 1.2)
XMETADescription: utop configuration
XMETARequires: findlib, lambda-term
Library "utop-camlp4"
Build$: flag(camlp4)
Install$: flag(camlp4)
FindlibName: camlp4
FindlibParent: utop
Path: src/camlp4
Modules: UTop_camlp4
BuildDepends: utop, camlp4
XMETAType: syntax
XMETADescription: Camlp4 integration
Executable utop
Install: true
Path: src/top
CompiledObject: byte
MainIs: uTop_top.ml
BuildDepends: threads, findlib, lambda-term, utop
DataFiles: utop.el ($datadir/emacs/site-lisp)
Executable "utop-full"
Install: true
Path: src/top
CompiledObject: byte
MainIs: uTop_top_full.ml
BuildDepends: threads, findlib, lambda-term, utop
DataFiles: utop.el ($datadir/emacs/site-lisp)
# +-------------------------------------------------------------------+
# | Doc |
# +-------------------------------------------------------------------+
Document "utop-api"
Title: API reference for utop
Type: ocamlbuild (0.3)
Install: true
InstallDir: $htmldir/api
DataFiles: style.css
BuildTools: ocamldoc
XOCamlbuildPath: ./
XOCamlbuildLibraries: utop
XOCamlbuildExtraArgs: "-docflag -t -docflag 'API reference for utop' -docflags '-colorize-code -short-functors -charset utf-8 -css-style style.css'"
# +-------------------------------------------------------------------+
# | Manual pages |
# +-------------------------------------------------------------------+
Document "utop-man"
Type: custom (0.3)
Title: Man page for utop
Install: true
BuildTools: gzip
XCustom: $gzip -c man/utop.1 > man/utop.1.gz
XCustomClean: $rm man/utop.1.gz
DataFiles: man/utop.1.gz
InstallDir: $mandir/man1
Document "utop-full-man"
Type: custom (0.3)
Title: Man page for utop
Install: true
BuildTools: gzip
XCustom: $gzip -c man/utop-full.1 > man/utop-full.1.gz
XCustomClean: $rm man/utop-full.1.gz
DataFiles: man/utop-full.1.gz
InstallDir: $mandir/man1
Document "utoprc-man"
Type: custom (0.3)
Title: Man page for utoprc
Install: true
BuildTools: gzip
XCustom: $gzip -c man/utoprc.5 > man/utoprc.5.gz
XCustomClean: $rm man/utoprc.5.gz
DataFiles: man/utoprc.5.gz
InstallDir: $mandir/man5
# +-------------------------------------------------------------------+
# | Configuration examples |
# +-------------------------------------------------------------------+
Document "utoprcs"
Type: custom (0.3)
Title: utoprc examples
XCustom: true
Install: true
DataFiles: utoprc-dark, utoprc-light
# +-------------------------------------------------------------------+
# | Misc |
# +-------------------------------------------------------------------+
SourceRepository head
Type: git
Location: https://github.com/diml/utop.git
Browser: https://github.com/diml/utop
# -*- conf -*-
<src/**/*.ml{,i}>: cppo_V_OCAML, cppo_interact, package(compiler-libs)
<src/camlp5/**/*.ml{,i}>: use_camlp5
<**/*.ml>: warn(-3-40@8)
# OASIS_START
# DO NOT EDIT (digest: 0e8c977c59cd4b29b0e0ba0f7c9f1d20)
# Ignore VCS directories, you can use the same kind of rule outside
# OASIS_START/STOP if you want to exclude directories that contains
# useless stuff for the build process
true: annot, bin_annot
<**/.svn>: -traverse
<**/.svn>: not_hygienic
".bzr": -traverse
".bzr": not_hygienic
".hg": -traverse
".hg": not_hygienic
".git": -traverse
".git": not_hygienic
"_darcs": -traverse
"_darcs": not_hygienic
# Library utop
"src/lib/utop.cmxs": use_utop
<src/lib/*.ml{,i,y}>: package(findlib)
<src/lib/*.ml{,i,y}>: package(lambda-term)
<src/lib/*.ml{,i,y}>: package(threads)
# Library utop-camlp4
"src/camlp4/utop-camlp4.cmxs": use_utop-camlp4
<src/camlp4/*.ml{,i,y}>: package(camlp4)
<src/camlp4/*.ml{,i,y}>: package(findlib)
<src/camlp4/*.ml{,i,y}>: package(lambda-term)
<src/camlp4/*.ml{,i,y}>: package(threads)
<src/camlp4/*.ml{,i,y}>: use_utop
# Executable utop
"src/top/uTop_top.byte": package(findlib)
"src/top/uTop_top.byte": package(lambda-term)
"src/top/uTop_top.byte": package(threads)
"src/top/uTop_top.byte": use_utop
# Executable utop-full
"src/top/uTop_top_full.byte": package(findlib)
"src/top/uTop_top_full.byte": package(lambda-term)
"src/top/uTop_top_full.byte": package(threads)
"src/top/uTop_top_full.byte": use_utop
<src/top/*.ml{,i,y}>: package(findlib)
<src/top/*.ml{,i,y}>: package(lambda-term)
<src/top/*.ml{,i,y}>: package(threads)
<src/top/*.ml{,i,y}>: use_utop
# OASIS_STOP
#!/bin/sh
# OASIS_START
# DO NOT EDIT (digest: dc86c2ad450f91ca10c931b6045d0499)
set -e
FST=true
for i in "$@"; do
if $FST; then
set --
FST=false
fi
case $i in
--*=*)
ARG=${i%%=*}
VAL=${i##*=}
set -- "$@" "$ARG" "$VAL"
;;
*)
set -- "$@" "$i"
;;
esac
done
ocaml setup.ml -configure "$@"
# OASIS_STOP
(install
(section share)
(files utoprc-dark utoprc-light))
(install
(section share_root)
(files
(src/top/utop.el as emacs/site-lisp/utop.el)))
(alias
(name examples)
(deps examples/custom-utop/myutop.bc examples/interact/test_program.bc))
(lang dune 1.0)
(name utop)
(lang dune 1.0)
;; This file is used by `make all-supported-ocaml-versions`
(context (opam (switch 4.02.3)))
(context (opam (switch 4.03.0)))
(context (opam (switch 4.04.2)))
(context (opam (switch 4.05.0)))
(context (opam (switch 4.06.1)))
(context (opam (switch 4.07.0)))
OC := ocamlbuild -classic-display -no-links -use-ocamlfind
build:
$(OC) -tag thread -pkg threads,utop myutop.top
clean:
$(OC) -clean
To build the custom toplevel in this directory, run:
$ dune build myutop.bc
(executable
(name myutop)
(flags :standard -safe-string)
(link_flags -linkall)
(libraries utop))
OC := ocamlbuild -classic-display -no-links -use-ocamlfind
build:
$(OC) -pkg threads,compiler-libs.toplevel,utop test_program.byte
clean:
$(OC) -clean
true: thread, linkall, predicate(create_toploop), warn(-40), bin_annot