Merge branch 'maint'

This commit is contained in:
Bastien Guerry 2013-05-15 16:31:54 +02:00
commit 8b15ff9d07
3 changed files with 39 additions and 40 deletions

View File

@ -52,7 +52,7 @@ This can be used to add additional functionality after the table is sent
to the receiver position, otherwise, if table is not sent, the functions to the receiver position, otherwise, if table is not sent, the functions
are not run.") are not run.")
(defvar org-TBLFM-begin-regexp "|\n[ \t]*#\\+TBLFM: ") (defvar org-table-TBLFM-begin-regexp "|\n[ \t]*#\\+TBLFM: ")
(defcustom orgtbl-optimized (eq org-enable-table-editor 'optimized) (defcustom orgtbl-optimized (eq org-enable-table-editor 'optimized)
"Non-nil means use the optimized table editor version for `orgtbl-mode'. "Non-nil means use the optimized table editor version for `orgtbl-mode'.
@ -3144,8 +3144,8 @@ with the prefix ARG."
(setq checksum c1))) (setq checksum c1)))
(user-error "No convergence after %d iterations" imax)))))) (user-error "No convergence after %d iterations" imax))))))
(defun org-calc-current-TBLFM (&optional arg) (defun org-table-calc-current-TBLFM (&optional arg)
"Apply the #+TBLFM in the line to the table." "Apply the #+TBLFM in the line at point to the table."
(interactive "P") (interactive "P")
(unless (org-at-TBLFM-p) (user-error "Not at a #+TBLFM line")) (unless (org-at-TBLFM-p) (user-error "Not at a #+TBLFM line"))
(let ((formula (buffer-substring (let ((formula (buffer-substring
@ -3154,33 +3154,29 @@ with the prefix ARG."
s e) s e)
(save-excursion (save-excursion
;; Insert a temporary formula at right after the table ;; Insert a temporary formula at right after the table
(goto-char (org-TBLFM-begin)) (goto-char (org-table-TBLFM-begin))
(setq s (set-marker (make-marker) (point))) (setq s (set-marker (make-marker) (point)))
(insert (concat formula "\n")) (insert (concat formula "\n"))
(setq e (set-marker (make-marker) (point))) (setq e (set-marker (make-marker) (point)))
;; Recalculate the table ;; Recalculate the table
(beginning-of-line 0) ; move to the inserted line (beginning-of-line 0) ; move to the inserted line
(skip-chars-backward " \r\n\t") (skip-chars-backward " \r\n\t")
(if (org-at-table-p) (if (org-at-table-p)
(unwind-protect (unwind-protect
(org-call-with-arg 'org-table-recalculate (or arg t)) (org-call-with-arg 'org-table-recalculate (or arg t))
;; delete the formula inserted temporarily ;; delete the formula inserted temporarily
(delete-region s e)))))) (delete-region s e))))))
(defun org-TBLFM-begin () (defun org-table-TBLFM-begin ()
"Find the beginning of the TBLFM lines and return its position. "Find the beginning of the TBLFM lines and return its position.
Return nil when the beginning of TBLFM line was not found." Return nil when the beginning of TBLFM line was not found."
(save-excursion (save-excursion
(when (progn (forward-line 1) (when (progn (forward-line 1)
(re-search-backward (re-search-backward
org-TBLFM-begin-regexp org-table-TBLFM-begin-regexp
nil t)) nil t))
(point-at-bol 2)))) (point-at-bol 2))))
(defun org-table-expand-lhs-ranges (equations) (defun org-table-expand-lhs-ranges (equations)
"Expand list of formulas. "Expand list of formulas.
If some of the RHS in the formulas are ranges or a row reference, expand If some of the RHS in the formulas are ranges or a row reference, expand

View File

@ -126,6 +126,7 @@ Stars are put in group 1 and the trimmed body in group 2.")
(declare-function org-table-edit-field "org-table" (arg)) (declare-function org-table-edit-field "org-table" (arg))
(declare-function org-table-justify-field-maybe "org-table" (&optional new)) (declare-function org-table-justify-field-maybe "org-table" (&optional new))
(declare-function org-table-set-constants "org-table" ()) (declare-function org-table-set-constants "org-table" ())
(declare-function org-table-calc-current-TBLFM "org-table" (&optional arg))
(declare-function org-id-get-create "org-id" (&optional force)) (declare-function org-id-get-create "org-id" (&optional force))
(declare-function org-id-find-id-file "org-id" (id)) (declare-function org-id-find-id-file "org-id" (id))
(declare-function org-tags-view "org-agenda" (&optional todo-only match)) (declare-function org-tags-view "org-agenda" (&optional todo-only match))
@ -5109,7 +5110,7 @@ Support for group tags is controlled by the option
(concat "\\<" org-deadline-string " *<\\([^>]+\\)>") (concat "\\<" org-deadline-string " *<\\([^>]+\\)>")
org-deadline-time-hour-regexp org-deadline-time-hour-regexp
(concat "\\<" org-deadline-string (concat "\\<" org-deadline-string
" *<\\(.+[0-9]\\{1,2\\}:[0-9]\\{2\\}[^>]*\\)>") " *<\\([^>]+[0-9]\\{1,2\\}:[0-9]\\{2\\}[0-9-+:hdwmy \t.]*\\)>")
org-deadline-line-regexp org-deadline-line-regexp
(concat "\\<\\(" org-deadline-string "\\).*") (concat "\\<\\(" org-deadline-string "\\).*")
org-scheduled-regexp org-scheduled-regexp
@ -5118,7 +5119,7 @@ Support for group tags is controlled by the option
(concat "\\<" org-scheduled-string " *<\\([^>]+\\)>") (concat "\\<" org-scheduled-string " *<\\([^>]+\\)>")
org-scheduled-time-hour-regexp org-scheduled-time-hour-regexp
(concat "\\<" org-scheduled-string (concat "\\<" org-scheduled-string
" *<\\(.+[0-9]\\{1,2\\}:[0-9]\\{2\\}[^>]*\\)>") " *<\\([^>]+[0-9]\\{1,2\\}:[0-9]\\{2\\}[0-9-+:hdwmy \t.]*\\)>")
org-closed-time-regexp org-closed-time-regexp
(concat "\\<" org-closed-string " *\\[\\([^]]+\\)\\]") (concat "\\<" org-closed-string " *\\[\\([^]]+\\)\\]")
org-keyword-time-regexp org-keyword-time-regexp
@ -20265,7 +20266,9 @@ This command does many different things, depending on context:
(and (eq type 'table-row) (and (eq type 'table-row)
(= (point) (org-element-property :end context)))) (= (point) (org-element-property :end context))))
(save-excursion (save-excursion
(if (org-at-TBLFM-p) (org-calc-current-TBLFM) (if (org-at-TBLFM-p)
(progn (require 'org-table)
(org-table-calc-current-TBLFM))
(goto-char (org-element-property :contents-begin context)) (goto-char (org-element-property :contents-begin context))
(org-call-with-arg 'org-table-recalculate (or arg t)) (org-call-with-arg 'org-table-recalculate (or arg t))
(orgtbl-send-table 'maybe))) (orgtbl-send-table 'maybe)))

View File

@ -808,7 +808,7 @@ reference (with row). Mode string N."
(forward-line 4) (forward-line 4)
(should (equal (org-at-TBLFM-p) nil)))) (should (equal (org-at-TBLFM-p) nil))))
(ert-deftest test-org-table/org-TBLFM-begin () (ert-deftest test-org-table/org-table-TBLFM-begin ()
(org-test-with-temp-text-in-file (org-test-with-temp-text-in-file
" "
| 1 | | 1 |
@ -817,27 +817,27 @@ reference (with row). Mode string N."
" "
(goto-char (point-min)) (goto-char (point-min))
(should (equal (org-TBLFM-begin) (should (equal (org-table-TBLFM-begin)
nil)) nil))
(goto-char (point-min)) (goto-char (point-min))
(forward-line 1) (forward-line 1)
(should (equal (org-TBLFM-begin) (should (equal (org-table-TBLFM-begin)
nil)) nil))
(goto-char (point-min)) (goto-char (point-min))
(forward-line 3) (forward-line 3)
(should (= (org-TBLFM-begin) (should (= (org-table-TBLFM-begin)
14)) 14))
(goto-char (point-min)) (goto-char (point-min))
(forward-line 4) (forward-line 4)
(should (= (org-TBLFM-begin) (should (= (org-table-TBLFM-begin)
14)) 14))
)) ))
(ert-deftest test-org-table/org-TBLFM-begin-for-multiple-TBLFM-lines () (ert-deftest test-org-table/org-table-TBLFM-begin-for-multiple-TBLFM-lines ()
"For multiple #+TBLFM lines." "For multiple #+TBLFM lines."
(org-test-with-temp-text-in-file (org-test-with-temp-text-in-file
" "
@ -848,32 +848,32 @@ reference (with row). Mode string N."
" "
(goto-char (point-min)) (goto-char (point-min))
(should (equal (org-TBLFM-begin) (should (equal (org-table-TBLFM-begin)
nil)) nil))
(goto-char (point-min)) (goto-char (point-min))
(forward-line 1) (forward-line 1)
(should (equal (org-TBLFM-begin) (should (equal (org-table-TBLFM-begin)
nil)) nil))
(goto-char (point-min)) (goto-char (point-min))
(forward-line 3) (forward-line 3)
(should (= (org-TBLFM-begin) (should (= (org-table-TBLFM-begin)
14)) 14))
(goto-char (point-min)) (goto-char (point-min))
(forward-line 4) (forward-line 4)
(should (= (org-TBLFM-begin) (should (= (org-table-TBLFM-begin)
14)) 14))
(goto-char (point-min)) (goto-char (point-min))
(forward-line 5) (forward-line 5)
(should (= (org-TBLFM-begin) (should (= (org-table-TBLFM-begin)
14)) 14))
)) ))
(ert-deftest test-org-table/org-TBLFM-begin-for-pultiple-TBLFM-lines-blocks () (ert-deftest test-org-table/org-table-TBLFM-begin-for-pultiple-TBLFM-lines-blocks ()
(org-test-with-temp-text-in-file (org-test-with-temp-text-in-file
" "
| 1 | | 1 |
@ -888,50 +888,50 @@ reference (with row). Mode string N."
" "
(goto-char (point-min)) (goto-char (point-min))
(should (equal (org-TBLFM-begin) (should (equal (org-table-TBLFM-begin)
nil)) nil))
(goto-char (point-min)) (goto-char (point-min))
(forward-line 1) (forward-line 1)
(should (equal (org-TBLFM-begin) (should (equal (org-table-TBLFM-begin)
nil)) nil))
(goto-char (point-min)) (goto-char (point-min))
(forward-line 3) (forward-line 3)
(should (= (org-TBLFM-begin) (should (= (org-table-TBLFM-begin)
14)) 14))
(goto-char (point-min)) (goto-char (point-min))
(forward-line 4) (forward-line 4)
(should (= (org-TBLFM-begin) (should (= (org-table-TBLFM-begin)
14)) 14))
(goto-char (point-min)) (goto-char (point-min))
(forward-line 5) (forward-line 5)
(should (= (org-TBLFM-begin) (should (= (org-table-TBLFM-begin)
14)) 14))
(goto-char (point-min)) (goto-char (point-min))
(forward-line 6) (forward-line 6)
(should (= (org-TBLFM-begin) (should (= (org-table-TBLFM-begin)
14)) 14))
(goto-char (point-min)) (goto-char (point-min))
(forward-line 8) (forward-line 8)
(should (= (org-TBLFM-begin) (should (= (org-table-TBLFM-begin)
61)) 61))
(goto-char (point-min)) (goto-char (point-min))
(forward-line 9) (forward-line 9)
(should (= (org-TBLFM-begin) (should (= (org-table-TBLFM-begin)
61)) 61))
(goto-char (point-min)) (goto-char (point-min))
(forward-line 10) (forward-line 10)
(should (= (org-TBLFM-begin) (should (= (org-table-TBLFM-begin)
61)))) 61))))
(ert-deftest test-org-table/org-calc-current-TBLFM () (ert-deftest test-org-table/org-table-calc-current-TBLFM ()
(org-test-with-temp-text-in-file (org-test-with-temp-text-in-file
" "
| 1 | | | 1 | |
@ -942,7 +942,7 @@ reference (with row). Mode string N."
" "
(let ((got (progn (goto-char (point-min)) (let ((got (progn (goto-char (point-min))
(forward-line 3) (forward-line 3)
(org-calc-current-TBLFM) (org-table-calc-current-TBLFM)
(buffer-string))) (buffer-string)))
(expect " (expect "
| 1 | 1 | | 1 | 1 |
@ -956,7 +956,7 @@ reference (with row). Mode string N."
(let ((got (progn (goto-char (point-min)) (let ((got (progn (goto-char (point-min))
(forward-line 4) (forward-line 4)
(org-calc-current-TBLFM) (org-table-calc-current-TBLFM)
(buffer-string))) (buffer-string)))
(expect " (expect "
| 1 | 2 | | 1 | 2 |
@ -968,8 +968,8 @@ reference (with row). Mode string N."
(should (string= got (should (string= got
expect))))) expect)))))
(ert-deftest test-org-table/org-calc-current-TBLFM-when-stop-because-of-error () (ert-deftest test-org-table/org-table-calc-current-TBLFM-when-stop-because-of-error ()
"org-calc-current-TBLFM should preserve the input as it was." "org-table-calc-current-TBLFM should preserve the input as it was."
(org-test-with-temp-text-in-file (org-test-with-temp-text-in-file
" "
| 1 | 1 | | 1 | 1 |
@ -987,7 +987,7 @@ reference (with row). Mode string N."
")) "))
(goto-char (point-min)) (goto-char (point-min))
(forward-line 4) (forward-line 4)
(should-error (org-calc-current-TBLFM)) (should-error (org-table-calc-current-TBLFM))
(setq got (buffer-string)) (setq got (buffer-string))
(message "%s" got) (message "%s" got)
(should (string= got (should (string= got