From 2d4521a032ec3e4174c97b2b2e9a08491e9870fb Mon Sep 17 00:00:00 2001 From: Daniele Nicolodi Date: Wed, 21 Oct 2020 17:47:15 +0200 Subject: [PATCH 4/4] org-table: Remove unused org-tbl-calc-modes variable * org-table.el (org-tbl-calc-modes): Remove the variable declaration as the varialble is only used as a local variable in `org-table-eval-formula'. * org-table.el (org-table--set-calc-mode): Drop convenience macro. * org-table.el (org-table-eval-formula): Rename `org-tbl-calc-modes` local variable without the org-table prefix and usr the gained screen real estate to avoid indirection through covenience macro. --- lisp/org-table.el | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/lisp/org-table.el b/lisp/org-table.el index 6b92656bd..1651decd3 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -676,8 +676,6 @@ Will be filled automatically during use.") ("_" . "Names for values in row below this one.") ("^" . "Names for values in row above this one."))) -(defvar org-tbl-calc-modes nil) - (defvar org-pos nil) @@ -721,9 +719,6 @@ Field is restored even in case of abnormal exit." (org-table-goto-column ,column) (set-marker ,line nil))))) -(defsubst org-table--set-calc-mode (var value) - (setq org-tbl-calc-modes (plist-put org-tbl-calc-modes var value))) - ;;; Predicates @@ -2424,7 +2419,7 @@ location of point." equation (org-table-get-formula equation (equal arg '(4))))) (n0 (org-table-current-column)) - (org-tbl-calc-modes (copy-sequence org-calc-default-modes)) + (calc-modes (copy-sequence org-calc-default-modes)) (numbers nil) ; was a variable, now fixed default (keep-empty nil) form form0 formrpl formrg bw fmt ev orig lispp literal @@ -2440,11 +2435,11 @@ location of point." (let ((c (string-to-char (match-string 1 fmt))) (n (string-to-number (match-string 2 fmt)))) (cl-case c - (?p (org-table--set-calc-mode 'calc-internal-prec n)) - (?n (org-table--set-calc-mode 'calc-float-format (list 'float n))) - (?f (org-table--set-calc-mode 'calc-float-format (list 'fix n))) - (?s (org-table--set-calc-mode 'calc-float-format (list 'sci n))) - (?e (org-table--set-calc-mode 'calc-float-format (list 'eng n))))) + (?p (setf (cl-getf calc-modes 'calc-internal-prec) n)) + (?n (setf (cl-getf calc-modes 'calc-float-format) (list 'float n))) + (?f (setf (cl-getf calc-modes 'calc-float-format) (list 'fix n))) + (?s (setf (cl-getf calc-modes 'calc-float-format) (list 'sci n))) + (?e (setf (cl-getf calc-modes 'calc-float-format) (list 'eng n))))) ;; Remove matched flags from the mode string. (setq fmt (replace-match "" t t fmt))) (while (string-match "\\([tuTUNLEDRFS]\\)" fmt) @@ -2452,16 +2447,16 @@ location of point." (cl-case c (?t (setq duration t numbers t duration-output-format org-table-duration-custom-format)) - (?u (org-table--set-calc-mode 'calc-simplify-mode 'units)) + (?u (setf (cl-getf calc-modes 'calc-simplify-mode) 'units)) (?T (setq duration t numbers t duration-output-format nil)) (?U (setq duration t numbers t duration-output-format 'hh:mm)) (?N (setq numbers t)) (?L (setq literal t)) (?E (setq keep-empty t)) - (?D (org-table--set-calc-mode 'calc-angle-mode 'deg)) - (?R (org-table--set-calc-mode 'calc-angle-mode 'rad)) - (?F (org-table--set-calc-mode 'calc-prefer-frac t)) - (?S (org-table--set-calc-mode 'calc-symbolic-mode t)))) + (?D (setf (cl-getf calc-modes 'calc-angle-mode) 'deg)) + (?R (setf (cl-getf calc-modes 'calc-angle-mode) 'rad)) + (?F (setf (cl-getf calc-modes 'calc-prefer-frac) t)) + (?S (setf (cl-getf calc-modes 'calc-symbolic-mode) t)))) ;; Remove matched flags from the mode string. (setq fmt (replace-match "" t t fmt))) (unless (string-match "\\S-" fmt) @@ -2606,7 +2601,7 @@ location of point." (setq ev (if (and duration (string-match "^[0-9]+:[0-9]+\\(?::[0-9]+\\)?$" form)) form - (calc-eval (cons form org-tbl-calc-modes) + (calc-eval (cons form calc-modes) (when (and (not keep-empty) numbers) 'num))) ev (if duration (org-table-time-seconds-to-string (if (string-match "^[0-9]+:[0-9]+\\(?::[0-9]+\\)?$" ev) -- 2.28.0