From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Arthur Miller Newsgroups: gmane.emacs.bugs Subject: bug#50646: 28.0.50; narrow-to-defun sometimes narrows to wrong defun Date: Sun, 19 Sep 2021 08:36:54 +0200 Message-ID: References: <3a6fa91859db00e5c382752ddedfbdd0@webmail.orcon.net.nz> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10620"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 50646@debbugs.gnu.org To: Phil Sainty Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Sep 19 08:38:24 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mRqT0-0002aK-TX for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 19 Sep 2021 08:38:23 +0200 Original-Received: from localhost ([::1]:35416 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mRqSz-0006bt-3p for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 19 Sep 2021 02:38:21 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37430) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mRqSg-0006bc-VU for bug-gnu-emacs@gnu.org; Sun, 19 Sep 2021 02:38:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54075) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mRqSg-0000M8-NY for bug-gnu-emacs@gnu.org; Sun, 19 Sep 2021 02:38:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mRqSg-0002zA-IZ for bug-gnu-emacs@gnu.org; Sun, 19 Sep 2021 02:38:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Arthur Miller Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 19 Sep 2021 06:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50646 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 50646-submit@debbugs.gnu.org id=B50646.163203342711394 (code B ref 50646); Sun, 19 Sep 2021 06:38:02 +0000 Original-Received: (at 50646) by debbugs.gnu.org; 19 Sep 2021 06:37:07 +0000 Original-Received: from localhost ([127.0.0.1]:37385 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mRqRn-0002xc-2I for submit@debbugs.gnu.org; Sun, 19 Sep 2021 02:37:07 -0400 Original-Received: from mail-oln040092075068.outbound.protection.outlook.com ([40.92.75.68]:50590 helo=EUR04-VI1-obe.outbound.protection.outlook.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mRqRi-0002x1-Lo for 50646@debbugs.gnu.org; Sun, 19 Sep 2021 02:37:05 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GVyL3qW9XmvIXRH4GopRQ6wgZQbK4Jh10PZbM/mhcZcywe9NnVNCEUU69OgCVaQUWlgUE9OGYkG3a69NwN2qQul1j+DCQhnU85B3ZKBmKwUm/1IxoJrzkokCQ3dhRD2fPiK0PjYfUpKMw9MDGCJAyG6VpsUf97Xv4B7/0rF0RQjyRWF0ozrkckNMlbNZHBRlJa6yjv+h7c3oAQT9JxVP+OfR4zE9tEeIdzEeSPu+30kR/ZQpT/p8if9vT3xh7o/wJ6NXVoaas3OkEVVFrGdmVuASkFMJ4ogMKi5XDaUQBL6qohJtKMwNbRpfKITSKG6bx+dZpfBb84NuNt/8rcdUqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=prwO7IfnRtiCLcqh8bbxQTHJV5L2t/q4QRkKYuXsCVY=; b=iPgpE7wsowWZbb4vMjQA4Io5O6Z7GScdbnuSxIH5gticjPmPKtqdByF6dH9vg/5HulRkRRB/P8eaYCFIllzTCdVCwIWij9CE/+T9qiAwID36g3hUK5TLXLLM5JkcS7v2Sy2BIiRTcWb3leCs4kBflYGRTX/O7RR0mdmr9wl8USChJjvi5vgzYhndwAkUYrr89Xlr2nz5KJIxoKAJ4hu2swpC8/9LAdSi36XDYuPHn0aalQ1gOfhfvRtbsIf5HEg8h0G/MH09r+jpkBYh7t64SSBkBwgBI2Q9ct5DVGV+yDCgPHXxhCBM4MT5nxhlC+IvwVb8M10znBcT1pYtwGon3w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=live.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=prwO7IfnRtiCLcqh8bbxQTHJV5L2t/q4QRkKYuXsCVY=; b=cM/TucDvxtxEDS2w+NxZr0feXgVkP1LQ9PSCeaRPSCcCt4I/f2frWzhqFVB64xz0mNp1FdUTHloAjC1WAP4IoPUuQ33FfEn5j+vvAQ3x4UQcLRm9j0sFXHoQvUUf4A+EAs63oswBuxQ3eIz4fLxImzOQiZl+BApgI5IhVX8iiuL5F6YeazkBBoBS/6V0QwQ1o6QM/VP092TGAhIqP1jgNqfTjl6EVfnZSmQu75euxh+45+Sw1PmoStPYtFg09A8c334OHlvFe48yinfqLzsgeK4emG4jWNdXTEJDVlOhhnQXnjdnY+ssWs03oco88j2qAtdQVAVbX3b6luhxLpsQRQ== Original-Received: from AM9PR09MB4977.eurprd09.prod.outlook.com (2603:10a6:20b:304::20) by AM9PR09MB5139.eurprd09.prod.outlook.com (2603:10a6:20b:300::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.17; Sun, 19 Sep 2021 06:36:55 +0000 Original-Received: from AM9PR09MB4977.eurprd09.prod.outlook.com ([fe80::c55c:ece5:bed2:a9dc]) by AM9PR09MB4977.eurprd09.prod.outlook.com ([fe80::c55c:ece5:bed2:a9dc%9]) with mapi id 15.20.4523.018; Sun, 19 Sep 2021 06:36:55 +0000 In-Reply-To: <3a6fa91859db00e5c382752ddedfbdd0@webmail.orcon.net.nz> (Phil Sainty's message of "Sun, 19 Sep 2021 15:41:03 +1200") X-TMN: [VbxWixcYRo06J+Nf6ZDu95beZTsHQguk] X-ClientProxiedBy: AM6P195CA0028.EURP195.PROD.OUTLOOK.COM (2603:10a6:209:81::41) To AM9PR09MB4977.eurprd09.prod.outlook.com (2603:10a6:20b:304::20) X-Microsoft-Original-Message-ID: <87a6k9f4vt.fsf@live.com> X-MS-Exchange-MessageSentRepresentingType: 1 Original-Received: from pascal.homepc (81.232.177.30) by AM6P195CA0028.EURP195.PROD.OUTLOOK.COM (2603:10a6:209:81::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Sun, 19 Sep 2021 06:36:54 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b7bbb817-a4a3-4101-0192-08d97b37df58 X-MS-TrafficTypeDiagnostic: AM9PR09MB5139: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: emwRwDa/k8lBaERMPN5iBVKhZVCI5b2e7mbP7jlVJzKTkUcN0hZTUVJ0k8HAy6ZKv4ok9kUNhUOe5ZjKwE46WonAVpj7aSoE/NpMv7RVTAkeKNkc2uk+7fvpKkvw9HR1ftJb+gFZKB3pFbJlHsEKaO3r6fbhg9akb+ueFa9LCA+Bq6KQdHhXTLmfaO9oLOsb0EezFuo9P1W6kyG5QZOggZApppHbKr1LfVP+ldRdLnMQD02xw5R6RzGhOI+tNt9adZg83ualL8JgrE0XC8giYCVTw7qpgu38qk/4XTvhhMsdPu1hKjt2wfs4a+6lUXcr2kqNgXCJoPsSq8AorYo+e+jc0j8lezoeV/C3HAzgSJafxIi1utyQOyD5XcLI6zrRW1tfzSMOnVu7epsUY8EomsSyeXxZkny/21LYw7LMl7zGAFtfUFdQDpjFlT7RmerUcWWMPQ76YijlgZYiuylfTRdwYZafk1WKMoXaZbniM7E= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: E+j7cxHGMyhHtKS/1k53vTlE4UBVp+NH2jXMSuH7U+nuwgeyxmDH37ZVQfXLUTJaiO0HMEZ3ydR7v97QEo3NPrw9Bc1+aW/DIKrO2WvERcR56yx7aszckz6tdomr8WcuqLgZx2+Ev7V0WjPLzmGR9Q== X-OriginatorOrg: sct-15-20-3174-20-msonline-outlook-72e6e.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: b7bbb817-a4a3-4101-0192-08d97b37df58 X-MS-Exchange-CrossTenant-AuthSource: AM9PR09MB4977.eurprd09.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Sep 2021 06:36:55.4501 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR09MB5139 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:214686 Archived-At: Phil Sainty writes: > On 2021-09-18 05:06, arthur.miller@live.com wrote: >> 1. run Emacs -Q -l /path/to/attached/help-mode.el >> 2. type C-x f > > C-h f > >> 3. in minibuffer type: when RET >> The help-mode buffer that opens should show help for 'when' form, but it >> shows the source code for the 'pop' macro which precedes the 'when' in >> subr.el. > >> The docs for 'narrow-to-defun' says the "current-defun" is one that >> contains the point or follows the point. > > I can reproduce the issue using your code, but I'm not sure whether the > reason for it is a misunderstanding of what 'point' is, some vagueness > in the 'narrow-to-defun' docstring, or an actual regression. > > To eliminate the first: > > "Like other positions, point designates a place between two characters > (or before the first character, or after the last character), rather > than a particular character. Usually terminals display the cursor over > the character that immediately follows point; point is actually before > the character on which the cursor sits." > > -- quoted from (info "(elisp)Point") Yes, I am aware that point is between two characters. I also use the bar for the cursor, and it is displayed before the first character; I think. > 'narrow-to-defun' says "The current defun is the one that contains point > or follows point." and if you place the cursor over the opening "(" of > "(defmacro when" then that defmacro form "follows point", and indeed > narrow-to-defun works as intended. Than it is probably my understanding of "follows" the point. In my understanding it was the "one that comes after" the point :). Notice that I tried to move the point one character forward (or I think even two, but I don't remember any more), but it didn't helped. When I moved few characters, like with forward-word helps, which is also what you say. > The issue is what happens when point is somewhere earlier than that > position, but still *after* the previous form. In that instance > narrow-to-defun narrows to the previous form, which is surely what is > happening in your code. > > If so, all you need for reproducing this is to experiment with > narrow-to-defun at the various positions between two forms. > > That is a consequence of 'beginning-of-defun' jumping to the beginning > of the previous defun in that situation That sounds like a plausible explanation. I haven't looked into the code for narrow-to-defun. My question is though, why it happens only with 'when'? I haven't found any other form to show same behaviour. There probably are some, I just haven't found them by manually testing. > reasonable behaviour for that function); but for 'narrow-to-defun' > the effect does seem contrary to its docstring. > > I think we just want to change the docstring of 'narrow-to-defun' -- > the last relevant commit looks like: > > > commit 050cc68b402f5998193a6026d0eeeecb9d2cb9c4 > Author: Lennart Borgman > Date: Wed Apr 11 04:12:20 2012 +0200 > > `narrow-to-defun' fixup > > * emacs-lisp/lisp.el (narrow-to-defun): `beginning-of-defun' goes > to previous function when point is on the first character of a > function. Take care of that in `narrow-to-defun'. > > Fixes: debbugs:6157 > > https://debbugs.gnu.org/cgi/bugreport.cgi?bug=6157 > Anyway, thank you for the explanation and for the time and for the updated docs.