Browse Source

Make @0 reference the last data line in a table.

The last data line in a table is often a line with important data, for
example sums of a column.  In tables with varying length, the row
number of this line is constantly changing, which makes it hard to
write programs creating tables and then installing formulas.

This patch introduces @0 as a special reference to the last row, so
that @0$3 would be the field in the last row, 3rd column.
Carsten Dominik 17 years ago
parent
commit
5ff646fc90
3 changed files with 9 additions and 2 deletions
  1. 2 1
      doc/org.texi
  2. 5 0
      lisp/ChangeLog
  3. 2 1
      lisp/org-table.el

+ 2 - 1
doc/org.texi

@@ -1781,7 +1781,8 @@ Org also uses another, more general operator that looks like this:
 
 
 @noindent
 @noindent
 Column references can be absolute like @samp{1}, @samp{2},...@samp{N},
 Column references can be absolute like @samp{1}, @samp{2},...@samp{N},
-or relative to the current column like @samp{+1} or @samp{-2}.
+or relative to the current column like @samp{+1} or @samp{-2}.  As a special
+case, @samp{@@0} references the last data line in the table.
 
 
 The row specification only counts data lines and ignores horizontal
 The row specification only counts data lines and ignores horizontal
 separator lines (hlines).  You can use absolute row numbers
 separator lines (hlines).  You can use absolute row numbers

+ 5 - 0
lisp/ChangeLog

@@ -1,3 +1,8 @@
+2008-12-12  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org-table.el (org-table-get-specials): Make @0 reference the
+	last line in a table.
+
 2008-12-11  Carsten Dominik  <carsten.dominik@gmail.com>
 2008-12-11  Carsten Dominik  <carsten.dominik@gmail.com>
 
 
 	* org.el (org-log-done): Fix docstring.
 	* org.el (org-log-done): Fix docstring.

+ 2 - 1
lisp/org-table.el

@@ -1897,7 +1897,8 @@ For all numbers larger than LIMIT, shift them by DELTA."
 	(beginning-of-line 2)
 	(beginning-of-line 2)
 	(setq l (1+ l)))
 	(setq l (1+ l)))
       (setq org-table-current-line-types (apply 'vector (nreverse types))
       (setq org-table-current-line-types (apply 'vector (nreverse types))
-	    org-table-dlines (apply 'vector (cons nil (nreverse dlines)))
+	    org-table-dlines (apply 'vector (cons (car dlines)
+						  (nreverse dlines)))
 	    org-table-hlines (apply 'vector (cons nil (nreverse hlines)))))))
 	    org-table-hlines (apply 'vector (cons nil (nreverse hlines)))))))
 
 
 (defun org-table-maybe-eval-formula ()
 (defun org-table-maybe-eval-formula ()