Emacs: the Free Software IDE
Diffing is comparing two files, say two versions of a source file. Most programmers are familiar with diff and patch. Emacs provides a powerful front end for diff and patch. For one thing, Emacs' ediff mode shows the two (or three) files in the editor one above the other. The differences are highlighted on any display capable of color (Figure 10). The entire line is indicated, and the exact differences are indicated in different colors.
Not only that, but you can use single-character commands to move differences from one file to the other; a or b moves the line from the A or B buffer, respectively, to the other. This allows you to walk through two files, compare them and accept or reject each difference.
To step through the two files one difference at a time, put the ediff control panel in focus. Use the spacebar to advance and the P key to go back (Figure 11). Ediff mode can keep up with changes you make on the fly. Try adding a line to goodbye.c right after the printf line, a call to flush();.
Emacs has a huge library of built-in help. The gateway to Emacs' help is Ctrl-H. If you aren't familiar with Emacs at all, get started with the tutorial, Ctrl-H T. If you are already familiar with Emacs, you should walk through the tutorial; there's always something to learn about Emacs.
If you are familiar with the GNU program Info, you already know how to use Emacs' help system. Ctrl-H I gets you to the top menu of the Info system. From there, Memacs gets you to the Emacs documentation. And, of course, the documentation for Info is available from the top-level Info menu.
If you want documentation for other programs or for Linux function calls, you can use Emacs as an Info reader. Or, you can read the man pages from within Emacs. You can use Emacs as a front end for Man with the command M-X manual-entry. Or you can have Emacs interpret the man page and display it for you with the woman (WithOut MAN) package. Since the Cygwin tools for Windows (www.cygwin.com) include man pages but not a program to read them, woman is just the ticket.
For example, to see the man page for printf, put the cursor over the word printf in your source code. Enter M-X woman and press Return. Emacs will propose printf as the default manual entry. There are two printf man pages, one in man 3 and one in man 1. Tell Emacs you want man 3 by pressing 3 Tab. Emacs will complete the filename, then press Return. Emacs will show you the man page for printf.
Emacs is a fully integrated development environment. While a front end for external programs, Emacs uses free software for the back end. In that sense, it is better integrated into Linux than some proprietary IDEs. There is very little missing from Emacs, but if something is missing, Emacs is open-source and free software. You can write it.
Charles Curley (w3.trib.com/~ccurley) lives in Wyoming. He has 23 years' experience with computers, much of that as a software developer. He has worked for Hughes Aircraft, Hewlett-Packard, Microsoft and the Jet Propulsion Lab. He contributed to Sams' Teach Yourself Emacs in 24 Hours (ISBN: 0-672-31594-7).
Getting Started with DevOps - Including New Data on IT Performance from Puppet Labs 2015 State of DevOps Report
August 27, 2015
12:00 PM CDT
DevOps represents a profound change from the way most IT departments have traditionally worked: from siloed teams and high-anxiety releases to everyone collaborating on uneventful and more frequent releases of higher-quality code. It doesn't matter how large or small an organization is, or even whether it's historically slow moving or risk averse — there are ways to adopt DevOps sanely, and get measurable results in just weeks.
Free to Linux Journal readers.Register Now!
- Three More Lessons
- Django Models and Migrations
- August 2015 Issue of Linux Journal: Programming
- Hacking a Safe with Bash
- The Controversy Behind Canonical's Intellectual Property Policy
- Secure Server Deployments in Hostile Territory, Part II
- Shashlik - a Tasty New Android Simulator
- Huge Package Overhaul for Debian and Ubuntu
- Embed Linux in Monitoring and Control Systems
- KDE Reveals Plasma Mobile