summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Dominik <carsten.dominik@gmail.com>2010-12-12 13:22:11 +0100
committerCarsten Dominik <carsten.dominik@gmail.com>2010-12-12 13:22:11 +0100
commit5f44294c83daaad1035a467f4f449fcd68cf3437 (patch)
treecf7b22e2e2c75f55e16fd63b7d5341df20f9bf9f
parent93135fa8144cc684721bdeadc317e48e919df20a (diff)
downloadorg-mode-5f44294c83daaad1035a467f4f449fcd68cf3437.tar.gz
Support #+CONSTANTS in non - Org-mode files
* lisp/org-table.el (orgtbl-ctrl-c-ctrl-c): Parse buffer for constants. Patch by Seweryn
-rw-r--r--lisp/org-table.el20
1 files changed, 16 insertions, 4 deletions
diff --git a/lisp/org-table.el b/lisp/org-table.el
index 116c3fc..951bff7 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -3721,12 +3721,13 @@ to execute outside of tables."
If it is a table to be sent away to a receiver, do it.
With prefix arg, also recompute table."
(interactive "P")
- (let ((pos (point)) action)
+ (let ((pos (point)) action consts-str consts cst)
(save-excursion
(beginning-of-line 1)
- (setq action (cond ((looking-at "[ \t]*#\\+ORGTBL:.*\n[ \t]*|") (match-end 0))
- ((looking-at "[ \t]*|") pos)
- ((looking-at "[ \t]*#\\+TBLFM:") 'recalc))))
+ (setq action (cond
+ ((looking-at "[ \t]*#\\+ORGTBL:.*\n[ \t]*|") (match-end 0))
+ ((looking-at "[ \t]*|") pos)
+ ((looking-at "[ \t]*#\\+TBLFM:") 'recalc))))
(cond
((integerp action)
(goto-char action)
@@ -3739,6 +3740,17 @@ With prefix arg, also recompute table."
(run-hooks 'orgtbl-after-send-table-hook)))
((eq action 'recalc)
(save-excursion
+ (goto-char (point-min))
+ (while (re-search-forward "^[ \t]*#\\+CONSTANTS: \\(.*\\)" nil t)
+ (setq const-str (substring-no-properties (match-string 1)))
+ (setq consts (append consts (org-split-string const-str "[ \t]+")))
+ (when consts
+ (let (e)
+ (while (setq e (pop consts))
+ (if (string-match "^\\([a-zA-Z0][_a-zA-Z0-9]*\\)=\\(.*\\)" e)
+ (push (cons (match-string 1 e) (match-string 2 e)) cst)))
+ (setq org-table-formula-constants-local cst)))))
+ (save-excursion
(beginning-of-line 1)
(skip-chars-backward " \r\n\t")
(if (org-at-table-p)