emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* headlines without timestampes
@ 2014-05-29 13:02 zhenjiang zech xu
  2014-05-29 16:59 ` Bastien
  0 siblings, 1 reply; 3+ messages in thread
From: zhenjiang zech xu @ 2014-05-29 13:02 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 392 bytes --]

Hi orgmoders,

I am wondering if there is function to dissect a heading into timestamps
(for all various forms) and true title of text?

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?

Thanks,
Zech

[-- Attachment #2: Type: text/html, Size: 654 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: headlines without timestampes
  2014-05-29 13:02 headlines without timestampes zhenjiang zech xu
@ 2014-05-29 16:59 ` Bastien
  2014-05-29 23:38   ` zhenjiang zech xu
  0 siblings, 1 reply; 3+ messages in thread
From: Bastien @ 2014-05-29 16:59 UTC (permalink / raw)
  To: zhenjiang zech xu; +Cc: emacs-orgmode

Hi,

zhenjiang zech xu <zhenjiang.xu@gmail.com> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: headlines without timestampes
  2014-05-29 16:59 ` Bastien
@ 2014-05-29 23:38   ` zhenjiang zech xu
  0 siblings, 0 replies; 3+ messages in thread
From: zhenjiang zech xu @ 2014-05-29 23:38 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 954 bytes --]

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


On Thu, May 29, 2014 at 10:59 AM, Bastien <bzg@gnu.org> wrote:

> Hi,
>
> zhenjiang zech xu <zhenjiang.xu@gmail.com> 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
>

[-- Attachment #2: Type: text/html, Size: 1552 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-05-29 23:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-29 13:02 headlines without timestampes zhenjiang zech xu
2014-05-29 16:59 ` Bastien
2014-05-29 23:38   ` zhenjiang zech xu

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).