{"id":10544,"date":"2022-05-21T13:33:29","date_gmt":"2022-05-21T17:33:29","guid":{"rendered":"https:\/\/irreal.org\/blog\/?p=10544"},"modified":"2022-05-21T13:33:29","modified_gmt":"2022-05-21T17:33:29","slug":"looping-through-org-headings","status":"publish","type":"post","link":"https:\/\/irreal.org\/blog\/?p=10544","title":{"rendered":"Looping Through Org Headings"},"content":{"rendered":"<p>I\u2019ve got several functions that do some sort of processing on Org files. Many of them were written years ago when I was just starting with Org-mode and as a result, they often take a naive approach to, say, locating Org top level headers. My typical solution was to do a regular expression search on something like <code>^\\\\*[ *]<\/code>.<\/p>\n<p>There are, of course, better ways and Kaushal Modi over at <a href=\"https:\/\/scripter.co\">A Scripter\u2019s Notes<\/a> shows us one of them. If you want to <a href=\"https:\/\/scripter.co\/looping-through-org-mode-headings\/?utm_source=atom_feed\">loop through all Org headers and do something to each entry<\/a>, Org has a function just for that, <code>org-map-entries<\/code>. This mapping function will loop through each Org entry and call a function (with no arguments) that can assume the point is at the beginning of the heading.<\/p>\n<p>You can filter the entries to look at by things such as tags, properties, or the level of the header. You can filter on the absence or presence of a tag or tags, or for any tags or properties satisfying a regular expression.<\/p>\n<p>Modi ends his post with an example of adding a property to each heading. The <code>org-map-entries<\/code> function is versatile and useful and makes dealing with Org files programmatically a bit easier. If you do any Elisp programming involving Org files, be sure to take a look at Modi\u2019s post.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I\u2019ve got several functions that do some sort of processing on Org files. Many of them were written years ago when I was just starting with Org-mode and as a result, they often take a naive approach to, say, locating &hellip; <a href=\"https:\/\/irreal.org\/blog\/?p=10544\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[18,77],"class_list":["post-10544","post","type-post","status-publish","format-standard","hentry","category-general","tag-emacs","tag-org"],"_links":{"self":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/10544","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10544"}],"version-history":[{"count":1,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/10544\/revisions"}],"predecessor-version":[{"id":10545,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/10544\/revisions\/10545"}],"wp:attachment":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10544"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10544"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10544"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}