diff options
author | Nicolas Goaziou <n.goaziou@gmail.com> | 2012-07-31 15:27:58 +0200 |
---|---|---|
committer | Nicolas Goaziou <n.goaziou@gmail.com> | 2012-07-31 15:42:30 +0200 |
commit | fcca4ab8e459b1d589ded4ddcb206ad6637600cd (patch) | |
tree | a045a92e7e0dc083fd8f0c4666624683baef7707 | |
parent | e3f30e12d27932d8330df1ca94657baa8097ed90 (diff) | |
download | org-mode-fcca4ab8e459b1d589ded4ddcb206ad6637600cd.tar.gz |
Fix filling when point is at the very end of a paragraph
* lisp/org.el (org-fill-paragraph): Fix filling when point is at the
very end of a paragraph.
* testing/lisp/test-org.el: Add test.
-rw-r--r-- | lisp/org.el | 9 | ||||
-rw-r--r-- | testing/lisp/test-org.el | 9 |
2 files changed, 15 insertions, 3 deletions
diff --git a/lisp/org.el b/lisp/org.el index 8936430..8b38854 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -20894,14 +20894,17 @@ width for filling." ;; Elements that may contain `line-break' type objects. ((paragraph verse-block) (let ((beg (org-element-property :contents-begin element)) - (end (org-element-property :contents-end element))) + (end (org-element-property :contents-end element)) + (type (org-element-type element))) ;; Do nothing if point is at an affiliated keyword or at ;; verse block markers. - (if (or (< (point) beg) (>= (point) end)) t + (if (or (< (point) beg) + (and (eq type 'verse-block) (>= (point) end))) + t ;; At a verse block, first narrow to current "paragraph" ;; and set current element to that paragraph. (save-restriction - (when (eq (org-element-type element) 'verse-block) + (when (eq type 'verse-block) (narrow-to-region beg end) (save-excursion (end-of-line) diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 5f08adf..9747491 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -143,6 +143,15 @@ http://article.gmane.org/gmane.emacs.orgmode/21459/" (let ((fill-column 20)) (org-fill-paragraph) (should (equal (buffer-string) "some \\\\\nlong text")))) + ;; Special case: fill correctly a paragraph when point is at its + ;; very end. + (should + (equal "A B" + (org-test-with-temp-text "A\nB" + (let ((fill-column 20)) + (goto-char (point-max)) + (org-fill-paragraph) + (buffer-string))))) ;; At a verse block, fill paragraph at point, also preserving line ;; breaks. Though, do nothing when point is at the block ;; boundaries. |