{"id":50,"date":"2012-07-17T07:15:00","date_gmt":"2012-07-17T07:15:00","guid":{"rendered":"https:\/\/www.root42.de\/blog\/?p=50"},"modified":"2012-07-17T07:15:00","modified_gmt":"2012-07-17T07:15:00","slug":"commenting-out-line-or-region-in-emacs","status":"publish","type":"post","link":"https:\/\/www.root42.de\/blog\/?p=50","title":{"rendered":"Commenting out line or region in Emacs"},"content":{"rendered":"<p>What I always wanted: commenting or uncommenting a line or region using emacs. Of course, there is comment-region, but this is much nicer:<\/p>\n<pre><br \/>(defun comment-or-uncomment-line-or-region ()<br \/>  \"Comments or uncomments the current line or region.\"<br \/>  (interactive)<br \/>  (if (region-active-p)<br \/>      (comment-or-uncomment-region (region-beginning) (region-end))<br \/>    (comment-or-uncomment-region (line-beginning-position) (line-end-position))<br \/>    )<br \/>  )<br \/><br \/>(define-key c-mode-base-map (kbd \"C-\/\") 'comment-or-uncomment-line-or-region)<br \/><\/pre>\n<p>See also the corresponding <a href=\"http:\/\/stackoverflow.com\/questions\/9688748\/emacs-comment-uncomment-current-line\">Stackoverflow<\/a> question.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What I always wanted: commenting or uncommenting a line or region using emacs. Of course, there is comment-region, but this is much nicer: (defun comment-or-uncomment-line-or-region () &#8220;Comments or uncomments the current line or region.&#8221; (interactive) (if (region-active-p) (comment-or-uncomment-region (region-beginning) (region-end)) (comment-or-uncomment-region (line-beginning-position) (line-end-position)) ) )(define-key c-mode-base-map (kbd &#8220;C-\/&#8221;) &#8216;comment-or-uncomment-line-or-region) See also the corresponding Stackoverflow question.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[38,7,6,8],"tags":[],"_links":{"self":[{"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/50"}],"collection":[{"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=50"}],"version-history":[{"count":0,"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/50\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=50"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=50"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=50"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}