From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Antoine Kalmbach Newsgroups: gmane.emacs.bugs Subject: bug#55847: 29.0.50; line-number-at-pos ignores absolute parameter when checking position range Date: Thu, 09 Jun 2022 10:44:25 +0300 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37984"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 55847@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jun 09 09:46:08 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 1nzCrn-0009fR-QB for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 09 Jun 2022 09:46:07 +0200 Original-Received: from localhost ([::1]:49148 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzCrd-0006Dz-Oe for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 09 Jun 2022 03:46:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53598) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzCqk-0006DZ-DK for bug-gnu-emacs@gnu.org; Thu, 09 Jun 2022 03:45:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:50971) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzCqk-0001Rm-5f for bug-gnu-emacs@gnu.org; Thu, 09 Jun 2022 03:45:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nzCqk-0003UC-3B for bug-gnu-emacs@gnu.org; Thu, 09 Jun 2022 03:45:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Antoine Kalmbach Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 09 Jun 2022 07:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55847 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: notabug Original-Received: via spool by 55847-submit@debbugs.gnu.org id=B55847.165476068013357 (code B ref 55847); Thu, 09 Jun 2022 07:45:02 +0000 Original-Received: (at 55847) by debbugs.gnu.org; 9 Jun 2022 07:44:40 +0000 Original-Received: from localhost ([127.0.0.1]:44868 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nzCqE-0003TE-PX for submit@debbugs.gnu.org; Thu, 09 Jun 2022 03:44:40 -0400 Original-Received: from meesny.iki.fi ([195.140.195.201]:46710) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nzCqC-0003T1-ET for 55847@debbugs.gnu.org; Thu, 09 Jun 2022 03:44:29 -0400 Original-Received: from qfinm256.local (unknown [66.159.213.92]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: ane) by meesny.iki.fi (Postfix) with ESMTPSA id 4821120048; Thu, 9 Jun 2022 10:44:26 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1654760666; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to; bh=blSylN+/K+GzLIg0eRXdlenH9f2VZzHckcWU82iMG7s=; b=izYGiwbXyHNvET20z3GLhKsYQod3bcmlWsx2bbp/ZH0v6H+Wk71RjxrLlWIdYorpDqnPoN c1uEmikxVwgelGLvfNS+nhkfdc5GXWvZlaWIVUrGNgRHhsD4q2HFs3Q65NDEAgtVlHfcS/ pGB6LNTHEyOYyXnqj/OVih+ztqYewu0= In-Reply-To: <83bkv35k3r.fsf@gnu.org> (message from Eli Zaretskii on Wed, 08 Jun 2022 17:02:32 +0300) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1654760666; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to; bh=blSylN+/K+GzLIg0eRXdlenH9f2VZzHckcWU82iMG7s=; b=XL5Ltg5F+f+ckl2v3CaC6zAvTMW/WWQNAQtP4jS4rU4NkHw1tAZ9HuEBgREq4ty5sGr+2q bIkDNut1p1eGfzlMbn1WDiSUZIDG2cjzRFSDNejTNBoSgg0ppee9fNZfSdTlUBp7K7zbG8 h7ihZQBldBMQMOmraxhEtln0+k9zU+s= ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=ane smtp.mailfrom=ane@iki.fi ARC-Seal: i=1; s=meesny; d=iki.fi; t=1654760666; a=rsa-sha256; cv=none; b=e2zc77Ic6Mpfxscfpvsydq68YbqIphnS3NrLwJdbPVyXIgGnpILnq4srpGPojMMypT+pf6 1VPjGiQzwcyZi3ivnzPbrEvDdVdR43L5PVlTxxK6J1AFj4Vtr+6NqrKI8SF0/PN6I5EUJO 1Nbj3phSs4LW7WOM1xnoNZxdHG3pvW8= 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:234022 Archived-At: Eli Zaretskii writes: >> 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. > Hmm. The reason I reported a bug is that the pre-28.1 version of line-number-at-pos, which was in Lisp, did in fact work when the buffer was narrowed. What is more, the docstring states that: If the buffer is narrowed, the return value by default counts the lines from the beginning of the accessible portion of the buffer. But if the second optional argument ABSOLUTE is non-nil, the value counts the lines from the absolute start of the buffer, disregarding the narrowing. Hence I would assume that if absolute is non-nil the call to line-number-at-pos should work even if the buffer is narrowed, instead of throwing an error. > You mean BEG, not BEGV_BYTE, I believe. BEGV_BYTE is the _byte_ > position corresponding to BEGV (which is a character position). Right, yes. The actual beginning of the buffer, 1. > 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. > Yes, thanks, this fixes it, it's what the Lisp version of pre-28 did this when absolute was non-nil. -- Antoine Kalmbach