3

I am refactoring legacy code. Looks like:

for (int i = 0; i < something.length; i++) {
    .... 
    ....
    lots of code here
    ....
    if (a.good != b.bad) {
       ....
       ....  .... 
       ....
       lots of code here
       ....
       if (foo.bar == spam.something && something else) {
           .... 
           ....
           lots of code here
           ....
           I AM HERE SOMEWHERE. 
           ....
       }
    }
}

What happens a lot is, I am at a point in code and all I can see is basically small portion of the code. So I have to scroll to get the global context.

       if (foo.bar == spam.something && something else) {
           .... 
           ....
           lots of code here
           ....
           I AM HERE SOMEWHERE. 
           ....
       }

What I would like to see is something like:

for (int i = 0; i < something.length; i++) {
    ...
    if (a.good != b.bad) {
       ...
       if (foo.bar == spam.something && something else) {
           I AM HERE SOMEWHERE. 
           // code
       }
    }
}

I want emacs to collapse code between conditionals, loops and functions. If this happens automatically then that would be great. How can I do that?

2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.