Add Zettel ref getting defaulting to root dir
This commit is contained in:
parent
e2a97570e0
commit
4aa9d98818
3 changed files with 12 additions and 5 deletions
|
@ -82,6 +82,8 @@ next up:
|
||||||
* if moving backwards, we do not take away id space from *future* note creation
|
* if moving backwards, we do not take away id space from *future* note creation
|
||||||
* if moving forwards, every zettel created within a minute would delay next zettel creation *another* minute
|
* if moving forwards, every zettel created within a minute would delay next zettel creation *another* minute
|
||||||
|
|
||||||
|
* [ ] (CODE) switch -- comments to --- doc comments for function descriptions etc
|
||||||
|
|
||||||
## Options
|
## Options
|
||||||
|
|
||||||
atm:
|
atm:
|
||||||
|
|
|
@ -44,10 +44,10 @@ end
|
||||||
function A.get_next_link_on_line(links, curpos)
|
function A.get_next_link_on_line(links, curpos)
|
||||||
local nearestpos = BIGNUMBER
|
local nearestpos = BIGNUMBER
|
||||||
local nearestlink
|
local nearestlink
|
||||||
for k, link in pairs(links) do
|
for _, ln in pairs(links) do
|
||||||
if link.endpos > curpos and link.endpos < nearestpos then
|
if ln.endpos > curpos and ln.endpos < nearestpos then
|
||||||
nearestpos = link.endpos
|
nearestpos = ln.endpos
|
||||||
nearestlink = link
|
nearestlink = ln
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return nearestlink
|
return nearestlink
|
||||||
|
|
|
@ -75,7 +75,13 @@ function ls.get_zettel_by_anchor(anchor, all)
|
||||||
return all[anchor]
|
return all[anchor]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Returns the path to the zettel defined by a reference link.
|
||||||
|
-- Takes a set of files as optional variable in.
|
||||||
|
-- If no set provided will use the (recursive) results
|
||||||
|
-- of zettel_root directory.
|
||||||
function ls.get_zettel_by_ref(ref, files)
|
function ls.get_zettel_by_ref(ref, files)
|
||||||
|
files = files or ls.get_all_files(o.zettel().rootdir, true)
|
||||||
|
|
||||||
local name_only_match
|
local name_only_match
|
||||||
for full_path, bname in pairs(files) do
|
for full_path, bname in pairs(files) do
|
||||||
if full_path == ref then return full_path end
|
if full_path == ref then return full_path end
|
||||||
|
@ -84,5 +90,4 @@ function ls.get_zettel_by_ref(ref, files)
|
||||||
return name_only_match
|
return name_only_match
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return ls
|
return ls
|
||||||
|
|
Loading…
Reference in a new issue