From: Alex Branham <alex.branham@gmail.com>
To: Org-mode <emacs-orgmode@gnu.org>
Subject: [PATCH] make org-comment-dwim comment headings if on a heading
Date: Mon, 20 Nov 2017 15:14:54 -0600 [thread overview]
Message-ID: <87zi7godo1.fsf@gmail.com> (raw)
[-- 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
next reply other threads:[~2017-11-20 21:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-20 21:14 Alex Branham [this message]
2017-11-22 23:17 ` [PATCH] make org-comment-dwim comment headings if on a heading 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zi7godo1.fsf@gmail.com \
--to=alex.branham@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).