Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Ways to use Emacs when programming C++ with Visual Studio?

603 views
Skip to first unread message

Thorsten Jolitz

unread,
Oct 24, 2014, 4:36:29 PM10/24/14
to help-gn...@gnu.org

Hi List,

I did some web research about how to (still) use Emacs (somehow) when
programming C++ with MS Visual Studio (Express). What I found was more
or less:

- there are workarounds to activate Emacs Keybindings in VS

- emacs(client) can be configured as editor in VS (like it can be
e.g. configured as editor in firefox)

- emacs can be used (after setting quite a lot of environmental
variables) to interact with the MSVS C++ compiler via the cmd line

I'm really new to this C++ thing, so I would appreciate some tips about
this topic, what can be done, what not, what is the state-of-the-art
(some prominent links I found are really old, like 10 years or so,
talking about Emacs 19...)?

Are there actually C++ teams with both Emacs and Visual Studio users? I
could imagine that e.g. in a Scala (SBT or Maven) project some
programmers use Eclipse, others Emacs ENSIME, and they can happily
co-exist, but would a similar co-existance be possible in a C++ project
on Windows with Emacs and Visual Studio?

--
cheers,
Thorsten



Óscar Fuentes

unread,
Oct 25, 2014, 10:48:14 PM10/25/14
to help-gn...@gnu.org
Thorsten Jolitz <tjo...@gmail.com> writes:

[snip]

> - emacs can be used (after setting quite a lot of environmental
> variables) to interact with the MSVS C++ compiler via the cmd line

VS comes with batch files for setting those environment variables. You
can write a .bat that takes an arbitrary number of arguments, executes
the VS .bat that sets the environment variables and then executes those
arguments as a command. This is mine:

rem vc2013.bat
@call "c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\vcvars32.bat"
%*

>From Emacs you do

M-x compile vc2013.bat <command>

> I'm really new to this C++ thing, so I would appreciate some tips about
> this topic, what can be done, what not, what is the state-of-the-art
> (some prominent links I found are really old, like 10 years or so,
> talking about Emacs 19...)?
>
> Are there actually C++ teams with both Emacs and Visual Studio users? I
> could imagine that e.g. in a Scala (SBT or Maven) project some
> programmers use Eclipse, others Emacs ENSIME, and they can happily
> co-exist, but would a similar co-existance be possible in a C++ project
> on Windows with Emacs and Visual Studio?

Absolutely. I only use the VS IDE for debugging (which seldom happens.)
99% of the time is coding and everything is done from Emacs. You can use
CMake too, that creates VC project files, makefiles, etc from the same
build specification.


Thorsten Jolitz

unread,
Oct 27, 2014, 5:20:27 AM10/27/14
to help-gn...@gnu.org
Óscar Fuentes <o...@wanadoo.es> writes:

> Thorsten Jolitz <tjo...@gmail.com> writes:
>
> [snip]
>
>> - emacs can be used (after setting quite a lot of environmental
>> variables) to interact with the MSVS C++ compiler via the cmd line
>
> VS comes with batch files for setting those environment variables. You
> can write a .bat that takes an arbitrary number of arguments, executes
> the VS .bat that sets the environment variables and then executes those
> arguments as a command. This is mine:
>
> rem vc2013.bat
> @call "c:\Program Files (x86)\Microsoft Visual Studio
> 12.0\VC\bin\vcvars32.bat"
> %*
>
> From Emacs you do
>
> M-x compile vc2013.bat <command>

That looks easy enough, thanks.

>> I'm really new to this C++ thing, so I would appreciate some tips about
>> this topic, what can be done, what not, what is the state-of-the-art
>> (some prominent links I found are really old, like 10 years or so,
>> talking about Emacs 19...)?
>>
>> Are there actually C++ teams with both Emacs and Visual Studio users? I
>> could imagine that e.g. in a Scala (SBT or Maven) project some
>> programmers use Eclipse, others Emacs ENSIME, and they can happily
>> co-exist, but would a similar co-existance be possible in a C++ project
>> on Windows with Emacs and Visual Studio?
>
> Absolutely. I only use the VS IDE for debugging (which seldom happens.)
> 99% of the time is coding and everything is done from Emacs. You can use
> CMake too, that creates VC project files, makefiles, etc from the same
> build specification.

Thats really good news. Thanks again for the hints.

--
cheers,
Thorsten


Emanuel Berg

unread,
Nov 6, 2014, 8:08:22 PM11/6/14
to
Thorsten Jolitz <tjo...@gmail.com> writes:

> I'm really new to this C++ thing, so I would
> appreciate some tips

Here is a tip: don't do it!

I'm sure it is possible to a certain extent but it'll
just require lots of work and then at the first sign
of trouble you'll start to think somewhere along the
transition it went wrong, and you'll go back there,
and it'll all be shaky until someone says you should
use some new tool or module with VS, and then you are
*really* done for...

When I did my bachelor in CS I was sent to a hospital
where they did MS Access and that IDE and VBA and
their SQL.

So I thought, let's not be a snob, I'll do it with
Emacs and MySQL and all first so I have a almost
complete understanding of the problem start-to-finish,
then I'll just go there, do it all with their crap
tools and be done with it.

First part of that plan worked out very good, but then
to use that software, I developed an intense hatred
(no exaggeration) for everything MS, everything GUI,
everything mouse... It would literally hurt my eyes
and fingers and arm to use that stuff. Mentally the
most frustrating thing was being constantly aware all
problems would vanish in zero time, would they just
allow me to use professional tools...

When I was done, the hatred actually didn't disappear
instantly, but lingered on. But now, too much time has
passed, and all those negatives I don't suffer from
anymore (because I don't use MS Access, the mouse,
etc.), so know, my system is clean of the hatred as
well.

I even wrote about this [1], if anyone is interested
in ergonomics and the like.

Your plan is actually a lot better, because you plan
on using transition tools - if you get it to work like
instantly, fine, probably if you spend several hours
step-by-step to get it to work, I'd advice not to drop
it.

Remember, in the computer world, portable and
tool-independent solutions are everywhere. If someone
says, here we do it like this, and you must, too -
then that speaks volumes about the person saying that.
Unless you have a bunch of kids that would otherwise
starve, there is absolutely no reason to put up with
it.

[1] http://user.it.uu.se/~embe8573/about/degree/x.pdf
(check out the ToC for interface stuff)

--
underground experts united

Thorsten Jolitz

unread,
Nov 7, 2014, 5:21:55 AM11/7/14
to help-gn...@gnu.org
Emanuel Berg <embe...@student.uu.se> writes:

Hi,

> Thorsten Jolitz <tjo...@gmail.com> writes:
>
>> I'm really new to this C++ thing, so I would
>> appreciate some tips
>
> Here is a tip: don't do it! [SNIP]

thanks for the tips and the link!
Not sure if going the Emacs way is accepted, lets see ...

--
cheers,
Thorsten


3246251...@gmail.com

unread,
Nov 9, 2014, 7:51:29 PM11/9/14
to
I am in the same situation. At work Windows is a must, unfortunately. We use Msvc but I am avidly a fan of GNU like things and always use emacs for all. So when I first joined I set about making emacs my ide. Only time - like previous poster said - I use vc ide is for debugging.

But as another poster said, it will consume time. A lot of times I have been working on a problem for work and spent a while hacking emacs to get something to work. I have needed to change some things in compile . el for instance.

But when it's all set up its very nice. I run compilation mode through emacs etc - and with said changes to compile I can jump to the line of error etc. I use CEDET/semantic for Intellisense. Vc mode and all the rest of it. We use msys at work so that is used in shell mode.

I generally forget I am on windows because all is done on emacs whose windows I spread across two monitors and just keep at least a permanent middle split of buffers.

I would say it's worth it but expect a little annoyance and thus perseverance to hack things around to get it to work.

Thorsten Jolitz

unread,
Nov 10, 2014, 5:44:15 AM11/10/14
to help-gn...@gnu.org
Its promising that Emacs can be and is used in Windows/MSVS teams,
thanks for sharing your experiences. I'm definitely prepared to invest
some time and effort in this, I only have to find out if its considered
acceptable to 'do your own thing' instead of adapting to the
"environment".

--
cheers,
Thorsten


3246251...@gmail.com

unread,
Nov 11, 2014, 9:28:57 AM11/11/14
to
There are people here who are no doubt have way more experience than me with Emacs. But if you have any questions regarding setting up emacs on windows, ask here

Ken Goldman

unread,
Nov 24, 2014, 6:00:43 PM11/24/14
to help-gn...@gnu.org
On 11/6/2014 8:09 PM, Emanuel Berg wrote:
> Thorsten Jolitz <tjo...@gmail.com> writes:
>
>> I'm really new to this C++ thing, so I would
>> appreciate some tips

My pattern:

I use emacs for heavy coding.

I use Visual Studio for compiling, fixing minor coding errors that the
compiler finds, and for debugging.

I use autorevert to keep the emacs buffers in sync with disk. There's a
similar setting in VS.

It might seem odd, but I believe in the best tool for the job. Emacs is
a great editor for coding. VS is a great debugger, easier to set up and
use (IMHO) than eclipse.






Mike

unread,
Nov 25, 2014, 6:40:44 PM11/25/14
to
I agree with you. That was the way I would use it. Emacs for editing, but in the debugging phase use VS and make the hopefully small changes debugging would throw up through the VS editor.
I would just keep exitting and re-starting emacs to ensure I got the edits I had made in VS. Thanks for letting me know about autorevert. I'll try that out.
Sometimes, even during debugging, I'd find that the edits I wanted to make were easier using Emacs. So I'd make the changes in Emacs, then I would close every file window in VS, save all the files open in Emacs, then tell VS to rebuild everything! Not really much fun, but as Emacs is my favorite editor by far,and VS my favorite debugger for Windows, I could not find a better way.



Ken Goldman

unread,
Nov 26, 2014, 9:56:08 AM11/26/14
to help-gn...@gnu.org
On 11/25/2014 6:40 PM, Mike wrote:
>
> Thanks for letting me know about autorevert.
>

Besides autorevert, there's also M-x revert-buffer, which does it manually.

> So I'd make the changes in Emacs, then I would close every file
> window in VS, save all the files open in Emacs, then tell VS to
> rebuild everything! Not really much fun,

Tools - Options - Documents - Detect when file is changed outside the
environment - auto-load changes if saved.

I assume that Microsoft added that option so their developers could use
emacs. :-)


mfl...@scu.edu

unread,
Nov 26, 2014, 4:54:25 PM11/26/14
to
Cool. Thanks for letting me know about that.
0 new messages