nvim-orgmode/orgmode

Refiling ignores preamble export options

darg2012 opened this issue · 2 comments

Describe the bug

Appreciate the repo, but partially broke after recently updating. Content on the refile location ignores preamble export options, starting only on the first header. Broken by 72d48c6. Possibly related to #729.

Steps to reproduce

  1. Open nvim with included minimal init.lua
  2. Activate capture of test template w/<leader>oce
  3. Close capture w/<C-c>
  4. Open ~/Downloads/test.org

Expected behavior

#+date: 2024/06/22 1:40:29 # <-- Missing lines
                            # <-- Missing lines
* Saturday 06/22/24

** Test

- 

Emacs functionality

No response

Minimal init.lua

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or 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({
         org_capture_templates = {
            t = { description = 'Task', template = '* TODO %?\n  %u' },
            e = {
              description = 'Test',
              template =
                 '#+date: %<%Y/%m/%d %H:%M:%S>\n'..
                 '\n'..
                 '* %<%A> %<%m/%d/%y>\n\n'..
                 '** Test\n\n'..
                 '- %?\n',
              target = '~/Downloads/test.org'
             }
           }
         })
      end,
  },
})

Screenshots and recordings

No response

OS / Distro

MacOS 12.7.2

Neovim version/commit

NVIM v0.10.0 Release

Additional context

No response

Is this actually possible in the same way in Emacs? As I understood, the capture feature works on the scope of headlines. The preamble has a file scope.
What you actually target is the capture feature. I am not aware, what the intent of Emacs orgmode here is, because I use orgmode only with Neovim and this plugin. The way it is implemented is, that it refiles the first headline in the capture buffer to the target file and optionally headline defined in the template, before closing it.

If you write multiple headlines on the first level, all but the first are also ignored like your preamble.

To decide, if the issue you brought up is actually a bug or implemented as intent, it would be great, if you could research, how this works in Emacs.

You bring a good point, I haven't checked the behavior on emacs. I will have to look into it and test the template capture mechanism.

Since creating this issue, I also noted another bug that also wasn't present before the refactor commit where if the target destination is a with a date variable, i.e. target = './%Y/%m/%d.org', such string only gets evaluated the first time the capture template mechanism is engaged and only reevalutes it once neovim is restarted. Such behavior becomes a problem in cases where daily logs are created and a single instance of neovim is running for multiple days.

I have no experience with lisp and some with lua but I hope to learn how emacs templating works and also how this plugin handled it before and after the refactor so I contribute to this project. In the meantime, I have reverted to the previous version since I use this feature everyday.