From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: headlines without timestampes Date: Thu, 29 May 2014 18:59:34 +0200 Message-ID: <877g54zfk9.fsf@bzg.ath.cx> References: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:56160) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wq3gC-0004gb-8u for emacs-orgmode@gnu.org; Thu, 29 May 2014 12:59:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wq3g3-0001vJ-4g for emacs-orgmode@gnu.org; Thu, 29 May 2014 12:59:48 -0400 Received: from mail-wg0-x22d.google.com ([2a00:1450:400c:c00::22d]:60407) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wq3g2-0001ua-UJ for emacs-orgmode@gnu.org; Thu, 29 May 2014 12:59:39 -0400 Received: by mail-wg0-f45.google.com with SMTP id m15so700724wgh.28 for ; Thu, 29 May 2014 09:59:37 -0700 (PDT) In-Reply-To: (zhenjiang zech xu's message of "Thu, 29 May 2014 07:02:32 -0600") 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: zhenjiang zech xu Cc: emacs-orgmode@gnu.org Hi, zhenjiang zech xu writes: > For a simple example, assuming current entry is: > > * [2014-05-06 Thu] this is the heading >    blahblah... > > I'd like to get the time string and the title "this is the heading" > separately. Is there a canonical way to do that with org-mode APIs? This function returns a CONS with the timestamp and the rest of the heading: (defun get-timestamp-and-heading () (interactive) (save-excursion (org-back-to-heading t) (let* ((h (org-element-property :raw-value (org-element-at-point))) (h-no-ts (replace-regexp-in-string org-ts-regexp-both "" h)) (ts (and (string-match org-ts-regexp-both h) (match-string 0 h)))) (cons (org-trim h-no-ts) ts)))) HTH, -- Bastien