Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#59 Enhanced Indentation Methods

open
nobody
None
5
2004-02-25
2004-02-25
Wally Crooze
No

It would be very useful to have an indent style which
would allow the reader to select a tab spacing (some
prefer 2,3,4 or 8) of there choice and the code would
be "pretty". To achieve this tabs would be used for
indents and spaces for line continuation (beyond ancor)
and inline alignment.

Part a): Enhancement to AutoIndent

I would like Nedit to be able to be configured to
indent with a mixture of tabs and spaces. The idea is
that for normal code indentation it uses tabs, but for
line continuation I would like to see tabs used up to
the beginning of the anchor and then continue on with
spaces.

Example: Note (-> represents a tab)

->for (i = 0; i < 10; i++) {
->->result = dog(arg1,arg2,arg3);
->->printf("The results of dog(%d,%d,%d) is %d\n",
->-> arg1,arg2,arg3,result);
->}

What this allows is the tab spacing to be of any size
(readers choice) and that the code will still be
"pretty", i.e. the arguments for printf will be aligned
following the open paranthesis no matter what.

This could be achieved by returning a float from the
NewLine macro. The integar part being number of spaces
to add and decimal part (to precision of 2) being
number of spaces to add after the tabs... e.g. 3.02
would mean 3 tabs and 2 spaces, 3.2 would be 3 tabs and
20 spaces. Anybody who requires more than 99 spaces
needs a labotomy.

Part b): Configurable through Tabs Preference
An option to use spaces for non-indentation alignment
would be good to, i.e. inline alignment. Such as
aligning parameter definitions:

->int i;
->float f;
->sema s;

or inline comment alignment:

->page = a & PAGE_MASK; // Get start
of current page
->next = (a + PAGE_SIZE) & PAGE_MASK; // Get start
of next page

Discussion

  • Wally Crooze
    Wally Crooze
    2004-08-20

    Logged In: YES
    user_id=530199

    Suggestions on how to implement this would be nice?!

     
  • Thorsten Haude
    Thorsten Haude
    2004-08-20

    Logged In: YES
    user_id=119143

    a) looks nice, though I'm not sure if the actual effect is
    actually useful. Without looking at the code, I would
    suggest an array instead of the float.
    b) could probably be done by letting the type-in macro
    change the tab stop setting.

     
  • Wally Crooze
    Wally Crooze
    2004-08-24

    Logged In: YES
    user_id=530199

    It makes it "tab size" independant... everyone has their own
    preference and when many people are sharing the same code...
    such as an open-source project it becomes distracting.

    The fact the people are now adding editor specific comments
    in the file to indicate what tab-spacing and other options
    the file should conform to. YUK!

    Option b may be the way to go... eliminating the "newline"
    option.

     
  • Thorsten Haude
    Thorsten Haude
    2004-08-24

    Logged In: YES
    user_id=119143

    My guess is that neither of these two will be directly
    hardcoded in NEdit. Option a) is of limited use as long as
    there there are people using another pattern, b) is a case
    of YCDIWAM (you can do it with a macro).

    However, I agree that the interfaces of the three smart
    indent macro blocks should be more powerful. I suggest that
    we think about this independent of this particular problem.
    Maybe there are other application possible with a good
    interface. This could bring more people in the boat.

     
  • Wally Crooze
    Wally Crooze
    2004-08-24

    Logged In: YES
    user_id=530199

    I just want more power... I'm happy for another Bug or RFE
    to be opened and this related to it. I will try to define a
    macro using option b to suit myself and will publish it in
    this RFE. Maybe this can eventually become a part of the
    default AutoIndent for most languages.

     
  • Thorsten Haude
    Thorsten Haude
    2004-08-24

    Logged In: YES
    user_id=119143

    My guess is that neither of these two will be directly
    hardcoded in NEdit. Option a) is of limited use as long as
    there there are people using another pattern, b) is a case
    of YCDIWAM (you can do it with a macro).

    However, I agree that the interfaces of the three smart
    indent macro blocks should be more powerful. I suggest that
    we think about this independent of this particular problem.
    Maybe there are other application possible with a good
    interface. This could bring more people in the boat.