Re: best to have max width of 79 or 80 in source code?
Xah Lee <xahlee <at> gmail.com>
2008-12-01 02:54:39 GMT
On Nov 30, 5:45 pm, "seber... <at> spawar.navy.mil"
<seber... <at> spawar.navy.mil> wrote:
> On Nov 30, 12:50 pm,XahLee<xah... <at> gmail.com> wrote:
>
> > in my opinion, hard wrappnig lines or in general any manual code
> > formatting is a major damage in computing, to the degree that
> > influenced bad tools and language design which forces humans to think
> > and do what dumb machines can easily automate. The line wrapping
> > convention largely spurred the perpetual time wasted on arguing about
> > code formatting and tools about it.
>
> I read some of the links you posted. I like idea of Emacs
> automagically handling wrapping but one of those links seemed to
> suggest that C and Python and Perl weren't amenable to this.
One cannot auto-format Python source code due to the fact that
formatting is part of the syntax, but C and Perl can to a large
extent. (the automatting needn't be something like 100% “perfect” to
be useful. (but it should be 100% correct. That is, the reformatted
code should not break the code))
actually, having learned a lot elisp in the past couple of years, i
think it's rather trivial to do. Basically, the command will just need
to inseart line breaks in the right places in the source code, then
call indent-region. (i.e. utilizing emacs's existing functions that
handle indentation for each lang.)
The tricky part would be to not break lines if it is inside string.
But there are existing function(s) to determine if cursor is inside
string. Also, lines must not be cut when inside comment block.
(Continue reading)