Merge branch 'master' of orgmode.org:org-mode
This commit is contained in:
commit
5700a0eb2d
170
lisp/org.el
170
lisp/org.el
|
@ -21763,94 +21763,88 @@ a footnote definition, try to fill the first paragraph within."
|
||||||
(cadadr (assoc 'paragraph-separate org-fb-vars))))
|
(cadadr (assoc 'paragraph-separate org-fb-vars))))
|
||||||
(fill-paragraph nil))
|
(fill-paragraph nil))
|
||||||
(with-syntax-table org-mode-transpose-word-syntax-table
|
(with-syntax-table org-mode-transpose-word-syntax-table
|
||||||
(save-excursion
|
;; Move to end of line in order to get the first paragraph
|
||||||
;; Move to end of line in order to get the first paragraph
|
;; within a plain list or a footnote definition.
|
||||||
;; within a plain list or a footnote definition.
|
(let ((element (save-excursion (end-of-line) (org-element-at-point))))
|
||||||
(end-of-line)
|
;; First check if point is in a blank line at the beginning of
|
||||||
(let ((element (org-element-at-point)))
|
;; the buffer. In that case, ignore filling.
|
||||||
;; First check if point is in a blank line at the beginning of
|
(case (org-element-type element)
|
||||||
;; the buffer. In that case, ignore filling.
|
;; Use major mode filling function is src blocks.
|
||||||
(if (< (point) (org-element-property :begin element)) t
|
(src-block (org-babel-do-key-sequence-in-edit-buffer (kbd "M-q")))
|
||||||
(case (org-element-type element)
|
;; Align Org tables, leave table.el tables as-is.
|
||||||
;; Use major mode filling function is src blocks.
|
(table-row (org-table-align) t)
|
||||||
(src-block (org-babel-do-key-sequence-in-edit-buffer (kbd "M-q")))
|
(table
|
||||||
;; Align Org tables, leave table.el tables as-is.
|
(when (eq (org-element-property :type element) 'org)
|
||||||
(table-row (org-table-align) t)
|
(org-table-align))
|
||||||
(table
|
t)
|
||||||
(when (eq (org-element-property :type element) 'org)
|
(paragraph
|
||||||
(org-table-align))
|
;; Paragraphs may contain `line-break' type objects.
|
||||||
t)
|
(let ((beg (max (point-min)
|
||||||
(paragraph
|
(org-element-property :contents-begin element)))
|
||||||
;; Paragraphs may contain `line-break' type objects.
|
(end (min (point-max)
|
||||||
(let ((beg (max (point-min)
|
(org-element-property :contents-end element))))
|
||||||
(org-element-property :contents-begin element)))
|
;; Do nothing if point is at an affiliated keyword.
|
||||||
(end (min (point-max)
|
(if (< (line-end-position) beg) t
|
||||||
(org-element-property :contents-end element))))
|
(when (derived-mode-p 'message-mode)
|
||||||
;; Do nothing if point is at an affiliated keyword.
|
;; In `message-mode', do not fill following citation
|
||||||
(if (< (point) beg) t
|
;; in current paragraph nor text before message body.
|
||||||
(when (derived-mode-p 'message-mode)
|
(let ((body-start (save-excursion (message-goto-body))))
|
||||||
;; In `message-mode', do not fill following
|
(when body-start (setq beg (max body-start beg))))
|
||||||
;; citation in current paragraph nor text before
|
(when (save-excursion
|
||||||
;; message body.
|
(re-search-forward
|
||||||
(let ((body-start (save-excursion (message-goto-body))))
|
(concat "^" message-cite-prefix-regexp) end t))
|
||||||
(when body-start (setq beg (max body-start beg))))
|
(setq end (match-beginning 0))))
|
||||||
(when (save-excursion
|
;; Fill paragraph, taking line breaks into account.
|
||||||
(re-search-forward
|
;; For that, slice the paragraph using line breaks as
|
||||||
(concat "^" message-cite-prefix-regexp) end t))
|
;; separators, and fill the parts in reverse order to
|
||||||
(setq end (match-beginning 0))))
|
;; avoid messing with markers.
|
||||||
;; Fill paragraph, taking line breaks into
|
(save-excursion
|
||||||
;; consideration. For that, slice the paragraph
|
(goto-char end)
|
||||||
;; using line breaks as separators, and fill the
|
(mapc
|
||||||
;; parts in reverse order to avoid messing with
|
(lambda (pos)
|
||||||
;; markers.
|
(fill-region-as-paragraph pos (point) justify)
|
||||||
(save-excursion
|
(goto-char pos))
|
||||||
(goto-char end)
|
;; Find the list of ending positions for line breaks
|
||||||
(mapc
|
;; in the current paragraph. Add paragraph
|
||||||
(lambda (pos)
|
;; beginning to include first slice.
|
||||||
(fill-region-as-paragraph pos (point) justify)
|
(nreverse
|
||||||
(goto-char pos))
|
(cons beg
|
||||||
;; Find the list of ending positions for line
|
(org-element-map
|
||||||
;; breaks in the current paragraph. Add paragraph
|
(org-element--parse-objects
|
||||||
;; beginning to include first slice.
|
beg end nil org-element-all-objects)
|
||||||
(nreverse
|
'line-break
|
||||||
(cons
|
(lambda (lb) (org-element-property :end lb)))))))
|
||||||
beg
|
t)))
|
||||||
(org-element-map
|
;; Contents of `comment-block' type elements should be
|
||||||
(org-element--parse-objects
|
;; filled as plain text, but only if point is within block
|
||||||
beg end nil org-element-all-objects)
|
;; markers.
|
||||||
'line-break
|
(comment-block
|
||||||
(lambda (lb) (org-element-property :end lb)))))))
|
(let* ((case-fold-search t)
|
||||||
t)))
|
(beg (save-excursion
|
||||||
;; Contents of `comment-block' type elements should be
|
(goto-char (org-element-property :begin element))
|
||||||
;; filled as plain text, but only if point is within block
|
(re-search-forward "^[ \t]*#\\+begin_comment" nil t)
|
||||||
;; markers.
|
(forward-line)
|
||||||
(comment-block
|
(point)))
|
||||||
(let* ((case-fold-search t)
|
(end (save-excursion
|
||||||
(beg (save-excursion
|
(goto-char (org-element-property :end element))
|
||||||
(goto-char (org-element-property :begin element))
|
(re-search-backward "^[ \t]*#\\+end_comment" nil t)
|
||||||
(re-search-forward "^[ \t]*#\\+begin_comment" nil t)
|
(line-beginning-position))))
|
||||||
(forward-line)
|
(when (and (>= (point) beg) (< (point) end))
|
||||||
(point)))
|
(fill-region-as-paragraph
|
||||||
(end (save-excursion
|
(save-excursion
|
||||||
(goto-char (org-element-property :end element))
|
(end-of-line)
|
||||||
(re-search-backward "^[ \t]*#\\+end_comment" nil t)
|
(re-search-backward "^[ \t]*$" beg 'move)
|
||||||
(line-beginning-position))))
|
(line-beginning-position))
|
||||||
(when (and (>= (point) beg) (< (point) end))
|
(save-excursion
|
||||||
(fill-region-as-paragraph
|
(beginning-of-line)
|
||||||
(save-excursion
|
(re-search-forward "^[ \t]*$" end 'move)
|
||||||
(end-of-line)
|
(line-beginning-position))
|
||||||
(re-search-backward "^[ \t]*$" beg 'move)
|
justify)))
|
||||||
(line-beginning-position))
|
t)
|
||||||
(save-excursion
|
;; Fill comments.
|
||||||
(beginning-of-line)
|
(comment (fill-comment-paragraph justify))
|
||||||
(re-search-forward "^[ \t]*$" end 'move)
|
;; Ignore every other element.
|
||||||
(line-beginning-position))
|
(otherwise t))))))
|
||||||
justify)))
|
|
||||||
t)
|
|
||||||
;; Fill comments.
|
|
||||||
(comment (fill-comment-paragraph justify))
|
|
||||||
;; Ignore every other element.
|
|
||||||
(otherwise t))))))))
|
|
||||||
|
|
||||||
(defun org-auto-fill-function ()
|
(defun org-auto-fill-function ()
|
||||||
"Auto-fill function."
|
"Auto-fill function."
|
||||||
|
|
|
@ -127,7 +127,8 @@
|
||||||
(lambda (a s v b)
|
(lambda (a s v b)
|
||||||
(org-ascii-export-to-ascii a s v b '(:ascii-charset utf-8))))))
|
(org-ascii-export-to-ascii a s v b '(:ascii-charset utf-8))))))
|
||||||
:filters-alist ((:filter-headline . org-ascii-filter-headline-blank-lines)
|
: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))
|
(:filter-section . org-ascii-filter-headline-blank-lines))
|
||||||
:options-alist ((:ascii-charset nil nil org-ascii-charset)))
|
: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
|
back-end used for export. INFO is a plist used as
|
||||||
a communication channel.
|
a communication channel.
|
||||||
|
|
||||||
This function only applies to `ascii' back-end. See
|
See `org-ascii-paragraph-spacing' for information."
|
||||||
`org-ascii-paragraph-spacing' for information."
|
|
||||||
(when (wholenump org-ascii-paragraph-spacing)
|
(when (wholenump org-ascii-paragraph-spacing)
|
||||||
(org-element-map tree 'paragraph
|
(org-element-map tree 'paragraph
|
||||||
(lambda (p)
|
(lambda (p)
|
||||||
|
@ -1802,6 +1802,18 @@ This function only applies to `ascii' back-end. See
|
||||||
p :post-blank org-ascii-paragraph-spacing)))))
|
p :post-blank org-ascii-paragraph-spacing)))))
|
||||||
tree)
|
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
|
;;; End-user functions
|
||||||
|
|
|
@ -196,7 +196,13 @@
|
||||||
(org-test-with-temp-text "#+NAME: para\nSome\ntext."
|
(org-test-with-temp-text "#+NAME: para\nSome\ntext."
|
||||||
(let ((fill-column 20))
|
(let ((fill-column 20))
|
||||||
(org-fill-paragraph)
|
(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 ()
|
(ert-deftest test-org/auto-fill-function ()
|
||||||
"Test auto-filling features."
|
"Test auto-filling features."
|
||||||
|
|
Loading…
Reference in New Issue