0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-09-30 03:27:54 +00:00

org-babel: haskell lhs export now displays errors and configurable org-babel-haskell-lhs2tex-command

This commit is contained in:
Eric Schulte 2009-10-04 17:23:50 -06:00
parent 63b360041f
commit 407bf3b816

View file

@ -50,6 +50,8 @@
(add-to-list 'org-babel-tangle-langs '("haskell" "hs")) (add-to-list 'org-babel-tangle-langs '("haskell" "hs"))
(defvar org-babel-haskell-lhs2tex-command "lhs2tex")
(defvar org-babel-haskell-eoe "\"org-babel-haskell-eoe\"") (defvar org-babel-haskell-eoe "\"org-babel-haskell-eoe\"")
(defun org-babel-execute:haskell (body params) (defun org-babel-execute:haskell (body params)
@ -141,7 +143,6 @@ Note that all standard org-babel literate programming
constructs (header arguments, no-web syntax etc...) are ignored." constructs (header arguments, no-web syntax etc...) are ignored."
(interactive) (interactive)
(let* ((contents (buffer-string)) (let* ((contents (buffer-string))
(lhs2tex-command "~/.cabal/bin/lhs2tex")
(haskell-regexp (haskell-regexp
(concat "^\\([ \t]*\\)#\\+begin_src[ \t]haskell*\\(.*\\)?[\r\n]" (concat "^\\([ \t]*\\)#\\+begin_src[ \t]haskell*\\(.*\\)?[\r\n]"
"\\([^\000]*?\\)[\r\n][ \t]*#\\+end_src.*")) "\\([^\000]*?\\)[\r\n][ \t]*#\\+end_src.*"))
@ -151,6 +152,7 @@ constructs (header arguments, no-web syntax etc...) are ignored."
(tmp-tex-file (concat tmp-file ".tex")) (tmp-tex-file (concat tmp-file ".tex"))
(lhs-file (concat base-name ".lhs")) (lhs-file (concat base-name ".lhs"))
(tex-file (concat base-name ".tex")) (tex-file (concat base-name ".tex"))
(command (concat org-babel-haskell-lhs2tex-command " " lhs-file " > " tex-file))
indentation) indentation)
;; escape haskell source-code blocks ;; escape haskell source-code blocks
(with-temp-file tmp-org-file (with-temp-file tmp-org-file
@ -177,12 +179,8 @@ constructs (header arguments, no-web syntax etc...) are ignored."
(delete-file tmp-tex-file) (delete-file tmp-tex-file)
;; save org exported latex to a .lhs file ;; save org exported latex to a .lhs file
(with-temp-file lhs-file (insert contents)) (with-temp-file lhs-file (insert contents))
;; process .lhs file with lhs2tex and place results in .tex file ;; process .lhs file with lhs2tex
(with-temp-file tex-file (message "running %s" command) (shell-command command)))
(insert (shell-command-to-string (concat lhs2tex-command " " lhs-file))))
(message "created %s and %s"
(file-name-nondirectory lhs-file)
(file-name-nondirectory tex-file))))
(provide 'org-babel-haskell) (provide 'org-babel-haskell)
;;; org-babel-haskell.el ends here ;;; org-babel-haskell.el ends here