Example #1
0
	def _export(cls, _format):
		""" Export current file in out format

		:flavor:	pdf or html
		:returns:	return code
		"""
		f = _format if _format == 'pdf' else 'html'
		emacs = os.path.expandvars(os.path.expanduser( \
				settings.get(u'org_export_emacs', u'/usr/bin/emacs')))
		if os.path.exists(emacs):
			cmd = [emacs, u'-nw', u'--batch', u'--visit=%s' \
					% (vim.eval(u'expand("%:p")'), ), \
					u'--funcall=org-export-as-%s' % f]

			# source init script as well
			init_script = cls._get_init_script()
			if init_script:
				cmd.extend(['--script', init_script])
			p = subprocess.Popen(cmd, stdout=subprocess.PIPE, \
					stderr=subprocess.PIPE)
			p.wait()
			if p.returncode != 0 or settings.get(u'org_export_verbose') == 1:
				echom('\n'.join(p.communicate()))

			return p.returncode
		else:
			echoe(u'Unable to find emacs binary %s' % emacs)
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

		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]
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'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]
Example #4
0
	def _get_init_script(cls):
		init_script = settings.get(u'org_export_init_script', u'')
		if init_script:
			init_script = os.path.expandvars(os.path.expanduser(init_script))
			if os.path.exists(init_script):
				return init_script
			else:
				echoe(u'Unable to find init script %s' % init_script)
Example #5
0
	def tohtml(cls):
		u"""
		Export the current buffer as html using emacs orgmode.
		"""
		ret = cls._export(u'html')
		if ret != 0:
			echoe(u'HTML export failed.')
		else:
			echom(u'Export successful: %s.%s' % (vim.eval(u'expand("%:r")'), 'html'))
Example #6
0
	def topdf(cls):
		u"""
		Export the current buffer as pdf using emacs orgmode.
		"""
		ret = cls._export(u'pdf')
		if ret != 0:
			echoe(u'PDF export failed.')
		else:
			echom(u'Export successful: %s.%s' % (vim.eval(u'expand("%:r")'), 'pdf'))