{"id":12218,"date":"2024-06-03T11:23:37","date_gmt":"2024-06-03T15:23:37","guid":{"rendered":"https:\/\/irreal.org\/blog\/?p=12218"},"modified":"2024-06-03T11:23:37","modified_gmt":"2024-06-03T15:23:37","slug":"a-flush-lines-example","status":"publish","type":"post","link":"https:\/\/irreal.org\/blog\/?p=12218","title":{"rendered":"A Flush-lines Example"},"content":{"rendered":"<p>\nI&rsquo;m fond of telling stories about folks using Emacs to solve difficult\u2014or at least complicated\u2014problems but Emacs is probably used more often to solve simple, one-off problems. These problems typically don&rsquo;t require anything fancier than, maybe, keyboard macros.\n<\/p>\n<p>\nMario Jason Braganza has a <a href=\"https:\/\/janusworx.com\/blog\/search-for-something-kill-the-line-in-emacs\/\">nice case in point<\/a>. The TL;DR is that he made a bulk purchase of comics and wondered how many he got. The site that he bought them from had all the information about the purchase but it included much more than just the titles. Each bit of information was on a separate line and Braganza decided to count just the title lines to see how many comics he had.\n<\/p>\n<p>\nSo Braganza downloaded the information and pasted it into Emacs. He thought that if he could get rid of the extraneous lines, he could simply do a line count to calculate the total number of comics he had bought.\n<\/p>\n<p>\nExperienced Emacers are jumping up and down yelling, &ldquo;I know, I know&rdquo;. The answer, of course, was <code>flush-lines<\/code>. You simply call <code>flush-lines<\/code>, give it a regular expression, and Emacs deletes any lines having a match for the regex. Braganza could, of course, have given it a complicated regex that got rid of all the unneeded lines at once but he chose the simpler\u2014and probably more rational\u2014method of eliminating one type of line at a time. In the end, he had only titles left and a simple line count gave him his answer.\n<\/p>\n<p>\nThis is, to be sure, a trivial example but it illustrates nicely one of the areas where Emacs shines: simple one-off tasks that would be tedious without the editing power of Emacs. Could you do this in some other editor? Maybe, but why should we care. It works in Emacs and that&rsquo;s all we need to know.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&rsquo;m fond of telling stories about folks using Emacs to solve difficult\u2014or at least complicated\u2014problems but Emacs is probably used more often to solve simple, one-off problems. These problems typically don&rsquo;t require anything fancier than, maybe, keyboard macros. Mario Jason &hellip; <a href=\"https:\/\/irreal.org\/blog\/?p=12218\">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-12218","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\/12218","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=12218"}],"version-history":[{"count":1,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/12218\/revisions"}],"predecessor-version":[{"id":12219,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/12218\/revisions\/12219"}],"wp:attachment":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=12218"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=12218"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=12218"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}