Skip to content

Commit d65dc79

Browse files
committed
Implement refile from org capture
1 parent 044a1eb commit d65dc79

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

lua/telescope/_extensions/orgmode/init.lua

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
local orgmode = require('orgmode.api')
2-
3-
local pickers = require("telescope.pickers")
4-
local finders = require("telescope.finders")
5-
local entry_display = require("telescope.pickers.entry_display")
6-
local conf = require("telescope.config").values
7-
81
-- TODO: include headline.level and headline.is_archived() as part of the
92
-- public orgmode api
103
-- TODO: add highlight groups

lua/telescope/_extensions/orgmode/refile_heading.lua

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ local Capture = require('orgmode.capture')
1313
return function(opts)
1414
opts = opts or {}
1515

16+
-- TODO: this should be included in return from Files.get_current_file
17+
local has_capture, is_capture = pcall(vim.api.nvim_buf_get_var, 0, 'org_capture')
18+
1619
local src_file = Files.get_current_file()
1720
local src_item = src_file:get_closest_headline()
1821
local src_lines = src_file:get_headline_lines(src_item)
@@ -36,9 +39,14 @@ return function(opts)
3639
return false
3740
end
3841
--utils.echo_info(string.format('Wrote %s', dst_file.filename))
39-
return true
42+
--return true
4043
else
41-
return Capture:_refile_to_end(dst_file.filename, src_lines, src_item)
44+
--return Capture:_refile_to_end(dst_file.filename, src_lines, src_item)
45+
Capture:_refile_to_end(dst_file.filename, src_lines, src_item)
46+
end
47+
48+
if has_capture and is_capture then
49+
Capture:kill()
4250
end
4351
end
4452

0 commit comments

Comments
 (0)