jed-users mailing list

[2005 Date Index] [2005 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: [Pkg-jed-devel] Bug#305668: jed mixes tabs and spaces in python mode


A user sent a bug-report via the Debian bugreprot system:

On 21.04.05, Vincent Bernat wrote:
> Package: jed
> Version: 0.99.16-5
> Severity: normal
> 
> When writing programs using python-mode, jed mixes tabs and spaces.
 
> Using indent=4, tab=8 is the worse setup :
 
> Here is what Guido recommends :
> 
> Indentation
> Use the default of Emacs Python-mode: 4 spaces for one indentation
> level.
 
> Tabs or Spaces?
> Never mix tabs and spaces. The most popular way of indenting Python is
> with spaces only. 
 
> See :
>   <URL:http://www.python.org/doc/essays/styleguide.html>
> 
> This bug is very annoying when opening the code with an editor (like
> Emacs) that says that indent=4 and tab=4.

The fast fix would be a line 
  TAB = 4;
in python_mode() for a consistent indent-tab behaviour. 

Until this is fixed, you can define a mode-hook in your .jedrc

define python_mode_hook ()
{
   TAB = 4;
}



For the most popular way (only spaces), set

   USE_TABS = 0;

in your .jedrc. 

However this is global to jed. If you want a fix only for python files,
you need to define the python_mode_hook as

define python_mode_hook ()
{
   TAB = 0;
}


The problem is how to handle existing files with TABs in them. 

We can convert them to spaces-only with untab_buffer(), a small helper
function in 
  jedmodes.sf.net/mode/bufutils/ 
however, we have to make sure, the variable TAB is correct, before doing 
this (as untab replaces a '\t' with TAB spaces.

public define untab_buffer()
{
   push_spot();
   mark_buffer();
   untab();
   pop_spot();
}


Single lines with TABs are easily reformatted pressing Key_Tab (i.e. with
indent-line), but auto-formatting the whole buffer with indent_buffer()
fails in most cases (because of the "missing" braces in python).


Günter



-- 
G.Milde web.de

--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.


[2005 date index] [2005 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]