rename link: doesn't destroy data, but you're on the hook now to make the global structure of the graph make sense to you.
clear link: extremely unsafe and might make notes unreachable if you're not careful.
QWWOAZ3P73XN74JBLI23YKM7KKRUCH55EMD7I6VPKG7B6DWZXB2QC
OQIWNGD4Q7G5ZW7KTM6FUUEYX43DZ6LNP3Q5BXXLGE35QLU3LX5AC
47RPC7ATVC6VSS7X6EPD4NB6PHZ5OU4KR62N2PV5WDDIJPQMO4UQC
QMWB3N3NKEACQBGY7JRFW5J74Z74CBLKJC2EDJJEDV7NKM2NQCGQC
GQBUV2XOMEPMTXMPCBQWGGIUXGQDX77VTGPFIG6YT7G64ASOYHXQC
CIOTARCZGYB3CVH6RMR2IGJ7UBKJAFOACPMCIGMHEXRCL63CKR6AC
IZAQ4C7DZ3OTGUPDYVRYJPHO6HT67HL7DZLPNIPWINBHNNLK42OAC
AUE2Y6HE5AIZVFO6EGLYNXKBDXGXJKDURTA4CFAEX6ZWRZKUCMUQC
SYUCEGP3UTN76WUUAO7E2BDEZFRZILUZBKB6LG5C2N54SFGDU5LAC
plan_draw()
end
function command.rename_link(args)
local from, to = args:match('(%w+)%s+to%s+(%w+)')
if from == nil then
from, to = args:match('(%w+)%s+(%w+)')
end
if Cursor_pane.col < 1 then
print('no current note')
return
end
local pane = Surface[Cursor_pane.col][Cursor_pane.row]
if pane == nil then
print('no current note')
return
end
print('renaming link', from, 'of', pane, 'to', to)
if Cache[pane.id].links[to] then
print(('%s already has a %s note'):format(pane.id, to))
return
end
local target = Cache[pane.id].links[from]
local from_opposite = Opposite[from]
Cache[pane.id].links[to] = Cache[pane.id].links[from]
Cache[pane.id].links[from] = nil
if Opposite[to] ~= Opposite[from] then
if Cache[target.id].links[Opposite[to]] then
print(('target %s already has a %s note'):format(target.id, Opposite[to]))
return
end
Cache[target.id].links[Opposite[to]] = Cache[target.id].links[Opposite[from]]
Cache[target.id].links[Opposite[from]] = nil
end
schedule_save(pane)
stop_editing(pane)
end
function command.clear_link(rel)
if rel == nil then
print('specify a link to clear')
return
end
if Cursor_pane.col < 1 then
print('no current note')
return
end
local pane = Surface[Cursor_pane.col][Cursor_pane.row]
if pane == nil then
print('no current note')
return
end
if Cache[pane.id].links[rel] == nil then
print(('%s has no %s note'):format(pane.id, rel))
return
end
print(('clearing link %s of %s (used to point to %s)'):format(rel, pane.id, Cache[pane.id].links[rel]))
Cache[pane.id].links[rel] = nil
schedule_save(pane)
stop_editing(pane)
refresh_pane_height(pane) -- just in case this is the final link