Fix some tests
* testing/lisp/test-org.el (test-org/comment-dwim): Fix tests
This commit is contained in:
parent
b4b2809eb1
commit
12ea0f08f4
|
@ -90,86 +90,81 @@
|
||||||
(should
|
(should
|
||||||
(equal "# \nComment"
|
(equal "# \nComment"
|
||||||
(org-test-with-temp-text "Comment"
|
(org-test-with-temp-text "Comment"
|
||||||
(progn (call-interactively 'comment-dwim)
|
(call-interactively #'org-comment-dwim)
|
||||||
(buffer-string)))))
|
(buffer-string))))
|
||||||
;; No region selected, no comment on current line and line empty:
|
;; No region selected, no comment on current line and line empty:
|
||||||
;; insert comment on this line.
|
;; insert comment on this line.
|
||||||
(should
|
(should
|
||||||
(equal "# \nParagraph"
|
(equal "# \nParagraph"
|
||||||
(org-test-with-temp-text "\nParagraph"
|
(org-test-with-temp-text "\nParagraph"
|
||||||
(progn (call-interactively 'comment-dwim)
|
(call-interactively #'org-comment-dwim)
|
||||||
(buffer-string)))))
|
(buffer-string))))
|
||||||
;; No region selected, and a comment on this line: indent it.
|
;; No region selected, and a comment on this line: indent it.
|
||||||
(should
|
(should
|
||||||
(equal "* Headline\n # Comment"
|
(equal "* Headline\n # Comment"
|
||||||
(org-test-with-temp-text "* Headline\n# Comment"
|
(org-test-with-temp-text "* Headline\n# <point>Comment"
|
||||||
(progn (forward-line)
|
|
||||||
(let ((org-adapt-indentation t))
|
(let ((org-adapt-indentation t))
|
||||||
(call-interactively 'comment-dwim))
|
(call-interactively #'org-comment-dwim))
|
||||||
(buffer-string)))))
|
(buffer-string))))
|
||||||
;; Also recognize single # at column 0 as comments.
|
;; Also recognize single # at column 0 as comments.
|
||||||
(should
|
(should
|
||||||
(equal "# Comment"
|
(equal "# Comment"
|
||||||
(org-test-with-temp-text "# Comment"
|
(org-test-with-temp-text "# Comment"
|
||||||
(progn (forward-line)
|
(call-interactively #'org-comment-dwim)
|
||||||
(call-interactively 'comment-dwim)
|
(buffer-string))))
|
||||||
(buffer-string)))))
|
|
||||||
;; Region selected and only comments and blank lines within it:
|
;; Region selected and only comments and blank lines within it:
|
||||||
;; un-comment all commented lines.
|
;; un-comment all commented lines.
|
||||||
(should
|
(should
|
||||||
(equal "Comment 1\n\nComment 2"
|
(equal "Comment 1\n\nComment 2"
|
||||||
(org-test-with-temp-text "# Comment 1\n\n# Comment 2"
|
(org-test-with-temp-text "# Comment 1\n\n# Comment 2"
|
||||||
(progn
|
|
||||||
(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)
|
(call-interactively #'org-comment-dwim)
|
||||||
(buffer-string)))))
|
(buffer-string))))
|
||||||
;; Region selected without comments: comment all lines if
|
;; Region selected without comments: comment all lines if
|
||||||
;; `comment-empty-lines' is non-nil, only non-blank lines otherwise.
|
;; `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"
|
||||||
(progn
|
|
||||||
(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))
|
||||||
(let ((comment-empty-lines nil))
|
(let ((comment-empty-lines nil))
|
||||||
(call-interactively 'comment-dwim))
|
(call-interactively #'org-comment-dwim))
|
||||||
(buffer-string)))))
|
(buffer-string))))
|
||||||
(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"
|
||||||
(progn
|
|
||||||
(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))
|
||||||
(let ((comment-empty-lines t))
|
(let ((comment-empty-lines t))
|
||||||
(call-interactively 'comment-dwim))
|
(call-interactively #'org-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
|
||||||
(equal "# \n#+KEYWORD: value"
|
(equal "# \n#+KEYWORD: value"
|
||||||
(org-test-with-temp-text "#+KEYWORD: value"
|
(org-test-with-temp-text "#+KEYWORD: value"
|
||||||
(progn (call-interactively 'comment-dwim)
|
(call-interactively #'org-comment-dwim)
|
||||||
(buffer-string)))))
|
(buffer-string))))
|
||||||
;; In a source block, use appropriate syntax.
|
;; In a source block, use appropriate syntax.
|
||||||
(should
|
(should
|
||||||
(equal " ;; "
|
(equal " ;; "
|
||||||
(org-test-with-temp-text "#+BEGIN_SRC emacs-lisp\n\n#+END_SRC"
|
(org-test-with-temp-text "#+BEGIN_SRC emacs-lisp\n<point>\n#+END_SRC"
|
||||||
(forward-line)
|
|
||||||
(let ((org-edit-src-content-indentation 2))
|
(let ((org-edit-src-content-indentation 2))
|
||||||
(call-interactively 'comment-dwim))
|
(call-interactively #'org-comment-dwim))
|
||||||
(buffer-substring-no-properties (line-beginning-position) (point)))))
|
(buffer-substring-no-properties (line-beginning-position)
|
||||||
|
(point)))))
|
||||||
(should
|
(should
|
||||||
(equal "#+BEGIN_SRC emacs-lisp\n ;; a\n ;; b\n#+END_SRC"
|
(equal "#+BEGIN_SRC emacs-lisp\n ;; a\n ;; b\n#+END_SRC"
|
||||||
(org-test-with-temp-text "#+BEGIN_SRC emacs-lisp\na\nb\n#+END_SRC"
|
(org-test-with-temp-text
|
||||||
(forward-line)
|
"#+BEGIN_SRC emacs-lisp\n<point>a\nb\n#+END_SRC"
|
||||||
(transient-mark-mode 1)
|
(transient-mark-mode 1)
|
||||||
(push-mark (point) t t)
|
(push-mark (point) t t)
|
||||||
(forward-line 2)
|
(forward-line 2)
|
||||||
(let ((org-edit-src-content-indentation 2))
|
(let ((org-edit-src-content-indentation 2))
|
||||||
(call-interactively 'comment-dwim))
|
(call-interactively #'org-comment-dwim))
|
||||||
(buffer-string)))))
|
(buffer-string)))))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue