summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2012-10-20 11:58:16 +0200
committerNicolas Goaziou <n.goaziou@gmail.com>2012-10-20 11:58:16 +0200
commit93040f46714f4b94ebbbd0ff8c3ccf58ae3437c5 (patch)
treefa25fdbb2a324fc92b3ee68fbc24fd63b02901fd
parent92199873c5796a31aecd573ee485bbb4accd5f28 (diff)
downloadorg-mode-93040f46714f4b94ebbbd0ff8c3ccf58ae3437c5.tar.gz
Fix auto filling in a paragraph directly following a comment
* lisp/org.el (org-auto-fill-function): Make sure `adaptive-fill-mode' mode is nil when pre-computed `fill-prefix' is the empty string. Otherwise filling functions from fill.el think it has to be computed again and overwrite it.
-rw-r--r--lisp/org.el5
-rw-r--r--testing/lisp/test-org.el16
2 files changed, 20 insertions, 1 deletions
diff --git a/lisp/org.el b/lisp/org.el
index 2442ab3..e700eb2 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -21065,7 +21065,10 @@ a footnote definition, try to fill the first paragraph within."
;; Check if auto-filling is meaningful.
(let ((fc (current-fill-column)))
(when (and fc (> (current-column) fc))
- (let ((fill-prefix (org-adaptive-fill-function)))
+ (let* ((fill-prefix (org-adaptive-fill-function))
+ ;; Enforce empty fill prefix, if required. Otherwise, it
+ ;; will be computed again.
+ (adaptive-fill-mode (not (equal fill-prefix ""))))
(when fill-prefix (do-auto-fill))))))
(defun org-comment-line-break-function (&optional soft)
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index d333cfc..fe4bc1c 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -254,6 +254,22 @@ http://article.gmane.org/gmane.emacs.orgmode/21459/"
(end-of-line)
(org-auto-fill-function)
(buffer-string)))))
+ ;; A hash within a line isn't a comment.
+ (should-not
+ (equal "12345 # 7890\n# 1"
+ (org-test-with-temp-text "12345 # 7890 1"
+ (let ((fill-column 12))
+ (end-of-line)
+ (org-auto-fill-function)
+ (buffer-string)))))
+ ;; Correctly interpret empty prefix.
+ (should-not
+ (equal "# a\n# b\nRegular\n# paragraph"
+ (org-test-with-temp-text "# a\n# b\nRegular paragraph"
+ (let ((fill-column 12))
+ (end-of-line 3)
+ (org-auto-fill-function)
+ (buffer-string)))))
;; Comment block: auto fill contents.
(should
(equal "#+BEGIN_COMMENT\n12345\n7890\n#+END_COMMENT"