简体   繁体   中英

Emacs support for VS2012 builds

I'm trying to get my .emacs set up so I can do builds of VS2012 projects from inside Emacs.

I followed the instructions on Emacswiki for doing this. It worked in the past for me with VS2005.

The problem is that this new version of VS appends a CPU designation on the front of every error/warning line, and emacs' C++ compiler parsing is getting confused and thinking that's part of the file name. For example, the error:

5>c:\dev\proj\my_class.h(35): warning C4100: 'command' : unreferenced formal parameter (my_class.cpp)

When visited with "next error", instead of bringing up the file and line, gives me the prompt:

Find this error in (default 5>my_class.h): ~/dev/proj/

Is there a tweak I can make in my .emacs (or perhaps the C and C++ modes) to fix this? Alternatively, is there a newer version of Emacs (or the mode .el files) that deals with VS2012 better? I'm currently using GNU Emacs 24.2.1

I think I've tracked this down.

The issue was not that GNU Emacs didn't try to support VS2012 compiler messages, the issue was that it had a couple of bugs in its support (in 24.2.1).

A bit of background: All the regexps Emacs uses to recognize errors and warnings are in a variable with the enchantingly redundant name of compilation-error-regexp-alist-alist . This is declared inside of the compile.el elisp file.

The main issue is that the first match found in the list is used, not the largest. There's a regexp on that list for edg-1 (Edison Design Group's front end for LLVM) that happens to match VS2012 errors and warnings. It was earlier in the list than the msft, so it was being used instead. Presto: bad directory match.

The issue was discussed in this thread on the emacs dev list, and fixed with a patch on 10/14/2012.

There are two fairly easy solutions.

  1. Upgrade to Emacs 24.3 or later. This should have the patch.
  2. (for the handy) Edit your lisp/progmodes/compile.el file. Find the "msft" entry in compilation-error-regexp-alist-alist , and move it somewhere in front of the offending "edg-1" entry. While you are at it, you may want to add a ? at the end of the first regexp line before the backslash (see the diff link ). Then byte-compile the file and restart emacs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM