diff options
author | Bastien Guerry <bzg@altern.org> | 2011-10-27 18:23:08 +0200 |
---|---|---|
committer | Bastien Guerry <bzg@altern.org> | 2011-10-27 18:23:08 +0200 |
commit | 901121ac4597e18ab19087fdb210b6a7a6951b85 (patch) | |
tree | 9fb2391d391298a1a49a615805d5d3318f7476d0 | |
parent | 44435f3ee3eca7fb91505442ae6ea6a9ffe4725f (diff) | |
parent | 23b8111ffaacfff4b4e41bdca364472d5f695d7a (diff) | |
download | org-mode-901121ac4597e18ab19087fdb210b6a7a6951b85.tar.gz |
Merge branch 'master' of orgmode.org:org-mode
-rw-r--r-- | lisp/org-table.el | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/lisp/org-table.el b/lisp/org-table.el index e85d034..edcdbe1 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -2986,20 +2986,24 @@ when a line/row is swaped out of that privileged position. So for formulas that use a range of rows or columns, it may often be better to anchor the formula with \"I\" row markers, or to offset from the borders of the table using the @< @> $< $> makers." - (let (n nmax len char) - (while (string-match "\\([@$]\\)\\(<+\\|>+\\)" s) - (setq nmax (if (equal (match-string 1 s) "@") - (1- (length org-table-dlines)) - org-table-current-ncol) - len (- (match-end 2) (match-beginning 2)) - char (string-to-char (match-string 2 s)) - n (if (= char ?<) - len - (- nmax len -1))) - (if (or (< n 1) (> n nmax)) - (error "Reference \"%s\" in expression \"%s\" points outside table" - (match-string 0 s) s)) - (setq s (replace-match (format "%s%d" (match-string 1 s) n) t t s)))) + (let (n nmax len char (start 0)) + (while (string-match "\\([@$]\\)\\(<+\\|>+\\)\\|\\(remote([^\)]+)\\)" + s start) + (if (match-end 3) + (setq start (match-end 3)) + (setq nmax (if (equal (match-string 1 s) "@") + (1- (length org-table-dlines)) + org-table-current-ncol) + len (- (match-end 2) (match-beginning 2)) + char (string-to-char (match-string 2 s)) + n (if (= char ?<) + len + (- nmax len -1))) + (if (or (< n 1) (> n nmax)) + (error "Reference \"%s\" in expression \"%s\" points outside table" + (match-string 0 s) s)) + (setq start (match-beginning 0)) + (setq s (replace-match (format "%s%d" (match-string 1 s) n) t t s))))) s) (defun org-table-formula-substitute-names (f) @@ -4668,6 +4672,8 @@ The return value is either a single string for a single field, or a list of the fields in the rectangle ." (save-match-data (let ((id-loc nil) + ;; Protect a bunch of variables from being overwritten + ;; by the context of the remote table org-table-column-names org-table-column-name-regexp org-table-local-parameters org-table-named-field-locations org-table-current-line-types org-table-current-begin-line @@ -4704,7 +4710,8 @@ list of the fields in the rectangle ." (error "Cannot find a table at NAME or ID %s" name-or-id)) (setq tbeg (point-at-bol)) (org-table-get-specials) - (setq form (org-table-formula-substitute-names form)) + (setq form (org-table-formula-substitute-names + (org-table-formula-handle-first/last-rc form))) (if (and (string-match org-table-range-regexp form) (> (length (match-string 0 form)) 1)) (save-match-data |