def setUp(self): self.keybindings = [] # this has to be registered since some plugins execute :au orgmode and # the group can not be found vim.command(""" augroup orgmode au BufEnter * :if &filetype == "org" | call <SID>OrgRegisterMenu() | endif au BufLeave * :if &filetype == "org" | call <SID>OrgUnregisterMenu() | endif au BufDelete * :call <SID>OrgDeleteUnusedDocument(expand('<abuf>')) augroup END """) # TODO: this is obsolete with nvim testing vim.EVALRESULTS = { u'exists("g:org_debug")': 0, u'exists("b:org_debug")': 0, u'exists("*repeat#set()")': 0, u'b:changedtick': 0, u'exists("b:org_plugins")': 0, u'exists("g:org_plugins")': 1, u'g:org_plugins': ORG_PLUGINS, } for plugin in filter(lambda p: p != '|', ORG_PLUGINS): try: ORGMODE.register_plugin(plugin) except PluginError: pass if plugin in ORGMODE._plugins: self.keybindings.extend(ORGMODE._plugins[plugin].keybindings)
def test_filter_items(self): # only headings with date and todo should be returned vim.command(u_encode(u"let g:org_todo_keywords = ['TODO', 'STARTED', '|', 'DONE']")) tmpdate = date.today() odate = OrgDate(True, tmpdate.year, tmpdate.month, tmpdate.day) tmp_head = Heading(title=u'Refactor the code', todo=u'TODO', active_date=odate) tmp_head_01 = Heading(title=u'Refactor the code', todo=u'STARTED', active_date=odate) headings = [tmp_head, tmp_head_01] filtered = list(filter_items(headings, [contains_active_date, contains_active_todo])) self.assertEqual(len(filtered), 2) self.assertEqual(filtered, headings) # try a longer list headings = headings * 3 filtered = list(filter_items(headings, [contains_active_date, contains_active_todo])) self.assertEqual(len(filtered), 6) self.assertEqual(filtered, headings) # date does not contain all needed fields thus gets ignored tmpdate = date.today() odate = OrgDate(True, tmpdate.year, tmpdate.month, tmpdate.day) tmp_head = Heading(title=u'Refactor the code', active_date=odate) headings = [tmp_head] filtered = list(filter_items(headings, [contains_active_date, contains_active_todo])) self.assertEqual([], filtered)
def setUp(self): global counter counter += 1 vim.CMDHISTORY = [] vim.CMDRESULTS = {} vim.EVALHISTORY = [] vim.EVALRESULTS = { # no org_todo_keywords for b u_encode(u'exists("b:org_todo_keywords")'): u_encode('0'), # global values for org_todo_keywords u_encode(u'exists("g:org_todo_keywords")'): u_encode('1'), u_encode(u'g:org_todo_keywords'): [u_encode(u'TODO'), u_encode(u'|'), u_encode(u'DONE')], u_encode(u'exists("g:org_debug")'): u_encode(u'0'), u_encode(u'exists("b:org_debug")'): u_encode(u'0'), u_encode(u'exists("*repeat#set()")'): u_encode(u'0'), u_encode(u'b:changedtick'): u_encode(u'%d' % counter), u_encode(u"v:count"): u_encode(u'0')} if not u'ShowHide' in ORGMODE.plugins: ORGMODE.register_plugin(u'ShowHide') self.showhide = ORGMODE.plugins[u'ShowHide'] vim.current.buffer[:] = [u_encode(i) for i in u""" * Überschrift 1 Text 1 Bla bla ** Überschrift 1.1 Text 2 Bla Bla bla ** Überschrift 1.2 Text 3 **** Überschrift 1.2.1.falsch Bla Bla bla bla *** Überschrift 1.2.1 * Überschrift 2 * Überschrift 3 asdf sdf """.split(u'\n') ] self.buff = vim.current.buffer[:] vim.command("set ft=org")
def test_toggle_folding_first_heading_with_no_children_reverse(self): vim.current.buffer[:] = [ u_encode(i) for i in u""" * Überschrift 1 Text 1 Bla bla * Überschrift 2 * Überschrift 3 asdf sdf """.split(u'\n') ] vim.current.window.cursor = (2, 0) vim.command("set ft=org") vim.feedkeys("zR") vim.command("2,5foldclose!") self.assertEqual(foldclosed(2), 2) self.assertEqual(foldclosed(6), -1) self.assertEqual(foldclosed(7), -1) self.assertNotEqual(self.showhide.toggle_folding(reverse=True), None) self.assertEqual(vim.CMDHISTORY[-1], u_encode(u'2,5foldopen!')) self.assertEqual(vim.current.window.cursor, [2, 0])
def setUp(self): global counter counter += 1 vim.CMDHISTORY = [] vim.CMDRESULTS = {} vim.EVALHISTORY = [] vim.EVALRESULTS = { # no org_todo_keywords for b u_encode(u'exists("b:org_todo_keywords")'): u_encode('0'), # global values for org_todo_keywords u_encode(u'exists("g:org_todo_keywords")'): u_encode('1'), u_encode(u'g:org_todo_keywords'): [u_encode(u'TODO'), u_encode(u'|'), u_encode(u'DONE')], u_encode(u'exists("g:org_debug")'): u_encode(u'0'), u_encode(u'exists("g:org_debug")'): u_encode(u'0'), u_encode(u'exists("*repeat#set()")'): u_encode(u'0'), u_encode(u"v:count"): u_encode(u'0'), u_encode(u'b:changedtick'): u_encode(u'%d' % counter), u_encode(u"v:lnum"): u_encode(u'0')} vim.current.buffer[:] = [u_encode(i) for i in u""" * Überschrift 1 Text 1 Bla bla ** Überschrift 1.1 Text 2 Bla Bla bla ** Überschrift 1.2 Text 3 **** Überschrift 1.2.1.falsch Bla Bla bla bla *** Überschrift 1.2.1 * Überschrift 2 * Überschrift 3 asdf sdf """.split(u'\n') ] vim.command("set ft=org") vim.feedkeys("zM")
def test_filter_items(self): # only headings with date and todo should be returned vim.command( u_encode( u"let g:org_todo_keywords = ['TODO', 'STARTED', '|', 'DONE']")) tmpdate = date.today() odate = OrgDate(True, tmpdate.year, tmpdate.month, tmpdate.day) tmp_head = Heading(title=u'Refactor the code', todo=u'TODO', active_date=odate) tmp_head_01 = Heading(title=u'Refactor the code', todo=u'STARTED', active_date=odate) headings = [tmp_head, tmp_head_01] filtered = list( filter_items(headings, [contains_active_date, contains_active_todo])) self.assertEqual(len(filtered), 2) self.assertEqual(filtered, headings) # try a longer list headings = headings * 3 filtered = list( filter_items(headings, [contains_active_date, contains_active_todo])) self.assertEqual(len(filtered), 6) self.assertEqual(filtered, headings) # date does not contain all needed fields thus gets ignored tmpdate = date.today() odate = OrgDate(True, tmpdate.year, tmpdate.month, tmpdate.day) tmp_head = Heading(title=u'Refactor the code', active_date=odate) headings = [tmp_head] filtered = list( filter_items(headings, [contains_active_date, contains_active_todo])) self.assertEqual([], filtered)
def test_toggle_folding_first_heading_with_no_children(self): vim.current.buffer[:] = [u_encode(i) for i in u""" * Überschrift 1 Text 1 Bla bla * Überschrift 2 * Überschrift 3 asdf sdf """.split(u'\n') ] vim.command("set ft=org") vim.feedkeys("zR") for i in range(len(vim.current.buffer)): self.assertEqual(foldclosed(i), -1) vim.feedkeys("zM") for i, val in enumerate([-1, -1, 2, 2, 2, 2, -1, 7, 7]): self.assertEqual(foldclosed(i), val) vim.current.window.cursor = (2, 0) self.assertNotEqual(self.showhide.toggle_folding(), None) self.assertEqual(vim.CMDHISTORY[-1], u_encode(u'normal! 1zo')) self.assertEqual(vim.current.window.cursor, [2, 0])