From 3053c13d2c345cc5b222b7401b89656ef4ad695d Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Tue, 1 May 2012 01:41:50 +0200 Subject: [PATCH] org-table.el: Fix bug in a free variable name. * org-table.el (org-tbl-calc-modes): Rename from `org-table-modes'. (org-set-calc-mode, org-table-eval-formula): Use it. Thanks to Mikkel Kristiansen for reporting this and to Nick Dokos for tracking down the bug and proposing a fix. --- lisp/org-table.el | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/lisp/org-table.el b/lisp/org-table.el index 37e5c4f91..f1bb0ac27 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -2368,7 +2368,7 @@ of the new mark." (looking-at org-table-auto-recalculate-regexp)) (org-table-recalculate) t)) -(defvar org-table-modes) +(defvar org-tbl-calc-modes) ;; Dynamically bound in `org-table-eval-formula' (defsubst org-set-calc-mode (var &optional value) (if (stringp var) (setq var (assoc var '(("D" calc-angle-mode deg) @@ -2376,10 +2376,10 @@ of the new mark." ("F" calc-prefer-frac t) ("S" calc-symbolic-mode t))) value (nth 2 var) var (nth 1 var))) - (if (memq var org-table-modes) - (setcar (cdr (memq var org-table-modes)) value) - (cons var (cons value org-table-modes))) - org-table-modes) + (if (memq var org-tbl-calc-modes) + (setcar (cdr (memq var org-tbl-calc-modes)) value) + (cons var (cons value org-tbl-calc-modes))) + org-tbl-calc-modes) (defun org-table-eval-formula (&optional arg equation suppress-align suppress-const @@ -2437,7 +2437,7 @@ not overwrite the stored one." equation (org-table-get-formula equation (equal arg '(4))))) (n0 (org-table-current-column)) - (modes (copy-sequence org-calc-default-modes)) + (org-tbl-calc-modes (copy-sequence org-calc-default-modes)) (numbers nil) ; was a variable, now fixed default (keep-empty nil) n form form0 formrpl formrg bw fmt x ev orig c lispp literal @@ -2453,12 +2453,13 @@ not overwrite the stored one." (setq c (string-to-char (match-string 1 fmt)) n (string-to-number (match-string 2 fmt))) (if (= c ?p) - (setq modes (org-set-calc-mode 'calc-internal-prec n)) - (setq modes (org-set-calc-mode - 'calc-float-format - (list (cdr (assoc c '((?n . float) (?f . fix) - (?s . sci) (?e . eng)))) - n)))) + (setq org-tbl-calc-modes (org-set-calc-mode 'calc-internal-prec n)) + (setq org-tbl-calc-modes + (org-set-calc-mode + 'calc-float-format + (list (cdr (assoc c '((?n . float) (?f . fix) + (?s . sci) (?e . eng)))) + n)))) (setq fmt (replace-match "" t t fmt))) (if (string-match "T" fmt) (setq duration t numbers t @@ -2479,7 +2480,7 @@ not overwrite the stored one." (setq keep-empty t fmt (replace-match "" t t fmt))) (while (string-match "[DRFS]" fmt) - (setq modes (org-set-calc-mode (match-string 0 fmt))) + (setq org-tbl-calc-modes (org-set-calc-mode (match-string 0 fmt))) (setq fmt (replace-match "" t t fmt))) (unless (string-match "\\S-" fmt) (setq fmt nil)))) @@ -2588,7 +2589,7 @@ not overwrite the stored one." duration-output-format) ev)) (or (fboundp 'calc-eval) (error "Calc does not seem to be installed, and is needed to evaluate the formula")) - (setq ev (calc-eval (cons form modes) (if numbers 'num)) + (setq ev (calc-eval (cons form org-tbl-calc-modes) (if numbers 'num)) ev (if duration (org-table-time-seconds-to-string (string-to-number ev) duration-output-format) ev))) -- 2.11.4.GIT