GNU bug report logs - #57551
29.0.50; hide-show in python-mode selects the current block imperfectly

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Dima Kogan <dima@HIDDEN>; dated Fri, 2 Sep 2022 21:26:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 57551 <at> debbugs.gnu.org:


Received: (at 57551) by debbugs.gnu.org; 5 Sep 2022 07:48:21 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Sep 05 03:48:21 2022
Received: from localhost ([127.0.0.1]:46339 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oV6qD-00028H-7p
	for submit <at> 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 <dima@HIDDEN>) id 1oV6qB-00027s-4Q
 for 57551 <at> 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: <xms:vakVYzxbETj6FETsMyToo2EZTLKkvOV3Cwob0AQXrCbLIHLt6jzC7Q>
 <xme:vakVY7TcoeLDectDJOYSHyG58nlvOaRqCSty0P-l2mU83xs3fAg94L-RwSdkDcZXj
 at2n8iM0TIr3tY2>
X-ME-Received: <xmr:vakVY9UIhXD2b2KDgSkYi1rnOGeXfByqmVDgUvkT8R-zYpxVsXJAHvO0>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdelhedguddvgecutefuodetggdotefrod
 ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh
 necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd
 enucfjughrpehffgfhvfevufffjgfkgggtsehttdertddtredtnecuhfhrohhmpeffihhm
 rgcumfhoghgrnhcuoeguihhmrgesshgvtghrvghtshgruhgtvgdrnhgvtheqnecuggftrf
 grthhtvghrnhepgfeifeehgedvkeekvdevvdelvdegleevtedvueejvdejveduveeuleev
 leevudetnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh
 epughimhgrsehsvggtrhgvthhsrghutggvrdhnvght
X-ME-Proxy: <xmx:vakVY9iM043xeOLgUl2j9XSrAa-NQKQsghUv3wTkAMGx0gW92nnP-w>
 <xmx:vakVY1DMANdKF3NrXjjNvhc9IR8IOieBo-_jIzOifxRA9ECgS7jwxw>
 <xmx:vakVY2J6jX2Kls7OnFmJUjZxT8sU6iBcfeTMFQEnB_umV3JNTVibPw>
 <xmx:vakVYy5bTkvGChQj0nVsPTTVJ_7Q6dlGyxx5vBbKjTG4m1Jjml0xng>
Feedback-ID: i3e8042a0:Fastmail
Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon,
 5 Sep 2022 03:48:13 -0400 (EDT)
References: <87zgfhtqng.fsf@HIDDEN>
 <eke7zgff41cz.wl-kobarity@HIDDEN>
User-agent: mu4e 1.8.7; emacs 29.0.50
From: Dima Kogan <dima@HIDDEN>
To: kobarity <kobarity@HIDDEN>
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: <eke7zgff41cz.wl-kobarity@HIDDEN>
Message-ID: <87tu5ms1mu.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 57551
Cc: 57551 <at> debbugs.gnu.org, Lars Ingebrigtsen <larsi@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
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.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#57551; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 4 Sep 2022 17:02:06 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Sep 04 13:02:06 2022
Received: from localhost ([127.0.0.1]:45559 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oUt0Y-0006Xe-6w
	for submit <at> 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 <andreas.roehler@HIDDEN>) id 1oUt0U-0006XU-6W
 for submit <at> 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 <andreas.roehler@HIDDEN>)
 id 1oUt0T-0000qn-QM
 for bug-gnu-emacs@HIDDEN; 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 <andreas.roehler@HIDDEN>)
 id 1oUt0R-0000de-Im
 for bug-gnu-emacs@HIDDEN; 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 <bug-gnu-emacs@HIDDEN>; Sun, 04 Sep 2022
 19:01:54 +0200
Message-ID: <19c5c343-0a74-a8b3-055e-681d40a43b71@HIDDEN>
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@HIDDEN
References: <87zgfhtqng.fsf@HIDDEN>
 <eke7zgff41cz.wl-kobarity@HIDDEN>
From: =?UTF-8?Q?Andreas_R=c3=b6hler?= <andreas.roehler@HIDDEN>
In-Reply-To: <eke7zgff41cz.wl-kobarity@HIDDEN>
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@HIDDEN; 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 <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
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








Information forwarded to bug-gnu-emacs@HIDDEN:
bug#57551; Package emacs. Full text available.

Message received at 57551 <at> debbugs.gnu.org:


Received: (at 57551) by debbugs.gnu.org; 4 Sep 2022 15:15:51 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Sep 04 11:15:51 2022
Received: from localhost ([127.0.0.1]:45441 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oUrLj-0003lq-HR
	for submit <at> 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 <kobarity@HIDDEN>) id 1oUrLi-0003le-EK
 for 57551 <at> 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 <at> 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: <eke7zgff41cz.wl-kobarity@HIDDEN>
From: kobarity <kobarity@HIDDEN>
To: Dima Kogan <dima@HIDDEN>
Subject: Re: 29.0.50;
 hide-show in python-mode selects the current block imperfectly
In-Reply-To: <87zgfhtqng.fsf@HIDDEN>
References: <87zgfhtqng.fsf@HIDDEN>
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 <at> debbugs.gnu.org, Lars Ingebrigtsen <larsi@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
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,




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#57551; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 2 Sep 2022 21:25:57 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Sep 02 17:25:56 2022
Received: from localhost ([127.0.0.1]:40533 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oUEAm-00072N-Fa
	for submit <at> 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 <dima@HIDDEN>) id 1oUEAl-00072G-Ai
 for submit <at> 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 <dima@HIDDEN>)
 id 1oUEAi-0001mR-Qz
 for bug-gnu-emacs@HIDDEN; 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 <dima@HIDDEN>)
 id 1oUEAd-00057g-2q
 for bug-gnu-emacs@HIDDEN; 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: <xms:13QSY7ftmp3mGjyzOV1kcYhq8Q7mBPShuMWagDwL3EBZpe7bxEZeyw>
 <xme:13QSYxO9M2tRYtYRFpcNKgi69uETZNtrgP3ANa6LL-nfvrwzJLeWzKgE7bEkJ4ghc
 9eO3YJISazT6zeQ>
X-ME-Received: <xmr:13QSY0jryt9HfZQNFPZRKGVa_dchOq8erlboPScNfgBlCUncC4HaIDKY>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdeltddgudeigecutefuodetggdotefrod
 ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh
 necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd
 enucfjughrpefhvfevufffkfggtgesthdtredttddttdenucfhrhhomhepffhimhgrucfm
 ohhgrghnuceoughimhgrsehsvggtrhgvthhsrghutggvrdhnvghtqeenucggtffrrghtth
 gvrhhnpedufefhteekvefhtdejjeetjeetgffhjeejfeeiudektdeggeeutefhfeettdef
 jeenucffohhmrghinhepghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpedtnecurf
 grrhgrmhepmhgrihhlfhhrohhmpeguihhmrgesshgvtghrvghtshgruhgtvgdrnhgvth
X-ME-Proxy: <xmx:13QSY89JDDT7YXpiqkZSa-gY30IJ-eQFwdum_g5Z2yadKfm4UL6a1g>
 <xmx:13QSY3sro_wgvSgbiQ6Qtt68T7RmXeqCZJwTNC7RZpc_9SwJg6mW2Q>
 <xmx:13QSY7Gh1GqGAiWhrr6Lfx1cdwikLFX8H4xgprrlAasiT8EExZB3xw>
 <xmx:13QSYwUgr65yujCy9ZQVvreJBV-QujvLi3LdhhCxFPgj2zXRWBcCxg>
Feedback-ID: i3e8042a0:Fastmail
Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri,
 2 Sep 2022 17:25:42 -0400 (EDT)
From: Dima Kogan <dima@HIDDEN>
To: bug-gnu-emacs@HIDDEN
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@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
Received-SPF: pass client-ip=64.147.123.24; envelope-from=dima@HIDDEN;
 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 <larsi@HIDDEN>, kobarity <kobarity@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
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!




Acknowledgement sent to Dima Kogan <dima@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#57551; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 5 Sep 2022 08:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.