From b2e7720b41dccecea2dc78bccac9cabfb0a9761e Mon Sep 17 00:00:00 2001 From: Jeremie Dimino Date: Wed, 30 Aug 2017 01:29:54 +0100 Subject: [PATCH] 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 --- doc/usage.rst | 19 +++++++++++-------- src/workspace.ml | 5 +++++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/doc/usage.rst b/doc/usage.rst index c877e6ba..c14968c9 100644 --- a/doc/usage.rst +++ b/doc/usage.rst @@ -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 ~~~~~~~ diff --git a/src/workspace.ml b/src/workspace.ml index ddd8a19c..6ee16417 100644 --- a/src/workspace.ml +++ b/src/workspace.ml @@ -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