summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2013-04-26 14:27:38 +0200
committerNicolas Goaziou <n.goaziou@gmail.com>2013-04-26 14:27:38 +0200
commit75c8be1d8b1fcafc88ac99702654dfe9a85d609e (patch)
treef1322631663a2d414350860bbbb3b8514ce0bcb9
parent73b7f3192c6a1ae5cd31636a3b1b22e036717fbb (diff)
downloadorg-mode-75c8be1d8b1fcafc88ac99702654dfe9a85d609e.tar.gz
Fix error when filling a table from an affiliated keyword
* lisp/org.el (org-fill-paragraph): Move to table beginning before aligning the table when M-q is called from an affiliated keyword. * testing/lisp/test-org.el: Add test.
-rw-r--r--lisp/org.el4
-rw-r--r--testing/lisp/test-org.el13
2 files changed, 13 insertions, 4 deletions
diff --git a/lisp/org.el b/lisp/org.el
index 126f9ee..48b4232 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -22188,7 +22188,9 @@ a footnote definition, try to fill the first paragraph within."
(table-row (org-table-align) t)
(table
(when (eq (org-element-property :type element) 'org)
- (org-table-align))
+ (save-excursion
+ (goto-char (org-element-property :post-affiliated element))
+ (org-table-align)))
t)
(paragraph
;; Paragraphs may contain `line-break' type objects.
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index 36f92d9..259dc04 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -124,9 +124,16 @@
(ert-deftest test-org/fill-paragraph ()
"Test `org-fill-paragraph' specifications."
;; At an Org table, align it.
- (org-test-with-temp-text "|a|"
- (org-fill-paragraph)
- (should (equal (buffer-string) "| a |\n")))
+ (should
+ (equal "| a |\n"
+ (org-test-with-temp-text "|a|"
+ (org-fill-paragraph)
+ (buffer-string))))
+ (should
+ (equal "#+name: table\n| a |\n"
+ (org-test-with-temp-text "#+name: table\n| a |"
+ (org-fill-paragraph)
+ (buffer-string))))
;; At a paragraph, preserve line breaks.
(org-test-with-temp-text "some \\\\\nlong\ntext"
(let ((fill-column 20))