From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#55847: 29.0.50; line-number-at-pos ignores absolute parameter when checking position range Date: Wed, 08 Jun 2022 17:02:32 +0300 Message-ID: <83bkv35k3r.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37391"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 55847@debbugs.gnu.org To: Antoine Kalmbach Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jun 08 16:38:18 2022 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 1nywp8-0009b7-E1 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 08 Jun 2022 16:38:18 +0200 Original-Received: from localhost ([::1]:47904 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nywp7-0006JP-Ez for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 08 Jun 2022 10:38:17 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50780) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nywH0-0007A6-FO for bug-gnu-emacs@gnu.org; Wed, 08 Jun 2022 10:03:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:50026) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nywH0-0005tf-6L for bug-gnu-emacs@gnu.org; Wed, 08 Jun 2022 10:03:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nywH0-0002cq-3X for bug-gnu-emacs@gnu.org; Wed, 08 Jun 2022 10:03:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 08 Jun 2022 14:03:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55847 X-GNU-PR-Package: emacs Original-Received: via spool by 55847-submit@debbugs.gnu.org id=B55847.165469696610050 (code B ref 55847); Wed, 08 Jun 2022 14:03:02 +0000 Original-Received: (at 55847) by debbugs.gnu.org; 8 Jun 2022 14:02:46 +0000 Original-Received: from localhost ([127.0.0.1]:43919 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nywGj-0002bz-K5 for submit@debbugs.gnu.org; Wed, 08 Jun 2022 10:02:45 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:37440) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nywGh-0002bh-R9; Wed, 08 Jun 2022 10:02:44 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:33562) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nywGc-0005ro-Es; Wed, 08 Jun 2022 10:02:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=CT8N2FLo+25sv1d9bcwFIUPMTW1ks3kdl7VvbwpCl3M=; b=LmmgznQNlc0n j1iuiLYy0OrG1OJMPMF6FNiHATzZR5ueMO2SlEyqOf1rzkUG+8aVri2XmOR0Vc3mkuDIAtQc3pbqK rczZDuby6ukt5gVqpvu0m1s2kkZYOcYyuTZPMYTCIHvydZCVxXJQh7clxbgPoCZ22Nf/J6uDJfw60 03d+gDFfawdrC9u/XD3R9jN3BM9htZP446YPEIKA3O+xrh+qVKW/AO0ghWCQG+mUgmXciV9hqEZ2n kg04Bg4HQ0RKebk31V9ZfcTuePKBEcVWlAfiShLUeMHXnavu9YECVoWT3jaMdh4DMa+DIlrUEzpM9 hSiZiMQ0GD2TA9NJn/ehug==; Original-Received: from [87.69.77.57] (port=3553 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nywGb-0001Ai-Oo; Wed, 08 Jun 2022 10:02:38 -0400 In-Reply-To: (message from Antoine Kalmbach on Wed, 08 Jun 2022 14:44:10 +0300) 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:233976 Archived-At: tags 55847 notabug thanks > From: Antoine Kalmbach > Date: Wed, 08 Jun 2022 14:44:10 +0300 > > > When working with a narrowed buffer, line-number-at-pos complains > that the passed position parameter is out of range. > > I believe this occurs because in fns.c there is check as follows: > > if (pos < BEGV || pos > ZV) Yes, and that's by design. With very rare exceptions, Emacs always behaves as if text outside of the narrowed region doesn't exist. This is not a bug. > This works just fine when the buffer isn't narrowed, but narrowing > affects BEGV. Suppose the buffer is narrowed, and you want to get the > line number for position x where x is before where the current narrowing > begins, passing (line-number-at-pos x t) now reports an error, because > the correct thing to check is BEGV_BYTE, not BEGV. You mean BEG, not BEGV_BYTE, I believe. BEGV_BYTE is the _byte_ position corresponding to BEGV (which is a character position). Anyway, if you want to get line-number-at-pos outside of the restriction, you can simply do (save-restriction (widen) (line-number-at-pos POS)) This is what we do in Emacs if we want to access position outside of the narrowed region.