Interpret empty jbuild-workspace files as default configuration

If a workspace file is empty, interpret it the same as if it contained:

  (context default)

As discussed in #234
This commit is contained in:
Jeremie Dimino 2017-08-30 01:29:54 +01:00
parent c71acbd930
commit b2e7720b41
2 changed files with 16 additions and 8 deletions

View File

@ -16,13 +16,6 @@ jbuild-workspace
The root of the current workspace is determined by looking up a
``jbuild-workspace`` file in the current directory and parent directories.
``jbuilder`` prints out the root when starting:
.. code:: bash
$ jbuilder runtest
Workspace root: /usr/local/home/jdimino/workspaces/public-jane/+share+
...
More precisely, it will choose the outermost ancestor directory containing a
``jbuild-workspace`` file as root. For instance if you are in
@ -54,7 +47,7 @@ in ancestor directories. For instance ``jbuild-workspace.dev``. If such a file
is found, it will mark the root of the workspace. ``jbuilder`` will however not
read its contents.
The rationale for this rule is that it is good practice to have a
The rationale for this rule is that it is good practice to have a
``jbuild-workspace.dev`` file at the root of your project.
For quick experiments, simply do this to mark the root:
@ -312,6 +305,16 @@ a typical ``jbuild-workspace`` file looks like:
The rest of this section describe the stanzas available.
Note that an empty ``jbuild-workspace`` file is interpreted the same
as one containing exactly:
.. code:: scheme
(context default)
This allows you to use an empty ``jbuilder-workspace`` file to mark
the root of your project.
context
~~~~~~~

View File

@ -65,6 +65,11 @@ let t sexps =
| _ ->
(merlin_ctx, ctx :: ctxs))
in
let contexts =
match contexts with
| [] -> [Context.Default]
| _ -> contexts
in
let merlin_ctx =
match merlin_ctx with
| Some _ -> merlin_ctx