Mailing List Archive

Xemacs Python Mode.
Hi,

Does anyone know if I can set emacs mode to indent with ONLY tabs? (and
if so, how?) While I'm at it I'd like the tabs to show up as four spaces
while in Python mode also.

Personally, I prefer the only spaces method, but I'm transfering code
between Linux and the Mac a lot, and all the Mac editors seem to use
tabs. combining the two makes for a big mess if you use different
editors, so I guess I need to just go with all tabs.

-Thanks,

-Chris




--
Christopher Barker,
Ph.D.
cbarker@jps.net --- --- ---
http://www.jps.net/cbarker -----@@ -----@@ -----@@
------@@@ ------@@@ ------@@@
Water Resources Engineering ------ @ ------ @ ------ @
Coastal and Fluvial Hydrodynamics ------- --------- --------
------------------------------------------------------------------------
------------------------------------------------------------------------
Xemacs Python Mode. [ In reply to ]
Chris Barker wrote:
>
> Hi,
>
> Does anyone know if I can set emacs mode to indent with ONLY tabs? (and
> if so, how?) While I'm at it I'd like the tabs to show up as four spaces
> while in Python mode also.
>

I have my emacs setup to use one tab per indent level, and to display
tabs as four spaces. I believe that this is all controlled by the
following three settings found in the customization section of my .emacs
file.


(custom-set-variables
'(py-indent-offset 4)
'(tab-width 4)
'(py-smart-indentation nil)
...
)

--
Dr. Gary Herron <gherron@aw.sgi.com>
206-287-5616
Alias | Wavefront
1218 3rd Ave, Suite 800, Seattle WA 98101
Xemacs Python Mode. [ In reply to ]
Thanks Gary,

This gets me close enough to be functional, but isn't quite there. The
problem is that if there are spaces in there, it won't reset them to
tabs, which is what I would like. For the most part, it won't be an
issue, but I'd just like it to be totally consistent.

What I really want is for Python mode to have an option like
"use-only-tabs" or "use-only-spaces". In fact all you would really need
to do is have py-indent settable to an arbitrary string, rather that an
integer. Then folks could set it to be four spaces, or a tab, or two
tabs, or whatever.

Quite frankly, I'm confused as to why anyone would think it's a good
idea to mix tabs and spaces at all, but that's what we're stuck with.



Gary Herron wrote:
> Chris Barker wrote:
> > Does anyone know if I can set emacs mode to indent with ONLY tabs? (and
> > if so, how?) While I'm at it I'd like the tabs to show up as four spaces
> > while in Python mode also.
> >
>
> I have my emacs setup to use one tab per indent level, and to display
> tabs as four spaces. I believe that this is all controlled by the
> following three settings found in the customization section of my .emacs
> file.
>
> (custom-set-variables
> '(py-indent-offset 4)
> '(tab-width 4)
> '(py-smart-indentation nil)
> ...
> )


--
Christopher Barker,
Ph.D.
cbarker@jps.net --- --- ---
http://www.jps.net/cbarker -----@@ -----@@ -----@@
------@@@ ------@@@ ------@@@
Water Resources Engineering ------ @ ------ @ ------ @
Coastal and Fluvial Hydrodynamics ------- --------- --------
------------------------------------------------------------------------
------------------------------------------------------------------------
Xemacs Python Mode. [ In reply to ]
Chris> This gets me close enough to be functional, but isn't quite
Chris> there. The problem is that if there are spaces in there, it won't
Chris> reset them to tabs, which is what I would like.

Sounds like a one-shot pass over the code with sed, tr, indent or Emacs'
tabify command should do the trick. I'm not used to TAB==SPC*4 mode, so I
won't hazard a guess at the appropriate settings, but a little
experimentation should converge on a solution fairly quickly.

In fact, maybe Emacs' tabify command will just do the right thing if you
have tab-width set properly. Try C-h f tabify RET.

Skip Montanaro | http://www.mojam.com/
skip@mojam.com | http://www.musi-cal.com/~skip/
847-475-3758
Xemacs Python Mode. [ In reply to ]
>>>>> "SM" == Skip Montanaro <skip@mojam.com> writes:

SM> In fact, maybe Emacs' tabify command will just do the right
SM> thing if you have tab-width set properly. Try C-h f tabify
SM> RET.

M-x tabify should do it unless you have different indentation levels
(some with equiv 4 spaces, some with equiv 8 spaces). In that case,
tho' I haven't tried it, I'm guessing Gordon's tabcleaner.py should do
the trick nicely.

ftp://ftp.python.org/pub/python/contrib/All/tabcleaner.py

-Barry