Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refiling ignores preamble export options #760

Open
darg2012 opened this issue Jun 22, 2024 · 2 comments
Open

Refiling ignores preamble export options #760

darg2012 opened this issue Jun 22, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@darg2012
Copy link

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

@darg2012 darg2012 added the bug Something isn't working label Jun 22, 2024
@seflue
Copy link
Contributor

seflue commented Jun 29, 2024

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.

@darg2012
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants