diff options
author | Alex Branham <branham@utexas.edu> | 2017-11-29 14:41:12 +0100 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2017-11-29 14:41:12 +0100 |
commit | ee7ead62aa6b35675e663ecac4d9275409c9f6c7 (patch) | |
tree | fc9b7d3f0c4cb7132ff91b0d5cf46e2985b593c5 | |
parent | acfb1ca4b894ac0f800b409f821686f4a75bceb4 (diff) | |
download | org-mode-ee7ead62aa6b35675e663ecac4d9275409c9f6c7.tar.gz |
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
-rw-r--r-- | lisp/org.el | 12 | ||||
-rw-r--r-- | testing/lisp/test-org.el | 6 |
2 files changed, 14 insertions, 4 deletions
diff --git a/lisp/org.el b/lisp/org.el index 5bf79bc..fc45a98 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -22813,11 +22813,15 @@ strictly within a source block, use appropriate comment syntax." (forward-line))))))))) (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") - (if (org-in-src-block-p) - (org-babel-do-in-edit-buffer (call-interactively 'comment-dwim)) - (call-interactively 'comment-dwim))) + (cond ((org-at-heading-p) + (call-interactively #'org-toggle-comment)) + ((org-in-src-block-p) + (org-babel-do-in-edit-buffer (call-interactively #'comment-dwim))) + (t (call-interactively #'comment-dwim)))) ;;; Timestamps API diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index fb9ed2f..d5e7ba3 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -148,6 +148,12 @@ (org-test-with-temp-text "#+KEYWORD: value" (call-interactively #'org-comment-dwim) (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. (should (equal " ;; " |