Merge branch 'master' of orgmode.org:org-mode

This commit is contained in:
Bastien Guerry 2013-02-25 10:15:49 +01:00
commit 5700a0eb2d
3 changed files with 104 additions and 92 deletions

View File

@ -21763,14 +21763,11 @@ a footnote definition, try to fill the first paragraph within."
(cadadr (assoc 'paragraph-separate org-fb-vars))))
(fill-paragraph nil))
(with-syntax-table org-mode-transpose-word-syntax-table
(save-excursion
;; Move to end of line in order to get the first paragraph
;; within a plain list or a footnote definition.
(end-of-line)
(let ((element (org-element-at-point)))
(let ((element (save-excursion (end-of-line) (org-element-at-point))))
;; First check if point is in a blank line at the beginning of
;; the buffer. In that case, ignore filling.
(if (< (point) (org-element-property :begin element)) t
(case (org-element-type element)
;; Use major mode filling function is src blocks.
(src-block (org-babel-do-key-sequence-in-edit-buffer (kbd "M-q")))
@ -21787,34 +21784,31 @@ a footnote definition, try to fill the first paragraph within."
(end (min (point-max)
(org-element-property :contents-end element))))
;; Do nothing if point is at an affiliated keyword.
(if (< (point) beg) t
(if (< (line-end-position) beg) t
(when (derived-mode-p 'message-mode)
;; In `message-mode', do not fill following
;; citation in current paragraph nor text before
;; message body.
;; 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))))
;; 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 avoid messing with
;; markers.
;; Fill paragraph, taking line breaks into account.
;; For that, slice the paragraph using line breaks as
;; separators, and fill the parts in reverse order to
;; avoid messing with markers.
(save-excursion
(goto-char end)
(mapc
(lambda (pos)
(fill-region-as-paragraph pos (point) justify)
(goto-char pos))
;; Find the list of ending positions for line
;; breaks in the current paragraph. Add paragraph
;; Find the list of ending positions for line breaks
;; in the current paragraph. Add paragraph
;; beginning to include first slice.
(nreverse
(cons
beg
(cons beg
(org-element-map
(org-element--parse-objects
beg end nil org-element-all-objects)
@ -21850,7 +21844,7 @@ a footnote definition, try to fill the first paragraph within."
;; Fill comments.
(comment (fill-comment-paragraph justify))
;; Ignore every other element.
(otherwise t))))))))
(otherwise t))))))
(defun org-auto-fill-function ()
"Auto-fill function."

View File

@ -127,7 +127,8 @@
(lambda (a s v b)
(org-ascii-export-to-ascii a s v b '(:ascii-charset utf-8))))))
:filters-alist ((:filter-headline . org-ascii-filter-headline-blank-lines)
(:filter-parse-tree . org-ascii-filter-paragraph-spacing)
(:filter-parse-tree org-ascii-filter-paragraph-spacing
org-ascii-filter-comment-spacing)
(:filter-section . org-ascii-filter-headline-blank-lines))
:options-alist ((:ascii-charset nil nil org-ascii-charset)))
@ -1791,8 +1792,7 @@ TREE is the parse tree. BACK-END is the symbol specifying
back-end used for export. INFO is a plist used as
a communication channel.
This function only applies to `ascii' back-end. See
`org-ascii-paragraph-spacing' for information."
See `org-ascii-paragraph-spacing' for information."
(when (wholenump org-ascii-paragraph-spacing)
(org-element-map tree 'paragraph
(lambda (p)
@ -1802,6 +1802,18 @@ This function only applies to `ascii' back-end. See
p :post-blank org-ascii-paragraph-spacing)))))
tree)
(defun org-ascii-filter-comment-spacing (tree backend info)
"Filter removing blank lines between comments.
TREE is the parse tree. BACK-END is the symbol specifying
back-end used for export. INFO is a plist used as
a communication channel."
(org-element-map tree '(comment comment-block)
(lambda (c)
(when (memq (org-element-type (org-export-get-next-element c info))
'(comment comment-block))
(org-element-put-property c :post-blank 0))))
tree)
;;; End-user functions

View File

@ -196,7 +196,13 @@
(org-test-with-temp-text "#+NAME: para\nSome\ntext."
(let ((fill-column 20))
(org-fill-paragraph)
(should (equal (buffer-string) "#+NAME: para\nSome\ntext.")))))
(should (equal (buffer-string) "#+NAME: para\nSome\ntext."))))
;; Do not move point after table when filling a table.
(should-not
(org-test-with-temp-text "| a | b |\n| c | d |\n"
(forward-char)
(org-fill-paragraph)
(eobp))))
(ert-deftest test-org/auto-fill-function ()
"Test auto-filling features."