From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Yuri Khan Newsgroups: gmane.emacs.help Subject: Re: how to highlight block end in Python-mode indentation Date: Sun, 21 May 2017 19:04:47 +0700 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" Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1495368348 15994 195.159.176.226 (21 May 2017 12:05:48 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 21 May 2017 12:05:48 +0000 (UTC) Cc: Skip Montanaro , "help-gnu-emacs@gnu.org" To: Krishnakant Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun May 21 14:05:44 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 1dCPcE-00040E-Gc for geh-help-gnu-emacs@m.gmane.org; Sun, 21 May 2017 14:05:42 +0200 Original-Received: from localhost ([::1]:37783 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dCPcI-0000fE-DL for geh-help-gnu-emacs@m.gmane.org; Sun, 21 May 2017 08:05:46 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59285) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dCPbi-0000eO-P3 for help-gnu-emacs@gnu.org; Sun, 21 May 2017 08:05:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dCPbh-0002p4-Ps for help-gnu-emacs@gnu.org; Sun, 21 May 2017 08:05:10 -0400 Original-Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]:38602) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dCPbh-0002oX-JY for help-gnu-emacs@gnu.org; Sun, 21 May 2017 08:05:09 -0400 Original-Received: by mail-wm0-x232.google.com with SMTP id e127so4146938wmg.1 for ; Sun, 21 May 2017 05:05:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-transfer-encoding; bh=wgroM13w2t1iqy9RkjQBsdIWer2UxDFmUxNYlkq/Rk8=; b=Qihn7HEVATybwzg8+KpaB/OVsUeLQiol+a58H9969LHuAZ7Z2waJX0f3usb9RlMzcf 7Ob39XiGfI/y3lYhIJHA2KFzp1b3AY6IHTSsXBwN7F27JJnnPEBh2FtIv7g51d4VqZs4 AMMlijGLzVskDVZdLeXHEmRXQN0JCzWXTaS38e7Ny25/qhgSTe8LnRMwhariTWlw/1e4 keIyVNEBS+79EiiV6TFVCuLVzjq56YyruAJueHrc3A/HS1dnW+2Q+NP0WX8AmeyfIHJe VifjPDQflpVS5MXIF4X+RtGvq5NHwIoziXA9o132ZP1E4pHtmqU7RFT2nAq33ldeyzs9 SsVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc:content-transfer-encoding; bh=wgroM13w2t1iqy9RkjQBsdIWer2UxDFmUxNYlkq/Rk8=; b=OnzqNug6UQpLsEzGL449ZtXcuR4d72lB8i9bLKFLy/f36aemILN2sKdWUU8kVy43q5 XTTuzXM9jp5vyU1QvIjMFqyfrni/myWlg5u0QkeAGANfLm0B/AIPkwMv+4GTpHyMmU6o Q2j2RckvAUSqUX4Q2N68Fa1/avbjz4AFMw2ivNfirg/7Y2iXGeTPUyalkIAS2MqaqAV+ yz9m+E6omTvZ11UdkLEk94ULBce2JdE/FNE8n3D5gyYvZAMxVREXaeYOxm1QL4FdQs6q Cbk56N9sF/UtFCx9z68bm/6O85U1mdBcZgwzihA/6+B64hadzNJaX0zmI865/NaPhEH+ w2qQ== X-Gm-Message-State: AODbwcC3yoCQR6/28KI+tp6js+WETRhWsMKmY7LaAqeE6LwDwoFPJAFz xaLXVitBp+9OgnB7V5oo/QQY2c+SxQ== X-Received: by 10.223.150.18 with SMTP id b18mr8252753wra.98.1495368308431; Sun, 21 May 2017 05:05:08 -0700 (PDT) Original-Received: by 10.223.163.196 with HTTP; Sun, 21 May 2017 05:04:47 -0700 (PDT) In-Reply-To: <6624ae5f-ff47-ebd4-2c0f-871c9845d29b@openmailbox.org> X-Google-Sender-Auth: 7G_34t3pCSbls5FSenhLVVfBAGA X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::232 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:113104 Archived-At: On Sun, May 21, 2017 at 6:38 PM, Krishnakant wrote= : > The base is large enough, more than 1500 lines in a buffer (python module= ). 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 i= ndentation, 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 wanting t= o 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 elpy w= ork > 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.)