{"id":13396,"date":"2025-11-09T10:28:10","date_gmt":"2025-11-09T15:28:10","guid":{"rendered":"https:\/\/irreal.org\/blog\/?p=13396"},"modified":"2025-11-09T10:28:21","modified_gmt":"2025-11-09T15:28:21","slug":"org-tables-in-comments-and-docstrings","status":"publish","type":"post","link":"https:\/\/irreal.org\/blog\/?p=13396","title":{"rendered":"Org Tables In Comments And Docstrings"},"content":{"rendered":"<p>\nIf you&rsquo;ve been using Org-mode for a while, you&rsquo;re probably familiar with its table editing functionality and may even know that you can use that functionality anywhere in Emacs with <a href=\"https:\/\/orgmode.org\/manual\/Orgtbl-Mode.html\">orgtbl-mode<\/a>. For most non-Org applications, of course, those tables will be in some sort of comment.\n<\/p>\n<p>\nAndrew over at the <a href=\"https:\/\/flandrew.srht.site\">Listful Andrew site<\/a> has a <a href=\"https:\/\/flandrew.srht.site\/listful\/org-tables-in-comments-and-docstrings-in-emacs-lisp-and-bash.html\">useful post<\/a> on how to do that. It&rsquo;s a little more finicky than you might think because the editing won&rsquo;t work if the table lines are commented out. It&rsquo;s easy to work around that, of course, but Andrew offers some other strategies.\n<\/p>\n<p>\nWhen you&rsquo;re in Elisp, the easiest way to add a table to a comment is to add it do a Docstring. That&rsquo;s easy and the table can be edited at will. Andrew offer another method using his custom description macro. Most of us won&rsquo;t have that macro, of course, but it&rsquo;s another strategy.\n<\/p>\n<p>\nFinally, Andrew considers adding tables to Bash comments. The problems are similar to those encountered with Elisp: you can&rsquo;t edit tables whose rows are commented out. As with Elisp, that&rsquo;s easily worked around but again there are better ways.\n<\/p>\n<p>\nOne way is to use the null command <code>:<\/code> to introduce the comment string. See Andrew&rsquo;s post for the details. Another way is to use a here document or a here string. Again, see Andrew&rsquo;s post for the details.\n<\/p>\n<p>\nTables in comments isn&rsquo;t something that you need all the time but it&rsquo;s nice to have to ability to add them when you do. Andrew&rsquo;s post is a nice demonstration of how to do that.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you&rsquo;ve been using Org-mode for a while, you&rsquo;re probably familiar with its table editing functionality and may even know that you can use that functionality anywhere in Emacs with orgtbl-mode. For most non-Org applications, of course, those tables will &hellip; <a href=\"https:\/\/irreal.org\/blog\/?p=13396\">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],"class_list":["post-13396","post","type-post","status-publish","format-standard","hentry","category-general","tag-emacs"],"_links":{"self":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/13396","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=13396"}],"version-history":[{"count":1,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/13396\/revisions"}],"predecessor-version":[{"id":13397,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/13396\/revisions\/13397"}],"wp:attachment":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=13396"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=13396"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=13396"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}