path: root/lisp/ob-calc.el
diff options
Diffstat (limited to 'lisp/ob-calc.el')
1 files changed, 11 insertions, 9 deletions
diff --git a/lisp/ob-calc.el b/lisp/ob-calc.el
index f5e70de..415cab1 100644
--- a/lisp/ob-calc.el
+++ b/lisp/ob-calc.el
@@ -1,4 +1,4 @@
-;;; ob-calc.el --- org-babel functions for calc code evaluation
+;;; ob-calc.el --- Babel Functions for Calc -*- lexical-binding: t; -*-
;; Copyright (C) 2010-2016 Free Software Foundation, Inc.
@@ -28,18 +28,18 @@
;;; Code:
(require 'ob)
(require 'calc)
-(unless (featurep 'xemacs)
- (require 'calc-trail)
- (require 'calc-store))
+(require 'calc-trail)
+(require 'calc-store)
(declare-function calc-store-into "calc-store" (&optional var))
(declare-function calc-recall "calc-store" (&optional var))
(declare-function math-evaluate-expr "calc-ext" (x))
+(declare-function org-trim "org" (s &optional keep-lead))
(defvar org-babel-default-header-args:calc nil
"Default arguments for evaluating an calc source block.")
-(defun org-babel-expand-body:calc (body params)
+(defun org-babel-expand-body:calc (body _params)
"Expand BODY according to PARAMS, return the expanded body." body)
(defvar org--var-syms) ; Dynamically scoped from org-babel-execute:calc
@@ -48,7 +48,7 @@
"Execute a block of calc code with Babel."
(unless (get-buffer "*Calculator*")
(save-window-excursion (calc) (calc-quit)))
- (let* ((vars (mapcar #'cdr (org-babel-get-header params :var)))
+ (let* ((vars (org-babel--get-vars params))
(org--var-syms (mapcar #'car vars))
(var-names (mapcar #'symbol-name org--var-syms)))
@@ -85,15 +85,17 @@
;; parse line into calc objects
(car (math-read-exprs line)))))))))
- (mapcar #'org-babel-trim
+ (mapcar #'org-trim
(split-string (org-babel-expand-body:calc body params) "[\n\r]"))))
(with-current-buffer (get-buffer "*Calculator*")
- (calc-eval (calc-top 1)))))
+ (prog1
+ (calc-eval (calc-top 1))
+ (calc-pop 1)))))
(defun org-babel-calc-maybe-resolve-var (el)
(if (consp el)
- (if (and (equal 'var (car el)) (member (cadr el) org--var-syms))
+ (if (and (eq 'var (car el)) (member (cadr el) org--var-syms))
(calc-recall (cadr el))
(prog1 (calc-top 1)