本文整理汇总了Python中orgmode.ORGMODE类的典型用法代码示例。如果您正苦于以下问题:Python ORGMODE类的具体用法?Python ORGMODE怎么用?Python ORGMODE使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ORGMODE类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
global counter
counter += 1
vim.CMDHISTORY = []
vim.CMDRESULTS = {}
vim.EVALHISTORY = []
vim.EVALRESULTS = {
# no org_todo_keywords for b
u'exists("b:org_todo_keywords")'.encode(u"utf-8"): "0".encode(u"utf-8"),
# global values for org_todo_keywords
u'exists("g:org_todo_keywords")'.encode(u"utf-8"): "1".encode(u"utf-8"),
u"g:org_todo_keywords".encode(u"utf-8"): [
u"TODO".encode(u"utf-8"),
u"DONE".encode(u"utf-8"),
u"|".encode(u"utf-8"),
],
u'exists("g:org_improve_split_heading")'.encode(u"utf-8"): u"0".encode(u"utf-8"),
u'exists("b:org_improve_split_heading")'.encode(u"utf-8"): u"0".encode(u"utf-8"),
u'exists("g:org_debug")'.encode(u"utf-8"): u"0".encode(u"utf-8"),
u'exists("b:org_debug")'.encode(u"utf-8"): u"0".encode(u"utf-8"),
u'exists("*repeat#set()")'.encode(u"utf-8"): u"0".encode(u"utf-8"),
u"b:changedtick".encode(u"utf-8"): (u"%d" % counter).encode(u"utf-8"),
u"&ts".encode(u"utf-8"): u"8".encode(u"utf-8"),
u'exists("g:org_tag_column")'.encode(u"utf-8"): u"0".encode(u"utf-8"),
u'exists("b:org_tag_column")'.encode(u"utf-8"): u"0".encode(u"utf-8"),
u"v:count".encode(u"utf-8"): u"0".encode(u"utf-8"),
}
if not u"EditStructure" in ORGMODE.plugins:
ORGMODE.register_plugin(u"EditStructure")
self.editstructure = ORGMODE.plugins[u"EditStructure"]
vim.current.buffer[:] = [
i.encode(u"utf-8")
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"
)
]
示例2: parent
def parent(cls, mode):
u"""
Focus parent heading
:returns: parent heading or None
"""
heading = ORGMODE.get_document().current_heading()
if not heading:
if mode == u"visual":
vim.command(u"normal! gv".encode(u"utf-8"))
else:
echo(u"No heading found")
return
if not heading.parent:
if mode == u"visual":
vim.command(u"normal! gv".encode(u"utf-8"))
else:
echo(u"No parent heading found")
return
p = heading.parent
if mode == u"visual":
cls._change_visual_selection(heading, p, direction=Direction.BACKWARD, parent=True)
else:
vim.current.window.cursor = (p.start_vim, p.level + 1)
return p
示例3: parent_next_sibling
def parent_next_sibling(cls, mode):
u"""
Focus the parent's next sibling
:returns: parent's next sibling heading or None
"""
heading = ORGMODE.get_document().current_heading()
if not heading:
if mode == u"visual":
vim.command(u"normal! gv".encode(u"utf-8"))
else:
echo(u"No heading found")
return
if not heading.parent or not heading.parent.next_sibling:
if mode == u"visual":
vim.command(u"normal! gv".encode(u"utf-8"))
else:
echo(u"No parent heading found")
return
ns = heading.parent.next_sibling
if mode == u"visual":
cls._change_visual_selection(heading, ns, direction=Direction.FORWARD, parent=False)
elif mode == u"operator":
vim.current.window.cursor = (ns.start_vim, 0)
else:
vim.current.window.cursor = (ns.start_vim, ns.level + 1)
return ns
示例4: parent
def parent(cls, mode):
u"""
Focus parent heading
:returns: parent heading or None
"""
heading = ORGMODE.get_document().current_heading()
if not heading:
if mode == u'visual':
vim.command(u'normal gv'.encode(u'utf-8'))
else:
echo(u'No heading found')
return
if not heading.parent:
if mode == u'visual':
vim.command(u'normal gv'.encode(u'utf-8'))
else:
echo(u'No parent heading found')
return
if mode == u'visual':
cls._change_visual_selection(heading, heading.parent, direction=DIRECTION_BACKWARD, parent=True)
else:
vim.current.window.cursor = (heading.parent.start_vim, heading.parent.level + 1)
return heading.parent
示例5: global_toggle_folding
def global_toggle_folding(cls, reverse=False):
""" Toggle folding globally
:reverse: If False open folding by one level otherwise close it by one.
"""
d = ORGMODE.get_document()
if reverse:
foldlevel = int(vim.eval(u'&foldlevel'.encode(u'utf-8')))
if foldlevel == 0:
# open all folds because the user tries to close folds beyound 0
vim.eval(u'feedkeys("zR", "n")'.encode(u'utf-8'))
else:
# vim can reduce the foldlevel on its own
vim.eval(u'feedkeys("zm", "n")'.encode(u'utf-8'))
else:
found = False
for h in d.headings:
res = cls._fold_depth(h)
if res:
found = res[1]
if found:
break
if not found:
# no fold found and the user tries to advance the fold level
# beyond maximum so close everything
vim.eval(u'feedkeys("zM", "n")'.encode(u'utf-8'))
else:
# fold found, vim can increase the foldlevel on its own
vim.eval(u'feedkeys("zr", "n")'.encode(u'utf-8'))
return d
示例6: set_todo_state
def set_todo_state(cls, state):
u""" Set todo state for buffer.
:bufnr: Number of buffer the todo state should be updated for
:state: The new todo state
"""
lineno, colno = vim.current.window.cursor
d = ORGMODE.get_document(allow_dirty=True)
heading = d.find_current_heading()
if not heading:
return
current_state = heading.todo
# move cursor along with the inserted state only when current position
# is in the heading; otherwite do nothing
if heading.start_vim == lineno:
if current_state is None and state is None:
offset = 0
elif current_state is None:
offset = len(state)
elif state is None:
offset = -len(current_state)
else:
offset = len(current_state) - len(state)
vim.current.window.cursor = (lineno, colno + offset)
# set new headline
heading.todo = state
d.write_heading(heading)
示例7: _get_agendadocuments
def _get_agendadocuments(self):
u"""
Return the org documents of the agenda files; return None if no
agenda documents are defined.
TODO: maybe turn this into an decorator?
"""
# load org files of agenda
agenda_files = settings.get(u'org_agenda_files', u',')
if not agenda_files or agenda_files == ',':
echoe((u"No org_agenda_files defined. Use :let "
u"g:org_agenda_files=['~/org/index.org'] to add "
u"files to the agenda view."))
return
agenda_files = [os.path.realpath(os.path.expanduser(f))
for f in agenda_files]
for agenda_file in agenda_files:
vim.command((u'badd %s' % agenda_file).encode(u'utf-8'))
# determine the buffer nr of the agenda files
agenda_nums = [get_bufnumber(fn) for fn in agenda_files]
# collect all documents of the agenda files and create the agenda
return [ORGMODE.get_document(i) for i in agenda_nums if i is not None]
示例8: jump_to_first_character
def jump_to_first_character(cls):
heading = ORGMODE.get_document().current_heading()
if not heading:
vim.eval(u'feedkeys("^", "n")'.encode(u'utf-8'))
return
vim.current.window.cursor = (vim.current.window.cursor[0], heading.level + 1)
示例9: a_heading
def a_heading(cls, selection=u'inner', skip_children=False):
u"""
a heading text object
"""
heading = ORGMODE.get_document().current_heading()
if heading:
if selection != u'inner':
heading = heading if not heading.parent else heading.parent
line_start, col_start = [ int(i) for i in vim.eval(u'getpos("\'<")'.encode(u'utf-8'))[1:3] ]
line_end, col_end = [ int(i) for i in vim.eval(u'getpos("\'>")'.encode(u'utf-8'))[1:3] ]
start = line_start
end = line_end
if heading.start_vim < line_start:
start = heading.start_vim
if heading.end_vim > line_end and not skip_children:
end = heading.end_vim
elif heading.end_of_last_child_vim > line_end and skip_children:
end = heading.end_of_last_child_vim
swap_cursor = u'o' if vim.current.window.cursor[0] == line_start else u''
vim.command((u'normal! %dgg%s%dgg$%s' % \
(start, vim.eval(u'visualmode()'.encode(u'utf-8')), end, swap_cursor)).encode(u'utf-8'))
if selection == u'inner':
return u'OrgAInnerHeadingVisual' if not skip_children else u'OrgAInnerTreeVisual'
else:
return u'OrgAOuterHeadingVisual' if not skip_children else u'OrgAOuterTreeVisual'
else:
vim.command(u'normal! gv'.encode(u'utf-8'))
示例10: set_tags
def set_tags(cls):
u""" Set tags for current heading
"""
d = ORGMODE.get_document()
heading = d.current_heading()
if not heading:
return
# retrieve tags
res = None
if heading.tags:
res = vim.eval(u'input("Tags: ", ":%s:", "customlist,Org_complete_tags")' % u':'.join(heading.tags))
else:
res = vim.eval(u'input("Tags: ", "", "customlist,Org_complete_tags")')
if res is None:
# user pressed <Esc> abort any further processing
return
# remove empty tags
heading.tags = filter(lambda x: x.strip() != u'', res.decode(u'utf-8').strip().strip(u':').split(u':'))
d.write()
return u'OrgSetTags'
示例11: parent_next_sibling
def parent_next_sibling(cls, mode):
u"""
Focus the parent's next sibling
:returns: parent's next sibling heading or None
"""
heading = ORGMODE.get_document().current_heading()
if not heading:
if mode == u'visual':
vim.command(u'normal gv'.encode(u'utf-8'))
else:
echo(u'No heading found')
return
if not heading.parent or not heading.parent.next_sibling:
if mode == u'visual':
vim.command(u'normal gv'.encode(u'utf-8'))
else:
echo(u'No parent heading found')
return
ns = heading.parent.next_sibling
if mode == u'visual':
cls._change_visual_selection(heading, ns, direction=DIRECTION_FORWARD, parent=False)
elif mode == u'operator':
vim.current.window.cursor = (ns.start_vim, 0)
else:
vim.current.window.cursor = (ns.start_vim, ns.level + 1)
return ns
示例12: _move_heading
def _move_heading(cls, direction=Direction.FORWARD, including_children=True):
u""" Move heading up or down
:returns: heading or None
"""
d = ORGMODE.get_document()
heading = d.current_heading()
if (not heading) or \
(direction == Direction.FORWARD and not heading.next_sibling) or \
(direction == Direction.BACKWARD and not heading.previous_sibling):
return None
cursor_offset_within_the_heading_vim = vim.current.window.cursor[0] - (heading._orig_start + 1)
if not including_children:
heading.previous_sibling.children.extend(heading.children)
del heading.children
heading_insert_position = 0 if direction == Direction.FORWARD else -1
l = heading.get_parent_list()
idx = heading.get_index_in_parent_list()
del l[idx]
if l is not None and idx is not None:
l.insert(idx + heading_insert_position, heading)
else:
raise HeadingDomError(u'Current heading is not properly linked in DOM')
d.write()
vim.current.window.cursor = (heading.start_vim + cursor_offset_within_the_heading_vim, vim.current.window.cursor[1])
return True
示例13: edit_at_first_character
def edit_at_first_character(cls):
heading = ORGMODE.get_document().current_heading()
if not heading:
vim.eval(u'feedkeys("I", "n")'.encode(u'utf-8'))
return
vim.current.window.cursor = (vim.current.window.cursor[0], heading.level + 1)
vim.command(u'startinsert'.encode(u'utf-8'))
示例14: setUp
def setUp(self):
global counter
counter += 1
vim.CMDHISTORY = []
vim.CMDRESULTS = {}
vim.EVALHISTORY = []
vim.EVALRESULTS = {
# no org_todo_keywords for b
u'exists("b:org_todo_keywords")'.encode(u'utf-8'): '0'.encode(u'utf-8'),
# global values for org_todo_keywords
u'exists("g:org_todo_keywords")'.encode(u'utf-8'): '1'.encode(u'utf-8'),
u'g:org_todo_keywords'.encode(u'utf-8'): [u'TODO'.encode(u'utf-8'), u'DONE'.encode(u'utf-8'), u'|'.encode(u'utf-8')],
u'exists("g:org_improve_split_heading")'.encode(u'utf-8'): u'0'.encode(u'utf-8'),
u'exists("b:org_improve_split_heading")'.encode(u'utf-8'): u'0'.encode(u'utf-8'),
u'exists("g:org_debug")'.encode(u'utf-8'): u'0'.encode(u'utf-8'),
u'exists("b:org_debug")'.encode(u'utf-8'): u'0'.encode(u'utf-8'),
u'exists("*repeat#set()")'.encode(u'utf-8'): u'0'.encode(u'utf-8'),
u'b:changedtick'.encode(u'utf-8'): (u'%d' % counter).encode(u'utf-8'),
u'&ts'.encode(u'utf-8'): u'8'.encode(u'utf-8'),
u'exists("g:org_tag_column")'.encode(u'utf-8'): u'0'.encode(u'utf-8'),
u'exists("b:org_tag_column")'.encode(u'utf-8'): u'0'.encode(u'utf-8'),
u"v:count".encode(u'utf-8'): u'0'.encode(u'utf-8')}
if not u'EditStructure' in ORGMODE.plugins:
ORGMODE.register_plugin(u'EditStructure')
self.editstructure = ORGMODE.plugins[u'EditStructure']
vim.current.buffer[:] = [ i.encode(u'utf-8') 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')]
示例15: realign_all_tags
def realign_all_tags(cls):
u"""
Updates tags when user finishes editing a heading
"""
d = ORGMODE.get_document()
for heading in d.all_headings():
heading.set_dirty_heading()
d.write()