[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: configuring emacs as a programmer's editor

From: Le Wang
Subject: Re: configuring emacs as a programmer's editor
Date: 30 Jun 2006 00:37:24 -0700
User-agent: G2/0.2

Ted wrote:
> OK, I have used emacs as just a clone of Notepad for quite a while.  I
> know that is under-using it, but I found configuring it to be more
> useful to me a bit onerous.  I find the emacs documentation a bit dense
> on one side, and short of the details and examples I need on the other.
> I have a basic .emacs file, appended below, that seems like it should
> support most of the programming languages I use.  I constructed it by
> copying and pasting portions of .emacs files I found published on the
> web.
> I need something that will work for me on both Windows XP and SUSE
> Linux 10.  But on Windows, I have MS Visual Studio, and so need emacs
> to support primarily SQL, Perl, PHP, while on Linux, I need it to
> support these plus the C++ and fortran gcc compilers.  While I do a lot
> of Java, I use Netbeans almost exclusively for my java programming.
> Finally, I need to be able to specify whether to submit my SQL to
> PostgreSQL or to MySQL, if that is possible.
> I suppose I have two questions.  1) How do I modify the .emacs file
> I've managed to cobble together to fully support my needs?  and 2)
> Although I can get into perl mode (using cperl-mode, I think), by
> loading or creating a perl script file, I find invariably that the run,
> kill, next error, and check syntax items on the Perl submenu are
> disabled.  Why?  And how do I fix that?  I have guessed that emacs is
> largely written in, and configured using lisp, and that to really
> understand this, I should learn lisp

You don't need to be an Emacs lisp master to customize your Emacs.
Your .emacs file looks like a good start.  Although there are some
obvious problems that you'll easily be able to fix, once you have a
tiny bit of lisp under your belt.  I actually find that there is an
abundance of material to get you started in lisp, and it doesn't take
that much time to get the basics down.


1.  Google groups for past q/a

2.  Emacs Wiki


If you have specific questions, ask them, and people will try to help.
The most important thing is to just jump in and get over that "lisp is
so hard" hump.  It's really not.  It's a different way of thinking
about programming, and I find that knowing Emacs lisp (I'm a novice
myself) actually helps me think about other code I write in different
ways.  It's kind of cool that way.

The great thing about Emacs is that it's self documenting, so the
trivial questions you have can be addressed by actually exploring Emacs

For example, your cperl-mode compile commands are missing.  So you
begin by asking Emacs about "cperl-mode":

<C-h> f

And Emacs shows you the help text associated this command  (See the
wiki for other ways Emacs documents itself, including the powerful
apropos features).

Now, you click on the underlined `cperl-mode', and open up the source
code.  You search for the name a missing menu item -- "Check Syntax",
and you find:

          ["Check syntax" cperl-check-syntax (fboundp 'mode-compile)]

This occurs in the `easy-menu-define' context, so you suspect that this
is where the menu item is defined.  Now what do these tokens mean?  The
first string is obvious.  Emacs tells you "cperl-check-syntax" is the
actual command that triggers the function.       (<C-h> f
cperl-check-syntax)  And "fboundp" checks if a feature is present.  You
evaluate the "(fboundp 'mode-compile)" sexp by placing the cursor on
"]" and pressinng <C-x><C-e>, and find that it's nil, meaning that the
"mode-compile" is missing.  You put it all together and parse this line
as -- define "Check Syntax" menu item, invoking `cperl-check-syntax' if
`mode-compile' feature is present.  Obviously it's failing because
`mode-compile' is missing.  You then do a web search and find that it's
available here:  "";.  You follow
the instructions on the web page and install the package.  Voila.  Now
you know Emacs as more than a "Notepad clone", and it all builds up
from there.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]