emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] make org-comment-dwim comment headings if on a heading
@ 2017-11-20 21:14 Alex Branham
  2017-11-22 23:17 ` Nicolas Goaziou
  0 siblings, 1 reply; 6+ messages in thread
From: Alex Branham @ 2017-11-20 21:14 UTC (permalink / raw)
  To: Org-mode

[-- Attachment #1: Type: text/plain, Size: 1422 bytes --]

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 <branham@utexas.edu>
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




[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Make-org-comment-dwim-check-if-on-a-heading.patch --]
[-- Type: text/x-diff, Size: 1264 bytes --]

From 43fd460accf071e1c69df5fcbbcce0e4943563f2 Mon Sep 17 00:00:00 2001
From: Alex Branham <branham@utexas.edu>
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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-11-29 20:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-20 21:14 [PATCH] make org-comment-dwim comment headings if on a heading Alex Branham
2017-11-22 23:17 ` Nicolas Goaziou
2017-11-27  3:07   ` Alex Branham
2017-11-29 13:46     ` Nicolas Goaziou
2017-11-29 15:24       ` Alex Branham
2017-11-29 20:17         ` Nicolas Goaziou

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).