Skip to content

Commit 3fbb674

Browse files
committed
feat: support id links for headlines
Relies on an api extension of orgmode.
1 parent 0c439b8 commit 3fbb674

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

lua/telescope-orgmode/actions.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function M.insert(_)
6565

6666
-- Link to a specific heading if is set
6767
if entry.value.headline then
68-
destination = 'file:' .. entry.value.file.filename .. '::*' .. entry.value.headline.title
68+
destination = org.get_link_to_headline(entry.value.headline)
6969
end
7070

7171
org.insert_link(destination)
@@ -83,11 +83,11 @@ function M._find_orgfiles(opts, prompt_bufnr)
8383
M._update_picker(orgfiles, opts.prompt_titles.orgfiles, prompt_bufnr)
8484
end
8585

86-
function M._update_picker(results, title, prompt_bufnr)
86+
function M._update_picker(finder, title, prompt_bufnr)
8787
local current_picker = action_state.get_current_picker(prompt_bufnr)
8888

8989
current_picker.layout.prompt.border:change_title(title)
90-
current_picker:refresh(results)
90+
current_picker:refresh(finder)
9191
end
9292

9393
return M

lua/telescope-orgmode/entry_maker/headlines.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ local function index_headlines(file_results, opts)
2020
file = file_entry.file,
2121
filename = file_entry.filename,
2222
headline = headline,
23-
title = nil,
2423
}
2524
table.insert(results, entry)
2625
end

lua/telescope-orgmode/org.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ function M.refile(opts)
2828
return OrgApi.refile(opts)
2929
end
3030

31+
---@param headline OrgApiHeadline
32+
---@return string
33+
function M.get_link_to_headline(headline)
34+
return OrgApi.get_link_to_headline(headline._section) ---@diagnostic disable-line: invisible
35+
end
36+
3137
function M.insert_link(destination)
3238
return OrgApi.insert_link(destination)
3339
end

lua/telescope-orgmode/typehints.lua

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
---@field start_col number
4040
---@field end_line number
4141
---@field end_col number
42+
---
43+
---@class OrgHeadline
44+
---@field headline TSNode
45+
---@field file OrgFile
4246

4347
---@class OrgApiHeadline
4448
---@field title string headline title without todo keyword, tags and priority. Ex. `* TODO I am a headline :SOMETAG:` returns `I am a headline`
@@ -59,7 +63,10 @@
5963
---@field priority string|nil
6064
---@field is_archived boolean headline marked with the `:ARCHIVE:` tag
6165
---@field headlines OrgApiHeadline[]
62-
--
66+
---@field id_get_or_create number
67+
---@field private _section OrgHeadline
68+
---@field private _index number
69+
6370
---@class OrgApiRefileOpts
6471
---@field source OrgApiHeadline
6572
---@field destination OrgApiFile | OrgApiHeadline

0 commit comments

Comments
 (0)