Merge branch 'maint'

This commit is contained in:
Nicolas Goaziou 2013-07-10 14:14:18 +02:00
commit 5074999605
2 changed files with 51 additions and 25 deletions

View File

@ -22316,34 +22316,41 @@ a footnote definition, try to fill the first paragraph within."
(goto-char (org-element-property :end element)) (goto-char (org-element-property :end element))
(re-search-backward "^[ \t]*#\\+end_comment" nil t) (re-search-backward "^[ \t]*#\\+end_comment" nil t)
(line-beginning-position)))) (line-beginning-position))))
(when (and (>= (point) beg) (< (point) end)) (if (or (< (point) beg) (> (point) end)) t
(fill-region-as-paragraph (fill-region-as-paragraph
(save-excursion (save-excursion (end-of-line)
(end-of-line) (re-search-backward "^[ \t]*$" beg 'move)
(re-search-backward "^[ \t]*$" beg 'move) (line-beginning-position))
(line-beginning-position)) (save-excursion (beginning-of-line)
(save-excursion (re-search-forward "^[ \t]*$" end 'move)
(beginning-of-line) (line-beginning-position))
(re-search-forward "^[ \t]*$" end 'move) justify))))
(line-beginning-position))
justify)))
t)
;; Fill comments. ;; Fill comments.
(comment (comment
(let ((begin (org-element-property :post-affiliated element)) (let ((begin (org-element-property :post-affiliated element))
(end (save-excursion (end (org-element-property :end element)))
(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.
(when (and (>= (point) begin) (<= (point) end)) (when (and (>= (point) begin) (<= (point) end))
(let ((fill-prefix (save-excursion (let ((begin (save-excursion
(beginning-of-line) (end-of-line)
(looking-at "[ \t]*#") (if (re-search-backward "^[ \t]*#[ \t]*$" begin t)
(concat (match-string 0) " ")))) (progn (forward-line) (point))
(save-excursion begin)))
(fill-region-as-paragraph begin end justify)))))) (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. ;; Ignore every other element.
(otherwise t)))))) (otherwise t))))))

View File

@ -69,7 +69,8 @@
(goto-char (point-max)) (goto-char (point-max))
(call-interactively 'comment-dwim) (call-interactively 'comment-dwim)
(buffer-string))))) (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 (should
(equal "# Comment 1\n\n# Comment 2" (equal "# Comment 1\n\n# Comment 2"
(org-test-with-temp-text "Comment 1\n\nComment 2" (org-test-with-temp-text "Comment 1\n\nComment 2"
@ -77,7 +78,18 @@
(transient-mark-mode 1) (transient-mark-mode 1)
(push-mark (point) t t) (push-mark (point) t t)
(goto-char (point-max)) (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))))) (buffer-string)))))
;; In front of a keyword without region, insert a new comment. ;; In front of a keyword without region, insert a new comment.
(should (should
@ -206,6 +218,13 @@
(let ((fill-column 20)) (let ((fill-column 20))
(org-fill-paragraph) (org-fill-paragraph)
(buffer-string))))) (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. ;; Do nothing at affiliated keywords.
(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))