emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] headlines without timestampes


From: zhenjiang zech xu
Subject: Re: [O] headlines without timestampes
Date: Thu, 29 May 2014 17:38:24 -0600

didn't know the regexp org-ts-regexp-*. Thanks!


On Thu, May 29, 2014 at 10:59 AM, Bastien <address@hidden> wrote:
Hi,

zhenjiang zech xu <address@hidden> 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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]