Discussion:
[Swig-devel] Coding Style
Phineas Campbell
2015-04-17 10:12:54 UTC
Permalink
I am interested in helping the swig community and would like some
clarification on style.

Obviously when it comes to writing Python I will use PEP 8 however I notice
in the examples and auto generated c/c++ code the indentation level is 2
spaces.

I am not writing production code but would like to follow conventions for my
own work

Phineas Campbell
Miklos Vajna
2015-04-20 20:06:05 UTC
Permalink
Hi,
Post by Phineas Campbell
I am interested in helping the swig community and would like some
clarification on style.
Obviously when it comes to writing Python I will use PEP 8 however I notice
in the examples and auto generated c/c++ code the indentation level is 2
spaces.
I am not writing production code but would like to follow conventions for my
own work
If you use vim, you can put something like this to your vimrc:

au BufRead */swig*/* set tabstop=8 | set shiftwidth=2 | set softtabstop=2 | set expandtab " SWIG
au BufRead */swig*/Source/* set tabstop=8 | set shiftwidth=2 | set softtabstop=2 | set noexpandtab " SWIG Source
au BufNewFile,BufRead *.i set filetype=swig
au BufNewFile,BufRead *.swg set filetype=swig

HTH,

Miklos
Vadim Zeitlin
2015-04-22 21:56:39 UTC
Permalink
On Mon, 20 Apr 2015 22:06:05 +0200 Miklos Vajna <***@vmiklos.hu> wrote:

MV> If you use vim, you can put something like this to your vimrc:
MV>
MV> au BufRead */swig*/* set tabstop=8 | set shiftwidth=2 | set softtabstop=2 | set expandtab " SWIG
MV> au BufRead */swig*/Source/* set tabstop=8 | set shiftwidth=2 | set softtabstop=2 | set noexpandtab " SWIG Source

FWIW I also have "set textwidth=160" in my vimrc, as I'm unlikely to have
decided to use this myself (I always stick to 80 columns personally), I
think I was told to use this by someone (William?) for my patches. This
doesn't seem to be respected everywhere in SWIG sources however.

Also, one other thing I'd really like to clear up is whether tabs should
be expanded or not in CHANGES and CHANGES.current files as this is
completely inconsistent: Olly always uses them, William never does, Ian
uses them for some of the entries but not others and some other people
compromise on using a hard TAB in the first line of the changes description
but not the subsequent ones. I don't care at all about it but it's annoying
to have to stop and think every time whether tabs should be used or not
when adding an entry.

Regards,
VZ

Continue reading on narkive:
Loading...