From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eric Schulte" Subject: Re: Blorgit > Adding PDF export Date: Mon, 23 Nov 2009 08:38:33 -0700 Message-ID: References: <87r5s24ebl.fsf@missioncriticalit.com> <87fx8asu9s.fsf@missioncriticalit.com> <873a451jox.fsf_-_@missioncriticalit.com> <87y6lxxo2y.fsf@missioncriticalit.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NCazz-00017x-JP for emacs-orgmode@gnu.org; Mon, 23 Nov 2009 10:38:43 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NCazu-00015f-J9 for emacs-orgmode@gnu.org; Mon, 23 Nov 2009 10:38:42 -0500 Received: from [199.232.76.173] (port=42611 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NCazu-00015P-8a for emacs-orgmode@gnu.org; Mon, 23 Nov 2009 10:38:38 -0500 Received: from mail-pw0-f47.google.com ([209.85.160.47]:45437) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NCazt-0005q3-Qv for emacs-orgmode@gnu.org; Mon, 23 Nov 2009 10:38:38 -0500 Received: by pwi9 with SMTP id 9so3934703pwi.26 for ; Mon, 23 Nov 2009 07:38:36 -0800 (PST) In-Reply-To: <87y6lxxo2y.fsf@missioncriticalit.com> (Francesco Pizzolante's message of "Mon, 23 Nov 2009 16:23:01 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Francesco Pizzolante Cc: mailing-list-org-mode Thanks Francesco, These changes should now all be applied to the git repository. -- Eric Francesco Pizzolante 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