瀏覽代碼

Tables: Allow #+TBLFM to be indented

Carsten Dominik 16 年之前
父節點
當前提交
19748886eb
共有 7 個文件被更改,包括 38 次插入13 次删除
  1. 22 0
      lisp/ChangeLog
  2. 1 1
      lisp/org-clock.el
  3. 1 1
      lisp/org-colview-xemacs.el
  4. 1 1
      lisp/org-colview.el
  5. 1 1
      lisp/org-footnote.el
  6. 8 7
      lisp/org-table.el
  7. 4 2
      lisp/org.el

+ 22 - 0
lisp/ChangeLog

@@ -1,3 +1,25 @@
+2009-05-27  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org-table.el (org-table-store-formulas)
+	(org-table-get-stored-formulas, org-table-fix-formulas)
+	(org-table-edit-formulas, orgtbl-ctrl-c-ctrl-c)
+	(orgtbl-gather-send-defs): Allow indented #+TBLFM line.
+
+	* org.el (org-fontify-meta-lines, org-ctrl-c-ctrl-c): Allow
+	indented #+TBLFM line.
+
+	* org-footnote.el (org-footnote-goto-local-insertion-point): Allow
+	indented #+TBLFM line.
+
+	* org-colview.el (org-dblock-write:columnview): Allow indented
+	#+TBLFM line.
+
+	* org-colview-xemacs.el (org-dblock-write:columnview): Allow
+	indented #+TBLFM line.
+
+	* org-clock.el (org-dblock-write:clocktable): Allow indented
+	#+TBLFM line.
+
 2009-05-26  Carsten Dominik  <carsten.dominik@gmail.com>
 
 	* org-exp.el (org-export-format-source-code-or-example): Make

+ 1 - 1
lisp/org-clock.el

@@ -1183,7 +1183,7 @@ the currently selected interval size."
 	       (t (error "invalid formula in clocktable")))
 	    ;; Should we rescue an old formula?
 	    (when (stringp (setq content (plist-get params :content)))
-	      (when (string-match "^\\(#\\+TBLFM:.*\\)" content)
+	      (when (string-match "^\\([ \t]*#\\+TBLFM:.*\\)" content)
 		(setq recalc t)
 		(insert "\n" (match-string 1 (plist-get params :content)))
 		(beginning-of-line 0))))

+ 1 - 1
lisp/org-colview-xemacs.el

@@ -1407,7 +1407,7 @@ PARAMS is a property list of parameters:
       (while (setq line (pop content-lines))
 	(when (string-match "^#" line)
 	  (insert "\n" line)
-	  (when (string-match "^#\\+TBLFM" line)
+	  (when (string-match "^[ \t]*#\\+TBLFM" line)
 	    (setq recalc t))))
       (if recalc
 	  (progn (goto-char pos) (org-table-recalculate 'all))

+ 1 - 1
lisp/org-colview.el

@@ -1191,7 +1191,7 @@ PARAMS is a property list of parameters:
       (while (setq line (pop content-lines))
 	(when (string-match "^#" line)
 	  (insert "\n" line)
-	  (when (string-match "^#\\+TBLFM" line)
+	  (when (string-match "^[ \t]*#\\+TBLFM" line)
 	    (setq recalc t))))
       (if recalc
 	  (progn (goto-char pos) (org-table-recalculate 'all))

+ 1 - 1
lisp/org-footnote.el

@@ -457,7 +457,7 @@ ENTRY is (fn-label num-mark definition)."
   (beginning-of-line 0)
   (while (and (not (bobp)) (= (char-after) ?#))
     (beginning-of-line 0))
-  (if (looking-at "#\\+TBLFM:") (beginning-of-line 2))
+  (if (looking-at "[ \t]*#\\+TBLFM:") (beginning-of-line 2))
   (end-of-line 1)
   (skip-chars-backward "\n\r\t "))
 

+ 8 - 7
lisp/org-table.el

@@ -1813,11 +1813,12 @@ When NAMED is non-nil, look for a named equation."
   (setq alist (sort alist 'org-table-formula-less-p))
   (save-excursion
     (goto-char (org-table-end))
-    (if (looking-at "\\([ \t]*\n\\)*#\\+TBLFM:\\(.*\n?\\)")
+    (if (looking-at "\\([ \t]*\n\\)*[ \t]*#\\+TBLFM:\\(.*\n?\\)")
 	(progn
 	  ;; don't overwrite TBLFM, we might use text properties to store stuff
 	  (goto-char (match-beginning 2))
 	  (delete-region (match-beginning 2) (match-end 0)))
+      (org-indent-line-function)
       (insert "#+TBLFM:"))
     (insert " "
 	    (mapconcat (lambda (x)
@@ -1846,7 +1847,7 @@ When NAMED is non-nil, look for a named equation."
   (let (scol eq eq-alist strings string seen)
     (save-excursion
       (goto-char (org-table-end))
-      (when (looking-at "\\([ \t]*\n\\)*#\\+TBLFM: *\\(.*\\)")
+      (when (looking-at "\\([ \t]*\n\\)*[ \t]*#\\+TBLFM: *\\(.*\\)")
 	(setq strings (org-split-string (match-string 2) " *:: *"))
 	(while (setq string (pop strings))
 	  (when (string-match "\\`\\(@[0-9]+\\$[0-9]+\\|\\$\\([a-zA-Z0-9]+\\)\\) *= *\\(.*[^ \t]\\)" string)
@@ -1871,7 +1872,7 @@ 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))
-    (when (looking-at "#\\+TBLFM:")
+    (when (looking-at "[ \t]*#\\+TBLFM:")
       (let ((re (concat key "\\([0-9]+\\)"))
 	    (re2
 	     (when remove
@@ -2658,7 +2659,7 @@ Parameters get priority."
 (defun org-table-edit-formulas ()
   "Edit the formulas of the current table in a separate buffer."
   (interactive)
-  (when (save-excursion (beginning-of-line 1) (looking-at "#\\+TBLFM"))
+  (when (save-excursion (beginning-of-line 1) (looking-at "[ \t]*#\\+TBLFM"))
     (beginning-of-line 0))
   (unless (org-at-table-p) (error "Not at a table"))
   (org-table-get-specials)
@@ -3537,9 +3538,9 @@ With prefix arg, also recompute table."
   (let ((pos (point)) action)
     (save-excursion
       (beginning-of-line 1)
-      (setq action (cond ((looking-at "#\\+ORGTBL:.*\n[ \t]*|") (match-end 0))
+      (setq action (cond ((looking-at "[ \t]*#\\+ORGTBL:.*\n[ \t]*|") (match-end 0))
 			 ((looking-at "[ \t]*|") pos)
-			 ((looking-at "#\\+TBLFM:") 'recalc))))
+			 ((looking-at "[ \t]*#\\+TBLFM:") 'recalc))))
     (cond
      ((integerp action)
       (goto-char action)
@@ -3665,7 +3666,7 @@ a radio table."
     (goto-char (org-table-begin))
     (let (rtn)
       (beginning-of-line 0)
-      (while (looking-at "#\\+ORGTBL[: \t][ \t]*SEND +\\([a-zA-Z0-9_]+\\) +\\([^ \t\r\n]+\\)\\( +.*\\)?")
+      (while (looking-at "[ \t]*#\\+ORGTBL[: \t][ \t]*SEND +\\([a-zA-Z0-9_]+\\) +\\([^ \t\r\n]+\\)\\( +.*\\)?")
 	(let ((name (org-no-properties (match-string 1)))
 	      (transform (intern (match-string 2)))
 	      (params (if (match-end 3)

+ 4 - 2
lisp/org.el

@@ -4245,7 +4245,7 @@ will be prompted for."
 	     beg (match-end 0)
 	     '(font-lock-fontified t face org-meta-line))
 	    t)
-	   ((or (member dc1 '("caption:" "label:"))
+	   ((or (member dc1 '("caption:" "label:" "orgtbl:" "tblfm:"))
 		(and (match-end 4) (equal dc3 "attr")))
 	    (add-text-properties
 	     beg (match-end 0)
@@ -14803,7 +14803,9 @@ This command does many different things, depending on context:
       ;; Dynamic block
       (beginning-of-line 1)
       (save-excursion (org-update-dblock)))
-     ((save-excursion (beginning-of-line 1) (looking-at "#\\+\\([A-Z]+\\)"))
+     ((save-excursion
+	(beginning-of-line 1)
+	(looking-at "[ \t]*#\\+\\([A-Z]+\\)"))
       (cond
        ((equal (match-string 1) "TBLFM")
 	;; Recalculate the table before this line