Example #1
0
    def register(self):
        """
		Registration of plugin. Key bindings and other initialization should be done.
		"""
        self.commands.append(
            Command('OrgHyperlinkFollow',
                    ':py ORGMODE.plugins["Hyperlinks"].follow()'))
        self.keybindings.append(
            Keybinding('gl', Plug('OrgHyperlinkFollow', self.commands[-1])))
        self.menu + ActionEntry('&Follow Link', self.keybindings[-1])

        self.commands.append(
            Command('OrgHyperlinkCopy',
                    ':py ORGMODE.plugins["Hyperlinks"].follow(action="copy")'))
        self.keybindings.append(
            Keybinding('gyl', Plug('OrgHyperlinkCopy', self.commands[-1])))
        self.menu + ActionEntry('&Copy Link', self.keybindings[-1])

        self.commands.append(
            Command('OrgHyperlinkInsert',
                    ':py ORGMODE.plugins["Hyperlinks"].insert(<f-args>)',
                    arguments='*'))
        self.keybindings.append(
            Keybinding('gil', Plug('OrgHyperlinkInsert', self.commands[-1])))
        self.menu + ActionEntry('&Insert Link', self.keybindings[-1])

        self.menu + Separator()

        # find next link
        self.commands.append(
            Command(
                'OrgHyperlinkNextLink',
                ":if search('\[\{2}\zs[^][]*\(\]\[[^][]*\)\?\ze\]\{2}', 's') == 0 | echo 'No further link found.' | endif"
            ))
        self.keybindings.append(
            Keybinding('gn', Plug('OrgHyperlinkNextLink', self.commands[-1])))
        self.menu + ActionEntry('&Next Link', self.keybindings[-1])

        # find previous link
        self.commands.append(
            Command(
                'OrgHyperlinkPreviousLink',
                ":if search('\[\{2}\zs[^][]*\(\]\[[^][]*\)\?\ze\]\{2}', 'bs') == 0 | echo 'No further link found.' | endif"
            ))
        self.keybindings.append(
            Keybinding('go', Plug('OrgHyperlinkPreviousLink',
                                  self.commands[-1])))
        self.menu + ActionEntry('&Previous Link', self.keybindings[-1])

        self.menu + Separator()

        # Descriptive Links
        self.commands.append(
            Command('OrgHyperlinkDescriptiveLinks', ':setlocal cole=2'))
        self.menu + ActionEntry('&Descriptive Links', self.commands[-1])

        # Literal Links
        self.commands.append(
            Command('OrgHyperlinkLiteralLinks', ':setlocal cole=0'))
        self.menu + ActionEntry('&Literal Links', self.commands[-1])
Example #2
0
	def register(self):
		u"""
		Registration of plugin. Key bindings and other initialization should be done.
		"""
		cmd = Command(
			u'OrgHyperlinkFollow',
			u'%s ORGMODE.plugins[u"Hyperlinks"].follow()' % VIM_PY_CALL)
		self.commands.append(cmd)
		self.keybindings.append(
			Keybinding(u'gl', Plug(u'OrgHyperlinkFollow', self.commands[-1])))
		self.menu + ActionEntry(u'&Follow Link', self.keybindings[-1])

		cmd = Command(
			u'OrgHyperlinkCopy',
			u'%s ORGMODE.plugins[u"Hyperlinks"].follow(action=u"copy")' % VIM_PY_CALL)
		self.commands.append(cmd)
		self.keybindings.append(
			Keybinding(u'gyl', Plug(u'OrgHyperlinkCopy', self.commands[-1])))
		self.menu + ActionEntry(u'&Copy Link', self.keybindings[-1])

		cmd = Command(
			u'OrgHyperlinkInsert',
			u'%s ORGMODE.plugins[u"Hyperlinks"].insert(<f-args>)' % VIM_PY_CALL,
			arguments=u'*')
		self.commands.append(cmd)
		self.keybindings.append(
			Keybinding(u'gil', Plug(u'OrgHyperlinkInsert', self.commands[-1])))
		self.menu + ActionEntry(u'&Insert Link', self.keybindings[-1])

		self.menu + Separator()

		# find next link
		cmd = Command(
			u'OrgHyperlinkNextLink',
			u":if search('\\[\\{2}\\zs[^][]*\\(\\]\\[[^][]*\\)\\?\\ze\\]\\{2}', 's') == 0 | echo 'No further link found.' | endif")
		self.commands.append(cmd)
		self.keybindings.append(
			Keybinding(u'gn', Plug(u'OrgHyperlinkNextLink', self.commands[-1])))
		self.menu + ActionEntry(u'&Next Link', self.keybindings[-1])

		# find previous link
		cmd = Command(
			u'OrgHyperlinkPreviousLink',
			u":if search('\\[\\{2}\\zs[^][]*\\(\\]\\[[^][]*\\)\\?\\ze\\]\\{2}', 'bs') == 0 | echo 'No further link found.' | endif")
		self.commands.append(cmd)
		self.keybindings.append(
			Keybinding(u'go', Plug(u'OrgHyperlinkPreviousLink', self.commands[-1])))
		self.menu + ActionEntry(u'&Previous Link', self.keybindings[-1])

		self.menu + Separator()

		# Descriptive Links
		cmd = Command(u'OrgHyperlinkDescriptiveLinks', u':setlocal cole=2')
		self.commands.append(cmd)
		self.menu + ActionEntry(u'&Descriptive Links', self.commands[-1])

		# Literal Links
		cmd = Command(u'OrgHyperlinkLiteralLinks', u':setlocal cole=0')
		self.commands.append(cmd)
		self.menu + ActionEntry(u'&Literal Links', self.commands[-1])
Example #3
0
    def register(self):
        u"""
		Registration of plugin. Key bindings and other initialization should be done.
		"""
        # EditStructure related default settings
        settings.set(u'org_improve_split_heading', u'1')
        # EditStructure related keybindings
        self.keybindings.append(
            Keybinding(
                u'<C-S-CR>',
                Plug(
                    u'OrgNewHeadingAboveNormal',
                    u':silent! %s ORGMODE.plugins[u"EditStructure"].new_heading(below=False)<CR>'
                    % VIM_PY_CALL)))
        self.menu + ActionEntry(u'New Heading &above', self.keybindings[-1])
        self.keybindings.append(
            Keybinding(u'<localleader>hN',
                       u'<Plug>OrgNewHeadingAboveNormal',
                       mode=MODE_NORMAL))
        self.keybindings.append(
            Keybinding(u'<localleader><CR>',
                       u'<Plug>OrgNewHeadingAboveNormal',
                       mode=MODE_NORMAL))

        self.keybindings.append(
            Keybinding(
                u'<S-CR>',
                Plug(
                    u'OrgNewHeadingBelowNormal',
                    u':silent! %s ORGMODE.plugins[u"EditStructure"].new_heading(below=True)<CR>'
                    % VIM_PY_CALL)))
        self.menu + ActionEntry(u'New Heading &below', self.keybindings[-1])
        self.keybindings.append(
            Keybinding(u'<localleader>hh',
                       u'<Plug>OrgNewHeadingBelowNormal',
                       mode=MODE_NORMAL))
        self.keybindings.append(
            Keybinding(u'<leader><CR>',
                       u'<Plug>OrgNewHeadingBelowNormal',
                       mode=MODE_NORMAL))

        self.keybindings.append(
            Keybinding(
                u'<C-CR>',
                Plug(
                    u'OrgNewHeadingBelowAfterChildrenNormal',
                    u':silent! %s ORGMODE.plugins[u"EditStructure"].new_heading(below=True, end_of_last_child=True)<CR>'
                    % VIM_PY_CALL)))
        self.menu + ActionEntry(u'New Heading below, after &children',
                                self.keybindings[-1])
        self.keybindings.append(
            Keybinding(u'<localleader>hn',
                       u'<Plug>OrgNewHeadingBelowAfterChildrenNormal',
                       mode=MODE_NORMAL))
        self.keybindings.append(
            Keybinding(u'<CR>',
                       u'<Plug>OrgNewHeadingBelowAfterChildrenNormal',
                       mode=MODE_NORMAL))

        self.keybindings.append(
            Keybinding(
                u'<C-S-CR>',
                Plug(
                    u'OrgNewHeadingAboveInsert',
                    u'<C-o>:<C-u>silent! %s ORGMODE.plugins[u"EditStructure"].new_heading(below=False, insert_mode=True)<CR>'
                    % VIM_PY_CALL,
                    mode=MODE_INSERT)))
        self.keybindings.append(
            Keybinding(
                u'<S-CR>',
                Plug(
                    u'OrgNewHeadingBelowInsert',
                    u'<C-o>:<C-u>silent! %s ORGMODE.plugins[u"EditStructure"].new_heading(below=True, insert_mode=True)<CR>'
                    % VIM_PY_CALL,
                    mode=MODE_INSERT)))
        self.keybindings.append(
            Keybinding(
                u'<C-CR>',
                Plug(
                    u'OrgNewHeadingBelowAfterChildrenInsert',
                    u'<C-o>:<C-u>silent! %s ORGMODE.plugins[u"EditStructure"].new_heading(insert_mode=True, end_of_last_child=True)<CR>'
                    % VIM_PY_CALL,
                    mode=MODE_INSERT)))

        self.menu + Separator()

        self.keybindings.append(
            Keybinding(
                u'm{',
                Plug(
                    u'OrgMoveHeadingUpward',
                    u'%s ORGMODE.plugins[u"EditStructure"].move_heading_upward(including_children=False)<CR>'
                    % VIM_PY_CALL)))
        self.keybindings.append(
            Keybinding(
                u'm[[',
                Plug(
                    u'OrgMoveSubtreeUpward',
                    u'%s ORGMODE.plugins[u"EditStructure"].move_heading_upward()<CR>'
                    % VIM_PY_CALL)))
        self.menu + ActionEntry(u'Move Subtree &Up', self.keybindings[-1])
        self.keybindings.append(
            Keybinding(
                u'm}',
                Plug(
                    u'OrgMoveHeadingDownward',
                    u'%s ORGMODE.plugins[u"EditStructure"].move_heading_downward(including_children=False)<CR>'
                    % VIM_PY_CALL)))
        self.keybindings.append(
            Keybinding(
                u'm]]',
                Plug(
                    u'OrgMoveSubtreeDownward',
                    u'%s ORGMODE.plugins[u"EditStructure"].move_heading_downward()<CR>'
                    % VIM_PY_CALL)))
        self.menu + ActionEntry(u'Move Subtree &Down', self.keybindings[-1])

        self.menu + Separator()

        self.menu + ActionEntry(u'&Copy Heading', u'yah', u'yah')
        self.menu + ActionEntry(u'C&ut Heading', u'dah', u'dah')

        self.menu + Separator()

        self.menu + ActionEntry(u'&Copy Subtree', u'yar', u'yar')
        self.menu + ActionEntry(u'C&ut Subtree', u'dar', u'dar')
        self.menu + ActionEntry(u'&Paste Subtree', u'p', u'p')

        self.menu + Separator()

        self.keybindings.append(
            Keybinding(
                u'<ah',
                Plug(
                    u'OrgPromoteHeadingNormal',
                    u':silent! %s ORGMODE.plugins[u"EditStructure"].promote_heading(including_children=False)<CR>'
                    % VIM_PY_CALL)))
        self.menu + ActionEntry(u'&Promote Heading', self.keybindings[-1])
        self.keybindings.append(
            Keybinding(
                u'<<',
                Plug(
                    u'OrgPromoteOnHeadingNormal',
                    u':silent! %s ORGMODE.plugins[u"EditStructure"].promote_heading(including_children=False, on_heading=True)<CR>'
                    % VIM_PY_CALL)))
        self.keybindings.append(
            Keybinding(u'<{',
                       u'<Plug>OrgPromoteHeadingNormal',
                       mode=MODE_NORMAL))
        self.keybindings.append(
            Keybinding(u'<ih',
                       u'<Plug>OrgPromoteHeadingNormal',
                       mode=MODE_NORMAL))

        self.keybindings.append(
            Keybinding(
                u'<ar',
                Plug(
                    u'OrgPromoteSubtreeNormal',
                    u':silent! %s ORGMODE.plugins[u"EditStructure"].promote_heading()<CR>'
                    % VIM_PY_CALL)))
        self.menu + ActionEntry(u'&Promote Subtree', self.keybindings[-1])
        self.keybindings.append(
            Keybinding(u'<[[',
                       u'<Plug>OrgPromoteSubtreeNormal',
                       mode=MODE_NORMAL))
        self.keybindings.append(
            Keybinding(u'<ir',
                       u'<Plug>OrgPromoteSubtreeNormal',
                       mode=MODE_NORMAL))

        self.keybindings.append(
            Keybinding(
                u'>ah',
                Plug(
                    u'OrgDemoteHeadingNormal',
                    u':silent! %s ORGMODE.plugins[u"EditStructure"].demote_heading(including_children=False)<CR>'
                    % VIM_PY_CALL)))
        self.menu + ActionEntry(u'&Demote Heading', self.keybindings[-1])
        self.keybindings.append(
            Keybinding(
                u'>>',
                Plug(
                    u'OrgDemoteOnHeadingNormal',
                    u':silent! %s ORGMODE.plugins[u"EditStructure"].demote_heading(including_children=False, on_heading=True)<CR>'
                    % VIM_PY_CALL)))
        self.keybindings.append(
            Keybinding(u'>}',
                       u'<Plug>OrgDemoteHeadingNormal',
                       mode=MODE_NORMAL))
        self.keybindings.append(
            Keybinding(u'>ih',
                       u'<Plug>OrgDemoteHeadingNormal',
                       mode=MODE_NORMAL))

        self.keybindings.append(
            Keybinding(
                u'>ar',
                Plug(
                    u'OrgDemoteSubtreeNormal',
                    u':silent! %s ORGMODE.plugins[u"EditStructure"].demote_heading()<CR>'
                    % VIM_PY_CALL)))
        self.menu + ActionEntry(u'&Demote Subtree', self.keybindings[-1])
        self.keybindings.append(
            Keybinding(u'>]]',
                       u'<Plug>OrgDemoteSubtreeNormal',
                       mode=MODE_NORMAL))
        self.keybindings.append(
            Keybinding(u'>ir',
                       u'<Plug>OrgDemoteSubtreeNormal',
                       mode=MODE_NORMAL))

        # other keybindings
        self.keybindings.append(
            Keybinding(
                u'<C-d>',
                Plug(
                    u'OrgPromoteOnHeadingInsert',
                    u'<C-o>:silent! %s ORGMODE.plugins[u"EditStructure"].promote_heading(including_children=False, on_heading=True, insert_mode=True)<CR>'
                    % VIM_PY_CALL,
                    mode=MODE_INSERT)))
        self.keybindings.append(
            Keybinding(
                u'<C-t>',
                Plug(
                    u'OrgDemoteOnHeadingInsert',
                    u'<C-o>:silent! %s ORGMODE.plugins[u"EditStructure"].demote_heading(including_children=False, on_heading=True, insert_mode=True)<CR>'
                    % VIM_PY_CALL,
                    mode=MODE_INSERT)))