DRY nodes?

54 views
Skip to first unread message

The Living Cosmos

unread,
Oct 8, 2019, 3:53:30 AM10/8/19
to leo-editor
In generating code, one typically would want the name of the node to be the particular entity you were defining.

For instance, if you had a node per class, then you would not want to manually name each node and then in the body of the node write the same thing.

Is there a dont-repeat-yourself possibility for node naming in Leo?

Edward K. Ream

unread,
Oct 8, 2019, 4:20:43 AM10/8/19
to leo-editor
On Tue, Oct 8, 2019 at 2:53 AM The Living Cosmos <thequie...@gmail.com> wrote:
In generating code, one typically would want the name of the node to be the particular entity you were defining.

True, but automating this won't be easy.  As you will see from LeoPyRef.py, I use short prefixes to denote the class of nodes containing methods.  For example, "app." for the LeoApp class, and "adoc." for the AsciiDoctorCommands class.

For instance, if you had a node per class, then you would not want to manually name each node and then in the body of the node write the same thing.

Hmm.  This might be a good idea.

After I create a lot of methods (for a new class) I'll use a regex search/replace (headline only) to set the class's prefix:

Find:  ^(.)
Replace:  prefix.\1

Edward

The Living Cosmos

unread,
Oct 9, 2019, 2:26:47 AM10/9/19
to leo-e...@googlegroups.com
Maybe the reverse way would work: a directive in the body that dictates what the node headline will be:

@headline-from-first-line # of  body

--
You received this message because you are subscribed to a topic in the Google Groups "leo-editor" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/leo-editor/rSg_8qgCbig/unsubscribe.
To unsubscribe from this group and all its topics, send an email to leo-editor+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/CAMF8tS1woLUD0DoYkh%2Bb99AekDfttCY2L8fy91RgnVvny%2Bzh7g%40mail.gmail.com.

Edward K. Ream

unread,
Oct 9, 2019, 7:36:32 AM10/9/19
to leo-editor
On Wed, Oct 9, 2019 at 1:26 AM The Living Cosmos <thequie...@gmail.com> wrote:
Maybe the reverse way would work: a directive in the body that dictates what the node headline will be:

@headline-from-first-line # of  body

One could imagine a command that would act on a set of nodes, say the descendants.  The command could prompt for a prefix.

Edward
Reply all
Reply to author
Forward
0 new messages