Ivan Andrus  committed d8151f8

Add SageTeX support for org-mode exporting via latex

  • Participants
  • Parent commits 688966a
  • Branches default

Comments (0)

Files changed (1)

File emacs/sage-auctex.el

-;;; sage-auctex.el --- AUCTeX support for Sage code
+;;; sage-latex.el --- LaTeX support for Sage code
 ;; Copyright (C) 2012  Ivan Andrus
 ;;; Commentary:
-;; This file adds functionality to AUCTeX supporting usage of SageTeX.
+;; This file adds functionality to AUCTeX and org-mode, to support
+;; usage of SageTeX.
 ;;; Code:
-(eval-when-compile (and (require 'tex-site nil t)
-			(require 'tex)
-			(require 'tex-buf)))
+  (and (require 'tex-site nil t)
+       (require 'tex)
+       (require 'tex-buf))
+  (require 'org-latex nil t))
 (defun sage-run-sagetex (name command file)
   (ad-activate 'TeX-LaTeX-sentinel))
+(defun sage-org-latex-setup ()
+  "Sets up `org-mode' variables to support using SageTeX.
+Currently only `org-latex-to-pdf-process' is affected."
+  (let ((is-default (equal org-latex-to-pdf-process
+			   (default-value 'org-latex-to-pdf-process))))
+    (unless (loop for command in org-latex-to-pdf-process
+		  when (string-match "sagetex.sage" command) collect command)
+      (setcdr org-latex-to-pdf-process
+	      (cons (concat "if [ -f %b.sagetex.sage ]; then "
+			    sage-command " %b.sagetex.sage; fi")
+		    (cdr org-latex-to-pdf-process)))
+      (and (not is-default)
+	   (message
+	    "It appears you have made changes to `org-latex-to-pdf-process'. You may also wish to add support for SageTeX.")))))
 (eval-after-load 'tex '(sage-auctex-setup))
+(eval-after-load 'org-latex '(sage-org-latex-setup))
 (provide 'sage-auctex)
-;;; sage-auctex.el ends here
+;;; sage-latex.el ends here