Go Back   Rhinocerus > Newsgroup > Newsgroup comp.lang.java.* > Newsgroup comp.lang.java.programmer

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 06-19-2009, 07:53 PM
Ion Freeman
Guest
 
Posts: n/a
Default Condensed close curly braces at end of Java code blocks in Eclipse

Hi!
Frankly, most of the code I write is for publication somewhere, so
I try to keep everything within eighty columns and use vertical space
efficiently. I'm new to Eclipse, and I'd like to set up this behavior:
When a number of braced blocks end together at the end of a method
body or class, I'd like to compress them all. So
class outer{
class inner{
method body(){
for(){
if(){
finally{
// would have the final line
} } } } } }
-- visually every block of code is closed, but it's strictly in the
opposite order, so that all the closures happen on one line.

I'm having some trouble getting Eclipse to do this -- it doesn't seem
to be built in and I don't know where to start scripting it. I imagine
this is a pretty popular thing to do, so I was hoping there was a
snappable way I could get it done.

Can someone help me?

Ion
Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

  #2 (permalink)  
Old 06-19-2009, 08:43 PM
Donkey Hottie
Guest
 
Posts: n/a
Default Re: Condensed close curly braces at end of Java code blocks in Eclipse

"Ion Freeman" <ionfreeman@gmail.com> wrote in message
news:e8b5fac5-953d-45a1-8328-50a6c5c30d71@n8g2000vbb.googlegroups.com
> Hi!
> Frankly, most of the code I write is for publication
> somewhere, so I try to keep everything within eighty
> columns and use vertical space efficiently. I'm new to
> Eclipse, and I'd like to set up this behavior: When a
> number of braced blocks end together at the end of a
> method body or class, I'd like to compress them all. So
> class outer{
> class inner{
> method body(){
> for(){
> if(){
> finally{
> // would have the final line
> } } } } } }
> -- visually every block of code is closed, but it's
> strictly in the opposite order, so that all the closures
> happen on one line.
>
> I'm having some trouble getting Eclipse to do this -- it
> doesn't seem to be built in and I don't know where to
> start scripting it. I imagine this is a pretty popular
> thing to do, so I was hoping there was a snappable way I
> could get it done.
>


That looks awful. I understand the eighty columns limit, but saving vertical
space. Personally, I always put every curly brace on it own line.

Reply With Quote
  #3 (permalink)  
Old 06-19-2009, 09:27 PM
Peter Duniho
Guest
 
Posts: n/a
Default Re: Condensed close curly braces at end of Java code blocks inEclipse

On Fri, 19 Jun 2009 13:43:19 -0700, Donkey Hottie <donkey@fred.pp.fi>
wrote:

> [...]
>> I'm having some trouble getting Eclipse to do this -- it
>> doesn't seem to be built in and I don't know where to
>> start scripting it. I imagine this is a pretty popular
>> thing to do, so I was hoping there was a snappable way I
>> could get it done.

>
> That looks awful. I understand the eighty columns limit, but saving
> vertical space. Personally, I always put every curly brace on it own
> line.


Ditto. And even for those that use the "K&R" bracing style, the closing
braces have their own line.

Actually, I don't have any problem if someone really wants to format their
own code that way. If I knew how to convince Eclipse to do the braces
that way, I'd be happy to share that information. (But, I don't...sorry).

But a) I'd suggest it's not really the best way to publish code (even the
"K&R" style was supposedly mainly about conserving space in their book,
and they didn't wind up putting a bunch of closing braces on the same
line), and b) I'd certainly disagree that this is "a pretty popular thing
to do". I also foresee problems getting Eclipse to do it, as unlike other
bracing styles, doing it this way would require progressively accounting
for previously-existing blocks other than just for indentation, something
I think it's likely Eclipse just wasn't build to handle.

Pete
Reply With Quote
  #4 (permalink)  
Old 06-19-2009, 09:38 PM
Robert Klemme
Guest
 
Posts: n/a
Default Re: Condensed close curly braces at end of Java code blocks in Eclipse

On 19.06.2009 21:53, Ion Freeman wrote:

> Frankly, most of the code I write is for publication somewhere, so
> I try to keep everything within eighty columns and use vertical space
> efficiently. I'm new to Eclipse, and I'd like to set up this behavior:
> When a number of braced blocks end together at the end of a method
> body or class, I'd like to compress them all. So
> class outer{
> class inner{
> method body(){
> for(){
> if(){
> finally{
> // would have the final line
> } } } } } }
> -- visually every block of code is closed, but it's strictly in the
> opposite order, so that all the closures happen on one line.
>
> I'm having some trouble getting Eclipse to do this -- it doesn't seem
> to be built in and I don't know where to start scripting it. I imagine
> this is a pretty popular thing to do, so I was hoping there was a
> snappable way I could get it done.


If this happens frequently in your code you should probably rethink your
designs - especially how much you stuff into a single method. I have
rarely more than three consecutive closing brackets so I would not feel
the need to save that much vertical space.

Kind regards

robert

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
Reply With Quote
  #5 (permalink)  
Old 06-19-2009, 11:01 PM
Mark Rafn
Guest
 
Posts: n/a
Default Re: Condensed close curly braces at end of Java code blocks in Eclipse

Ion Freeman <ionfreeman@gmail.com> wrote:
>Hi!
> Frankly, most of the code I write is for publication somewhere, so
>I try to keep everything within eighty columns and use vertical space
>efficiently.


I'm down with that. I woudn't want to give up easy editing by myself or
others in pursuit of such, though.

>body or class, I'd like to compress them all. So
>class outer{
> class inner{
> method body(){
> for(){
> if(){
> finally{
> // would have the final line
>} } } } } }
>-- visually every block of code is closed, but it's strictly in the
>opposite order, so that all the closures happen on one line.


Eww. I'd object if I ever had to edit the code, but I guess for some
publications it'd be ok.

>I'm having some trouble getting Eclipse to do this


Yeah, it's probably a fairly uncommon formatting preference.

My recommendation: use java standards in your editor, including a bit more
indenting and spending the vertical space to give ending braces their own
line, and then format for publication as needed, based on the needs for that
specific use. Print snippets could compress the way you show, online could
stay more standard.

--
Mark Rafn dagon@dagon.net <http://www.dagon.net/>
Reply With Quote
  #6 (permalink)  
Old 06-20-2009, 01:28 AM
Tom Anderson
Guest
 
Posts: n/a
Default Re: Condensed close curly braces at end of Java code blocks inEclipse

On Fri, 19 Jun 2009, Ion Freeman wrote:

> Frankly, most of the code I write is for publication somewhere, so
> I try to keep everything within eighty columns and use vertical space
> efficiently. I'm new to Eclipse, and I'd like to set up this behavior:
> When a number of braced blocks end together at the end of a method
> body or class, I'd like to compress them all. So
> class outer{
> class inner{
> method body(){
> for(){
> if(){
> finally{
> // would have the final line
> } } } } } }
> -- visually every block of code is closed, but it's strictly in the
> opposite order, so that all the closures happen on one line.
>
> I'm having some trouble getting Eclipse to do this -- it doesn't seem
> to be built in and I don't know where to start scripting it. I imagine
> this is a pretty popular thing to do, so I was hoping there was a
> snappable way I could get it done.


Switch to python.

tom

--
NO REAL THAN YOU ARE -- Ego Leonard, The Zandvoort Man
Reply With Quote
  #7 (permalink)  
Old 06-20-2009, 03:50 PM
Robert Klemme
Guest
 
Posts: n/a
Default Re: Condensed close curly braces at end of Java code blocks inEclipse

On 20.06.2009 03:28, Tom Anderson wrote:
> On Fri, 19 Jun 2009, Ion Freeman wrote:


>> finally{
>> // would have the final line
>> } } } } } }
>> -- visually every block of code is closed, but it's strictly in the
>> opposite order, so that all the closures happen on one line.


> Switch to python.


I would getting rid of all the brackets consider to be cheating. :-)

Cheers

robert

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
Reply With Quote
  #8 (permalink)  
Old 06-20-2009, 07:32 PM
Seamus MacRae
Guest
 
Posts: n/a
Default Re: Condensed close curly braces at end of Java code blocks in Eclipse

Ion Freeman wrote:
> Hi!
> Frankly, most of the code I write is for publication somewhere, so
> I try to keep everything within eighty columns and use vertical space
> efficiently. I'm new to Eclipse, and I'd like to set up this behavior:
> When a number of braced blocks end together at the end of a method
> body or class, I'd like to compress them all. So
> class outer{
> class inner{
> method body(){
> for(){
> if(){
> finally{
> // would have the final line
> } } } } } }
> -- visually every block of code is closed, but it's strictly in the
> opposite order, so that all the closures happen on one line.


Eeeuw. How ... Lispy.
Reply With Quote
  #9 (permalink)  
Old 06-24-2009, 02:05 AM
Arne Vajhøj
Guest
 
Posts: n/a
Default Re: Condensed close curly braces at end of Java code blocks in Eclipse

Ion Freeman wrote:
> Frankly, most of the code I write is for publication somewhere, so
> I try to keep everything within eighty columns and use vertical space
> efficiently. I'm new to Eclipse, and I'd like to set up this behavior:
> When a number of braced blocks end together at the end of a method
> body or class, I'd like to compress them all. So
> class outer{
> class inner{
> method body(){
> for(){
> if(){
> finally{
> // would have the final line
> } } } } } }
> -- visually every block of code is closed, but it's strictly in the
> opposite order, so that all the closures happen on one line.
>
> I'm having some trouble getting Eclipse to do this -- it doesn't seem
> to be built in and I don't know where to start scripting it. I imagine
> this is a pretty popular thing to do, so I was hoping there was a
> snappable way I could get it done.


If you publish Java code, then you should follow Java coding
convention.

Arne
Reply With Quote
 
Reply

Popular Tags in the Forum
blocks, braces, close, code, condensed, curly, eclipse, end, java

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT. The time now is 04:26 PM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.