diff --git a/README.md b/README.md index a244116..63a2fac 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,8 @@ next up: * 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 +* [ ] (CODE) switch -- comments to --- doc comments for function descriptions etc + ## Options atm: diff --git a/lua/zettelkasten/action.lua b/lua/zettelkasten/action.lua index 8b52683..5c77270 100644 --- a/lua/zettelkasten/action.lua +++ b/lua/zettelkasten/action.lua @@ -44,10 +44,10 @@ end function A.get_next_link_on_line(links, curpos) local nearestpos = BIGNUMBER local nearestlink - for k, link in pairs(links) do - if link.endpos > curpos and link.endpos < nearestpos then - nearestpos = link.endpos - nearestlink = link + for _, ln in pairs(links) do + if ln.endpos > curpos and ln.endpos < nearestpos then + nearestpos = ln.endpos + nearestlink = ln end end return nearestlink diff --git a/lua/zettelkasten/files.lua b/lua/zettelkasten/files.lua index 793f8ea..4c23dc8 100644 --- a/lua/zettelkasten/files.lua +++ b/lua/zettelkasten/files.lua @@ -75,7 +75,13 @@ function ls.get_zettel_by_anchor(anchor, all) return all[anchor] 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) + files = files or ls.get_all_files(o.zettel().rootdir, true) + local name_only_match for full_path, bname in pairs(files) do 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 end - return ls