jceb / vim-orgmode

Text outlining and task management for Vim based on Emacs' Org-Mode
http://www.vim.org/scripts/script.php?script_id=3642
Other
3.12k stars 267 forks source link

"Too many files open" error in agenda view #194

Closed seece closed 9 years ago

seece commented 9 years ago

When opening TODO agenda view with <localleader>cat I run into a "Too many file names" error.

Error detected while processing :
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/pvaananen/.vim/bundle/orgmode/ftplugin/orgmode/plugins/Agenda.py", line 187, in list
_all_todos
    agenda_documents = cls._get_agendadocuments()
  File "/home/pvaananen/.vim/bundle/orgmode/ftplugin/orgmode/plugins/Agenda.py", line 83, in _get_
agendadocuments
    vim.command((u'badd %s' % agenda_file).encode(u'utf-8'))
vim.error: Vim(badd):E77: Too many file names 

My org_agenda_files filter includes a wilcard, but it should match only a couple of actual .org files

let g:org_agenda_files = ['~/Documents/*.org']
sotte commented 9 years ago

vim has a glob function. Maybe something like this (not tested)

let g:org_agenda_files = glob("/home/user/Documents/*.org")
seece commented 9 years ago

Thanks for the reply. I tried changing the config to the following, where user is my username.

let g:org_agenda_files = [glob("/home/user/Documents/*.org")]

Now I get the following error message when issuing <localleader>cat

Error detected while processing :
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/pvaananen/.vim/bundle/orgmode/ftplugin/orgmode/plugins/Agenda.py", line 187, in
list_all_todos
    agenda_documents = cls._get_agendadocuments()
  File "/home/pvaananen/.vim/bundle/orgmode/ftplugin/orgmode/plugins/Agenda.py", line 83, in _
get_agendadocuments
    vim.command((u'badd %s' % agenda_file).encode(u'utf-8'))
vim.error: Vim:E492: Not an editor command: /home/pvaananen/Documents/test_document.org
/home/pvaananen/Documents/test.org
sotte commented 9 years ago

I don't think you need the []. This should be fine:

let g:org_agenda_files = glob("/home/user/Documents/*.org")

glob already returns a list. In vim juts type the following to get a list of all your org files:

:echo glob("/home/user/Documents/*.org")
seece commented 9 years ago

Seems like glob returns a string with each item separated by a linefeed. The plugin doesn't understand this, but I managed to get it working by splitting the string into lines by hand in my configuration file:

 let g:org_agenda_files = split(glob("/home/user/Documents/*.org"), "\n")

One could handle this also in _get_agendadocuments of Agenda.py with a simple heuristic:

if len(agenda_files) == 1 and "\n" in agenda_files:
    agenda_files = agenda_files.split("\n")
sotte commented 9 years ago

Glad it works for you!