* Is there a mode that helps enforce coding guidelines?
@ 2003-05-28 14:05 Petter Wintzell
2003-05-28 16:27 ` Dan Anderson
` (4 more replies)
0 siblings, 5 replies; 12+ messages in thread
From: Petter Wintzell @ 2003-05-28 14:05 UTC (permalink / raw)
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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Is there a mode that helps enforce coding guidelines?
2003-05-28 14:05 Is there a mode that helps enforce coding guidelines? Petter Wintzell
@ 2003-05-28 16:27 ` Dan Anderson
2003-05-29 12:44 ` Kevin Dziulko
2003-05-28 16:43 ` Kai Großjohann
` (3 subsequent siblings)
4 siblings, 1 reply; 12+ messages in thread
From: Dan Anderson @ 2003-05-28 16:27 UTC (permalink / raw)
Cc: help-gnu-emacs
You could probably program one in eLISP. Don't ask me how, i'm still an
emacs noob. :)
-Dan
On Wed, 2003-05-28 at 10:05, Petter Wintzell wrote:
> 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
> _______________________________________________
> Help-gnu-emacs mailing list
> Help-gnu-emacs@gnu.org
> http://mail.gnu.org/mailman/listinfo/help-gnu-emacs
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Is there a mode that helps enforce coding guidelines?
2003-05-28 14:05 Is there a mode that helps enforce coding guidelines? Petter Wintzell
2003-05-28 16:27 ` Dan Anderson
@ 2003-05-28 16:43 ` Kai Großjohann
2003-05-28 17:03 ` Phillip Lord
2003-05-28 17:50 ` Sandip Chitale
` (2 subsequent siblings)
4 siblings, 1 reply; 12+ messages in thread
From: Kai Großjohann @ 2003-05-28 16:43 UTC (permalink / raw)
petter_wintzell@yahoo.com (Petter Wintzell) writes:
> 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.
For the line length, you could set the Emacs window to have the right
width. But I've also seen mention of vvb.el which draws a vertical
bar. Not sure if that is applicable.
Regarding indentation style, maybe C-x h C-M-\ is good enough? You
can configure the indentation engine quite a bit in most modes. For
C and similar, see the CC mode info file.
Alas, the Emacs indentation styles do not add or remove newlines, so
the hanging braces thing cannot be checked (if I assume correctly
what you mean). You can configure CC mode to auto-insert newlines
when you hit `{', I think.
The GNU indent program can add or remove newlines.
--
This line is not blank.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Is there a mode that helps enforce coding guidelines?
2003-05-28 16:43 ` Kai Großjohann
@ 2003-05-28 17:03 ` Phillip Lord
2003-05-28 18:29 ` Kai Großjohann
0 siblings, 1 reply; 12+ messages in thread
From: Phillip Lord @ 2003-05-28 17:03 UTC (permalink / raw)
>>>>> "Kai" == Kai Großjohann <kai.grossjohann@gmx.net> writes:
Kai> petter_wintzell@yahoo.com (Petter Wintzell) writes:
>> 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.
Kai> For the line length, you could set the Emacs window to have the
Kai> right width. But I've also seen mention of vvb.el which draws
Kai> a vertical bar. Not sure if that is applicable.
There is also my own wide-column.el. It changes the colour of the
cursor when the line gets too long. Cheesy eh?
Kai> Regarding indentation style, maybe C-x h C-M-\ is good enough?
Kai> You can configure the indentation engine quite a bit in most
Kai> modes. For C and similar, see the CC mode info file.
Kai> Alas, the Emacs indentation styles do not add or remove
Kai> newlines, so the hanging braces thing cannot be checked (if I
Kai> assume correctly what you mean). You can configure CC mode to
Kai> auto-insert newlines when you hit `{', I think.
`c-toggle-auto-state'.
I love it, although I am sad that it doesn't fix code that has already
been done "wrong".
Kai> The GNU indent program can add or remove newlines. -- This
Kai> line is not blank.
There are alternatives for other languages (the original poster didn't
say which language he wanted). I'm sure someone wrote a launcher for
"checkstyle" which works on java.
Cheers
Phil
^ permalink raw reply [flat|nested] 12+ messages in thread
* Is there a mode that helps enforce coding guidelines?
2003-05-28 14:05 Is there a mode that helps enforce coding guidelines? Petter Wintzell
2003-05-28 16:27 ` Dan Anderson
2003-05-28 16:43 ` Kai Großjohann
@ 2003-05-28 17:50 ` Sandip Chitale
2003-05-29 3:38 ` Peter Milliken
2003-06-03 15:58 ` Colin Marquardt
4 siblings, 0 replies; 12+ messages in thread
From: Sandip Chitale @ 2003-05-28 17:50 UTC (permalink / raw)
Well, there are some modes like JDEE (for Java) which integrate some external
utilities which check the style e.g. checkstyle. When run the utility emits
compiler error style output in a buffer. The error messages are hyperlinked to
the source. Integration is not exactly the way you asked for but it is useful.
sandip
petter_wintzell@yahoo.com (Petter Wintzell) wrote in message news:<f0077d93.0305280605.3f2e9e83@posting.google.com>...
> 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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Is there a mode that helps enforce coding guidelines?
2003-05-28 17:03 ` Phillip Lord
@ 2003-05-28 18:29 ` Kai Großjohann
2003-05-29 14:09 ` Phillip Lord
0 siblings, 1 reply; 12+ messages in thread
From: Kai Großjohann @ 2003-05-28 18:29 UTC (permalink / raw)
Phillip Lord <p.lord@russet.org.uk> writes:
> There is also my own wide-column.el. It changes the colour of the
> cursor when the line gets too long. Cheesy eh?
Cool. So it only checks the current line, ie the line that point is
on? I hope I don't forget to mention your package next time.
--
This line is not blank.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Is there a mode that helps enforce coding guidelines?
2003-05-28 14:05 Is there a mode that helps enforce coding guidelines? Petter Wintzell
` (2 preceding siblings ...)
2003-05-28 17:50 ` Sandip Chitale
@ 2003-05-29 3:38 ` Peter Milliken
2003-06-01 21:45 ` Alan Mackenzie
2003-06-02 10:37 ` Petter Wintzell
2003-06-03 15:58 ` Colin Marquardt
4 siblings, 2 replies; 12+ messages in thread
From: Peter Milliken @ 2003-05-29 3:38 UTC (permalink / raw)
*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" <petter_wintzell@yahoo.com> wrote in message
news:f0077d93.0305280605.3f2e9e83@posting.google.com...
> 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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Is there a mode that helps enforce coding guidelines?
2003-05-28 16:27 ` Dan Anderson
@ 2003-05-29 12:44 ` Kevin Dziulko
0 siblings, 0 replies; 12+ messages in thread
From: Kevin Dziulko @ 2003-05-29 12:44 UTC (permalink / raw)
It's not an answer to your exact question, but one could just make use of
the different styles, including home made ones. Just change the value of
c-set-style. So while coding at work, you could set it to a personal
style you've defined, set it to gnu style while working on open source
projects, etc.
This won't help you with highlighting rule-breakers, but could be usefull
in the meantime.
On 28 May 2003, Dan Anderson wrote:
> You could probably program one in eLISP. Don't ask me how, i'm still an
> emacs noob. :)
>
> -Dan
>
> On Wed, 2003-05-28 at 10:05, Petter Wintzell wrote:
> > 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
> > _______________________________________________
> > Help-gnu-emacs mailing list
> > Help-gnu-emacs@gnu.org
> > http://mail.gnu.org/mailman/listinfo/help-gnu-emacs
>
>
>
> _______________________________________________
> Help-gnu-emacs mailing list
> Help-gnu-emacs@gnu.org
> http://mail.gnu.org/mailman/listinfo/help-gnu-emacs
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Is there a mode that helps enforce coding guidelines?
2003-05-28 18:29 ` Kai Großjohann
@ 2003-05-29 14:09 ` Phillip Lord
0 siblings, 0 replies; 12+ messages in thread
From: Phillip Lord @ 2003-05-29 14:09 UTC (permalink / raw)
>>>>> "Kai" == Kai Großjohann <kai.grossjohann@gmx.net> writes:
Kai> Phillip Lord <p.lord@russet.org.uk> writes:
>> There is also my own wide-column.el. It changes the colour of the
>> cursor when the line gets too long. Cheesy eh?
Kai> Cool. So it only checks the current line, ie the line that
Kai> point is on? I hope I don't forget to mention your package
Kai> next time.
Yeah, it works on the current line. Its a "fix this as you go" kind of
package. I use a red cursor, which goes orange, then yellow, then
white as your line gets more absurd in length. The code is quite
generic. You could get it to flash the screen, make a beep, or with
emacs's new sound facilities, get it to play "Ride of the Valkyries"
progressively louder if you wanted.
As you can guess it was very wet and miserable one weekend, and I seem
to remember having the flu as well....
Phil
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Is there a mode that helps enforce coding guidelines?
2003-05-29 3:38 ` Peter Milliken
@ 2003-06-01 21:45 ` Alan Mackenzie
2003-06-02 10:37 ` Petter Wintzell
1 sibling, 0 replies; 12+ messages in thread
From: Alan Mackenzie @ 2003-06-01 21:45 UTC (permalink / raw)
In comp.emacs Peter Milliken <peterm@resmed.com.au> wrote:
[ .... ]
> 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.
After? You mean the stuff that gets executed when the condition
evaluates to non-zero? Don't confuse people!
There is always exactly one statement so bounded by an 'if'. Sometimes
this statement is empty (i.e. a bare semicolon), often it is a compound
statement. But it is always one statement. For some reason, people who
write coding standards frequently don't understand this, and it drives me
crazy!
> Peter
--
Alan Mackenzie (Munich, Germany)
Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Is there a mode that helps enforce coding guidelines?
2003-05-29 3:38 ` Peter Milliken
2003-06-01 21:45 ` Alan Mackenzie
@ 2003-06-02 10:37 ` Petter Wintzell
1 sibling, 0 replies; 12+ messages in thread
From: Petter Wintzell @ 2003-06-02 10:37 UTC (permalink / raw)
Thanks to everyone who replied to my posting with good advice!
What I wanted was a mode that could help me both write new code
according to some standard, and also check exisiting code to see that
the standard was followed. Also, it should be easy to switch between
coding standards.
There seems to be no such mode at the moment, even if the individual
issues (line length and what else I mentioned) can be solved easily
enough.
Thanks,
/Petter
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Is there a mode that helps enforce coding guidelines?
2003-05-28 14:05 Is there a mode that helps enforce coding guidelines? Petter Wintzell
` (3 preceding siblings ...)
2003-05-29 3:38 ` Peter Milliken
@ 2003-06-03 15:58 ` Colin Marquardt
4 siblings, 0 replies; 12+ messages in thread
From: Colin Marquardt @ 2003-06-03 15:58 UTC (permalink / raw)
petter_wintzell@yahoo.com (Petter Wintzell) writes:
> 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.
Take a look at <http://www.jpl.org/elips/develock.el.gz>:
,----
| ;;; Commentary:
|
| ;; Develock is a minor mode which provides the ability to make font-
| ;; lock highlight leading and trailing whitespaces, long lines and the
| ;; other garbages in the file buffer for Lisp modes, ChangeLog mode,
| ;; Texinfo mode, C modes, Java mode, Jde-mode , CPerl mode, Perl mode,
| ;; HTML modes and some Mail modes. Here is an example of how to set
| ;; up your startup file (possibly .emacs) to use Develock:
`----
HTH,
Colin
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2003-06-03 15:58 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-05-28 14:05 Is there a mode that helps enforce coding guidelines? Petter Wintzell
2003-05-28 16:27 ` Dan Anderson
2003-05-29 12:44 ` Kevin Dziulko
2003-05-28 16:43 ` Kai Großjohann
2003-05-28 17:03 ` Phillip Lord
2003-05-28 18:29 ` Kai Großjohann
2003-05-29 14:09 ` Phillip Lord
2003-05-28 17:50 ` Sandip Chitale
2003-05-29 3:38 ` Peter Milliken
2003-06-01 21:45 ` Alan Mackenzie
2003-06-02 10:37 ` Petter Wintzell
2003-06-03 15:58 ` Colin Marquardt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).