pymode.sl patch not working
G. Milde
g.milde at quantentunnel.de
Mon Dec 4 08:42:33 CET 2006
Dear fellow packagers,
The jed/trunk/debian/patches/fix-pymode-tab-space.dpatch
doesnot work as I would expect:
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().
Should I file a bugreport or reopen the bug?
Should I try to patch the patch? (Alas, I do
not have expertise in producing of modifying dpatches.)
My proposal for a remedy would be a split of the jedmodes-version of
pymode into
pymode.sl -- basic updated pymode without non-standard dependencies
py-extra.sl -- additional functions for users with slang-extensions
installed
The basic pymode.sl should then also be suggested as update for the
upstream distro.
----- Forwarded message from "G. Milde" <g.milde at web.de> -----
From: "G. Milde" <g.milde at web.de>
To: jed-users-l at elara.jtan.com
Subject: Re: Looking for Python programmers for testing.
Mail-Followup-To: jed-users-l at elara.jtan.com
On 12.09.06, G. Milde wrote:
Unfortunately, the patch doesnot solve the problem of mixed TAB and Space
use for indenting code lines.
... [ Example moved up ]
> > 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 hardwired 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
SYNOPSIS
Number of spaces to indent a code block
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
* inferring 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
----- End forwarded message -----
More information about the Pkg-jed-devel
mailing list