Re: match braces?

2009-09-04 Thread Steven D'Aprano
On Fri, 04 Sep 2009 00:25:34 -0700, lallous wrote:

> Hello,
> 
> Thank you all for your replies.
> 
> A simple suggestion as Chris' actually might help.
> 
> I am used to two spaces indentation since years, and apparently two
> spaces won't make it clear if no visuals were present (braces, or
> begin/end, ...)

I'm not sure about that.
  A two space indent seems pretty obvious to me.
  But perhaps that's because I'm using a monospaced font.
I suppose if you use a proportional font, spaces will be much narrower, 
and it may be harder to notice the indent.

> Though it is not comfortable to change a style, I will play with 8
> spaces indentation, it would naturally make it clearer ;)

How about trying four spaces first?
Eight spaces is rather a lot, especially once you get to the third
indent level and a third of the page is whitespace.



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: match braces?

2009-09-04 Thread lallous
Hello,

Thank you all for your replies.

A simple suggestion as Chris' actually might help.

I am used to two spaces indentation since years, and apparently two
spaces won't make it clear if no visuals were present (braces, or
begin/end, ...)

Though it is not comfortable to change a style, I will play with 8
spaces indentation, it would naturally make it clearer ;)

--
Elias

On Sep 3, 11:43 am, Chris Rebert  wrote:
> On Thu, Sep 3, 2009 at 2:38 AM, lallous wrote:
> > Hello
>
> > In C/C++ you use the braces where as in Python you use the indentation
> > levels.
> > Most editors offer a Ctrl+[ to match the braces so that you can easily
> > identify the scopes (more correctly "statements blocks").
>
> > I am finding it difficult to see blocks
>
> Erm, how does the indentation itself not make it plainly and explicitly clear?
> Perhaps you need to set your tabstops wider?
>
> Cheers,
> Chris

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: match braces?

2009-09-03 Thread John Nagle

lallous wrote:

Hello

In C/C++ you use the braces where as in Python you use the indentation
levels.
Most editors offer a Ctrl+[ to match the braces so that you can easily
identify the scopes (more correctly "statements blocks").

I am finding it difficult to see blocks and/or jump from end to start
with some IDE hotkeys, when coding in Python. Any advise?


   Write more subroutines.

   If indentation gets deep enough that you have problems following
your own code, it's time to break some of the code out as another
function.

John Nagle
--
http://mail.python.org/mailman/listinfo/python-list


Re: match braces?

2009-09-03 Thread Joshua Judson Rosen
Grant Edwards  writes:
>
> On 2009-09-03, Ben Finney  wrote:
> > Tim Chase  writes:
> > >
> > > Any editor worth its salt will offer indentation-based folding (I know
> > > vim does, and I would be astonished if emacs didn't.
> >
> > Emacs calls that ???hide/show???, and the ???hs-minor-mode??? can
> > be enabled for any buffer (and can thus of course be automatically
> > enabled on defined conditions, e.g. whenever a Python buffer is
> > detected).
> >
> > Learn more at http://www.emacswiki.org/cgi-bin/wiki/HideShow>.
> 
> There's only one problem: it doesn't work out-of-the-box.  At
> least it never has for me.  The only thing it knows how to hide
> is the entire body of a function definition.  I never want to
> do that.  What I want to do is hide/unhide the blocks within
> if/then/else or loops so that the control flow is clearer.
> Emacs hs-minor-mode won't do that (at least not for me).

Hm. I wasn't aware of hs-minor-mode. But I've often used
set-selective-display (C-x $), which hides all lines that are indented
more than ARG columns (and un-hides them if you don't give an argument).

But to fulfill the specific request of moving up to the top of a given
block, there's also a `python-beginning-of-block' command in
python-mode (bound to C-c C-u). If you set the mark (C-SPC) before you
do python-beginning-of-block, then you can use `C-x C-x' or `C-u SPC'
to jump back where you were.


-- 
Don't be afraid to ask (Lf.((Lx.xx) (Lr.f(rr.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: match braces?

2009-09-03 Thread Grant Edwards
On 2009-09-03, Ben Finney  wrote:
> Tim Chase  writes:
>
>> Any editor worth its salt will offer indentation-based folding (I know
>> vim does, and I would be astonished if emacs didn't.
>
> Emacs calls that ???hide/show???, and the ???hs-minor-mode??? can be enabled 
> for
> any buffer (and can thus of course be automatically enabled on defined
> conditions, e.g. whenever a Python buffer is detected).
>
> Learn more at http://www.emacswiki.org/cgi-bin/wiki/HideShow>.

There's only one problem: it doesn't work out-of-the-box.  At
least it never has for me.  The only thing it knows how to hide
is the entire body of a function definition.  I never want to
do that.  What I want to do is hide/unhide the blocks within
if/then/else or loops so that the control flow is clearer.
Emacs hs-minor-mode won't do that (at least not for me).

ISTR that you are supposed to be able to get it working by
replacing python-mode with some after-market version and then
patching the hide-show code or something like that -- but I've
never been brave enough (or bored enough) to attempt it.

-- 
Grant Edwards   grante Yow! Not SENSUOUS ... only
  at   "FROLICSOME" ... and in
   visi.comneed of DENTAL WORK ... in
   PAIN!!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: match braces?

2009-09-03 Thread Ben Finney
Tim Chase  writes:

> Any editor worth its salt will offer indentation-based folding (I know
> vim does, and I would be astonished if emacs didn't.

Emacs calls that “hide/show”, and the ‘hs-minor-mode’ can be enabled for
any buffer (and can thus of course be automatically enabled on defined
conditions, e.g. whenever a Python buffer is detected).

Learn more at http://www.emacswiki.org/cgi-bin/wiki/HideShow>.

-- 
 \ “Creativity can be a social contribution, but only in so far as |
  `\society is free to use the results.” —Richard Stallman |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: match braces?

2009-09-03 Thread Tim Chase

In C/C++ you use the braces where as in Python you use the indentation
levels.
Most editors offer a Ctrl+[ to match the braces so that you can easily
identify the scopes (more correctly "statements blocks").

I am finding it difficult to see blocks and/or jump from end to start
with some IDE hotkeys, when coding in Python. Any advise?


Any editor worth its salt will offer indentation-based folding (I 
know vim does, and I would be astonished if emacs didn't.  With 
other editors, YMMV).  You can just collapse the indented section 
to get a big-picture view.


-tkc

--
http://mail.python.org/mailman/listinfo/python-list


Re: match braces?

2009-09-03 Thread Chris Rebert
On Thu, Sep 3, 2009 at 2:38 AM, lallous wrote:
> Hello
>
> In C/C++ you use the braces where as in Python you use the indentation
> levels.
> Most editors offer a Ctrl+[ to match the braces so that you can easily
> identify the scopes (more correctly "statements blocks").
>
> I am finding it difficult to see blocks

Erm, how does the indentation itself not make it plainly and explicitly clear?
Perhaps you need to set your tabstops wider?

Cheers,
Chris
-- 
http://mail.python.org/mailman/listinfo/python-list


match braces?

2009-09-03 Thread lallous
Hello

In C/C++ you use the braces where as in Python you use the indentation
levels.
Most editors offer a Ctrl+[ to match the braces so that you can easily
identify the scopes (more correctly "statements blocks").

I am finding it difficult to see blocks and/or jump from end to start
with some IDE hotkeys, when coding in Python. Any advise?


Thanks,
Elias
-- 
http://mail.python.org/mailman/listinfo/python-list