mark/unmark-first-parents

31 views
Skip to first unread message

tscv11

unread,
Feb 4, 2018, 12:50:28 AM2/4/18
to leo-editor
Here are two basic commands I created for researching .leo files. I use them
to mark/unmark the 'breadcrumbs' to nodes when marking/unmarking those nodes
themselves (first parents, counting the way Leo does). I like knowing which
categories and subcategories contain nodes I've marked (the current node is
marked as well, naturally, showing where the breadcrumbs lead).

It's not the code I want to share, really, as much as the idea. My apologies
if this has been covered before. I did a cursory search in LeoRef.py and on
the net before posting this, but it's always possible I've missed something.
I also realize that this may only be useful for my own study habits - I'm
sorry if it doesn't apply to you.

   
tscv11

mark-unmark-first-parents.leo

tscv11

unread,
Feb 4, 2018, 1:01:42 AM2/4/18
to leo-e...@googlegroups.com
As an afterthought, for those who are wary of .leo files from 'unknown' sources, here's the code:

@language python

def mark_first_parents():
   
   
"""mark the first parent of each node, moving up the tree
        to the top level. print the list of marked parents."""

   
    parent_lst
= []
    p
= c.p
    old_p
= p
    c
.markHeadline(p)
   
   
for parent in p.parents():
       
if parent:
            c
.selectPosition(parent)
            c
.markHeadline(parent)
            parent_lst
.append(parent.h)
   
    c
.redraw()
   
if parent_lst:
        g
.es("marked: " + str(parent_lst))
       
    c
.selectPosition(old_p)
       
mark_first_parents
()

@language python

def unmark_first_parents():
   
   
"""unmark the first parent of each node, moving up the tree
        to the top level. print the list of unmarked parents."""

   
    parent_lst
= []
    p
= c.p
    c
.clearMarked(p)
   
   
for parent in p.parents():
       
if parent:
            c
.selectPosition(parent)
            c
.clearMarked(parent)
            parent_lst
.append(parent.h)
   
    c
.redraw()
   
if parent_lst:
        g
.es("unmarked: " + str(parent_lst))
       
unmark_first_parents
()


- tscv11


Message has been deleted

Edward K. Ream

unread,
Feb 4, 2018, 7:07:40 AM2/4/18
to leo-editor
On Sun, Feb 4, 2018 at 12:01 AM, tscv11 <tsc....@gmail.com> wrote:
As an afterthought, for those who are wary of .leo files from 'unknown' sources, here's the code:

​Thanks for this.  The scripts could be copied to leo/scripts/scripts.leo.  In this case, I may create new commands from them.

Edward
Message has been deleted
Message has been deleted
Message has been deleted

tscv11

unread,
Feb 4, 2018, 5:46:36 PM2/4/18
to leo-editor
After consulting Edward and Terry, the finished (I think) 'unmark-first-parents' command now works as intended.

@language python

def unmark_first_parents():
   
   
"""unmark the first parent of each node, moving up the tree
        to the top level. print the list of unmarked parents."""

   

    parent_lst
= []

    old_p
= p = c.p

   
if p.isMarked():
        c
.clearMarked(p)
   
   
for nd in p.self_and_siblings():
       
if nd.v != old_p.v:
           
if nd.v.isMarked():
               
break
   
   
else:
       
for parent in p.parents():
           
if parent.isMarked():

Edward K. Ream

unread,
Feb 10, 2018, 5:23:48 AM2/10/18
to leo-editor
On Sun, Feb 4, 2018 at 4:46 PM, tscv11 <tsc....@gmail.com> wrote:
After consulting Edward and Terry, the finished (I think) 'unmark-first-parents' command now works as intended.

​Excellent.  Thanks for this work.  This is on the list of things before Leo 5.7b2.

Edward

Edward K. Ream

unread,
Feb 10, 2018, 5:30:37 AM2/10/18
to leo-editor
On Sat, Feb 10, 2018 at 4:23 AM, Edward K. Ream <edre...@gmail.com> wrote:

This is on the list of things before Leo 5.7b2.

​I've just created #714 for this, with a milestone of 5.7. This will ensure it remains on my radar for 5.7b2, coming in a day or three.

Edward
Reply all
Reply to author
Forward
0 new messages