Re: Code beautifiers, anyone?
For those who are interested, you can check out the response I also got from the FreeBSD mailinglist: http://lists.freebsd.org/pipermail/freebsd-questions/2006-August/subject.html#129680 All the best, Kyrre
Re: Code beautifiers, anyone?
At 03:24 25.08.2006, Nick Holland wrote: Yeah. Use vi or emacs. :) The OpenBSD developers spend a lot of time making code fit what they call "KNF" -- Kernel Normal Form, documented in style(7) They do it carefully by hand, not using automatic tools. Why? To get EYES ON THE CODE. Go look at the commit logs, they often end up catching errors doing this. Run your "ugly" code through an automatic beautifier, you end up with ugly code that now looks pretty...every bug remains, and your knowledge of what is in there doesn't improve. Sure, you might be able to read it better LATER, but the point is, you didn't read it NOW. If you don't, the bad guys may... Even though I'm not a coder, this technique helps me on the FAQ, as well. Take a chunk, "normalize" it, and then go "Eww. We can do better". :) Nick. Man, I don't know how to thank you enough for showing me the normal form! I had no idea a standard for this existed, or how to create one myself, but now I surely do and it's all thanks to you! All the best, Kyrre
Re: Code beautifiers, anyone?
On 24/08/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > It's possible you're already doing this, or are already aware, but > Vim (a text editor, http://vim.sf.net) does nice code formatting. > It has built-in support for just about everything. > > Once you get familiar with vim, you'll find you can re-format an > entire source file with a few keystrokes. > > Matt > > Vim works for me, but just occasionally it gets wrong. See if it fits your needs. Turn of vi compatibility mode (the example rc will do /usr/local/share/vim63/vimrc) Open your code vG (select all) followed by = should try to auto indent all your code. Regards Edd
Re: Code beautifiers, anyone?
Nick Holland wrote: > Use vi or emacs. :) Additionally for emacs users: You can define how c code should be indented for the openbsd project with this code in your .emacs. (defun KNF-c-style () "OpenBSD KNF C-style." (interactive) (local-set-key "\C-c\C-c" 'compile) (c-set-style "bsd") (setq fill-column 80) (setq c-basic-offset 8) (c-set-offset 'arglist-cont '*) (c-set-offset 'arglist-cont-nonempty '*) (c-set-offset 'statement-cont '4) ) (add-hook 'c-mode-common-hook 'KNF-c-style) # Han
Re: Code beautifiers, anyone?
> The OpenBSD developers spend a lot of time making code fit what they > call "KNF" -- Kernel Normal Form, documented in style(7) style(9) -p.
Re: Code beautifiers, anyone?
Kyrre Nygerd wrote: Hello people, I'm looking for the best ways to create a line of code beautification (reformatting) scripts -- one for C, one for Ruby, one for Bash and one for web development languages like XHTML, XML, CSS, PHP and Ajax. Whether as frontline warriors or household maids, they would ensure proper indentation, linebreaks, spaces, tabs and so forth. Can anybody help me? Yeah. Use vi or emacs. :) The OpenBSD developers spend a lot of time making code fit what they call "KNF" -- Kernel Normal Form, documented in style(7) They do it carefully by hand, not using automatic tools. Why? To get EYES ON THE CODE. Go look at the commit logs, they often end up catching errors doing this. Run your "ugly" code through an automatic beautifier, you end up with ugly code that now looks pretty...every bug remains, and your knowledge of what is in there doesn't improve. Sure, you might be able to read it better LATER, but the point is, you didn't read it NOW. If you don't, the bad guys may... Even though I'm not a coder, this technique helps me on the FAQ, as well. Take a chunk, "normalize" it, and then go "Eww. We can do better". :) Nick.
Re: Code beautifiers, anyone?
I have used tidy (for html) and perltidy to clean up messy/generated code in the past. Both are extremely customizable in the format they output code. Tim Donahue On Thu, 24 Aug 2006 14:59:31 +0200 Kyrre Nygerd <[EMAIL PROTECTED]> wrote: > Hello people, > > I'm looking for the best ways to create a line of code beautification > (reformatting) scripts -- one for C, one for Ruby, one for Bash and > one for web development languages like XHTML, XML, CSS, PHP and Ajax. > Whether as frontline warriors or household maids, they would ensure > proper indentation, linebreaks, spaces, tabs and so forth. > > Can anybody help me? > > My studies of architectural science has taught me to pay extreme care > to the correction of details, and I now wish to apply these teachings > to all my code. I find myself always reformatting whatever my > associates give me. Not that they're bad programmers, they just care > more about the code itself rather than its structure, and I dare not > argue with that. When their code is messy, however, my heart feels > messy and I can't get any sleep. > > I wish to be in full control of my code beautifiers. That is, I wish > to have them as simple and meaningful as possible. Give me an easy > Bash over a complex Ruby any day. > > There's a lot of messed up tools out there. Companies with flashy > websites just doing this for the money. So apart from the bullshit, > I've managed to spot out the Ruby Beautifier and GNU Indent as two > worthy code beautifiers. However I get the feeling they are more > complex than they ought to be, and if less is more, my search will > have to continue. > > All the best, > Kyrre
Re: Code beautifiers, anyone?
On Thu, Aug 24, 2006 at 02:59:31PM +0200, Kyrre Nyg?rd wrote: > to all my code. I find myself always reformatting whatever my > associates give me. Not that they're bad programmers, they just > care more about the code itself rather than its structure, and I > dare not argue with that. When their code is messy, however, my It's possible you're already doing this, or are already aware, but Vim (a text editor, http://vim.sf.net) does nice code formatting. It has built-in support for just about everything. Once you get familiar with vim, you'll find you can re-format an entire source file with a few keystrokes. Matt
Re: Code beautifiers, anyone?
On Thu, Aug 24, 2006 at 02:59:31PM +0200, Kyrre Nyg?rd wrote: > Hello people, > > I'm looking for the best ways to create a line of code beautification > (reformatting) scripts -- one for C, one for Ruby, one for Bash and > one for web development languages like XHTML, XML, CSS, PHP and Ajax. > Whether as frontline warriors or household maids, they would ensure > proper indentation, linebreaks, spaces, tabs and so forth. Why create when they already exist? > Can anybody help me? > > My studies of architectural science has taught me to pay extreme care > to the correction of details, and I now wish to apply these teachings > to all my code. I find myself always reformatting whatever my > associates give me. Not that they're bad programmers, they just care > more about the code itself rather than its structure, and I dare not > argue with that. When their code is messy, however, my heart feels > messy and I can't get any sleep. While I, too, like neat code, it really isn't too difficult to run stuff through indent(1) or similar. > I wish to be in full control of my code beautifiers. That is, I wish > to have them as simple and meaningful as possible. Give me an easy > Bash over a complex Ruby any day. > > There's a lot of messed up tools out there. Companies with flashy > websites just doing this for the money. Well, that's what a company is for. > So apart from the bullshit, > I've managed to spot out the Ruby Beautifier and GNU Indent as two > worthy code beautifiers. However I get the feeling they are more > complex than they ought to be, and if less is more, my search will > have to continue. Okay... but where's the question? Even in the ports tree, I see devel/astyle (C, C++, Java), devel/gindent (GNU indent), and devel/perltidy (for Perl, obviously). There's also www/tidy for HTML and such, though I don't think it does PHP well. (And what the heck is Ajax in this context? Do you, perhaps, mean javascript?) True, it looks like you'd have to make your own port for that Ruby beautifier... and I have no clue about how complex these utilities might be, but I can personally testify that www/tidy and indent(1) can be pretty useful. Joachim
Code beautifiers, anyone?
Hello people, I'm looking for the best ways to create a line of code beautification (reformatting) scripts -- one for C, one for Ruby, one for Bash and one for web development languages like XHTML, XML, CSS, PHP and Ajax. Whether as frontline warriors or household maids, they would ensure proper indentation, linebreaks, spaces, tabs and so forth. Can anybody help me? My studies of architectural science has taught me to pay extreme care to the correction of details, and I now wish to apply these teachings to all my code. I find myself always reformatting whatever my associates give me. Not that they're bad programmers, they just care more about the code itself rather than its structure, and I dare not argue with that. When their code is messy, however, my heart feels messy and I can't get any sleep. I wish to be in full control of my code beautifiers. That is, I wish to have them as simple and meaningful as possible. Give me an easy Bash over a complex Ruby any day. There's a lot of messed up tools out there. Companies with flashy websites just doing this for the money. So apart from the bullshit, I've managed to spot out the Ruby Beautifier and GNU Indent as two worthy code beautifiers. However I get the feeling they are more complex than they ought to be, and if less is more, my search will have to continue. All the best, Kyrre