Browse Source

org-element: Fix table and table.el mix

* lisp/org-element.el (org-element-table-parser): Properly parse an
  Org table followed by a line starting with a "+".

* testing/lisp/test-org-element.el (test-org-element/context): Fix
  test.
Nicolas Goaziou 9 years ago
parent
commit
106ca75307
2 changed files with 5 additions and 4 deletions
  1. 4 2
      lisp/org-element.el
  2. 1 2
      testing/lisp/test-org-element.el

+ 4 - 2
lisp/org-element.el

@@ -2493,9 +2493,11 @@ Assume point is at the beginning of the table."
     (let* ((case-fold-search t)
 	   (table-begin (point))
 	   (type (if (looking-at "[ \t]*|") 'org 'table.el))
+           (end-re (format "^[ \t]*\\($\\|[^| \t%s]\\)"
+			   (if (eq type 'org) "" "+")))
 	   (begin (car affiliated))
 	   (table-end
-	    (if (re-search-forward org-table-any-border-regexp limit 'm)
+	    (if (re-search-forward end-re limit 'move)
 		(goto-char (match-beginning 0))
 	      (point)))
 	   (tblfm (let (acc)
@@ -2560,7 +2562,7 @@ containing `:begin', `:end', `:contents-begin', `:contents-end',
 				(end-of-line)
 				(skip-chars-backward " \t")
 				(point))))
-	   (end (progn (forward-line) (point))))
+	   (end (line-beginning-position 2)))
       (list 'table-row
 	    (list :type type
 		  :begin begin

+ 1 - 2
testing/lisp/test-org-element.el

@@ -3330,8 +3330,7 @@ Text
   ;; Do not find objects in table rules.
   (should
    (eq 'table-row
-       (org-test-with-temp-text "| a | b |\n+---+---+\n| c | d |"
-	 (forward-line)
+       (org-test-with-temp-text "| a | b |\n|-<point>--|---|\n| c | d |"
 	 (org-element-type (org-element-context)))))
   ;; Find objects in parsed affiliated keywords.
   (should