Project management in Leo

95 views
Skip to first unread message

gar

unread,
Jul 19, 2019, 2:09:33 PM7/19/19
to leo-editor
Imagine you develop several tied software projects at the moment. 
Imagine they all use the same settings (like basic paths, colors, whatever else).

In before-leo world you probably have several template files which you fill with current values and include into your projects and reuse settings in there
(file.cfg.in -> file.cfg idiom, where file.cfg.in is under source control and file.cfg is ignored)
And how to deal with this in leo?
AFAIK it's impossible to include other .leo projects or their parts.

How to implement settings/code reuse?
Put everything into myLeoSettings.leo?

Chris George

unread,
Jul 19, 2019, 3:36:36 PM7/19/19
to leo-editor
I can think of several approaches.

@outline-data tree-abbreviations in myLeoSettings.leo that is available to all Leo files.
@button
@command
Point all files to an @file node and share the settings via a single text file. ie. conf.py or a YAML file

There may be reasons some of these approaches wouldn't work for your case. But some might.

HTH,

Chris

gar

unread,
Jul 19, 2019, 4:16:28 PM7/19/19
to leo-e...@googlegroups.com
And how it is possible to specify setings in @file? As I understand
every setting should be a single outline
> --
> You received this message because you are subscribed to the Google Groups
> "leo-editor" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to leo-editor+...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/leo-editor/d03f3fa6-6ebb-4cf4-90f1-c73b128c44b7%40googlegroups.com.
>

vitalije

unread,
Jul 20, 2019, 4:12:31 AM7/20/19
to leo-editor
You can use clones. For example:
--@settings
----my-shared-settings
------...
----some-specific-settings-for-this-outline
------....

--@file my-shared-settings-somewhere.txt
----my-shared-settings

where `my-shared-settings` node is cloned from the @file subtree.

Quite often I use some script to combine some nodes, process them and generate some output file. And such script I put in a node with the following headline: `@button n-save @key=Ctrl-s`. Then whenever I open this outline and whenever I hit Ctrl-s to save the outline, this script is executed. Of course I put in this script `c.save()` call and on every save my files are regenerated. 

When working for a web I often use Coffeescript, some html template generators like Pug, Sass for generating css files, ... Now all of these command line tools have watching mode where they watch folders for file changes and whenever source file is changed they regenerate the output file. But then you also need to run some packaging tool to bundle all generated files. Instead of watching for file changes, my script bound to Ctrl-s regenerate source files in memory and without saving them execute suitable tool only on changed sources and produced outputs bundle in the final file. This makes the whole process much faster.

Attached to this message is a Leo file that I have extracted from one of my projects. I hope that I didn't miss anything that the script require. 

In the outline you can find build server implemented in Coffeescript. You have to use npm or yarn to install necessary modules for this server to work. Once installed you start server by executing `coffee tools/build-server.coffee and it will start listening on port 8011. The script bound to Ctrl-s will search outline for nodes with the headlines like: @vendor, @pug, @coffee, @bulma and for each found node, it checks if the content of this node and its subtree has changed since last time and if it is, this content is sent to build server which transforms the source and returns result that script writes to output file. 

There is one more thing I use for sharing outlines. There are three commands `set-reference-file`, `update-ref-file` and `read-ref-file`. The first lets you choose a reference file for this outline, i.e. public shared outline. It adds a top level headline `---begin-private-area---` to the outline. In the body of this node is the path to the public Leo file. Everything below this node is private, and above is public. The public file should be added to version control (git, fossil,...) and the private file should be added to ignored files for version control tool. And then in the script bound to Ctrl-s you can add `c.fileCommands.save_ref()`, so every time you save your private Leo file, at the same time is updated the public Leo file. That way they never get out of sync.

HTH Vitalije

web-porject-template.leo

gar

unread,
Jul 22, 2019, 4:24:43 AM7/22/19
to leo-e...@googlegroups.com
Oh thank you very very very very much. You workflow is really cool.
I was thinking about something similar but actually all I need - is to adopt your ideas.
Not sure that I will be able to understand everything right now - but I am going to try and try until succeed.
Thank you again.

сб, 20 июл. 2019 г. в 11:12, vitalije <vita...@gmail.com>:
To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/75b65033-8868-42f9-9954-f56e681fd3b6%40googlegroups.com.

vitalije

unread,
Jul 22, 2019, 4:41:36 AM7/22/19
to leo-e...@googlegroups.com
You are welcome. If you need any clarification regarding my script or help to adjust it to your needs, I'll be happy to help.
Vitalije

Edward K. Ream

unread,
Jul 30, 2019, 7:25:46 AM7/30/19
to leo-editor
On Sat, Jul 20, 2019 at 3:12 AM vitalije <vita...@gmail.com> wrote:
You can use clones. [snip] where `my-shared-settings` node is cloned from the @file subtree.
[snip]
`@button n-save @key=Ctrl-s`. Then whenever I open this outline and whenever I hit Ctrl-s to save the outline, this script is executed. Of course I put in this script `c.save()` call and on every save my files are regenerated. 

Clever, and useful.  Thanks for sharing this tip.

[snip]
Instead of watching for file changes, my script bound to Ctrl-s regenerate source files in memory and without saving them execute suitable tool only on changed sources and produced outputs bundle in the final file. This makes the whole process much faster.

Another great tip.

Once installed you start [the coffeescript] server by executing `coffee tools/build-server.coffee and it will start listening on port 8011. The script bound to Ctrl-s will search outline for nodes with the headlines like: @vendor, @pug, @coffee, @bulma and for each found node, it checks if the content of this node and its subtree has changed since last time and if it is, this content is sent to build server which transforms the source and returns result that script writes to output file. 

Ditto.

There is one more thing I use for sharing outlines. There are three commands `set-reference-file`, `update-ref-file` and `read-ref-file`.

Many thanks for all this.

Edward

Edward K. Ream

unread,
Jul 30, 2019, 7:27:56 AM7/30/19
to leo-editor
On Tue, Jul 30, 2019 at 6:25 AM Edward K. Ream <edre...@gmail.com> wrote:
On Sat, Jul 20, 2019 at 3:12 AM vitalije <vita...@gmail.com> wrote:

Many thanks for all this.

I'll add one or more FAQ entries containing these tips.

Edward
Reply all
Reply to author
Forward
0 new messages