title: How can I filter compilation output only for a specific mode or buffer in Emacs?
body: <p>I have a HTML page, with <code>html-mode</code> enabled. I call function <code>sgml-validate</code> to check for any markup errors. It's based on <code>compilation-mode</code>. I want to remove some warnings from the compilation output, so I wrote a function and hooked it to <code>compilation-filter-hook</code> (this variable is not documented, but <code>compilation-filter</code> invokes it). Everything works. My problem is that how can I ensure my filter function only gets called when I started the compilation process on a HTML page (via <code>sgml-validate</code>)?</p>
  
  <p>I see two methods, but none of them worked:</p>
  
  <ul>
  <li>First, I can check the value of <code>major-mode</code>. But it always returns <code>compilation-mode</code>, since that is enabled on the <code>*compilation*</code> buffer. (I found a filter function in the <a href="http://www.emacswiki.org/emacs/grep+.el" rel="nofollow noreferrer">source code of <code>grep+</code></a>, and they did check the value of <code>major-mode</code>. I can't figure out how can it work correctly.)</li>
  <li>The other idea was than to only hook my filter function to the HTML file's buffer, but for similar reasons it couldn't work as the output of compilation process goes to a seperate buffer.</li>
  </ul>