Merge branch 'maint'
This commit is contained in:
commit
5074999605
53
lisp/org.el
53
lisp/org.el
|
@ -22316,34 +22316,41 @@ a footnote definition, try to fill the first paragraph within."
|
|||
(goto-char (org-element-property :end element))
|
||||
(re-search-backward "^[ \t]*#\\+end_comment" nil t)
|
||||
(line-beginning-position))))
|
||||
(when (and (>= (point) beg) (< (point) end))
|
||||
(if (or (< (point) beg) (> (point) end)) t
|
||||
(fill-region-as-paragraph
|
||||
(save-excursion
|
||||
(end-of-line)
|
||||
(re-search-backward "^[ \t]*$" beg 'move)
|
||||
(line-beginning-position))
|
||||
(save-excursion
|
||||
(beginning-of-line)
|
||||
(re-search-forward "^[ \t]*$" end 'move)
|
||||
(line-beginning-position))
|
||||
justify)))
|
||||
t)
|
||||
(save-excursion (end-of-line)
|
||||
(re-search-backward "^[ \t]*$" beg 'move)
|
||||
(line-beginning-position))
|
||||
(save-excursion (beginning-of-line)
|
||||
(re-search-forward "^[ \t]*$" end 'move)
|
||||
(line-beginning-position))
|
||||
justify))))
|
||||
;; Fill comments.
|
||||
(comment
|
||||
(let ((begin (org-element-property :post-affiliated element))
|
||||
(end (save-excursion
|
||||
(goto-char (org-element-property :end element))
|
||||
(skip-chars-backward " \r\t\n")
|
||||
(line-end-position))))
|
||||
;; Do not fill comments when at a blank line or at
|
||||
;; affiliated keywords.
|
||||
(end (org-element-property :end element)))
|
||||
(when (and (>= (point) begin) (<= (point) end))
|
||||
(let ((fill-prefix (save-excursion
|
||||
(beginning-of-line)
|
||||
(looking-at "[ \t]*#")
|
||||
(concat (match-string 0) " "))))
|
||||
(save-excursion
|
||||
(fill-region-as-paragraph begin end justify))))))
|
||||
(let ((begin (save-excursion
|
||||
(end-of-line)
|
||||
(if (re-search-backward "^[ \t]*#[ \t]*$" begin t)
|
||||
(progn (forward-line) (point))
|
||||
begin)))
|
||||
(end (save-excursion
|
||||
(end-of-line)
|
||||
(if (re-search-forward "^[ \t]*#[ \t]*$" end 'move)
|
||||
(1- (line-beginning-position))
|
||||
(skip-chars-backward " \r\t\n")
|
||||
(line-end-position)))))
|
||||
;; Do not fill comments when at a blank line or at
|
||||
;; affiliated keywords.
|
||||
(let ((fill-prefix (save-excursion
|
||||
(beginning-of-line)
|
||||
(looking-at "[ \t]*#")
|
||||
(concat (match-string 0) " "))))
|
||||
(when (> end begin)
|
||||
(save-excursion
|
||||
(fill-region-as-paragraph begin end justify))))))
|
||||
t))
|
||||
;; Ignore every other element.
|
||||
(otherwise t))))))
|
||||
|
||||
|
|
|
@ -69,7 +69,8 @@
|
|||
(goto-char (point-max))
|
||||
(call-interactively 'comment-dwim)
|
||||
(buffer-string)))))
|
||||
;; Region selected without comments: comment all non-blank lines.
|
||||
;; Region selected without comments: comment all lines if
|
||||
;; `comment-empty-lines' is non-nil, only non-blank lines otherwise.
|
||||
(should
|
||||
(equal "# Comment 1\n\n# Comment 2"
|
||||
(org-test-with-temp-text "Comment 1\n\nComment 2"
|
||||
|
@ -77,7 +78,18 @@
|
|||
(transient-mark-mode 1)
|
||||
(push-mark (point) t t)
|
||||
(goto-char (point-max))
|
||||
(call-interactively 'comment-dwim)
|
||||
(let ((comment-empty-lines nil))
|
||||
(call-interactively 'comment-dwim))
|
||||
(buffer-string)))))
|
||||
(should
|
||||
(equal "# Comment 1\n# \n# Comment 2"
|
||||
(org-test-with-temp-text "Comment 1\n\nComment 2"
|
||||
(progn
|
||||
(transient-mark-mode 1)
|
||||
(push-mark (point) t t)
|
||||
(goto-char (point-max))
|
||||
(let ((comment-empty-lines t))
|
||||
(call-interactively 'comment-dwim))
|
||||
(buffer-string)))))
|
||||
;; In front of a keyword without region, insert a new comment.
|
||||
(should
|
||||
|
@ -206,6 +218,13 @@
|
|||
(let ((fill-column 20))
|
||||
(org-fill-paragraph)
|
||||
(buffer-string)))))
|
||||
;; Use commented empty lines as separators when filling comments.
|
||||
(should
|
||||
(equal "# A B\n#\n# C"
|
||||
(org-test-with-temp-text "# A\n# B\n#\n# C"
|
||||
(let ((fill-column 20))
|
||||
(org-fill-paragraph)
|
||||
(buffer-string)))))
|
||||
;; Do nothing at affiliated keywords.
|
||||
(org-test-with-temp-text "#+NAME: para\nSome\ntext."
|
||||
(let ((fill-column 20))
|
||||
|
|
Loading…
Reference in New Issue