emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Francesco Pizzolante <fpz-djc/iPCCuDYQheJpep6IedvLeJWuRmrY@public.gmane.org>
To: Eric Schulte <schulte.eric-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: mailing-list-org-mode <emacs-orgmode-mXXj517/zsQ@public.gmane.org>
Subject: Re: Blorgit > Adding PDF export
Date: Mon, 23 Nov 2009 16:23:01 +0100	[thread overview]
Message-ID: <87y6lxxo2y.fsf@missioncriticalit.com> (raw)
In-Reply-To: <m2ljhxi9oi.fsf-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> (Eric Schulte's message of "Mon, 23 Nov 2009 07:43:09 -0700")

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:

--8<---------------cut here---------------start------------->8---
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))
--8<---------------cut here---------------end--------------->8---

Is this better?

Francesco


_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode-mXXj517/zsQ@public.gmane.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

  parent reply	other threads:[~2009-11-23 15:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-13 15:47 Blorgit > SVN integration Francesco Pizzolante
2009-11-13 17:45 ` Eric Schulte
     [not found]   ` <m2r5s2gvyc.fsf-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2009-11-19 10:06     ` Francesco Pizzolante
2009-11-19 15:17       ` Eric Schulte
     [not found]         ` <m2skcazgr6.fsf-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2009-11-20 12:36           ` Francesco Pizzolante
2009-11-20 17:15             ` Eric Schulte
2009-11-23 12:58           ` Blorgit > Adding PDF export Francesco Pizzolante
2009-11-23 14:43             ` Eric Schulte
     [not found]               ` <m2ljhxi9oi.fsf-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2009-11-23 15:23                 ` Francesco Pizzolante [this message]
2009-11-23 15:38                   ` Eric Schulte
2009-12-03 15:59           ` Blorgit > SVN integration Francesco Pizzolante
2009-12-05  3:54             ` Eric Schulte
     [not found]               ` <m27ht23wj2.fsf-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2009-12-07 12:33                 ` Francesco Pizzolante

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y6lxxo2y.fsf@missioncriticalit.com \
    --to=fpz-djc/ipccudyqhejpep6iedvlejwurmry@public.gmane.org \
    --cc=emacs-orgmode-mXXj517/zsQ@public.gmane.org \
    --cc=schulte.eric-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).