From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?ISO-8859-1?Q?Jan_B=F6cker?= Subject: Re: Re: Insert TODO or plain heading depending on context Date: Wed, 11 Aug 2010 00:07:51 +0200 Message-ID: <4C61CDB7.2040604@jboecker.de> References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Return-path: Received: from [140.186.70.92] (port=55006 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OiwzE-00054C-5O for emacs-orgmode@gnu.org; Tue, 10 Aug 2010 18:07:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OiwzD-0007L5-2G for emacs-orgmode@gnu.org; Tue, 10 Aug 2010 18:07:55 -0400 Received: from smtp01.worldserver.net ([217.13.200.36]:49248) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OiwzC-0007Kg-T4 for emacs-orgmode@gnu.org; Tue, 10 Aug 2010 18:07:55 -0400 In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Nathan Neff Cc: emacs-orgmode On 08/10/2010 11:41 PM, Nathan Neff wrote: > Is there a function in org-mode that returns the TODO > status of the heading that the cursor is currently in? > Yes, try "org-get-todo-state". (Found this using C-h f, typing "org", then using I-Search in the completion buffer.) This returns something like this: #("NEXT" 0 4 (fontified t org-category #("org-dev" 0 7 (fontified t face org-property-value org-category "projects")) face org-todo)) or nil if there is no TODO state. This syntax is new to me (elisp noob here), but the elisp reference told me it's just a string with text properties. The following code seems to accomplish your goal: (defun jb/smart-insert-heading () (if (org-get-todo-state) (call-interactively 'org-insert-todo-heading) (call-interactively 'org-insert-heading))) HTH, Jan