In my first thread I replied to Terry's comment about the fragility of UNLs with this, from near the bottom of this node: https://groups.google.com/d/msg/leo-editor/xf6_HBxlV_c/p9E72lFHM8cJ
> Now to adapt this to Leo - I propose a "canonical tree", which is simply
structured by date - YYYY / MM / DD (possibly HHMM, but I wouldn't). All
content gets created there as nodes there first, and that location never
changes. Clone nodes from there to "where they belong", by topic, function
whatever, but always us the master hierarchy location when creating UNLs.
I have implemented this process in Leo as follows - see also the attached
screenshot.
- every other node in the file is first created under today's date node,
- pressing "Ctrl-N" triggers a macro that
- goes to the first tree in the .leo file (arbitrarily titled
"!masterByCreationDate"). containing children titled YYYY-MM-DD
- goes to the bottom of that tree and checks if there is a node for
today, and if not, creates it
- if there is, goes to the bottommost node and then creates a new one
after its last child, with a default header of a timestamp as above, but
ending with HH:MM:SS
- then does an immediate clone of the node, ready to be moved to the
appropriate "main" location(s) in other outline(s)
Not having a clue about Python or any "real" programming, I've implemented
this in AutoHotKey - any tool snobs just consider what I've pasted below as
pseudocode, in the hope that it might inspire or otherwise help someone.
(comments start with semicolons, ^x = Ctrl-X etc)
;--------------------------------
; all new nodes to first go to !masterByCreationDate tree
#IfWinActive desiderata.leo ; ahk_class QWidget
^n::
Send !xgoto-first-node{Enter}
Send !xexpand-node{Enter}
Send !xgoto-next-node{Enter}
Send !xgoto-last-sibling{Enter}
ClipSaved := ClipboardAll ; save the clipboard's contents
clipboard = ; empty
; copy title of last date node to the clipboard
Send !xedit-headline{Enter}
Send ^a
Send ^c{Enter}
ClipWait ; Wait for the clipboard to contain text.
; compare title of last date node to today
TimeString = ; start empty
FormatTime, TimeString, YYYYMMDD, yyyy-MM-dd
; MsgBox Contents of the
clipboard:`n`n%clipboard%`n`nTimeString:`n`n%TimeString%
if clipboard = %TimeString%
{
; MsgBox Match!
Send !xexpand-next-level{Enter}
Send !xexpand-or-go-right{Enter}
Send !xgoto-last-sibling{Enter}
Send !xinsert-node{Enter}
TimeString = ; start empty
FormatTime, TimeString, YYYYMMDDHH24MISS, yyyy-MM-ddTHH:mm:ss
Send %TimeString%{Enter}
}
else
{
; MsgBox No match!
Send !xinsert-node{Enter}
TimeString = ; start empty
FormatTime, TimeString, YYYYMMDDHH24MISS, yyyy-MM-dd
Send %TimeString%{Enter}
}
Clipboard := ClipSaved ; restore the old clipboard's contents
ClipSaved = ; empty
Send !xcopy-node{Enter}
Send !xpaste-retaining-clones{Enter}
return
;--------------------------------
Of course UNLs will still break if the header gets renamed after the link
gets created, but that's just one of the cross-referencing issues to be
solved by the external FixLinks tool discussed in the original thread.
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/leo-editor/-/j5spk5uNXsQJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/leo-editor?hl=en.
<<attachment: leo-screen1.png>>
