emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Daniel Clemente <n142857@gmail.com>
To: emacs-orgmode list <emacs-orgmode@gnu.org>
Subject: Function to get the title of a heading
Date: Tue, 06 Jan 2009 19:53:20 +0100	[thread overview]
Message-ID: <871vvgs1un.fsf@gmail.com> (raw)


Hi,

  I want to get the title of some entry in Elisp. That is, from this heading:

*** TODO Do something!

  I want the "Do something!".


  I know no function to do this; although there is probably one. What I found is:

-  (org-entry-properties) returns the TODO keyword, the tags, and the category, but not the title.
-  (org-get-entry) has no useful documentation but it seems to return the content, not the heading.
-  (org-get-header HEADER) does something else related to mail; it seems to be unused and not much documented.
-  (org-get-heading t) seems to return the full line (even with keyword), but with properties:

#("TODO Do something!" 0 4
  (org-category "test1" fontified t face org-todo)
  4 18
  (org-category "test1" fontified t face org-level-3))


  Based on this, I did a function to remove the TODO keyword and the properties.

(defun org-get-heading-title ()
"Returns the heading of the current entry as a string, without the leading stars, the TODO keyword or the tags."
(let (
      (title-with-props (org-get-heading t))
      (keyword (org-get-todo-state))
      )
  (substring-no-properties title-with-props (if keyword (1+ (length keyword))))
  )
)

  Suggestions:
- This could also be implemented as a parameter to (org-get-heading).
- Or the title returned in (org-entry-properties)
- And (org-get-header HEADER) could be removed.
- In any case, such a function can be included in Org-mode so that it is easy to find.


  Thanks,
Daniel

             reply	other threads:[~2009-01-06 18:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-06 18:53 Daniel Clemente [this message]
2009-01-08 22:20 ` Carsten Dominik
2009-01-11 17:08   ` Daniel Clemente

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=871vvgs1un.fsf@gmail.com \
    --to=n142857@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --subject='Re: Function to get the title of a heading' \
    /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

Code repositories for project(s) associated with this 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).