From d228909d15b08878a967b3505171b218cfbd15f2 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Mon, 26 Nov 2018 19:50:08 +0100 Subject: [PATCH 1/2] org-element: Be more strict when looking for table.el tables * lisp/org-element.el (org-element--current-element): Increase number of checks to avoid more false positive. In particular "+-+" is not recognized anymore as a table.el table. --- lisp/org-element.el | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lisp/org-element.el b/lisp/org-element.el index cdb574e17..78b185197 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -3912,7 +3912,18 @@ element it has to parse." ((looking-at "%%(") (org-element-diary-sexp-parser limit affiliated)) ;; Table. - ((looking-at "[ \t]*\\(|\\|\\+\\(-+\\+\\)+[ \t]*$\\)") + ((or (looking-at "[ \t]*|") + ;; There is no strict definition of a table.el + ;; table. Try to prevent false positive while being + ;; quick. + (let ((rule-regexp "[ \t]*\\+\\(-+\\+\\)+[ \t]*$") + (next (line-beginning-position 2))) + (and (looking-at rule-regexp) + (save-excursion + (forward-line) + (re-search-forward "^[ \t]*\\($\\|[^|]\\)" limit t) + (and (> (line-beginning-position) next) + (org-match-line rule-regexp)))))) (org-element-table-parser limit affiliated)) ;; List. ((looking-at (org-item-re)) From 32a7305ddaca97334b380829f063ad95b0f59d3b Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Mon, 26 Nov 2018 19:51:51 +0100 Subject: [PATCH 2/2] Fix on table.el tables * lisp/org.el (org-return): Prevent wrong type error when on a table.el table. --- lisp/org.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index b78243c2c..ed766f9c6 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -20442,7 +20442,8 @@ object (e.g., within a comment). In these case, you need to use (cond ;; In a table, call `org-table-next-row'. However, before first ;; column or after last one, split the table. - ((or (and (eq (org-element-type context) 'table) + ((or (and (eq 'table (org-element-type context)) + (not (eq 'table.el (org-element-property :type context))) (>= (point) (org-element-property :contents-begin context)) (< (point) (org-element-property :contents-end context))) (org-element-lineage context '(table-row table-cell) t)) @@ -20468,9 +20469,8 @@ object (e.g., within a comment). In these case, you need to use (call-interactively #'org-open-at-point)) ;; Insert newline in heading, but preserve tags. ((and (not (bolp)) - (save-excursion (beginning-of-line) - (let ((case-fold-search nil)) - (looking-at org-complex-heading-regexp)))) + (let ((case-fold-search nil)) + (org-match-line org-complex-heading-regexp))) ;; At headline. Split line. However, if point is on keyword, ;; priority cookie or tags, do not break any of them: add ;; a newline after the headline instead.