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 266 forks source link

python3 compatibility #231

Closed akstrfn closed 8 years ago

Ron89 commented 8 years ago

Hey @akstrfn , would you mind send pull request with your non-master branch? So that we can be sure that all changes made in this PR are Python3 support relavant. If you send with general purpose master branch, and make some changes in the branch before we pulling it in, those unrelavant changes will be pulled in too.

Ron89 commented 8 years ago

Still, most of the functionalities are not working...

akstrfn commented 8 years ago

Hi @Ron89, these are all python3 commits if I remember correctly. My master branch is the same as my python3compatibility branch so there is no diff except maybe you want a pull request in a separate branch? Can you tell me what is not working for you?

Ron89 commented 8 years ago

When generate new checkbox/list_item:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/home/chong/.vim/plugged/vim-orgmode/ftplugin/orgmode/plugins/EditCheckbox.py", line 129, in new_checkbox
        vim.current.buffer[start:start] = [unicode(nc)]
    NameError: name 'unicode' is not defined

Checking checkbox with \cc has no effect. Generating new header \hn, etc. has no effect. Promoting header/checkbox/list with >> nd << has no effect.

When attempting to insert new date with \sa:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/chong/.vim/plugged/vim-orgmode/ftplugin/orgmode/plugins/Date.py", line 228, in insert_timestamp
    unicode(today.strftime(u'%Y-%m-%d %a'), u'utf-8'),
TypeError: decoding str is not supported

When attempting to create new tag with \st, after inputting tag:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/chong/.vim/plugged/vim-orgmode/ftplugin/orgmode/_vim.py", line 59, in r
    res = f(*args, **kwargs)
  File "/home/chong/.vim/plugged/vim-orgmode/ftplugin/orgmode/plugins/TagsProperties.py", line 97, in set_tags
    d.write()
  File "/home/chong/.vim/plugged/vim-orgmode/ftplugin/orgmode/vimbuffer.py", line 171, in write
    for h in sorted(self._deleted_headings, cmp=lambda x, y: cmp(x._orig_start, y._orig_start), reverse=True):
TypeError: 'cmp' is an invalid keyword argument for this function

Existing tag is shown as :<:f:i:l:t:e:r: :o:b.... Something is wrong there.

When Try to see Agenda with \caa or \cat

Error detected while processing :
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/chong/.vim/plugged/vim-orgmode/ftplugin/orgmode/plugins/Agenda.py", line 143, in list_next_week
    agenda_documents = cls._get_agendadocuments()
  File "/home/chong/.vim/plugged/vim-orgmode/ftplugin/orgmode/plugins/Agenda.py", line 83, in _get_agendadocuments
    return self._load_agendafiles(agenda_files)
  File "/home/chong/.vim/plugged/vim-orgmode/ftplugin/orgmode/plugins/Agenda.py", line 105, in _load_agendafiles
    return [ORGMODE.get_document(i) for i in agenda_nums if i is not None]
  File "/home/chong/.vim/plugged/vim-orgmode/ftplugin/orgmode/plugins/Agenda.py", line 105, in <listcomp>
    return [ORGMODE.get_document(i) for i in agenda_nums if i is not None]
  File "/home/chong/.vim/plugged/vim-orgmode/ftplugin/orgmode/_vim.py", line 301, in get_document
    self._documents[bufnr] = VimBuffer(bufnr).init_dom()
  File "/home/chong/.vim/plugged/vim-orgmode/ftplugin/orgmode/vimbuffer.py", line 59, in __init__
    self.update_changedtick()
  File "/home/chong/.vim/plugged/vim-orgmode/ftplugin/orgmode/vimbuffer.py", line 147, in update_changedtick
    (self.bufnr, vim.current.buffer.number)))
vim.error: Vim(endfunction):E171: Missing :endif
akstrfn commented 8 years ago

@Ron89 thanks for the details about the problems, I fixed some of them and most of the things work now. There are still some issues to be fixed (i.e. UserList issue) but I guess it is usable now so give it a spin if you want.

akstrfn commented 8 years ago

this can be pulled now except for an interesting thing that 'ß'.upper() returns SS but is not up to me to decide if that is ok ;) More details: https://bugs.python.org/issue4610

Ron89 commented 8 years ago

It seems the code has problem with some unicode letter, e.g. ß, as is found out by the test. It is recognised as SS in Python3 test.

akstrfn commented 8 years ago

That is the correct behaviour so I didn't want to change it. Python2 was basically doing it in a wrong way. I always wondered why my street in Germany has two SS in many online services, now I know :smile:

Ron89 commented 8 years ago

Problem still exists with Python2 built Vim.

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/chong/.vim/plugged/vim-orgmode/ftplugin/orgmode/plugins/EditCheckbox.py", line 44, in new
_checkbox
    d = ORGMODE.get_document()
  File "/Users/chong/.vim/plugged/vim-orgmode/ftplugin/orgmode/_vim.py", line 302, in get_document
    self._documents[bufnr] = VimBuffer(bufnr).init_dom()
  File "/Users/chong/.vim/plugged/vim-orgmode/ftplugin/orgmode/liborgmode/documents.py", line 146, in in
it_dom
    h = self.find_heading(heading=heading)
  File "/Users/chong/.vim/plugged/vim-orgmode/ftplugin/orgmode/liborgmode/documents.py", line 292, in fi
nd_heading
    self._content[start:end + 1], self.get_all_todo_states(),
  File "/Users/chong/.vim/plugged/vim-orgmode/ftplugin/orgmode/vimbuffer.py", line 399, in __getslice__
    for item in MultiPurposeList.__getslice__(self, i, j)]
  File "/Users/chong/.vim/plugged/vim-orgmode/ftplugin/orgmode/liborgmode/base.py", line 89, in __getsli
ce__
    return UserList.__getitem__(self, slice(i, j))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/UserList.py", line 31, in
 __getitem__
    def __getitem__(self, i): return self.data[i]
TypeError: sequence index must be integer, not 'slice'
Ron89 commented 8 years ago

Agenda function is also undermined by that sequence index must be integer, not 'slice' issue.

akstrfn commented 8 years ago

@Ron89 fixed.