Implement refile from org capture
This commit is contained in:
parent
044a1eba41
commit
d65dc79355
@ -1,10 +1,3 @@
|
|||||||
local orgmode = require('orgmode.api')
|
|
||||||
|
|
||||||
local pickers = require("telescope.pickers")
|
|
||||||
local finders = require("telescope.finders")
|
|
||||||
local entry_display = require("telescope.pickers.entry_display")
|
|
||||||
local conf = require("telescope.config").values
|
|
||||||
|
|
||||||
-- TODO: include headline.level and headline.is_archived() as part of the
|
-- TODO: include headline.level and headline.is_archived() as part of the
|
||||||
-- public orgmode api
|
-- public orgmode api
|
||||||
-- TODO: add highlight groups
|
-- TODO: add highlight groups
|
||||||
|
@ -13,6 +13,9 @@ local Capture = require('orgmode.capture')
|
|||||||
return function(opts)
|
return function(opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
|
|
||||||
|
-- TODO: this should be included in return from Files.get_current_file
|
||||||
|
local has_capture, is_capture = pcall(vim.api.nvim_buf_get_var, 0, 'org_capture')
|
||||||
|
|
||||||
local src_file = Files.get_current_file()
|
local src_file = Files.get_current_file()
|
||||||
local src_item = src_file:get_closest_headline()
|
local src_item = src_file:get_closest_headline()
|
||||||
local src_lines = src_file:get_headline_lines(src_item)
|
local src_lines = src_file:get_headline_lines(src_item)
|
||||||
@ -36,9 +39,14 @@ return function(opts)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
--utils.echo_info(string.format('Wrote %s', dst_file.filename))
|
--utils.echo_info(string.format('Wrote %s', dst_file.filename))
|
||||||
return true
|
--return true
|
||||||
else
|
else
|
||||||
return Capture:_refile_to_end(dst_file.filename, src_lines, src_item)
|
--return Capture:_refile_to_end(dst_file.filename, src_lines, src_item)
|
||||||
|
Capture:_refile_to_end(dst_file.filename, src_lines, src_item)
|
||||||
|
end
|
||||||
|
|
||||||
|
if has_capture and is_capture then
|
||||||
|
Capture:kill()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user