diff --git a/lisp/ob-haskell.el b/lisp/ob-haskell.el index cd930266c..a8240d02b 100644 --- a/lisp/ob-haskell.el +++ b/lisp/ob-haskell.el @@ -77,31 +77,28 @@ (defcustom org-babel-haskell-compiler "ghc" (defconst org-babel-header-args:haskell '((compile . :any)) "Haskell-specific header arguments.") - -(defun org-babel-haskell-with-session--worker (params todo) - "See `org-babel-haskell-with-session'." - (let* ((sn (cdr (assq :session params))) - (session (org-babel-haskell-initiate-session sn params)) - (one-shot (equal sn "none"))) - (unwind-protect - (funcall todo session) - (when (and one-shot (buffer-live-p session)) - ;; As we don't control how the session temporary buffer is - ;; created, we need to explicitly work around the hooks and - ;; query functions. - (with-current-buffer session - (let ((kill-buffer-query-functions nil) - (kill-buffer-hook nil)) - (kill-buffer session))))))) - (defmacro org-babel-haskell-with-session (session-symbol params &rest body) "Get the session identified by PARAMS and run BODY with it. -Get or create a session, as needed to match PARAMS. Assign the session to -SESSION-SYMBOL. Execute BODY. Destroy the session if needed. -Return the value of the last form of BODY." +Get or create a session, as needed to match PARAMS. Assign the +session to SESSION-SYMBOL. Execute BODY. Destroy the session if +needed. Return the value of the last form of BODY." (declare (indent 2) (debug (symbolp form body))) - `(org-babel-haskell-with-session--worker ,params (lambda (,session-symbol) ,@body))) + `(let* ((params ,params) + (sn (cdr (assq :session params))) + (session (org-babel-haskell-initiate-session sn params)) + (,session-symbol session) + (one-shot (equal sn "none"))) + (unwind-protect + (progn ,@body) + (when (and one-shot (buffer-live-p session)) + ;; As we don't control how the session temporary buffer is + ;; created, we need to explicitly work around the hooks and + ;; query functions. + (with-current-buffer session + (let ((kill-buffer-query-functions nil) + (kill-buffer-hook nil)) + (kill-buffer session))))))) (defun org-babel-haskell-execute (body params) "This function should only be called by `org-babel-execute:haskell'."