From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Krishnakant Newsgroups: gmane.emacs.help Subject: Re: how to highlight block end in Python-mode indentation Date: Sun, 21 May 2017 19:16:54 +0530 Message-ID: References: <2d520b33-249a-f112-8ab6-1b89c3c76512@openmailbox.org> <87vaowhcyw.fsf@debian.tompa.tv> <5a1d5274-26ae-9036-956b-39c3d2d6d35e@openmailbox.org> <6624ae5f-ff47-ebd4-2c0f-871c9845d29b@openmailbox.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1495374465 2338 195.159.176.226 (21 May 2017 13:47:45 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 21 May 2017 13:47:45 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 Cc: Skip Montanaro , "help-gnu-emacs@gnu.org" To: Yuri Khan Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun May 21 15:47:33 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dCRCm-0000Jo-6g for geh-help-gnu-emacs@m.gmane.org; Sun, 21 May 2017 15:47:32 +0200 Original-Received: from localhost ([::1]:38078 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dCRCr-0000N8-Tm for geh-help-gnu-emacs@m.gmane.org; Sun, 21 May 2017 09:47:37 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41205) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dCRCM-0000Mf-5W for help-gnu-emacs@gnu.org; Sun, 21 May 2017 09:47:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dCRCI-0001LL-U1 for help-gnu-emacs@gnu.org; Sun, 21 May 2017 09:47:06 -0400 Original-Received: from lb1.openmailbox.org ([5.79.108.160]:54812 helo=mail.openmailbox.org) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dCRCI-0001Ku-MX for help-gnu-emacs@gnu.org; Sun, 21 May 2017 09:47:02 -0400 Original-Received: by mail.openmailbox.org (Postfix, from userid 20002) id 3D99F514C69; Sun, 21 May 2017 15:47:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=openmailbox.org; s=openmailbox; t=1495374421; bh=h8+9UbWb1O9ojyvkzPvpmA5FCWm73qjXNbC2WuoP6Ms=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=uQQ6rf6PWHDAtDf4ttLhc58XvE/YDzyisveWO6ogfATMxNKexfZx9vAAjGxODcF4p +Z0UiubzuOQBk8k4mzlrOzFhYDTrhhHUEHcVT/Ya3js+XMkL3fH826ro1FysEn/CgK dSudswxfLTCf9ipkSPQNozPSJ0BBsdLA8XxxfPV8= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=openmailbox.org; s=openmailbox; t=1495374421; bh=h8+9UbWb1O9ojyvkzPvpmA5FCWm73qjXNbC2WuoP6Ms=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=uQQ6rf6PWHDAtDf4ttLhc58XvE/YDzyisveWO6ogfATMxNKexfZx9vAAjGxODcF4p +Z0UiubzuOQBk8k4mzlrOzFhYDTrhhHUEHcVT/Ya3js+XMkL3fH826ro1FysEn/CgK dSudswxfLTCf9ipkSPQNozPSJ0BBsdLA8XxxfPV8= In-Reply-To: Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 5.79.108.160 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:113106 Archived-At: On Sunday 21 May 2017 05:34 PM, Yuri Khan wrote: > On Sun, May 21, 2017 at 6:38 PM, Krishnakant w= rote: > >> The base is large enough, more than 1500 lines in a buffer (python mod= ule ). > That is a lot. See if any top-level functions or classes want to live > in separate modules. > >> There is a lot of nesting going on and we all know that we do get lost= in >> it. >> Do you have some solution? > Apply Torvalds=E2=80=99 razor: =E2=80=9Cif you need more than 3 levels = of indentation, > you=E2=80=99re screwed[=E2=80=A6], and should fix your program=E2=80=9D= . > > See which deep-nested blocks carry out some action that could be given > a name. Extract those as functions. If you see a block of code with an > explanatory comment before it =E2=80=94 that=E2=80=99s a function wanti= ng to break > out. > > Also, The Zen of Python, item 5: =E2=80=9CFlat is better than nested.=E2= =80=9D > > See if you have this pattern: > > def =E2=80=A6: > if some condition: > do something > =E2=80=A6 > > Rewrite this to: > > def =E2=80=A6: > if not some condition: > return > do something > =E2=80=A6 > > Similarly with loops, using =E2=80=9Ccontinue=E2=80=9D. > > Sometimes replacing conditions with conditional expressions (x if y > else z) and loops with comprehensions and utility functions will do > wonders to your nesting levels. > >> Basically I have now figured out that spaces instead of tabs makes elp= y work >> fine with highlight-indentation-mode. So our team will have to switch= to >> using spaces again. > You use tabs with Python in a *team*? > > Print out PEP8. Discuss it with your team. Unless you have good > reasons, format according to that. (Unfortunately, having lots of > existing code qualifies as =E2=80=9Cgood reasons=E2=80=9D.) > PEP8 just says about using space. It is more of a popular way of doing things rather than a highly=20 convincing advantage. I personally worked with both tabs and spaces and never find any major=20 problem as such. Just that I am myself blind and find managing tabs with screen readers=20 more convenient, but I am not against using any style. Never the less found white-space as the default in Emacs and is ok with=20 my team who needs to see the code (unlike me who depends on speech ). Happy hacking. Krishnakant.