title: Customizing repl/nrepl error messages
body: <p>There's an error I keep doing in Clojure once in a while and I don't do it often enough yet to know immediately what I forgot but I still do it often enough that it gets <em>really</em> annoying.</p>
  
  <p>Basically after using <code>nrepl-jack-in</code>, I often forgot to change to the correct namespace.</p>
  
  <p>So at the nrepl <code>user&gt;</code> prompt I enter a function and I get:</p>
  
  <pre><code>CompilerException java.lang.RuntimeException: Unable to resolve symbol: foo-bar-baz in this context, compiling:(NO_SOURCE_PATH:1)
  </code></pre>
  
  <p>printed in the <code>nrepl</code> buffer before giving me back the <code>user&gt;</code> prompt.</p>
  
  <p>So I figured out that instead of trying to mess up with Java / Clojure there was probably an easy way to give an hint directly from Emacs, using only some Emacs magic.</p>
  
  <p>How can I add a hook (?) or something similar to Emacs / nrepl-mode so that when a specific message gets printed (like, say, a message containing "Unable to resolve symbol" and "in this context") I could add one line saying something like:</p>
  
  <pre><code>"Didn't you forget to change namespace?"
  </code></pre>
  
  <p>or even:</p>
  
  <pre><code>"There's a .clj buffer opened using namespace abc.defk, didn't you forget to enter: (ns  abc.def) ?"
  </code></pre>
  
  <p>There are quite some error messages which I find quite cryptic in Clojure and it usually takes me a while to figure out what I'm doing wrong.  If I could "personalize" these error messages directly from Emacs I'd win quite some time.</p>
  
  <p>So how can I "intercept" nrepl outputs and tailor them to my needs?</p>