emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] Re: Blorgit > Adding PDF export


From: Eric Schulte
Subject: [Orgmode] Re: Blorgit > Adding PDF export
Date: Mon, 23 Nov 2009 08:38:33 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (darwin)

Thanks Francesco,

These changes should now all be applied to the git repository.

-- Eric

Francesco Pizzolante <address@hidden> writes:

> Eric,
>
>> First off this looks great.
>
> Thanks.
>
>> Rather than explicitly using the "/tmp" directory i would recommend
>> using the `make-temp-file' function, which should work across a wider
>> range of systems.  Additionally if you need to get the directory from a
>> path, or combine a file-name and a directory name into a path I'd
>> recommend the `expand-file-name' and `file-name-directory' functions
>> respectively.
>>
>> With those change I would love to include this new feature into the main
>> blorgit repository.
>
> I tried to take your remarks into account as much as possible.
>
> I only changed "org-interaction.el". Here's the diff:
>
> diff --git a/elisp/org-interaction.el b/elisp/org-interaction.el
> index 2311156..9b785e2 100644
> --- a/elisp/org-interaction.el
> +++ b/elisp/org-interaction.el
> @@ -65,6 +65,31 @@ latex as a string."
>          (write-file latex-path)
>          (kill-buffer (current-buffer)))))))
>
> +(defun org-file-to-pdf (file-path)
> +  "Open up an org file and export it as pdf."
> +  (let* ((file-name (file-name-nondirectory file-path))
> +        (file-dir (file-name-directory file-path))
> +        (org-tmp-path (make-temp-file "org-file-to-pdf-"))
> +        (pdf-tmp-path (concat org-tmp-path ".pdf"))
> +        (tex-tmp-path (concat org-tmp-path ".tex"))
> +        (pdf-path (expand-file-name (concat org-interaction-prefix file-name 
> ".pdf") file-dir)))
> +    (if (and (file-exists-p pdf-path)
> +            (< 0 (time-to-seconds
> +                  (time-subtract
> +                   (nth 5 (file-attributes pdf-path))
> +                   (nth 5 (file-attributes file-path))))))
> +       pdf-path
> +      (with-temp-filebuffer
> +       file-path
> +       (write-file org-tmp-path)
> +       (org-mode)
> +       (save-window-excursion
> +        (org-export-as-pdf nil)
> +        (rename-file pdf-tmp-path pdf-path t)
> +        (delete-file org-tmp-path)
> +        (delete-file tex-tmp-path)
> +        (kill-buffer (current-buffer)))))))
> +
>  ;; customization
>  (setq org-export-blocks-witheld '(hidden comment))
>
> Is this better?
>
> Francesco




reply via email to

[Prev in Thread] Current Thread [Next in Thread]