emacs - 如何从compilation-error-regexp-alist 文件函数中获取当前匹配的行?

标签 emacs elisp compile-mode

我正在运行命令 compile因此我可以从错误消息链接到关联的源,但我需要转换匹配行的大部分内容才能获取要链接的文件。 (该行显示了 clojure 命名空间,例如 foo-bar.quux ,需要将其转换为 foo_bar/quux.clj 。)

compilation-error-regexp-alist 的文档部分说,

Each elt has the form (REGEXP FILE [LINE COLUMN TYPE HYPERLINK HIGHLIGHT...]). ... FILE can also have the form (FILE FORMAT...), where the FORMATs (e.g. \"%s.c\") will be applied in turn to the recognized file name, until a file of that name is found. Or FILE can also be a function that returns (FILENAME) or (RELATIVE-FILENAME . DIRNAME). In the former case, FILENAME may be relative or absolute.

当我将条目添加到 compilation-error-regexp-alist-alist 时和compilation-error-regexp-alist具有 FILE 中的函数位置,我的函数被调用时不带参数。如何获取该函数内的匹配行?

最佳答案

开幕compile.el然后使用 C-s (funcall 进行搜索让我跳到:

           (setq file (if (functionp file) (funcall file)
                        (match-string-no-properties file))))

这似乎是相关点,并表明这些函数确实是在没有参数的情况下调用的,并且 match-data仍然非常有效,因此您可以使用 (match-string <the-file-sub-group>) 提取文件名.

关于emacs - 如何从compilation-error-regexp-alist 文件函数中获取当前匹配的行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18048407/

相关文章:

python - 如何用 emacs 拼写检查 python 文档字符串?

sql-server - 如何使用 sp_send_dbmail 发送纯文本电子邮件(带换行符)?

emacs - 如何在 Windows 上的 Emacs 中保留剪贴板内容?

emacs - 如何在org-mode中添加一个可以正确导出到latex的℃

c# - OutOfMemoryException 仅在发布时编译时抛出

windows - Emacs 中的路径名翻译,用于从远程(ssh 编译)错误文件名查找本地源文件路径

emacs - 暂时覆盖编译模式 regexp alist : dynamic binding weirdness?

emacs - Emacs配置dirtree

c - emacs C 和 C++

debugging - 如何调试字体锁定关键字错误