示例#1
0
	def realign_all_tags(cls):
		"""
		Updates tags when user finishes editing a heading
		"""
		for h in Document.headings():
			if h.tags:
				h.tags = h.tags
示例#2
0
    def realign_all_tags(cls):
        """
		Updates tags when user finishes editing a heading
		"""
        for h in Document.headings():
            if h.tags:
                h.tags = h.tags
示例#3
0
    def complete_tags(cls):
        """ build a list of tags and store it in variable b:org_tag_completion
		"""
        heading = Document.current_heading()
        if not heading:
            return

        leading_portion = vim.eval('a:ArgLead')
        cursor = int(vim.eval('a:CursorPos'))

        # extract currently completed tag
        idx_orig = leading_portion.rfind(':', 0, cursor)
        if idx_orig == -1:
            idx = 0
        else:
            idx = idx_orig

        current_tag = leading_portion[idx:cursor].lstrip(':')
        head = leading_portion[:idx + 1]
        if idx_orig == -1:
            head = ''
        tail = leading_portion[cursor:]

        # extract all tags of the current file
        all_tags = set()
        for h in Document.headings():
            for t in h.tags:
                all_tags.add(t)

        ignorecase = bool(
            int(settings.get('org_tags_completion_ignorecase', '0')))
        possible_tags = []
        current_tags = heading.tags
        for t in all_tags:
            if ignorecase:
                if t.lower().startswith(current_tag.lower()):
                    possible_tags.append(t)
            elif t.startswith(current_tag):
                possible_tags.append(t)

        vim.command(
            'let b:org_complete_tags = [%s]' %
            ', '.join(['"%s%s:%s"' % (head, i, tail) for i in possible_tags]))
示例#4
0
	def complete_tags(cls):
		""" build a list of tags and store it in variable b:org_tag_completion
		"""
		heading = Document.current_heading()
		if not heading:
			return

		leading_portion = vim.eval('a:ArgLead')
		cursor = int(vim.eval('a:CursorPos'))

		# extract currently completed tag
		idx_orig = leading_portion.rfind(':', 0, cursor)
		if idx_orig == -1:
			idx = 0
		else:
			idx = idx_orig

		current_tag = leading_portion[idx: cursor].lstrip(':')
		head = leading_portion[:idx + 1]
		if idx_orig == -1:
			head = ''
		tail = leading_portion[cursor:]

		# extract all tags of the current file
		all_tags = set()
		for h in Document.headings():
			for t in h.tags:
				all_tags.add(t)

		ignorecase = bool(int(settings.get('org_tags_completion_ignorecase', '0')))
		possible_tags = []
		current_tags = heading.tags
		for t in all_tags:
			if ignorecase:
				if t.lower().startswith(current_tag.lower()):
					possible_tags.append(t)
			elif t.startswith(current_tag):
				possible_tags.append(t)

		vim.command('let b:org_complete_tags = [%s]' % ', '.join(['"%s%s:%s"' % (head, i, tail) for i in possible_tags]))