Example #1
0
	def opendoc(cls, split=False, switch=False):
		u"""
		If you are in the agenda view jump to the document the item in the
		current line belongs to. cls.line2doc is used for that.

		:split: if True, open the document in a new split window.
		:switch: if True, switch to another window and open the the document
			there.
		"""
		row, _ = vim.current.window.cursor
		try:
			bufname, bufnr, destrow = cls.line2doc[row]
		except:
			return

		# reload source file if it is not loaded
		if get_bufname(bufnr) is None:
			vim.command((u'badd %s' % bufname).encode(u'utf-8'))
			bufnr = get_bufnumber(bufname)
			tmp = cls.line2doc[row]
			cls.line2doc[bufnr] = tmp
			# delete old endry
			del cls.line2doc[row]

		if split:
			vim.command((u"sbuffer %s" % bufnr).encode(u'utf-8'))
		elif switch:
			vim.command(u"wincmd w".encode(u'utf-8'))
			vim.command((u"buffer %d" % bufnr).encode(u'utf-8'))
		else:
			vim.command((u"buffer %s" % bufnr).encode(u'utf-8'))
		vim.command((u"normal! %dgg <CR>" % (destrow + 1)).encode(u'utf-8'))
Example #2
0
	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

		# glob for files in agenda_files
		resolved_files = []
		for f in agenda_files:
			f = glob.glob(os.path.join(os.path.expanduser(os.path.dirname(f)),
				          os.path.basename(f)))
			resolved_files.extend(f)

		agenda_files = [os.path.realpath(f) for f in resolved_files]

		# load the agenda files into buffers
		for agenda_file in agenda_files:
			vim.command((u'badd %s' % agenda_file.replace(" ", "\ ")).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]
Example #3
0
    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'vimwiki_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

        # glob for files in agenda_files
        resolved_files = []
        for f in agenda_files:
            f = glob.glob(
                os.path.join(os.path.expanduser(os.path.dirname(f)),
                             os.path.basename(f)))
            resolved_files.extend(f)

        agenda_files = [os.path.realpath(f) for f in resolved_files]

        # load the agenda files into buffers
        for agenda_file in agenda_files:
            vim.command(
                (u'badd %s' % agenda_file.replace(" ", "\ ")).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]
Example #4
0
    def opendoc(cls, split=False, switch=False):
        u"""
		If you are in the agenda view jump to the document the item in the
		current line belongs to. cls.line2doc is used for that.

		:split: if True, open the document in a new split window.
		:switch: if True, switch to another window and open the the document
			there.
		"""
        row, _ = vim.current.window.cursor
        try:
            bufname, bufnr, destrow = cls.line2doc[row]
        except:
            return

        # reload source file if it is not loaded
        if get_bufname(bufnr) is None:
            vim.command((u'badd %s' % bufname).encode(u'utf-8'))
            bufnr = get_bufnumber(bufname)
            tmp = cls.line2doc[row]
            cls.line2doc[bufnr] = tmp
            # delete old endry
            del cls.line2doc[row]

        if split:
            vim.command((u"sbuffer %s" % bufnr).encode(u'utf-8'))
        elif switch:
            vim.command(u"wincmd w".encode(u'utf-8'))
            vim.command((u"buffer %d" % bufnr).encode(u'utf-8'))
        else:
            vim.command((u"buffer %s" % bufnr).encode(u'utf-8'))
        vim.command((u"normal! %dgg <CR>" % (destrow + 1)).encode(u'utf-8'))
Example #5
0
	def _load_agendafiles(self, agenda_files):
		# glob for files in agenda_files
		resolved_files = []
		for f in agenda_files:
			f = glob.glob(os.path.join(
				os.path.expanduser(os.path.dirname(f)),
				os.path.basename(f)))
			resolved_files.extend(f)

		agenda_files = [os.path.realpath(f) for f in resolved_files]

		# load the agenda files into buffers
		for agenda_file in agenda_files:
			vim.command((u'badd %s' % agenda_file.replace(" ", "\ ")).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]
Example #6
0
    def _load_agendafiles(self, agenda_files):
        # glob for files in agenda_files
        resolved_files = []
        for f in agenda_files:
            f = glob.glob(
                os.path.join(os.path.expanduser(os.path.dirname(f)),
                             os.path.basename(f)))
            resolved_files.extend(f)

        agenda_files = [os.path.realpath(f) for f in resolved_files]

        # load the agenda files into buffers
        for agenda_file in agenda_files:
            vim.command(u_encode(u'badd %s' % agenda_file.replace(" ", "\\ ")))

        # 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]