Skip to content

org_refile can't refile headings #911

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

Closed
cezarmathe opened this issue Feb 27, 2025 · 4 comments
Closed

org_refile can't refile headings #911

cezarmathe opened this issue Feb 27, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@cezarmathe
Copy link

Describe the bug

I'm trying to move a heading from my-org-file.org to refile.org. Both files are located in ${HOME}/org. When I do <Leader>or the autocomplete omits a few characters from the start of each file, e.g. refile.org is shown as efile.org. Upon selecting any file or typing the correct file myself I get the following error: "nil" is not a file specified in the "org_agenda_files" setting. Refiling canceled..

Steps to reproduce

  1. Create a new file: refile.org.
  2. Create a new file: 2025-02-27.org.
  3. In 2025-02-27.org: <Leader>oit and add Hello, world!.
  4. In 2025-02-27.org: <Leader>or on the header you've added previously and type refile.org.

Expected behavior

I expect that <Leader>or moves the heading to the desired destination.

Emacs functionality

No response

Minimal init.lua

-- You can add your own plugins here or in other files in this directory!
--  I promise not to create any merge conflicts in this directory :)
--
-- See the kickstart.nvim README for more information
return {
  'nvim-orgmode/orgmode',
  event = 'VeryLazy',
  ft = { 'org' },
  config = function()
    -- Setup orgmode
    require('orgmode').setup {
      org_agenda_files = '~/org/**/*',
      org_default_notes_file = '~/org/refile.org',
    }

    -- NOTE: If you are using nvim-treesitter with ~ensure_installed = "all"~ option
    -- add ~org~ to ignore_install
    -- require('nvim-treesitter.configs').setup({
    --   ensure_installed = 'all',
    --   ignore_install = { 'org' },
    -- })
  end,
}

Screenshots and recordings

Screen.Recording.2025-02-27.at.13.06.23.mov

OS / Distro

MacOS 15.3.1

Neovim version/commit

NVIM v0.10.4 / Build type: Release / LuaJIT 2.1.1736781742

Additional context

No response

@cezarmathe cezarmathe added the bug Something isn't working label Feb 27, 2025
@kristijanhusak
Copy link
Member

The error is due to the missing /, I'll address that, but the autocompletion is strange. I'm not able to reproduce it, so I'll need some assistance from your side to figure out what's the issue. I think I know where it is, but I cannot reproduce.

Are you able to apply this patch to your local orgmode installation and give me the message output? These are the steps:

  1. Apply this patch:
diff --git a/lua/orgmode/utils/fs.lua b/lua/orgmode/utils/fs.lua
index ed27767..a3bdaf8 100644
--- a/lua/orgmode/utils/fs.lua
+++ b/lua/orgmode/utils/fs.lua
@@ -55,6 +55,7 @@ function M.trim_common_root(paths)
 
   local result = {}
   local root = vim.fn.fnamemodify(filepaths[1], ':h') .. '/'
+  print('root', vim.inspect(root))
 
   for _, path in ipairs(paths) do
     local relative_path = path:sub(#root + 1)
  1. Go through the same process like in the video, where you do <leader>or and press <tab> to autocomplete
  2. Cancel out from refile, and do :messages
  3. Give me the output of the line with root

@cezarmathe
Copy link
Author

The patch failed to apply. I've inspected the file manually and that's not how root is set in my installation. For me it's:

local root = vim.pesc(vim.fn.fnamemodify(filepaths[1], ':h')) .. '/'` 

I've added the print statement anyway and I went through the steps. This is the output: root "/Users/cezar%-fm/org/". Is % the issue? I don't have that character in my user name and home directory name.

By the way, the trailing / was the issue. Doing <Leader>or and selecting my efile.org/ from the autocomplete list works as expected. I think I was always trimming that trailing /.

@kristijanhusak
Copy link
Member

You are using an older version or orgmode. This issue was already reported and fixed #877.
Just update to the latest version.

@cezarmathe
Copy link
Author

I've updated my plugins and the issue disappeared. Thanks you! I'll keep in mind to update periodically.

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