summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Dominik <carsten.dominik@gmail.com>2009-05-27 18:14:33 +0200
committerCarsten Dominik <carsten.dominik@gmail.com>2009-05-28 17:44:12 +0200
commit19748886eb04a251d3c1afe69f28144015a3ce21 (patch)
tree1fdda84c232d40b4fc270b898985a7b8ad4ccb85
parent0c49456103a6daa8c0ea8dbb2fb8c3a8a0628274 (diff)
downloadorg-mode-19748886eb04a251d3c1afe69f28144015a3ce21.tar.gz
Tables: Allow #+TBLFM to be indented
-rwxr-xr-xlisp/ChangeLog22
-rw-r--r--lisp/org-clock.el2
-rw-r--r--lisp/org-colview-xemacs.el2
-rw-r--r--lisp/org-colview.el2
-rw-r--r--lisp/org-footnote.el2
-rw-r--r--lisp/org-table.el15
-rw-r--r--lisp/org.el6
7 files changed, 38 insertions, 13 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index e531074..86ac2fc 100755
--- a/lisp/ChangeLog
+++ b/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
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index e3af885..a6bd08d 100644
--- a/lisp/org-clock.el
+++ b/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))))
diff --git a/lisp/org-colview-xemacs.el b/lisp/org-colview-xemacs.el
index 118e61a..1bbdc82 100644
--- a/lisp/org-colview-xemacs.el
+++ b/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))
diff --git a/lisp/org-colview.el b/lisp/org-colview.el
index c8910f4..1434181 100644
--- a/lisp/org-colview.el
+++ b/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))
diff --git a/lisp/org-footnote.el b/lisp/org-footnote.el
index 9556a0d..f6c24ea 100644
--- a/lisp/org-footnote.el
+++ b/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 "))
diff --git a/lisp/org-table.el b/lisp/org-table.el
index 414e863..c52b394 100644
--- a/lisp/org-table.el
+++ b/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)
diff --git a/lisp/org.el b/lisp/org.el
index d36288a..b4eb95f 100644
--- a/lisp/org.el
+++ b/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