Преглед изворни кода

Tables: Don't modify remote references when changing a table

Rares Vernica writes:

>  I think I found another bug related to remote
>  references. When I insert/remove a row/column using the
>  table commands, the remote references to other tables are
>  also updated. I think org treats "remote" as a regular
>  function and updates the references inside it.
>
>  Here is an example:
>
>  #+TBLNAME: TableA
>  | 101 |
>  #+TBLFM: @1$1=remote(TableB,@1$1)
>
>  #+TBLNAME: TableB
>  | 101 |
>
>  If I go in the cell of TableA and do M-S-down arrow, I get
>  the following:
>
>  #+TBLNAME: TableA
>  |     |
>  | 101 |
>  #+TBLFM: @2$1=remote(TableB,@2$1)
>                             ^^^^
>
>  As you can see the remote reference has been updated. I
>  similar update happens when I remove a row or insert/remove
>  a column.

This commit makes sure that references inside calls to
remote() are not touched.
Carsten Dominik пре 16 година
родитељ
комит
06ddc5e9d2
2 измењених фајлова са 13 додато и 7 уклоњено
  1. 3 0
      lisp/ChangeLog
  2. 10 7
      lisp/org-table.el

+ 3 - 0
lisp/ChangeLog

@@ -1,5 +1,8 @@
 2009-04-15  Carsten Dominik  <carsten.dominik@gmail.com>
 
+	* org-table.el (org-table-fix-formulas): Do not change references
+	to remote tables.
+
 	* org-latex.el (org-export-latex-keywords): Fix regexp bug.
 
 2009-04-14  Carsten Dominik  <carsten.dominik@gmail.com>

+ 10 - 7
lisp/org-table.el

@@ -1882,14 +1882,17 @@ For all numbers larger than LIMIT, shift them by DELTA."
 	    s n a)
 	(when remove
 	  (while (re-search-forward re2 (point-at-eol) t)
-	    (replace-match "")))
+	    (unless (save-match-data (org-in-regexp "remote([^)]+?)"))
+	      (replace-match ""))))
 	(while (re-search-forward re (point-at-eol) t)
-	  (setq s (match-string 1) n (string-to-number s))
-	  (cond
-	   ((setq a (assoc s replace))
-	    (replace-match (concat key (cdr a)) t t))
-	   ((and limit (> n limit))
-	    (replace-match (concat key (int-to-string (+ n delta))) t 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))
+	     ((and limit (> n limit))
+	      (replace-match (concat key (int-to-string (+ n delta)))
+			     t t)))))))))
 
 (defun org-table-get-specials ()
   "Get the column names and local parameters for this table."