From mboxrd@z Thu Jan 1 00:00:00 1970 From: Francesco Pizzolante Subject: Re: Blorgit > Adding PDF export Date: Mon, 23 Nov 2009 16:23:01 +0100 Message-ID: <87y6lxxo2y.fsf@missioncriticalit.com> References: <87r5s24ebl.fsf@missioncriticalit.com> <87fx8asu9s.fsf@missioncriticalit.com> <873a451jox.fsf_-_@missioncriticalit.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: In-Reply-To: (Eric Schulte's message of "Mon, 23 Nov 2009 07:43:09 -0700") 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-mXXj517/zsQ@public.gmane.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org-mXXj517/zsQ@public.gmane.org To: Eric Schulte Cc: mailing-list-org-mode 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