diff options
author | Michael Brand <michael.ch.brand@gmail.com> | 2014-01-12 11:52:40 +0100 |
---|---|---|
committer | Michael Brand <michael.ch.brand@gmail.com> | 2014-01-12 11:52:40 +0100 |
commit | 9a5b8a74349a9439fd22bbea590127c51539a39f (patch) | |
tree | 5d8707ff71bf6c39ef51536932e370a8895aea57 | |
parent | bc1d54b84b46da7b3e5a143ac146d93dd1085acc (diff) | |
download | org-mode-9a5b8a74349a9439fd22bbea590127c51539a39f.tar.gz |
TBLFM remote ref: Improve indirection
* lisp/org-table.el (org-table-remote-reference-indirection): Use the
optional arg START of `string-match' to improve performance and to
avoid endless loop on user error.
-rw-r--r-- | lisp/org-table.el | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/lisp/org-table.el b/lisp/org-table.el index dac3cba..007fc14 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -5017,19 +5017,17 @@ For example \"remote($1, @>$2)\" => \"remote(year_2013, @>$1)\". This indirection works only with the format @ROW$COLUMN. The format \"B3\" is not supported because it can not be distinguished from a plain table name or ID." - (let ((index-last -1) index-this) - (while (and (setq index-this - (string-match (concat - ;; Same as in `org-table-eval-formula'. - "\\<remote([ \t]*\\(" - ;; Allow "$1", "@<", "$-1", "@<<$1" etc. - "[@$][^,]+" - ;; Same as in `org-table-eval-formula'. - "\\)[ \t]*,[ \t]*\\([^\n)]+\\))") - form)) - ;; Protect from last replace replaced itself. - (/= index-last index-this)) - (setq index-last index-this) + (let ((start 0)) + (while (string-match (concat + ;; Same as in `org-table-eval-formula'. + "\\<remote([ \t]*\\(" + ;; Allow "$1", "@<", "$-1", "@<<$1" etc. + "[@$][^,)]+" + ;; Same as in `org-table-eval-formula'. + "\\)[ \t]*,[ \t]*\\([^\n)]+\\))") + form + start) + (setq start (match-end 0)) ;; Substitute the remote reference with the value found in the ;; field. (setq form |