- Subject: Re: Looking for Python programmers for testing.
- From: "G. Milde" <g.milde@xxxxxx>
- Date: Thu, 23 Nov 2006 17:57:50 +0100
On 12.09.06, G. Milde wrote:
> On 11.09.06, Jörg Sommer wrote:
Unfortunately, the patch doesnot solve the problem of mixed TAB and Space
use for indenting code lines.
Example
USE_TABS = 1; TAB = 8; Py_Indent_Level = 4;
After pressing TAB on every of the code lines below, the second is indented
with 4 spaces while the third is indented with one tab and the last with a
mix of tab and spaces in one line!
def unindent(self, indent=None):
if indent is None:
if self.min_indent():
return
The problem is, that whitespace() will insert a mixture of tabs and
spaces as long as TAB != 0 and USE_TABS != 0. This might be solved by
using insert_spaces() instead of whitespace().
> > The old version sets TAB to zero if Py_Indent_Level != 8.
I now see the idea behind this approach: the Python interpreter does an
'untab' with a tab value of 8:
tabs are replaced (from left to right) by one to eight spaces such
that the total number of characters up to and including the
replacement is a multiple of eight
-- python2.4/html/ref/indentation.html
I.e. any other TAB setting will lead to immediate problems if tabs and
spaces are mixed in the script. Still ...
> I see two problems with this setting:
> 1. It would set TAB = 0 even if Tabs are used in the buffer
> 2. It uses the setting of Py_Indent_Level to determine if the user wants
> tabs to indent python code.
i.e. with the unpatched code, it is impossible to use "indent
with 8 spaces".
My new proposal is
Py_Indent_Level
USAGE
variable Py_Indent_Level = 4
DESCRIPTION
`Py_Indent_Level' is the default, used for the buffer-local
indent-level, for a buffer without indented code lines (e.g. a new one).
The pre-set value of 4 spaces corresponds to the "Style Guide for Python
Code" (http://www.python.org/dev/peps/pep-0008/)
The special value 0 means use hard tabs ("\t") for indentation.
i.e. instead of
* iferring the use of tabs from the relation of
Py_Indent_Level and TAB
> > >> + set_blocal_var(Py_Indent_Level == TAB, "py_use_tab");
or
* a second custom var for tab or spaces
> > > introducing a variable Py_Use_Tabs ...
tab use is mandated by Py_Indent_Level == 0. As no-one wants to
indent with 0 spaces, this will not limit the choice.
As a side effect: if the buffer local variable "py_use_tab" is replaced
by "py_indent_level" with a similar coding, auto-detection of indentation
can also determine and store the number of spaces used for one indent
level.
Two more problems with auto-detection in the dpatch:
long literal strings with ''' ''' are not skipped
continuation lines (other than """ """ strings) are not detected.
> > Inconsistent cases must be fixed by the user.
> Agreed. It would be nice if the auto-detection issued a warning in case
> of mixed tabs and spaces, though.
> Providing a function that replaces Tabs in indented code lines
> with Py_Indent_Level spaces might further facilitate this task.
The new version of pymode at jedmodes.sf.net/mode/pymode/ does
both. It comes with extensive documentation and a mode menu.
Günter
--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.
[2006 date index]
[2006 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]