From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 02 17:25:56 2022 Received: (at submit) by debbugs.gnu.org; 2 Sep 2022 21:25:57 +0000 Received: from localhost ([127.0.0.1]:40533 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oUEAm-00072N-Fa for submit@debbugs.gnu.org; Fri, 02 Sep 2022 17:25:56 -0400 Received: from lists.gnu.org ([209.51.188.17]:42680) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oUEAl-00072G-Ai for submit@debbugs.gnu.org; Fri, 02 Sep 2022 17:25:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36080) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oUEAi-0001mR-Qz for bug-gnu-emacs@gnu.org; Fri, 02 Sep 2022 17:25:54 -0400 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]:41481) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oUEAd-00057g-2q for bug-gnu-emacs@gnu.org; Fri, 02 Sep 2022 17:25:49 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 056BD320091F; Fri, 2 Sep 2022 17:25:43 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Fri, 02 Sep 2022 17:25:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secretsauce.net; h=cc:cc:content-type:date:date:from:from:in-reply-to:message-id :mime-version:reply-to:sender:subject:subject:to:to; s=fm3; t= 1662153943; x=1662240343; bh=Lx1DNvq9vxWN/GoTniM8p9k0vkrJuqEFlOv WdYo+38M=; b=TUvxHgparav7JrbIAis4q8xtqEhYaO56v7LJ4XO5HxsnfBZmmDO EkJhWB6ecWILRld6xLLVyfzeNliHOe5yzkEmLuRkFozBGYZgk5623UKtFN8SVxKJ 3ALZngrxofUcvMdU9LUNKteuGsGlHBxo8vZBkeBjKdAqKuNg9cOGoUpFc20C8PEx FlSkTJp41Vl+aL8Q5+Kzzuqx/WRYwLNnhXUd1wvn8Mf8GeGn9SB29U6CSM5nDgkp MDRt0agfcR/4c0u/5fb7iDmvITfldAoHuw40/8bmH4pitSbVlyKlbmxAqpWU6K6C xU9Udah5XdfaaetDMJ+nM/o+U8bbkL+rugg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:message-id:mime-version :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1662153943; x= 1662240343; bh=Lx1DNvq9vxWN/GoTniM8p9k0vkrJuqEFlOvWdYo+38M=; b=G yp6yESPyMoqF+WFtKgwJvBGkJhw63Lcc24AuRJqsrg6kHMbl9nqboGqOHum7GUlz 7EHygP/Z/HSIcONHoiQkSbcn3I55xWxbg9OTDq7L4/DYBwC791IRgXtN8EZ7LF4n 6eF1Mug8XoAM+B6+P8MQRQqAzztVgujNWisUAh/J/0UXn116zT/nNtEGuXnQUfVT a6tq2PLQOaVLpOQHd8TY1pmatiNPrRImnLMpKaVIiEzbkPDs/ENQaFQfNoQ70seC TnXOMHdEz9qGhXGia9N7JCURThzR3ecog4r89X3rnKYyIi6Qhkcozs41EOpXZhAX zxU7GCskDwEmDfJKbXiLg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdeltddgudeigecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufffkfggtgesthdtredttddttdenucfhrhhomhepffhimhgrucfm ohhgrghnuceoughimhgrsehsvggtrhgvthhsrghutggvrdhnvghtqeenucggtffrrghtth gvrhhnpedufefhteekvefhtdejjeetjeetgffhjeejfeeiudektdeggeeutefhfeettdef jeenucffohhmrghinhepghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepmhgrihhlfhhrohhmpeguihhmrgesshgvtghrvghtshgruhgtvgdrnhgvth X-ME-Proxy: Feedback-ID: i3e8042a0:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 2 Sep 2022 17:25:42 -0400 (EDT) From: Dima Kogan To: bug-gnu-emacs@gnu.org Subject: 29.0.50; hide-show in python-mode selects the current block imperfectly Date: Fri, 02 Sep 2022 14:25:39 -0700 Message-ID: <87zgfhtqng.fsf@secretsauce.net> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=64.147.123.24; envelope-from=dima@secretsauce.net; helo=wout1-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.7 (-) X-Debbugs-Envelope-To: submit Cc: Lars Ingebrigtsen , kobarity X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.7 (--) Hi. I've been using the recently-committed hide-show functionality from: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=56635 It's working well, but I just found a problem. Python lacks explicit block-end characters that a language like C has. This creates some ambiguity about what is intended, and I think emacs makes the wrong choice in at least one spot. Let's say we have a tst.py: def f(): if 1: 11 elif 2: 22 elif 3: 33 elif 4: 44 else: 5 If I want to collapse the "elif 2:" block, I move the point to somewhere inside that block, and (hs-hide-block). Placing the point at the end of the "elif 2:" line puts us unambiguously inside that block, so this does the job. But what if the point is at the start of the "elif 2:" line? Currently emacs considers this to be INSIDE this block also, so (hs-hide-block) there also hides the "elif 2" block, but should it? Would it not make more sense if the START of the "elif 2:" line was considered in the "def f():" block, but outside all the "if" blocks? Then (hs-hide-block) at the start of that line would collapse the whole "def f():" block. Currently the only point where this can be done is at the end of the "def f():" line. This also raises a question about what should happen if we (hs-hide-block) with the point on the "i" in any of the "elif" lines. Probably this should be outside the "elif" blocks too? Maybe? Thanks! From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 04 11:15:51 2022 Received: (at 57551) by debbugs.gnu.org; 4 Sep 2022 15:15:51 +0000 Received: from localhost ([127.0.0.1]:45441 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oUrLj-0003lq-HR for submit@debbugs.gnu.org; Sun, 04 Sep 2022 11:15:51 -0400 Received: from mail-pj1-f42.google.com ([209.85.216.42]:40639) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oUrLi-0003le-EK for 57551@debbugs.gnu.org; Sun, 04 Sep 2022 11:15:50 -0400 Received: by mail-pj1-f42.google.com with SMTP id t11-20020a17090a510b00b001fac77e9d1fso9931948pjh.5 for <57551@debbugs.gnu.org>; Sun, 04 Sep 2022 08:15:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:user-agent:references:in-reply-to:subject:cc:to:from :message-id:date:from:to:cc:subject:date; bh=wILRwOyCa8Epjp0OYsbSgleAkRyzho7pKopurx/1IKo=; b=g6vMWrJ4ih7vPifFggdnkxlAT07Ti979zzWL2gZBIt07SOqSssMMkv9yznPa0e6YKq GyvOcpNOimB7xP7j5sTZjP110KxEusyTbFNGy8KlSceRLEvLKjSJWeN0YAPH51nw70Z9 lZv7Xhrv8E1g2k9/5tvBRqKtw/1JVO6nTL/BU4Tl+rDIQBvhFSlTlAmBxN7aS0b2R9eT 3Pc27lygr1hhHuXJpJ0YjptYpuN6mn7GxMZ5dsUChmOJMX/LWtrvj1Usq8bwAa0Hn4De 2uvoAp4HEBWCBVqUoevN0Q7D6eTvmrFdcGpxwshWW+rwsw52KXU1UW2P8Zr7Y1gsu3Xg eIkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:references:in-reply-to:subject:cc:to:from :message-id:date:x-gm-message-state:from:to:cc:subject:date; bh=wILRwOyCa8Epjp0OYsbSgleAkRyzho7pKopurx/1IKo=; b=ZtC7ByeeOhME7t8H4G0/1x2w4zktR5l5z/UEy/ZFe1EcC+UEEOGQ7kNDOzHAsbhfFR KMzPo2nfFF5ovTNI1RzIjJ9RXJ4OGsvHVs0E6lWMVyQaf1USLLHVjaO8z0xRkmtKmBxe 2dppJCcTHodWCtrpGnWXYcK90lkDwvAwCsUOrakl7tmafzDZKnPqgmvInCEIuI7EQa3Y 4v7BqvEG6tFmv+C24+j+qT6d0vx6NC5mOV8XykPaK6D0fq/0CKphPu3WW/cvn3gqBwQT GS1GfbNh3wPilwZSVaWBig+Krc+ejz2GLUGwrKmlS01dmaAPdHajnMzsJqRedKbtHm/V O4PA== X-Gm-Message-State: ACgBeo0hVhuxCGvWa21qbNERcEcuhrqp5PO6NchngPiMWvOqMdDjObUQ nD5tYSE0Fi+fWxyArpwBQGVfgiIoZFQtRg== X-Google-Smtp-Source: AA6agR6SQI4Ht0V3owRYwa2e+RPjjilpxrbWgQyXpUaxfNj/SpPsAyQkczHpCrb1VgYV17Z+SMvSkw== X-Received: by 2002:a17:903:247:b0:16c:5017:9ad4 with SMTP id j7-20020a170903024700b0016c50179ad4mr46329073plh.115.1662304544487; Sun, 04 Sep 2022 08:15:44 -0700 (PDT) Received: from localhost (58x12x133x161.ap58.ftth.ucom.ne.jp. [58.12.133.161]) by smtp.gmail.com with ESMTPSA id s62-20020a625e41000000b005350ea966c7sm5699642pfb.154.2022.09.04.08.15.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 08:15:43 -0700 (PDT) Date: Mon, 05 Sep 2022 00:15:40 +0900 Message-ID: From: kobarity To: Dima Kogan Subject: Re: 29.0.50; hide-show in python-mode selects the current block imperfectly In-Reply-To: <87zgfhtqng.fsf@secretsauce.net> References: <87zgfhtqng.fsf@secretsauce.net> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.0.50 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 57551 Cc: 57551@debbugs.gnu.org, Lars Ingebrigtsen X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Dima Kogan wrote: > But what if the point is at the start of the "elif 2:" line? Currently > emacs considers this to be INSIDE this block also, so (hs-hide-block) > there also hides the "elif 2" block, but should it? Would it not make > more sense if the START of the "elif 2:" line was considered in the "def > f():" block, but outside all the "if" blocks? Then (hs-hide-block) at > the start of that line would collapse the whole "def f():" block. > Currently the only point where this can be done is at the end of the > "def f():" line. Hi. I think current hideshow behavior is in line with block navigation in Python mode. For example, if the point is at the start of the "elif 2:" line, M-x python-nav-beginning-of-block moves the point to "e" of "elif 2:". This implies that Emacs Python mode considers spaces before "elif 2:" to belong to the "elif 2:" block. So I think this is not a matter of hideshow, but of how the block should be recognized. The current implementation seems to assume that the block boundary is always at the end of the line, as shown in the following figure. _______________ |def f(): | |_____________ | || if 1: || ||________11__|| || elif 2: || ||________22__|| |______________| On the other hand, Dima seems to expect the block boundary to be as shown in the following figure. _______________ |def f(): | | _________ | | ___|if 1: _|| ||_______ 11|_ | | ___|elif 2:_|| ||_______ 22| | |______________| Although both models may have pros and cons, the current implementation seems more natural to me. In particular, it would be more natural for "elif" or "else" block to be adjacent to "if" block with nothing else in between. Regards, From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 04 13:02:06 2022 Received: (at submit) by debbugs.gnu.org; 4 Sep 2022 17:02:06 +0000 Received: from localhost ([127.0.0.1]:45559 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oUt0Y-0006Xe-6w for submit@debbugs.gnu.org; Sun, 04 Sep 2022 13:02:06 -0400 Received: from lists.gnu.org ([209.51.188.17]:53804) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oUt0U-0006XU-6W for submit@debbugs.gnu.org; Sun, 04 Sep 2022 13:02:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56712) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oUt0T-0000qn-QM for bug-gnu-emacs@gnu.org; Sun, 04 Sep 2022 13:02:01 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:50687) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oUt0R-0000de-Im for bug-gnu-emacs@gnu.org; Sun, 04 Sep 2022 13:02:01 -0400 Received: from [192.168.178.61] ([89.247.171.250]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MKsf5-1onmwB0RSP-00LHHC for ; Sun, 04 Sep 2022 19:01:54 +0200 Message-ID: <19c5c343-0a74-a8b3-055e-681d40a43b71@easy-emacs.de> Date: Sun, 4 Sep 2022 19:01:53 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: bug#57551: 29.0.50; hide-show in python-mode selects the current block imperfectly Content-Language: en-US To: bug-gnu-emacs@gnu.org References: <87zgfhtqng.fsf@secretsauce.net> From: =?UTF-8?Q?Andreas_R=c3=b6hler?= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:VL/DwN5LgU8NQUPV7G4Ugdp4XeO7yS8KAUbzQrKasZl+OSU227N HYlycdIzCz3ZAOczUmeFxPBKhF6NZiTGhsw/jlOab/Komr1VT8McFNE53BfcmE79IOszT+8 A5aR7vty9n5LMdExCADa4OwQRHqosQyJZAJ9oB1i/VdAGbMzGPmkPlNDYGC54iCE6iAuPlI YzfcWVYDRAPNLsZCGJTuQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:5FcV2GH22hc=:p6Tviio0K6dLGAb+rSwrH3 86Ghm7TX1GK/zgfqs+FnzObKBf2APqjmHhdtTxHntxp2A28GC1OiaQZ6Akhp6JkzHOKtihPMj LNhuek5fg8CB9MGP7uSDPgY4RvTsn3u4aPZ+2n0gdNlR2FzqumUsnOYo24O6mku8QzJqdWN4T ZdDh4hbFaBthF89pAieYDNLe3d6QiZisnOh33nq4C6MTN3FnXJJ98haP5J2hSDdxz5plNvduU Av/tYI7ss6zcNZrREqwH47IQcYdmVFInu/B0aieiNOpgzyUt4Dr4MRyL6QzFESdeiAi7Mxade +7LPhMX3/lJdtTdqvYfPvbsRz5Q6Fy4Ok8e4pkvw/is8tDXZcvqRCMAD1/VSvmbpva05V+4bQ Usrfhplbw3abh/ochPWICOzHMdxr7KI9aol8hBGsFqHve4roomrTbla2J+z5rTCVYVldJ5PgA OvXSWDg0EDqL6NSOGpHEYPGV3Jc6D6lZEE1IAH5bz+/AYOinFxmSK01TZKaYY9Oy8Xe3zfMsB LRPY0pkoAkExKoq6YGUpNWV83btG+KTbYh7Z6FuT5tfoCylb4txat77dL0bLPIiEwBo2yenfK vlg0Oh3GL3kgx1BZk1cOokobzw7q+shCqVCk+JmXY/UvbE7qg4hnJtx4dyn0Ff8a2FXklw/Kb diKlNUwtxQrmt08dcPDR8RUBMWfBVBRmD5mQnJYELmjKmRzWliO2q8Db8U1DiL3i0vcRftHL/ BmB7TqX8pDaBLWcbP7vWK/uH6Q6pk/6HifML3fTZRMNXeLb8+km8P609pfeTjs+XmMc71vvjx NKXfglAf6yIofufFkQmJbeGo2uApw== Received-SPF: none client-ip=212.227.17.24; envelope-from=andreas.roehler@easy-emacs.de; helo=mout.kundenserver.de X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, NICE_REPLY_A=-0.978, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Am 04.09.22 um 17:15 schrieb kobarity: > Dima Kogan wrote: >> But what if the point is at the start of the "elif 2:" line? Currently >> emacs considers this to be INSIDE this block also, so (hs-hide-block) >> there also hides the "elif 2" block, but should it? Would it not make >> more sense if the START of the "elif 2:" line was considered in the "def >> f():" block, but outside all the "if" blocks? Then (hs-hide-block) at >> the start of that line would collapse the whole "def f():" block. >> Currently the only point where this can be done is at the end of the >> "def f():" line. > Hi. I think current hideshow behavior is in line with block > navigation in Python mode. For example, if the point is at the start > of the "elif 2:" line, M-x python-nav-beginning-of-block moves the > point to "e" of "elif 2:". This implies that Emacs Python mode > considers spaces before "elif 2:" to belong to the "elif 2:" block. > So I think this is not a matter of hideshow, but of how the block > should be recognized. > > The current implementation seems to assume that the block boundary is > always at the end of the line, as shown in the following figure. > > _______________ > |def f(): | > |_____________ | > || if 1: || > ||________11__|| > || elif 2: || > ||________22__|| > |______________| > > On the other hand, Dima seems to expect the block boundary to be as > shown in the following figure. > > _______________ > |def f(): | > | _________ | > | ___|if 1: _|| > ||_______ 11|_ | > | ___|elif 2:_|| > ||_______ 22| | > |______________| > > Although both models may have pros and cons, the current > implementation seems more natural to me. In particular, it would be > more natural for "elif" or "else" block to be adjacent to "if" block > with nothing else in between. > > Regards, > > > Hi, IMO the if-block starts at column 4, with "if". It ends at any column lower than 4 below that number 22. Assume everything between with no regard of column as part of that block. Best, Andreas From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 05 03:48:21 2022 Received: (at 57551) by debbugs.gnu.org; 5 Sep 2022 07:48:21 +0000 Received: from localhost ([127.0.0.1]:46339 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oV6qD-00028H-7p for submit@debbugs.gnu.org; Mon, 05 Sep 2022 03:48:21 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:54455) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oV6qB-00027s-4Q for 57551@debbugs.gnu.org; Mon, 05 Sep 2022 03:48:19 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id A9B2B5C006E; Mon, 5 Sep 2022 03:48:13 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 05 Sep 2022 03:48:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secretsauce.net; h=cc:cc:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1662364093; x=1662450493; bh=U7 ljqoSrs8cGceatXAxggZEwfCDkUp2O/juNark6F0g=; b=qXFEWU1K2ZOayYU+RF hqKbfu213346JArjbhNq5n+hWuZqFVTvVLRMQl49ITqnPZEc4tNr8+237b3znAfn NTjCwLM2foYYrT29D26Fx/DFb4haa0ehBq2exZyzEfqbikdntBmqKWl80bfh1pOx Yqu83RT+3c6EyOQQLC1Fuh7Ndoy7+t/7dnap4iuLcarWtTqF5fepFLtCZe3J18k8 a1LwDSxyuOTFd6mcV3N5SJgy2T7ZQgc9uWuth3CIndhBm2M6oIFAU2VzXmZb1jQV U6USRwmpUcZhBe+3tr429mvDZ1t81vPGqWnV63NF+16xLN6V4yOns/H/bUWh9Cn8 roBQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1662364093; x=1662450493; bh=U7ljqoSrs8cGceatXAxggZEwfCDk Up2O/juNark6F0g=; b=fT4Cn96g2ox3B7h/ZzGgV7p2OXhGr7kHZXtxJfLfZHEM QNOLnCKeV9VNC/uazt/7xKisxtJc42lrcZA6pN4JYeVbWpPmF2lYLHmvq5yXmPvz U3hqUR7jZsKYfbv4TesHUZnltTJuGxn58o+y/7sp1do8MRrYORuwLbLaFfv4Itd6 8H5Lm9TlYhAqJda7kRXu862iEPt1rVPsTHA2mGyj+AiCHLMuxrFQyErtGP0ApX7H eo4Vz1puYIBPn0EqncrS3azi9EDZkH3//2+aan+Z1x6ZqdGmx2FPwZmpwwxluXuW sFrrrHU/VNrC4iQUI4tDC1jnc1l1GyQBwE3jyLAN/g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdelhedguddvgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpehffgfhvfevufffjgfkgggtsehttdertddtredtnecuhfhrohhmpeffihhm rgcumfhoghgrnhcuoeguihhmrgesshgvtghrvghtshgruhgtvgdrnhgvtheqnecuggftrf grthhtvghrnhepgfeifeehgedvkeekvdevvdelvdegleevtedvueejvdejveduveeuleev leevudetnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epughimhgrsehsvggtrhgvthhsrghutggvrdhnvght X-ME-Proxy: Feedback-ID: i3e8042a0:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 5 Sep 2022 03:48:13 -0400 (EDT) References: <87zgfhtqng.fsf@secretsauce.net> User-agent: mu4e 1.8.7; emacs 29.0.50 From: Dima Kogan To: kobarity Subject: Re: 29.0.50; hide-show in python-mode selects the current block imperfectly Date: Mon, 05 Sep 2022 00:44:22 -0700 In-reply-to: Message-ID: <87tu5ms1mu.fsf@secretsauce.net> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 57551 Cc: 57551@debbugs.gnu.org, Lars Ingebrigtsen X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Hi. Thanks for the analysis. I guess this isn't the right forum for this discussion, but I'll put it here anyway. The reason I think the "if" and "else" text and the preceding whitespace should be considered to lie outside their block is that this is how cc-mode works. Consider the C code equivalent to the Python code in the bug report: void f(void) { if(1) { 11; } else if(2) { 22; } else if(3) { 33; } else if(4) { 44; } else { 5; } return 0; } Here (hs-hide-block) hides the if/else blocks ONLY if the point is inside the {}. Otherwise, the whole f() is hidden. From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 05 05:43:04 2022 Received: (at submit) by debbugs.gnu.org; 5 Sep 2022 09:43:04 +0000 Received: from localhost ([127.0.0.1]:46460 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oV8dE-0007Bc-3I for submit@debbugs.gnu.org; Mon, 05 Sep 2022 05:43:04 -0400 Received: from lists.gnu.org ([209.51.188.17]:41924) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oV8dC-0007BU-ON for submit@debbugs.gnu.org; Mon, 05 Sep 2022 05:43:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38542) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oV8dC-0003IB-D5 for bug-gnu-emacs@gnu.org; Mon, 05 Sep 2022 05:43:02 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:32833) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oV8dA-0007q3-JP for bug-gnu-emacs@gnu.org; Mon, 05 Sep 2022 05:43:02 -0400 Received: from [192.168.178.61] ([89.247.171.232]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MfYgC-1p21X40IYK-00fyZC; Mon, 05 Sep 2022 11:42:54 +0200 Message-ID: <18fb0537-3fcb-8d14-6680-ef56d30dcbf0@easy-emacs.de> Date: Mon, 5 Sep 2022 11:42:53 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: bug#57551: 29.0.50; hide-show in python-mode selects the current block imperfectly Content-Language: en-US To: Dima Kogan References: <87zgfhtqng.fsf@secretsauce.net> <87tu5ms1mu.fsf@secretsauce.net> From: =?UTF-8?Q?Andreas_R=c3=b6hler?= In-Reply-To: <87tu5ms1mu.fsf@secretsauce.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:OIPvgCSCpDs2KdRlFevAT9HMebvKGb0pUjoFm/56oqAgD9iuI30 edyPxrrXatltfRiSKtgU+bfrBjduXY3V75MkzaFtl1/egSmMy1Kv2PCCXnUes6AorAI3BIE ApzJLG/wtD1SnIWdl7NTs+mAtA6VYLgONG9BT00O0hd1ChQTMcKjCt1+aKe84NByLP2Gkjq kdDylUiVHjIS3vSOtvI1A== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:E6htBQ7Oqww=:wcS/+Xh8UYrHumX5NNCPtb Vc1cATJ+OFmMjkO2g5WR/S2PpUuiKekjIWR1uyTwrtojS6hlbVAmMkvKM1LkiyPmH9Vm5ZToC Nkkp3AW/VsF3PqxeTV35fgFV6q2DLaDG1dgCZzA1OPYlN27WVK9WBDnwAtwhcz7ZPfMy8MLUu EvonPtiG44bP6Vj/vbfs5LmWWJ9SOWssdSpv50hhehwatskiuvFzMvrMyBrHoxmTyVb53Zd6N uEe/MezncWl8WNVC2yJtIDhcQRx5933s1wqXOtgUbowQ7MXWjzOfE8+MOgPoAAt9AHR9d/AtW wsIbLKV/+LZsPW2vHfGetiWd7aGfETpnZQNKlMtnhuujdLXZ2rEum+OSrDYCBJoX5rz0Yrufv NiZgzBVaMl9YBLvmtLVFdfTGhS6X1Dj14y8HBO2OWP/Y7m248RcNhWIxTz6bPuq3T0kMmtu62 1THCVE99UXK7/1X+ZgSoNfsPJdxZKdbKRaZ2JCk2D9bRM47oNjSakK+ZHRYMlApV1gHl8RZlN qTOiIBKC2Nd1PNESsJabvdGg+VL7hd+zgtfWBkywEvldn/0H8cqiCn6BXzVKtVTUtHBp0/JCQ q4+WYUJVkVYkObu5DU8lBmHRat9hUP1sL+RvdgGsuow5EImpBx02mK8Rv7tvV7pPGHcm2IvfA 5vo3KLk2KQfz3/ea75q+O9LrlM+GzNvGnRR/rLJj49nrYWESBNBvvkpwFFQaPIgQhqCoyUQJh 0oU+VLWa1houGN077fpKD93EmrDSiLRQVtBFcW4MIRk9pa4F1fwpdFtZ8Zg1vxZXrHOTZeAAm e3xow6QGJahP6Md7uALhFPGwdi9nw== Received-SPF: none client-ip=212.227.126.133; envelope-from=andreas.roehler@easy-emacs.de; helo=mout.kundenserver.de X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, NICE_REPLY_A=-0.978, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit Cc: bug-gnu-emacs@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Am 05.09.22 um 09:44 schrieb Dima Kogan: > Hi. Thanks for the analysis. I guess this isn't the right forum for this > discussion, but I'll put it here anyway. The reason I think the "if" and > "else" text and the preceding whitespace should be considered to lie > outside their block is that this is how cc-mode works. Consider the > C code equivalent to the Python code in the bug report: > > void f(void) > { > if(1) > { > 11; > } > else if(2) > { > 22; > } > else if(3) > { > 33; > } > else if(4) > { > 44; > } > else > { > 5; > } > > return 0; > } > > Here (hs-hide-block) hides the if/else blocks ONLY if the point is > inside the {}. Otherwise, the whole f() is hidden. > > > There is another point: might be more than one if-statement in a function. If the whole function-body is collapsed from just one statement, the others are invisible too. From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 10 09:20:50 2022 Received: (at 57551) by debbugs.gnu.org; 10 Sep 2022 13:20:51 +0000 Received: from localhost ([127.0.0.1]:36836 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oX0Pi-0007P2-Ie for submit@debbugs.gnu.org; Sat, 10 Sep 2022 09:20:50 -0400 Received: from mail-pf1-f177.google.com ([209.85.210.177]:42955) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oX0Pg-0007Oo-BJ for 57551@debbugs.gnu.org; Sat, 10 Sep 2022 09:20:48 -0400 Received: by mail-pf1-f177.google.com with SMTP id b23so4224372pfp.9 for <57551@debbugs.gnu.org>; Sat, 10 Sep 2022 06:20:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:subject:cc:to:from:message-id:date:from:to:cc:subject :date; bh=/Rs0R1K1tBhcGgWWEExAehMHOOO/6w0MPNPXMSzz6mo=; b=b9oK127Dgp2Wh8PyqdgkBoLUcFisHHUL4VPLxcF1jdeWknBGhEX5SG1Jss4yweCeKU zhl+y612R5ed8DpIxxz0gOFIloS4n00yAnuukxq2a5aN7+RoSAEPs1NpDnRflmYgrr5J 2PpDWifaJberHUIdnlvofFIokerDnJPRBhBvYEcYtFBa9VaLBVv5AmREWnSg+5b/inXH vbCB1EFbTrha6d3OrD+plOHHsw1bYfs9cjtE8qvMK4EmMhZRIysZLrfJvpsykkp2LKFS 4T5GGMC8iV5B/WyJBtx1p740EK/1Kprcp/hfXOu/uX0hgzgT5nwXs19413qWMFcs/D3u t8rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:subject:cc:to:from:message-id:date:x-gm-message-state :from:to:cc:subject:date; bh=/Rs0R1K1tBhcGgWWEExAehMHOOO/6w0MPNPXMSzz6mo=; b=jniB6wc942PbslhZHgdd+Wr/e1Oy3JWtelI+M/CG1hzf0QoVu+CQ0KXdSxnEm4iXp+ xCjPHsoXEritUiFuWoObKfuhzA177qtmwuF9eFNCFaKaqcEVfal8h91lLtlKdeX5l5dg PPJ+ams09GjDfJqTf8H5TSqr78W84RPLskjUNcqVmDncRQV0msYrhnFCENAtfWPk2uMP hOvM/v4A6dobK6lfH9D2B5lIQL7h6MNwx0UlIGTUfM9/w7uHYEmRlun5JoTIeUouBtvb VqynB9pExqjatuwkSWmhmBYvC8dHJNqHZsdxCfQuIhIu7sSHrtHt3vSGV/N84NVUkUzf 3ikg== X-Gm-Message-State: ACgBeo26tVg1WezauhDaaSwER3sXYpY4eEqUIe3XLjdTPMmxUFblqsso Gb5raIfaafrhjjzj9GgDWQU= X-Google-Smtp-Source: AA6agR4pFMpU1pC1puUY7yWmpThGU9FDv/ZMvri1mhw977Flr9vB/26pOuqPpzLGnrtvS/B7WhN7qw== X-Received: by 2002:a63:1f1b:0:b0:429:b4be:72f0 with SMTP id f27-20020a631f1b000000b00429b4be72f0mr15815111pgf.622.1662816042214; Sat, 10 Sep 2022 06:20:42 -0700 (PDT) Received: from localhost (58x12x133x161.ap58.ftth.ucom.ne.jp. [58.12.133.161]) by smtp.gmail.com with ESMTPSA id u20-20020a63ef14000000b00438834b14a1sm2193674pgh.80.2022.09.10.06.20.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Sep 2022 06:20:41 -0700 (PDT) Date: Sat, 10 Sep 2022 22:20:38 +0900 Message-ID: From: kobarity To: Andreas =?ISO-8859-1?Q?R=F6hler?= , Dima Kogan Subject: Re: 29.0.50; hide-show in python-mode selects the current block imperfectly In-Reply-To: <87tu5ms1mu.fsf@secretsauce.net> References: <87zgfhtqng.fsf@secretsauce.net> <87tu5ms1mu.fsf@secretsauce.net> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.0.50 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 57551 Cc: 57551@debbugs.gnu.org, Lars Ingebrigtsen X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Andreas R=F6hler wrote: >> The current implementation seems to assume that the block boundary is >> always at the end of the line, as shown in the following figure. >> >> _______________ >> |def f(): | >> |_____________ | >> || if 1: || >> ||________11__|| >> || elif 2: || >> ||________22__|| >> |______________| >> >> On the other hand, Dima seems to expect the block boundary to be as >> shown in the following figure. >> >> _______________ >> |def f(): | >> | _________ | >> | ___|if 1: _|| >> ||_______ 11|_ | >> | ___|elif 2:_|| >> ||_______ 22| | >> |______________| >> >IMO the if-block starts at column 4, with "if". It ends at any column=20 >lower than 4 below that number 22. Hi. Is it correct that you are expecting a single block as shown below? _______________ |def f(): | | _________ | | ___|if 1: || || 11 || || elif 2: || ||_______ 22__|| |______________| If so, this is another topic. Dima Kogan wrote: > Hi. Thanks for the analysis. I guess this isn't the right forum for this > discussion, but I'll put it here anyway. The reason I think the "if" and > "else" text and the preceding whitespace should be considered to lie > outside their block is that this is how cc-mode works. Consider the > C code equivalent to the Python code in the bug report: >=20 > void f(void) > { > if(1) > { > 11; > } > else if(2) > { > 22; > } > else if(3) > { > 33; > } > else if(4) > { > 44; > } > else > { > 5; > } >=20 > return 0; > } >=20 > Here (hs-hide-block) hides the if/else blocks ONLY if the point is > inside the {}. Otherwise, the whole f() is hidden. I think this is reasonable for cc-mode, where blocks are explicitly defined by curly braces only. Keywords like "if" or "else" have nothing to do with identifying blocks. Also, there is no need to consider how lines are constructed. However, Python does not have such block boundary characters. As Python blocks are identified with keywords and indentation, it is important how lines are constructed. It seems to me that limiting the block boundary to the end of a line is not a bad idea in Python mode. Andreas R=F6hler wrote: > There is another point: might be more than one if-statement in a=20 > function. If the whole function-body is collapsed from just one=20 > statement, the others are invisible too. Isn't this an expected behavior when hiding the function? Could you give an example and your expectation? Regards,