On Mon, Jun 23, 2025 at 9:36 AM 'Yaseen Mowzer' via leo-editor <
[email protected]> wrote:

> Hi all
>
> I'm using leo to manage a TODO list. I have two nodes "Next Actions" and
> "Done". When I complete a task I want to move it from "Next Actions" to
> "Done". Currently I'm doing this by holding Shift and then using the arrow
> keys to move the task to Done. But this takes a lot of keypresses. Is there
> a faster way to achieve something like this?
>

Sure. Write an `@button` or `@command` script to do exactly what you want.
You can bind keys to the script.

Here is tested code for an undoable "archive" command bound to F1:

Headline: @button archive @key=F1
Body:

u, undoType = c.undoer, 'Archive Node'
done = g.findNodeAnywhere(c, 'Done')
next_actions = g.findNodeAnywhere(c, 'Next Actions')
p = c.p
if not done:
    g.es_print('"Done" node not found')
elif p == done:
    g.es_print("Can't move 'Done'")
elif p == next_actions:
    g.es_print("Can't move 'Next Actions'")
elif p.parent() == done:
    g.es_print(f"Already archived: '{p.h}'")
else:
    bunch = u.beforeMoveNode(p)
    p.moveToLastChildOf(done)
    g.es_print(f"Node '{p.h}' moved to 'Done'")
    if not next_actions:
        g.es_print('"Next Actions" node not found')
    next_task = next_actions.lastChild() if next_actions else None
    u.afterMoveNode(p, undoType, bunch)
    c.selectPosition(next_task or next_actions)
    c.redraw()

Welcome to the world of Leo scripting!

Edward

-- 
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 view this discussion visit 
https://groups.google.com/d/msgid/leo-editor/CAMF8tS0%3DTsCmUyDSj39yniBCRvvEnTOy97iJc-tO4NuSvdrhJQ%40mail.gmail.com.

Reply via email to