Browse Source

Fix bugs with TBLNAME

Francesco Pizzolante writes:

> I'm using orgmode 6.30c and I still have this problem: if
> the #+TBLNAME: tag is not located in column 0, the remote
> reference does not work.
>
> Here's my little test:
>
> #+TBLNAME: A
>    |   |     T |
>    |---+-------|
>    |   |  2.00 |
>    |   |  5.00 |
>    |---+-------|
>    | # |  9.00 |
>    | ^ | total |
>    #+TBLFM: $2=vsum(@-I..@-II);%.2f
>
>    #+TBLNAME: price
>       |    T |    PU | Total |
>       |------+-------+-------|
>       | 9.00 | 10.25 | 92.25 |
>       |------+-------+-------|
>    #+TBLFM: @2$1=remote(A,$total);%.2f::@2$3=$1*$2;%.2f
>
>
> Just add a few spaces at the first line and when you recompute
> the second table you get a "Can't find remote table A" message.
>
> Moreover, in a LaTeX environment, using the orgtbl minor mode,
> the highlighting (font locking) does not work on the #+TBLNAME:
> line, even if located in column 0.
Carsten Dominik 15 years ago
parent
commit
1530e0eafe
2 changed files with 8 additions and 2 deletions
  1. 5 0
      lisp/ChangeLog
  2. 3 2
      lisp/org-table.el

+ 5 - 0
lisp/ChangeLog

@@ -1,5 +1,10 @@
 2009-09-15  Carsten Dominik  <carsten.dominik@gmail.com>
 
+	* org-table.el (orgtbl-line-start-regexp): Match also TBLNAME
+	statements.
+	(org-table-get-remote-range): Match indented #+TBLNAME
+	statements.
+
 	* org.el (org-convert-to-odd-levels)
 	(org-convert-to-oddeven-levels): Work also correctly if the file
 	is in outline-mode.

+ 3 - 2
lisp/org-table.el

@@ -3343,7 +3343,8 @@ table editor in arbitrary modes.")
 (defvar org-old-auto-fill-inhibit-regexp nil
   "Local variable used by `orgtbl-mode'")
 
-(defconst orgtbl-line-start-regexp "[ \t]*\\(|\\|#\\+\\(TBLFM\\|ORGTBL\\):\\)"
+(defconst orgtbl-line-start-regexp
+  "[ \t]*\\(|\\|#\\+\\(TBLFM\\|ORGTBL\\|TBLNAME\\):\\)"
   "Matches a line belonging to an orgtbl.")
 
 (defconst orgtbl-extra-font-lock-keywords
@@ -4224,7 +4225,7 @@ list of the fields in the rectangle ."
 	  (save-excursion
 	    (goto-char (point-min))
 	    (if (re-search-forward
-		 (concat "^#[ \t]*\\+TBLNAME:[ \t]*" (regexp-quote name-or-id) "[ \t]*$")
+		 (concat "^[ \t]*#\\+TBLNAME:[ \t]*" (regexp-quote name-or-id) "[ \t]*$")
 		 nil t)
 		(setq buffer (current-buffer) loc (match-beginning 0))
 	      (setq id-loc (org-id-find name-or-id 'marker))