emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] [PATCH] make org-comment-dwim comment headings if on a heading


From: Alex Branham
Subject: [O] [PATCH] make org-comment-dwim comment headings if on a heading
Date: Mon, 20 Nov 2017 15:14:54 -0600
User-agent: mu4e 0.9.18; emacs 25.3.1

This patch changes the behavior of `org-comment-dwim' so that if point is on a 
heading, it will toggle the heading.

Alex

>From 655cd7afdfdf28797052952eae0c4e87cd86f445 Mon Sep 17 00:00:00 2001
From: Alex Branham <address@hidden>
Date: Mon, 20 Nov 2017 15:12:34 -0600
Subject: [PATCH] Make org-comment-dwim comment headings if point is at heading

* listp/org.el (org-comment-dwim): If point is on heading, call
  org-toggle-comment.
---
 lisp/org.el | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index f873f1021..25fa3a533 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-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
-- 
2.15.0



Attachment: 0001-Make-org-comment-dwim-check-if-on-a-heading.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]