help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Is there a mode that helps enforce coding guidelines?


From: Peter Milliken
Subject: Re: Is there a mode that helps enforce coding guidelines?
Date: Thu, 29 May 2003 13:38:38 +1000

*some* of this list could be achieved using code
abbreviations/templates/skeletons whatever you want to call them i.e.
write/generate the code in the correct format/framework to begin with -
these tools will help with indentation and where to put braces etc
(depending upon the language of course :-)). They also generate the code
constructs in their entirety i.e. it saves on typing - which leads to higher
productivity, plus you nolonger have to worry about certain syntax errors
caused by forgetting to add a ';' or a clasing '}' (or worst of all - an
extra ';' in the wrong place!). Imagine hitting 3 keys to get the following:

    if ({expression}) {
        {statement}...
    }
    [elsif_part]...
    [else_part]

Then all you have to do is fill in the blanks and delete what isn't wanted
(single command). Or, 3 keystrokes to get this:

    switch ({expression}) {
        [case_part]...
        default :
            [statement]...
            break;
    }

There are quite a few utilities available for Emacs in this area, some come
standard with Emacs, others are add-ons available from the Internet
repositories. Ones that I know of are template.el, skeleton.el (both come
standard with Emacs) and a package I have authored called else-mode.el
(http://www.zipworld.com.au/~peterm). There is plenty of help available for
any of these, skeleton is the most popular and you can see good examples of
its use in the java mode stuff. I believe there is documentation being
compiled on Emacs Wiki for skeleton, ELSE (else-mode.el) comes with a
comprehensive users manual. So there shouldn't be any impediment to getting
code structures generated in the correct format at least.

I personally find coding templates a big help when moving between different
coding standards i.e. one project wants the opening { on the same line as
the if statement, the next project wants it on the line following, the next
project doesn't want one at all unless there are multiple statements after
the if! :-) All of these and more are easily configurable and available with
minimal work.

In the meantime, good luck with your search :-)

Peter


"Petter Wintzell" <address@hidden> wrote in message
news:address@hidden
> Hi,
>
> Is there an Emacs mode that can help a programmer follow a set of
> coding guidelines and style rules? I am thinking of the simple rules
> that exist in many companies and projects regarding line length,
> comment style, indent style, hanging braces, variable names and what
> not.
>
> I would like a mode that highlighted the text when I broke a
> guideline. It would also be nice if the mode could help me correct the
> error.
>
> One thing that would also be nice is if one could switch between
> different rule sets, so that I can easily have one set of rules when
> coding at work, one when coding at home, one when participating in a
> particular open source project, etc.
>
> Is there any such mode or functionality?
>
> Regards,
> /Petter




reply via email to

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