[Eric] Dedent of def in classes?

Geert Vancompernolle geert.eric4 at gmail.com
Tue Jan 6 18:04:19 GMT 2009


Detlev Offenbach wrote:
> On Freitag, 2. Januar 2009, Geert Vancompernolle wrote:
>   
>> Hi,
>>
>> When selecting "Settings | Preferences... | Editor | Typing", you can
>> select to configure typing for Python and Ruby.  When selecting Python,
>> you have the option to chose for automatic dedents of "else/elif" and
>> "except/finally".
>>
>> That same mechanism would be very handy for "def" when writing classes
>> too, but  I can't find a way to do that.
>>     
>
> What should be the dedent criteria for this use case?
>   
I would say, the moment the 4 chars "def " are typed, one could dedend 
the line according the following criteria:

"if there was a previous "def", the following "def" should start at the 
same column, else the "def" should start at column 1"

This would catch 2 cases:
* the "def" belongs to a class: this "def" would start 4 char locations 
to the right, compared to the column the class was started.  Subsequent 
"def" statements would start at the same indented column
* the "def" is an isolated function: this "def" should start at column 
1.  Subsequent "def" statements should also start at location 1, since 
they will also not be part of a class

If the writer has defined a class with several "def" statements and he 
now wants to define an "isolated" "def", he can dedend by typing 
Shift-Tab (or whatever, to move the cursor to column 1).  From then 
onwards, al subsequent "def" statements would also start at location 1, 
until again a class is defined.

I might overlook other situations, but this could be taken as a start.

-- 
Best rgds,

Geert
________________________________________________

*Use EcoCho <http://www.ecocho.com>: environmentally friendly search the 
internet!*


More information about the Eric mailing list