summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Brand <michael.ch.brand@gmail.com>2014-01-09 19:10:19 (GMT)
committer Michael Brand <michael.ch.brand@gmail.com>2014-01-09 19:10:19 (GMT)
commit34af2fe7ff397a72ed65e85ec90665f1273164dc (patch)
treee9e62faa0dc5cfedff44b59919cd0d812be09b25
parenta2619b714584a181667d11341f26ff12b9d212a3 (diff)
downloadorg-mode-34af2fe7ff397a72ed65e85ec90665f1273164dc.zip
org-mode-34af2fe7ff397a72ed65e85ec90665f1273164dc.tar.gz
Fix multiple TBLFM
Simplify commit release_8.2.4-14-geb28fe4 and commit release_8.2.5c-8-ga2619b7. * org-table.el (org-table-fix-formulas): Handle multiple #+TBLFM lines with `forward-line'.
-rw-r--r--lisp/org-table.el57
1 files changed, 28 insertions, 29 deletions
diff --git a/lisp/org-table.el b/lisp/org-table.el
index e55b685..4999f62 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -2274,36 +2274,35 @@ KEY is \"@\" or \"$\". REPLACE is an alist of numbers to replace.
For all numbers larger than LIMIT, shift them by DELTA."
(save-excursion
(goto-char (org-table-end))
- (let ((case-fold-search t)
- (s-end (min (save-excursion (re-search-forward "^\\S-*$\\|\\'" nil t))
- (save-excursion (org-end-of-subtree t)))))
- (while (re-search-forward "[ \t]*#\\+tblfm:" s-end t)
- (let ((msg "The formulas in #+TBLFM have been updated")
- (re (concat key "\\([0-9]+\\)"))
- (re2
- (when remove
- (if (or (equal key "$") (equal key "$LR"))
- (format "\\(@[0-9]+\\)?%s%d=.*?\\(::\\|$\\)"
- (regexp-quote key) remove)
- (format "@%d\\$[0-9]+=.*?\\(::\\|$\\)" remove))))
- s n a)
- (when remove
- (while (re-search-forward re2 (point-at-eol) t)
- (unless (save-match-data (org-in-regexp "remote([^)]+?)"))
- (if (equal (char-before (match-beginning 0)) ?.)
- (user-error "Change makes TBLFM term %s invalid, use undo to recover"
- (match-string 0))
- (replace-match "")))))
- (while (re-search-forward re (point-at-eol) t)
+ (while (let ((case-fold-search t)) (looking-at "[ \t]*#\\+tblfm:"))
+ (let ((msg "The formulas in #+TBLFM have been updated")
+ (re (concat key "\\([0-9]+\\)"))
+ (re2
+ (when remove
+ (if (or (equal key "$") (equal key "$LR"))
+ (format "\\(@[0-9]+\\)?%s%d=.*?\\(::\\|$\\)"
+ (regexp-quote key) remove)
+ (format "@%d\\$[0-9]+=.*?\\(::\\|$\\)" remove))))
+ s n a)
+ (when remove
+ (while (re-search-forward re2 (point-at-eol) t)
(unless (save-match-data (org-in-regexp "remote([^)]+?)"))
- (setq s (match-string 1) n (string-to-number s))
- (cond
- ((setq a (assoc s replace))
- (replace-match (concat key (cdr a)) t t)
- (message msg))
- ((and limit (> n limit))
- (replace-match (concat key (int-to-string (+ n delta))) t t)
- (message msg))))))))))
+ (if (equal (char-before (match-beginning 0)) ?.)
+ (user-error
+ "Change makes TBLFM term %s invalid, use undo to recover"
+ (match-string 0))
+ (replace-match "")))))
+ (while (re-search-forward re (point-at-eol) t)
+ (unless (save-match-data (org-in-regexp "remote([^)]+?)"))
+ (setq s (match-string 1) n (string-to-number s))
+ (cond
+ ((setq a (assoc s replace))
+ (replace-match (concat key (cdr a)) t t)
+ (message msg))
+ ((and limit (> n limit))
+ (replace-match (concat key (int-to-string (+ n delta))) t t)
+ (message msg))))))
+ (forward-line))))
(defun org-table-get-specials ()
"Get the column names and local parameters for this table."