diff options
author | Nicolas Goaziou <n.goaziou@gmail.com> | 2012-08-24 12:55:25 +0200 |
---|---|---|
committer | Nicolas Goaziou <n.goaziou@gmail.com> | 2012-08-24 12:58:43 +0200 |
commit | 8a97c601a14fd8358a5c1e90a1ffbeb9dc6a2e72 (patch) | |
tree | 1f3216eae4db3b044f825d8bbe99dee53ab327ff | |
parent | b1223be34d183229db3f5b0625b459a2783d9ef5 (diff) | |
download | org-mode-8a97c601a14fd8358a5c1e90a1ffbeb9dc6a2e72.tar.gz |
Do not fill verse blocks contents
* lisp/org.el (org-fill-context-prefix, org-fill-paragraph): Do not
fill verse blocks contents. Verse blocks can be used to format
free-form poetry, so filling has to be done manually.
* testing/lisp/test-org.el: Remove unnecessary tests.
-rw-r--r-- | lisp/org.el | 39 | ||||
-rw-r--r-- | testing/lisp/test-org.el | 15 |
2 files changed, 14 insertions, 40 deletions
diff --git a/lisp/org.el b/lisp/org.el index d03e913..a71b3e2 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -21055,7 +21055,7 @@ meant to be filled." ? )) ((looking-at "\\s-+") (match-string 0)) (t "")))) - ((comment-block verse-block) + (comment-block ;; Only fill contents if P is within block boundaries. (let* ((cbeg (save-excursion (goto-char post-affiliated) (forward-line) @@ -21074,8 +21074,8 @@ meant to be filled." "Fill element at point, when applicable. This function only applies to comment blocks, comments, example -blocks, paragraphs and verse blocks. Also, as a special case, -re-align table when point is at one. +blocks and paragraphs. Also, as a special case, re-align table +when point is at one. If JUSTIFY is non-nil (interactively, with prefix argument), justify as well. If `sentence-end-double-space' is non-nil, then @@ -21114,41 +21114,24 @@ a footnote definition, try to fill the first paragraph within." (org-table-align)) t) ;; Elements that may contain `line-break' type objects. - ((paragraph verse-block) + (paragraph (let ((beg (max (point-min) (org-element-property :contents-begin element))) (end (min (point-max) (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) - (and (eq type 'verse-block) (>= (point) end))) - t - ;; In verse blocks and `message-mode', boundaries of - ;; region to fill have to be tweaked. - (cond - ;; At a verse block, fill current "paragraph", that - ;; is part of text separated by blank lines. - ((eq type 'verse-block) - (save-excursion - (when (looking-at "[ \t]*$") - (skip-chars-backward " \r\t\n" beg)) - (when (re-search-backward "^[ \t]*$" beg t) - (forward-line) - (setq beg (point)))) - (when (save-excursion (re-search-forward "^[ \t]*$" end t)) - (setq end (match-beginning 0)))) - ;; In `message-mode', do not fill following citation - ;; in current paragraph nor text before message - ;; body. - ((derived-mode-p 'message-mode) + ;; Do nothing if point is at an affiliated keyword. + (if (< (point) beg) t + (when (derived-mode-p 'message-mode) + ;; In `message-mode', do not fill following + ;; citation in current paragraph nor text before + ;; message body. (let ((body-start (save-excursion (message-goto-body)))) (when body-start (setq beg (max body-start beg)))) (when (save-excursion (re-search-forward (concat "^" message-cite-prefix-regexp) end t)) - (setq end (match-beginning 0))))) + (setq end (match-beginning 0)))) ;; Fill paragraph, taking line breaks into consideration. ;; For that, slice the paragraph using line breaks as ;; separators, and fill the parts in reverse order to diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 09bf328..a289cbf 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -182,15 +182,6 @@ http://article.gmane.org/gmane.emacs.orgmode/21459/" (let ((fill-column 20)) (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. - (org-test-with-temp-text "#+BEGIN_VERSE\nSome \\\\\nlong\ntext\n#+END_VERSE" - (forward-line) - (let ((fill-column 20)) - (org-fill-paragraph) - (should (equal (buffer-string) - "#+BEGIN_VERSE\nSome \\\\\nlong text\n#+END_VERSE")))) (org-test-with-temp-text "#+BEGIN_VERSE\nSome \\\\\nlong\ntext\n#+END_VERSE" (let ((fill-column 20)) (org-fill-paragraph) @@ -244,10 +235,10 @@ http://article.gmane.org/gmane.emacs.orgmode/21459/" (end-of-line) (org-auto-fill-function) (buffer-string))))) - ;; Verse and comment block: auto fill contents. + ;; Comment block: auto fill contents. (should - (equal "#+BEGIN_VERSE\n12345\n7890\n#+END_VERSE" - (org-test-with-temp-text "#+BEGIN_VERSE\n12345 7890\n#+END_VERSE" + (equal "#+BEGIN_COMMENT\n12345\n7890\n#+END_COMMENT" + (org-test-with-temp-text "#+BEGIN_COMMENT\n12345 7890\n#+END_COMMENT" (let ((fill-column 5)) (forward-line) (end-of-line) |