{"id":240,"date":"2017-09-06T10:37:07","date_gmt":"2017-09-06T10:37:07","guid":{"rendered":"https:\/\/www.root42.de\/blog\/?p=240"},"modified":"2018-06-18T15:13:55","modified_gmt":"2018-06-18T15:13:55","slug":"parsing-compiler-or-grep-output-for-emacsclient","status":"publish","type":"post","link":"https:\/\/www.root42.de\/blog\/?p=240","title":{"rendered":"Parsing compiler or grep output for emacsclient"},"content":{"rendered":"<p>This short bash snippet allows you to copy and paste any grep or compiler output of the form <code>some\/file.java:12:34<\/code> to <code>emacsclient<\/code> to jump to the specified file, line and column in Emacs:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nfunction emacsClient()\r\n{\r\n  local IFS=&quot;:&quot;\r\n  set $1\r\n  if &#x5B; $# -eq 3 ]\r\n  then\r\n    emacsclient -n +&quot;$2:$3&quot; &quot;$1&quot;\r\n  elif &#x5B; $# -eq 2 ]\r\n  then\r\n    emacsclient -n +&quot;$2:1&quot; &quot;$1&quot;\r\n  else\r\n    emacsclient -n &quot;$1&quot;\r\n  fi\r\n}\r\n\r\nalias ec=emacsClient\r\n<\/pre>\n<p>Example call:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n$ grep -nH custom init.el\r\ninit.el:93:  (setq custom-file (expand-file-name &quot;custom.el&quot; (or (file-name-directory user-init-file) default-directory)))\r\ninit.el:94:  (load custom-file)\r\ninit.el:95:  (global-set-key (kbd &quot;&quot;) '(lambda () (interactive) (load custom-file)))\r\n$ ec init.el:95:\r\n$\r\n<\/pre>\n<p>Update: I forgot to make the IFS variable local to the function. This would break things like git-bash-prompt, if the IFS is suddenly set to something else.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This short bash snippet allows you to copy and paste any grep or compiler output of the form some\/file.java:12:34 to emacsclient to jump to the specified file, line and column in Emacs: function emacsClient() { local IFS=&quot;:&quot; set $1 if &#x5B; $# -eq 3 ] then emacsclient -n +&quot;$2:$3&quot; &quot;$1&quot; elif &#x5B; $# -eq 2 &hellip; <a href=\"https:\/\/www.root42.de\/blog\/?p=240\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Parsing compiler or grep output for emacsclient&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7,56,6],"tags":[],"_links":{"self":[{"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/240"}],"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=240"}],"version-history":[{"count":5,"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/240\/revisions"}],"predecessor-version":[{"id":293,"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/240\/revisions\/293"}],"wp:attachment":[{"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=240"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=240"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.root42.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=240"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}