Context is lost when archiving headline with level >1
Closed this issue · 2 comments
Describe the bug
Archiving a headline should add context, that is, the various ARCHIVE_
properties defined in
orgmode/lua/orgmode/capture/init.lua
Lines 288 to 292 in d2fde79
Since edc3ceb, this does not work anymore for headlines of level 2 or greater. It seems the culprit is
orgmode/lua/orgmode/capture/init.lua
Lines 176 to 178 in d2fde79
lines
including the archive props is overwritten with (promoted) lines based on the headline only, so the archive prop lines are lost.
Steps to reproduce
- Open nvim (with the minimal init.lua)
- Create the file
foo.org
containing* bar ** TODO baz
- If it is not already there, move the cursor into the second line (the "baz" line)
- Press
<Leader>o$
to trigger archiving the baz-headline. - Open
foo.org_archive
. It contains* TODO baz
Expected behavior
foo.org_archive
should contain
* TODO baz
:PROPERTIES:
:ARCHIVE_TIME: <current timestamp>
:ARCHIVE_FILE: </path/to/foo.org>
:ARCHIVE_CATEGORY: foo'
:ARCHIVE_TODO: TODO'
:END:
Emacs functionality
I have not tested this, but presume since it worked previously with nvim-orgmode, it works in Emacs as it had worked in nvim-orgmode.
Minimal init.lua
(Just the provided template)
local tmp_dir = vim.env.TMPDIR or vim.env.TMP or vim.env.TEMP or '/tmp'
local nvim_root = tmp_dir .. '/nvim_orgmode'
local lazy_root = nvim_root .. '/lazy'
local lazypath = lazy_root .. '/lazy.nvim'
-- Install lazy.nvim if not already installed
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
'git',
'clone',
'--filter=blob:none',
'https://github.com/folke/lazy.nvim.git',
'--branch=stable', -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require('lazy').setup({
{
'nvim-orgmode/orgmode',
event = 'VeryLazy',
ft = { 'org' },
config = function()
require('orgmode').setup()
end,
},
}, {
root = lazy_root,
lockfile = nvim_root .. '/lazy.json',
install = {
missing = false,
},
})
require('lazy').sync({
wait = true,
show = false,
})
Screenshots and recordings
No response
OS / Distro
macOS 14.5
Neovim version/commit
0.11.0-dev-18+g63e3a63d2
Additional context
I have started writing a test to demonstrate this , it can be applied with patch -p1 < test_archiving_with_context.patch
(on master as of d2fde79):
test_archiving_with_context.patch
Note the test is not complete, in particular, the precise content of the archive properties is not checked. But at least it should be sufficient to demonstrate the problem.
Edit: Fix links to code
Thanks for reporting. Should be fixed on latest master.
Thank you for the fast response, I can confirm it works now. 👍