From 43fd460accf071e1c69df5fcbbcce0e4943563f2 Mon Sep 17 00:00:00 2001 From: Alex Branham Date: Mon, 20 Nov 2017 15:08:09 -0600 Subject: [PATCH] Make org-comment-dwim check if on a heading * lisp/org.el (org-comment-dwim): if on a heading, comment the heading --- lisp/org.el | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index f873f1021..81bc9278f 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -22817,11 +22817,16 @@ 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. + +Calls `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-on-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 -- 2.15.0