Beispiel #1
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'))
Beispiel #2
0
	def tolatex(cls):
		u"""Export the current buffer as latex using emacs orgmode."""
		ret = cls._export(u'latex')
		if ret != 0:
			echoe(u'latex export failed.')
		else:
			echom(u'Export successful: %s.%s' % (vim.eval(u'expand("%:r")'), 'tex'))
Beispiel #3
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)
Beispiel #4
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)
Beispiel #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'))
Beispiel #6
0
	def tolatex(cls):
		u"""Export the current buffer as latex using emacs orgmode."""
		ret = cls._export(u'org-latex-export-to-latex')
		if ret != 0:
			echoe(u'latex export failed.')
		else:
			echom(u'Export successful: %s.%s' % (vim.eval(u'expand("%:r")'), 'tex'))
Beispiel #7
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]
Beispiel #8
0
    def _export(cls, format_):
        """Export current file to format.

		Args:
			format_: pdf or html

		Returns:
			return code
		"""
        emacsbin = os.path.expandvars(
            os.path.expanduser(
                settings.get(u'org_export_emacs', u'/usr/bin/emacs')))
        if not os.path.exists(emacsbin):
            echoe(u'Unable to find emacs binary %s' % emacsbin)

        # build the export command
        cmd = [
            emacsbin, u'-nw', u'--batch',
            u'--visit=%s' % vim.eval(u'expand("%:p")'),
            u'--funcall=%s' % format_
        ]
        # source init script as well
        init_script = cls._get_init_script()
        if init_script:
            cmd.extend(['--script', init_script])

        # export
        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
Beispiel #9
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]
Beispiel #10
0
	def _export(cls, format_):
		"""Export current file to format_.

		:format_:  pdf or html
		:returns:  return code
		"""
		emacsbin = os.path.expandvars(os.path.expanduser(
			settings.get(u'org_export_emacs', u'/usr/bin/emacs')))
		if not os.path.exists(emacsbin):
			echoe(u'Unable to find emacs binary %s' % emacsbin)

		# build the export command
		cmd = [
			emacsbin,
			u'-nw',
			u'--batch',
			u'--visit=%s' % vim.eval(u'expand("%:p")'),
			u'--funcall=%s' % format_
		]
		# source init script as well
		init_script = cls._get_init_script()
		if init_script:
			cmd.extend(['--script', init_script])

		# export
		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
Beispiel #11
0
	def tobeamer(cls):
		u"""Export the current buffer as beamer pdf using emacs orgmode."""
		ret = cls._export(u'org-beamer-export-to-pdf')
		if ret != 0:
			echoe(u'PDF export failed.')
		else:
			echom(u'Export successful: %s.%s' % (vim.eval(u'expand("%:r")'), 'pdf'))
Beispiel #12
0
	def tomarkdown(cls):
		u"""Export the current buffer as markdown using emacs orgmode."""
		ret = cls._export(u'org-md-export-to-markdown')
		if ret != 0:
			echoe('Markdown export failed. Make sure org-md-export-to-markdown is loaded in emacs, see the manual for details.')
		else:
			echom(u'Export successful: %s.%s' % (vim.eval(u'expand("%:r")'), 'md'))
Beispiel #13
0
	def tomarkdown(cls):
		u"""Export the current buffer as markdown using emacs orgmode."""
		ret = cls._export(u'org-md-export-to-markdown')
		if ret != 0:
			echoe('Markdown export failed. Make sure org-md-export-to-markdown is loaded in emacs, see the manual for details.')
		else:
			echom(u'Export successful: %s.%s' % (vim.eval(u'expand("%:r")'), 'md'))
Beispiel #14
0
	def tohtml(cls):
		u"""Export the current buffer as html using emacs orgmode."""
		ret = cls._export(u'org-html-export-to-html')
		if ret != 0:
			echoe(u'HTML export failed.')
		else:
			echom(u'Export successful: %s.%s' % (vim.eval(u'expand("%:r")'), 'html'))
Beispiel #15
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)
Beispiel #16
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)
Beispiel #17
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
        return self._load_agendafiles(agenda_files)
Beispiel #18
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
		return self._load_agendafiles(agenda_files)