瀏覽代碼

Merge branch 'maint'

Bastien Guerry 12 年之前
父節點
當前提交
8b15ff9d07
共有 3 個文件被更改,包括 39 次插入40 次删除
  1. 6 10
      lisp/org-table.el
  2. 6 3
      lisp/org.el
  3. 27 27
      testing/lisp/test-org-table.el

+ 6 - 10
lisp/org-table.el

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

+ 6 - 3
lisp/org.el

@@ -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-justify-field-maybe "org-table" (&optional new))
 (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-find-id-file "org-id" (id))
 (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 " *<\\([^>]+\\)>")
 	    org-deadline-time-hour-regexp
 	    (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
 	    (concat "\\<\\(" org-deadline-string "\\).*")
 	    org-scheduled-regexp
@@ -5118,7 +5119,7 @@ Support for group tags is controlled by the option
 	    (concat "\\<" org-scheduled-string " *<\\([^>]+\\)>")
 	    org-scheduled-time-hour-regexp
 	    (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
 	    (concat "\\<" org-closed-string " *\\[\\([^]]+\\)\\]")
 	    org-keyword-time-regexp
@@ -20265,7 +20266,9 @@ This command does many different things, depending on context:
 		       (and (eq type 'table-row)
 			    (= (point) (org-element-property :end context))))
 		   (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))
 		       (org-call-with-arg 'org-table-recalculate (or arg t))
 		       (orgtbl-send-table 'maybe)))

+ 27 - 27
testing/lisp/test-org-table.el

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