示例#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'))
示例#2
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'))
示例#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'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]
示例#4
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

		agenda_files = [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]