1

I would like to extract just the plain name of an org heading:

I tried with (nth 4 (org-heading-components))

Example:

* Some Heading Title [0/1]              ;; cursor in this line when executing
** TODO Some Todo Item

-> result is "Some Heading Title [0/1]"

-> desired result would be "Some Heading Title"
2
  • 2
    I would send a bug report to the Org mode mailing list. I don't see any reason why the statistics cookie should be part of the title: it should be a separate component.
    – NickD
    May 1, 2022 at 13:48
  • 1
    Its on my TODO-list now :-) May 3, 2022 at 9:01

1 Answer 1

2
(replace-regexp-in-string
  " \\[[[:digit:]]*[/%][[:digit:]]*\\]" "" 
  (nth 4 (org-heading-components)))
2
  • 1
    There are two forms of statistics cookie, one like this [/] and one like this: [%], so you might want to generalize the regexp to catch them both. BTW, initially they might be empty skeletons without numbers until they are first evaluated, so you might want to take that into account too.
    – NickD
    May 1, 2022 at 13:58
  • Thanks @NickD, amended. May 1, 2022 at 15:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.