From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Phil Sainty Newsgroups: gmane.emacs.bugs Subject: bug#50646: 28.0.50; narrow-to-defun sometimes narrows to wrong defun Date: Sun, 19 Sep 2021 15:41:03 +1200 Message-ID: <3a6fa91859db00e5c382752ddedfbdd0@webmail.orcon.net.nz> References: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18596"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Orcon Webmail Cc: 50646@debbugs.gnu.org To: arthur.miller@live.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Sep 19 05:42:13 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 1mRniX-0004e5-JN for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 19 Sep 2021 05:42:13 +0200 Original-Received: from localhost ([::1]:43526 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mRniV-0001oV-IP for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 18 Sep 2021 23:42:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51646) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mRniM-0001lo-Md for bug-gnu-emacs@gnu.org; Sat, 18 Sep 2021 23:42:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53947) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mRniM-0001lw-ET for bug-gnu-emacs@gnu.org; Sat, 18 Sep 2021 23:42:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mRniM-0006cT-2B for bug-gnu-emacs@gnu.org; Sat, 18 Sep 2021 23:42:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Phil Sainty Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 19 Sep 2021 03:42: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.163202287025381 (code B ref 50646); Sun, 19 Sep 2021 03:42:02 +0000 Original-Received: (at 50646) by debbugs.gnu.org; 19 Sep 2021 03:41:10 +0000 Original-Received: from localhost ([127.0.0.1]:37260 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mRnhV-0006bJ-QF for submit@debbugs.gnu.org; Sat, 18 Sep 2021 23:41:10 -0400 Original-Received: from smtp-2.orcon.net.nz ([60.234.4.43]:37291) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mRnhS-0006b8-8W for 50646@debbugs.gnu.org; Sat, 18 Sep 2021 23:41:08 -0400 Original-Received: from [10.253.37.70] (port=64510 helo=webmail.orcon.net.nz) by smtp-2.orcon.net.nz with esmtpa (Exim 4.90_1) (envelope-from ) id 1mRnhP-0004jt-4D; Sun, 19 Sep 2021 15:41:03 +1200 Original-Received: from ip-203-94-48-127.kinect.net.nz ([203.94.48.127]) via [10.253.37.253] by webmail.orcon.net.nz with HTTP (HTTP/1.1 POST); Sun, 19 Sep 2021 15:41:03 +1200 In-Reply-To: X-Sender: psainty@orcon.net.nz X-GeoIP: -- X-Spam_score: -2.9 X-Spam_score_int: -28 X-Spam_bar: -- 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:214676 Archived-At: 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") '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. 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 (which to me seems like a 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 -Phil