From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Branham Subject: [PATCH] make org-comment-dwim comment headings if on a heading Date: Mon, 20 Nov 2017 15:14:54 -0600 Message-ID: <87zi7godo1.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:56383) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGtPB-000160-OM for emacs-orgmode@gnu.org; Mon, 20 Nov 2017 16:15:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGtP7-000551-Oe for emacs-orgmode@gnu.org; Mon, 20 Nov 2017 16:15:01 -0500 Received: from mail-oi0-x232.google.com ([2607:f8b0:4003:c06::232]:43248) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eGtP7-00051R-Hj for emacs-orgmode@gnu.org; Mon, 20 Nov 2017 16:14:57 -0500 Received: by mail-oi0-x232.google.com with SMTP id h6so7107547oia.10 for ; Mon, 20 Nov 2017 13:14:57 -0800 (PST) Received: from earth (cpe-70-114-192-208.austin.res.rr.com. [70.114.192.208]) by smtp.gmail.com with ESMTPSA id a203sm4938468oib.47.2017.11.20.13.14.55 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Nov 2017 13:14:55 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Org-mode --=-=-= Content-Type: text/plain 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 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 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Make-org-comment-dwim-check-if-on-a-heading.patch >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 --=-=-=--