Refile top level heading in capture file
This commit is contained in:
parent
d65dc79355
commit
af0ec4052c
@ -1,7 +1,6 @@
|
|||||||
-- 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
|
||||||
-- TODO: add action to refile/capture
|
|
||||||
|
|
||||||
return require("telescope").register_extension {
|
return require("telescope").register_extension {
|
||||||
exports = {
|
exports = {
|
||||||
|
@ -14,10 +14,11 @@ return function(opts)
|
|||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
|
|
||||||
-- TODO: this should be included in return from Files.get_current_file
|
-- 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 is_capture = vim.F.npcall(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()
|
-- In capture, refile top level heading even if cursor closer to a subheading
|
||||||
|
local src_item = is_capture and src_file:get_headlines()[1] or 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)
|
||||||
|
|
||||||
local function refile(prompt_bufnr)
|
local function refile(prompt_bufnr)
|
||||||
@ -39,13 +40,11 @@ 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
|
|
||||||
else
|
else
|
||||||
--return Capture:_refile_to_end(dst_file.filename, src_lines, src_item)
|
|
||||||
Capture:_refile_to_end(dst_file.filename, src_lines, src_item)
|
Capture:_refile_to_end(dst_file.filename, src_lines, src_item)
|
||||||
end
|
end
|
||||||
|
|
||||||
if has_capture and is_capture then
|
if is_capture then
|
||||||
Capture:kill()
|
Capture:kill()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user