Make `org-comment-dwim' check if on a heading
* lisp/org.el (org-comment-dwim): If on a heading, comment the heading. * testing/lisp/test-org.el: Add test. TINYCHANGE
This commit is contained in:
parent
acfb1ca4b8
commit
ee7ead62aa
12
lisp/org.el
12
lisp/org.el
|
@ -22813,11 +22813,15 @@ strictly within a source block, use appropriate comment syntax."
|
||||||
(forward-line)))))))))
|
(forward-line)))))))))
|
||||||
|
|
||||||
(defun org-comment-dwim (_arg)
|
(defun org-comment-dwim (_arg)
|
||||||
"Call `comment-dwim' within a source edit buffer if needed."
|
"Call the comment command you mean.
|
||||||
|
Call `org-toggle-comment' if on a heading, otherwise call
|
||||||
|
`comment-dwim', within a source edit buffer if needed."
|
||||||
(interactive "*P")
|
(interactive "*P")
|
||||||
(if (org-in-src-block-p)
|
(cond ((org-at-heading-p)
|
||||||
(org-babel-do-in-edit-buffer (call-interactively 'comment-dwim))
|
(call-interactively #'org-toggle-comment))
|
||||||
(call-interactively 'comment-dwim)))
|
((org-in-src-block-p)
|
||||||
|
(org-babel-do-in-edit-buffer (call-interactively #'comment-dwim)))
|
||||||
|
(t (call-interactively #'comment-dwim))))
|
||||||
|
|
||||||
|
|
||||||
;;; Timestamps API
|
;;; Timestamps API
|
||||||
|
|
|
@ -148,6 +148,12 @@
|
||||||
(org-test-with-temp-text "#+KEYWORD: value"
|
(org-test-with-temp-text "#+KEYWORD: value"
|
||||||
(call-interactively #'org-comment-dwim)
|
(call-interactively #'org-comment-dwim)
|
||||||
(buffer-string))))
|
(buffer-string))))
|
||||||
|
;; Comment a heading
|
||||||
|
(should
|
||||||
|
(equal "* COMMENT Test"
|
||||||
|
(org-test-with-temp-text "* Test"
|
||||||
|
(call-interactively #'org-comment-dwim)
|
||||||
|
(buffer-string))))
|
||||||
;; In a source block, use appropriate syntax.
|
;; In a source block, use appropriate syntax.
|
||||||
(should
|
(should
|
||||||
(equal " ;; "
|
(equal " ;; "
|
||||||
|
|
Loading…
Reference in New Issue