emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: zhenjiang zech xu <zhenjiang.xu@gmail.com>
To: Bastien <bzg@gnu.org>
Cc: emacs-orgmode@gnu.org
Subject: Re: headlines without timestampes
Date: Thu, 29 May 2014 17:38:24 -0600	[thread overview]
Message-ID: <CAAp=d8rfZicO__sm4k=13B6vsd29Bo+kJNV2m=X0v-Yyawe5MA@mail.gmail.com> (raw)
In-Reply-To: <877g54zfk9.fsf@bzg.ath.cx>

[-- 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 --]

      reply	other threads:[~2014-05-29 23:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAAp=d8rfZicO__sm4k=13B6vsd29Bo+kJNV2m=X0v-Yyawe5MA@mail.gmail.com' \
    --to=zhenjiang.xu@gmail.com \
    --cc=bzg@gnu.org \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).