From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nathan Neff Subject: Re: Re: Insert TODO or plain heading depending on context Date: Tue, 10 Aug 2010 17:52:49 -0500 Message-ID: References: <4C61CDB7.2040604@jboecker.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: Received: from [140.186.70.92] (port=39213 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OixtQ-0004aa-36 for emacs-orgmode@gnu.org; Tue, 10 Aug 2010 19:06:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Oixgh-000540-5m for emacs-orgmode@gnu.org; Tue, 10 Aug 2010 18:52:52 -0400 Received: from mail-ww0-f49.google.com ([74.125.82.49]:57206) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oixgh-00053t-1Q for emacs-orgmode@gnu.org; Tue, 10 Aug 2010 18:52:51 -0400 Received: by wwi17 with SMTP id 17so556547wwi.30 for ; Tue, 10 Aug 2010 15:52:50 -0700 (PDT) In-Reply-To: <4C61CDB7.2040604@jboecker.de> 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: =?ISO-8859-1?Q?Jan_B=F6cker?= , emacs-orgmode On Tue, Aug 10, 2010 at 5:07 PM, Jan B=F6cker wro= te: > 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 () > =A0(if (org-get-todo-state) > =A0 =A0 =A0 =A0 =A0 (call-interactively 'org-insert-todo-heading) > =A0 =A0 =A0 =A0 (call-interactively 'org-insert-heading))) > > HTH, Jan > Thanks Jan, this helped a lot! I appreciate the C-h f reminder -- I have searched through org.el and didn't come up with the right search terms. This should help me in the future. BTW, your function works perfectly! Thanks, --Nate