​
On Thu, Mar 14, 2019 at 3:28 AM Matt Wilkie <[email protected]> wrote:

> Is there a code style guide for contributing to Leo?

​No, but you might consider running the beautify-node/tree command on the 
code. This command just regularizes whitespace and deletes extra blanks 
lines.

Also, you should use section references only in special circumstances, like 
<< imports >>.  fast_at.scan_lines is one of those special circumstances.  
Order is important, so @others would be dangerous, a point I made far too 
forcefully, to my sorrow.

Edward

P. S. Here is scan_lines:

def scan_lines(self, delims, first_lines, lines, start, test=False):
    '''Scan all lines of the file, creating vnodes.'''
    << init scan_lines >>
    << define dump_v >>
    i = 0 # To keep pylint happy.
    for i, line in enumerate(lines[start:]):
        # Order matters.
        << 1. common code for all lines >>
        << 2. short-circuit later tests >>
        << 3. handle @others >> # clears in_doc
        << 4. handle section refs >> # clears in_doc.
        # Order doesn't matter, but match more common sentinels first.
        << handle node_start >>
        << handle end of @doc & @code parts >>
        << handle @all >>
        << handle afterref >>
        << handle @first and @last >>
        << handle @comment >>
        << handle @delims >>
        << handle @raw >>
        << handle @-leo >>
        # These must be last, in this order.
        << Last 1. handle remaining @@ lines >>
        << Last 2. handle remaining @doc lines >>
        << Last 3. handle remaining @ lines >>
    else:
        # No @-leo sentinel
        return None, []
    # Handle @last lines.
    last_lines = lines[start+i:]
    if last_lines:
        last_lines = ['@last ' + z for z in last_lines]
        gnx2body[root_gnx] = gnx2body[root_gnx] + last_lines
    self.post_pass(gnx2body, gnx2vnode, root_v)
    return root_v, last_lines

This may be the only place in Leo where the speed gained by using section 
references matters.

EKR

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to