[ Combined Document ] | Contents | Previous | Next
For a close coupling of Emacs and MSVC, Christopher Payne <payneca@sagian.com> wrote a Visual Studio add-in that makes Emacs the default text editor. See http://www.rose-hulman.edu/~payneca/emacs/VisEmacs.html for more info on what it can do and how it works. For information on how to customize your general development environment to use Emacs with MSVC, read Charles Curley's text below. For VisEmacs alpha executables, download this VisEmacs.zip distribution.
Jeff Paquette <paquette@mediaone.net> made a small addition to VisEmacs to disable it during a debugging session. See http://atnetsend.ne.mediaone.net/programming.html#Visemacs for info and files.
Written by Charles Curley with a lot of help from: David Biesack, Caleb T. Deupree, John Huxoll Gardner, Anders Lindgren, and John Yates.
This is an app note on how to use Microsoft Visual C++ with Emacs. The experiments done below were done with Emacs 19.34.1 on Windows 95, using Visual C++ 4.0 Standard Edition. Your mileage may vary.
This writeup assumes minimal knowledge of Emacs hacking on the part of the reader.
First, Emacs requires any environmental variables to be set at boot time, in autoexec.bat (for Windows 95). This includes variables such as HOME. So if you haven't already done so, set the environment up so that Emacs' compile mode will correctly run VC++. There is a batch file in your VC++ installation's bin directory called "vcvars32.bat". Call it from your autoexec.bat file. Make sure you use the "call" keyword, or execution never returns from the called batch file. Here is what the relevant portion of my autoexec.bat looks like:
rem set up for MS C++ 4.0 call d:\msdevstd\bin\vcvars32.bat
Under NT, you can set the HOME and other environment variables in the System applet of the Control Panel.
John Huxoll Gardner writes that
These environment variables can be set through the control panel. Control Panel->System->Environment tab set include to d:\msdev\include;d:\msdev\mfc\include (or whatever) set lib to d:\msdev\lib;d:\msdev\mfc\lib (or whatever) set MSDevDir to d:\msdev
You should now be able to compile from Emacs. Load a source file from a VC++ project. Type M-X compile. Replace the proposed command line with:
nmake -f MyProject.mak
You will find that this defaults to a win 32 debug build. You can change it to a release build with:
nmake -f MyProject.mak CFG="MyProject - Win32 Release"
By the way, you can scroll in the M-X command buffer with up and down arrows. You can also scroll in the compile command buffer with the up and down arrows. Both seem to be fully editable as well.
Now set up the default value for the compile command line. Add the following to your .Emacs:
; Set up for Visual C++ compiling (setq compile-command '("nmake -f .mak " . 10))
If you work on the same project extensively, toss that in to the default string. You can always override it when you work on another project.
By the way, many if not all Microsoft command line programs now accept a dash (-) as a switch specifier as well as a slash (/). This was true as long ago as Mess-DOS 6.0, I believe. I use it because that eliminates one area where I have to remember which OS I am using. :-)
David Biesack suggests that perhaps it's easy to define Makefile in the project directory which does
PROJECT=MyProject all: debug debug: FORCE nmake /f $(PROJECT).mak CFG="$(PROJECT) - Win32 Debug" release: FORCE nmake /f $(PROJECT).mak CFG="$(PROJECT) - Win32 Release" FORCE:
and then you can simply change compile-command to "nmake".
Caleb T. Deupree reports that on VC++ 5.0 and up, "You can also set an option on Options/Build to export a makefile every time the project is saved, which you can then use to compile with 'nmake -f project.mak'." VC++ 4.0 builds the make file every time, and there is no option.
Those of you who never get compile time errors can skip this section.
One of the things that compile.el provides is the ability to scan the output from a compile session, and move from error message to error message. This facility depends on a series of regular expressions ("regexes") which are applied to search the compiler output. Normally, you shouldn't have to do anything. However, if you have problems with this facility, you can comment out the regexes you don't need and recompile. Search the file for "compilation-error-regexp-alist" and comment out as needed.
To recompile, make the file the active buffer. Emacs will recognize it as an elisp file, and add a pull-down menu for elisp functions. One is for compiling, the other will compile and then load.
By the way, the best (and so far, only :-) book I've seen on regular expressions is Jeffrey E. F. Friedl, *Mastering Regular Expressions*, O'Reilly & Assoc, Inc, 1997. It covers regex syntax and usage for Emacs, perl and other tools that regexes.
Then there is the problem that sometimes you modify the source from Microsoft's IDE. Here's some help for that.
Occasionally, you need to add a new function or variable from the Visual C++ IDE. This means that the copy of the file in your Emacs buffer is now obsolete. The simplest thing to is a two part manual effort. First, before you leave Emacs for VC++, make sure you save all your buffers (C-X S). When you return, you can revert buffers you know have been changed with M-X revert-buffer. If you try to modify a file that has been changed from outside Emacs (say, by VC++), Emacs will warn you and offer you the chance to revert the buffer, so you can safely try modifying files after making a change from VC++.
However, this depends on the user remembering to do something, always a hazard. The obvious way to handle the problem is to automate it, which Anders Lindgren has already done. He writes:
This feature will be present in the next version of Emacs. There will be two modes, `global-auto-revert-mode' that applies to all buffers while `auto-revert-mode' can be activated for individual buffers. You can get the latest version from: http://www.csd.uu.se/~andersl/emacs.shtml Please note that this feature comes with a prize: Normally Emacs acts like an extra backup system, keeping a copy of the files you are editing. Should some external program mess up a file, you can always save the copy you're editing. When using Auto-Revert mode Emacs will happily load the corrupt file, perhaps ruining you last chance to restore the original file content! -- Anders ;; .signature -- File added to the end of mail, containing joke or info. (defvar me '((profession . "Compiler Designer") (company . "IAR Systems") (age . 27) (country . "Sweden") (hair . "Long") (water-skier . t))) ;; .signature ends here.
(Now, *that* is an elisp hacker's sig line! :-)
The next version of Emacs to which Anders refers is, I believe, 20. I don't know when it will be released.
If you can't wait, you can scarf the source for autorevert.el in from Anders' web page. However, it is dependent on another Emacs package, Custom, which is not in the version of Emacs I have (19.34.1). Custom is available at http://www.dina.kvl.dk/~abraham/custom/. Installing the Custom package is beyond my meager elisp hacking skills, so you are on your own there. The next release will also include Custom.
Caleb T. Deupree also writes, "You might also mention a package mode-compile.el, which is a wrapper around compile mode and is available from the Emacs lisp archive or from http://www.cenatls.cena.dgac.fr/~boubaker/Emacs/index.html. It detects makefiles in directories and parses them for valid targets, performing many of the same tasks which you do in your hooks."
You can also set up VC++ to import a file into Emacs for you, all ready for editing. You will need the Gnuclient package, which is used to associate file extensions with Emacs. In VC++, go to the Tools pulldown menu, and click on Customize.... In the Tools tab, click on Add. Use Browse to locate your gnuclientw.exe file, and select it. For arguments, use +$(CurLine) "$(FilePath)" and for the directory use the $(WkspDir) (the quotes around FilePath handle paths with spaces in them). Set the Menu Text to say "Em&acs". The "+$(CurLine)" will set point in Emacs to the same line as the cursor position in VC++. The ampersand in the word "Em&acs" allows you to select emacs from the keyboard. (E is already used for the OLE control test container.)
You should now be able to go to any source file in your project. Then, use the pull-down menu Tools->Emacs. The active file in your VC++ ide should now be front and center in Emacs, all ready to edit as you wish. If you use keystrokes to work the menus, try <alt>T A to move the file into Emacs. Binding this tool to a keystroke will be left as an exercise for the student.
If you have the option of saving files before running tools, make sure this option is set. (I don't see it on VC++ 4.0.)
Jonathan Arnold's <jdarnold@buddydog.org> EmacsEdit "expert" for interfacing C++ Builder and Emacs.
Howard Melman <howard@silverstream.com> has put together some elisp to get imenu working with Java.
To create TAGS files for Java source files, use Paul's JDE below.
Paul Kinnucan <paulk@mathworks.com> has also implemented a Java Development Environment:
The JDE is an Emacs Lisp package that provides a highly configurable Emacs wrapper for command-line Java development tools, such as those provided in JavaSoft's JDK. The JDE provides menu access to a Java compiler, debugger, and API doc.
The JDE can be found at http://sunsite.auc.dk/jde/ (also mirrored at http://www.geocities.com/SiliconValley/Lakes/1506/).
Since NT Emacs version 20.3.1: Support for jdb has been added to gud.el package.
Jacob is a Java class browser and project manager for Emacs written by Clemens Lahme <Clemens.Lahme@gmd.de>. For details about Jacob, see http://home.pages.de/~kclee/clemens/jacob/.
David Fellows' <fellows@roo.cs.unb.ca> recipe for installing Emacs, JDE, and the Sun JDK: http://www.cs.unb.ca/courses/gen/getit-iz.html.
It provides emacs-19.34-6/jde-2.0.9/jdk-1.1{6,7}/rcs-5.7 plus some customizatins we feel are suitable for java begginners. Installation is supposed to be a "no-brainer"; most times it is.A caveat: Sun has just released jdk1.1.7 (and withdrawn 1.1.6) so the install file takehome.bat needs to be revised accordingly - the comments should make it obvious what to change. I will be updating the distribution to reflect this no later than this weekend.
There are a number of RCS x86 executables floating about. There is an "official" port of GNU RCS available, but it has the semantics that files are managed in CR/LF format. This causes problems if your files are shared with programs on Unix hosts (for more info, see Kai Rommel's message). The version of RCS in the Reed Kotler toolset, on the other hand, does not change the line format. Your call.
The "official" port of GNU RCS can be found in the following places:
DOS, Win95/NT and OS/2 32-bit executables (including diff), as well as formatted documentation files:
ComponentSoftware CS-RCS is a Windows front end to GNU RCS. Single user use of their software is free, and they even have directions on how to use it with Emacs:
David Matyas <davidm@ComponentSoftware.com> By default, CS-RCS check-out files using the Windows line-break conventions (<cr><lf>), as this mode is reasonable for most of the users. A "UNIX-Style" mode is available as well. (This mode is used mainly by users uses the Windows workstation as an X-Terminal.)
The Reed Kotler toolset can be found at http://www.reedkotler.com.
Note: If the version of RCS you are using does not append the traditional ",v" to RCS files, try setting the environment variable "RCSINIT" to "-x,v" ("set RCSINIT=-x,v").
You can find a free port of CVS from Cyclic Software.
If you use the pcl-cvs package, you'll need to fix a couple of things in the elisp to make it work on NT; Michael M. Schmitz <ms@ley.de> has some instructions describing what you need to do. John D. Amidon <jda@jhk.com> gives an example of what he used to set up pcl-cvs in his .emacs.
If you are having trouble getting vc-mode working with RCS or CVS, take a look at Peter Cherna's <peter.cherna@scala.com> problem description and fix.
Andy Eskilsson <andy.eskilsson@telelogic.se> has modified vc-mode to work with Clearcase, and it reportedly works very well; see http://www.fukt.hk-r.se/~flognat/vc/
Jari Aalto <jari.aalto@poboxes.com> has a page about using Clearcase software with Emacs. See "9.8 Clearcase software" at ftp://cs.uta.fi/pub/ssjaaa/emacs-elisp.html.
A perl-mode comes with the Emacs distribution, and will be used when you load and edit Perl files.
Users have also recommended an alternate mode named cperl-mode. You can get this from ftp://ftp.math.ohio-state.edu/pub/users/ilya/perl/.
From Jay Rogers <jay@rgrs.com>:
There are potentially two problems that cause the perl debugger to hang when started in emacs. One's an emacs problem while the other's a perl problem.First, get Emacs 19.34.4 or later for Windows 95/98/NT. It contains a fix that allows emacs to read all ASCII characters from the perl debugger, including the dreaded ^Z (aka EOF in DOS). It also groks the "drive:path" filename notation.
Second, some versions of the perl debugger itself need to be patched to work with emacs. They are perl versions 5.001 and less, and version 5.004_01. To fix, locate and change the code similar to the following code in lib/perl5db.pl
if (-e "/dev/tty") { $console = "/dev/tty"; $rcfile=".perldb"; } elsif (-e "con") { $console = ""; <---- change "con" to "" $rcfile="perldb.ini"; } else { $console = "sys\$command"; $rcfile="perldb.ini"; }
Doug Campbell <soup@ampersand.com> also has some suggestions for improving the interaction of perldb and Emacs.
The python-mode shipped with Python 1.5 requires a new custom.el before it can be used with Emacs 19.34. For more information, see the description of python-mode at http://www.python.org/emacs/python-mode/.
[ Combined Document ]
| Contents |
Previous |
Next
Steve Kemp, FAQ Maintainer
<skx@tardis.ed.ac.uk> |