我有一个HTML页面,启用了html-mode 。 我调用函数sgml-validate来检查是否有标记错误。 它基于compilation-mode 。 我想从编译输出中删除一些警告,所以我编写了一个函数并将其挂钩到compilation-filter-hook (该变量没有记录,但compilation-filter调用它)。 一切正常。 我的问题是,如何确保我的过滤器函数只在我开始在HTML页面上编译过程(通过sgml-validate )时被调用?
我看到两种方法,但都没有工作:
首先,我可以检查major-mode的价值。 但它总是返回compilation-mode ,因为它在*compilation*缓冲区中启用。 (我在grep+的源代码中找到了一个过滤函数,他们确实检查了major-mode的值,我不知道它是如何工作的。) 另一个想法是只将我的过滤器函数挂接到HTML文件的缓冲区,但出于类似的原因,它不能工作,因为编译过程的输出到了一个单独的缓冲区。I have a HTML page, with html-mode enabled. I call function sgml-validate to check for any markup errors. It's based on compilation-mode. I want to remove some warnings from the compilation output, so I wrote a function and hooked it to compilation-filter-hook (this variable is not documented, but compilation-filter 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 sgml-validate)?
I see two methods, but none of them worked:
First, I can check the value of major-mode. But it always returns compilation-mode, since that is enabled on the *compilation* buffer. (I found a filter function in the source code of grep+, and they did check the value of major-mode. I can't figure out how can it work correctly.) 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.最满意答案
听起来您可以建议smgl-validate,以便在它执行所有其他操作之前执行过滤。 例如:
(defadvice sgml-validate (around fix-filtering command activate) (let ((return-value ad-do-it)) (filter-function return-value))))It sounds like you can advise smgl-validate so that it performs the filtering before it performs all it's other operations. For example:
(defadvice sgml-validate (around fix-filtering command activate) (let ((return-value ad-do-it)) (filter-function return-value))))更多推荐
发布评论