我正在运行命令 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/