GNU bug report logs - #80150
30.1.90; No simple way to go to a line number from Lisp while respecting widen-automatically

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: Spencer Baugh <sbaugh@HIDDEN>; Done: Juri Linkov <juri@HIDDEN>; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
bug marked as fixed in version 31.0.50, send any further explanations to 80150 <at> debbugs.gnu.org and Spencer Baugh <sbaugh@HIDDEN> Request was from Juri Linkov <juri@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

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


Received: (at 80150) by debbugs.gnu.org; 19 Jan 2026 18:40:53 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jan 19 13:40:53 2026
Received: from localhost ([127.0.0.1]:49226 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vhuBJ-000313-0M
	for submit <at> debbugs.gnu.org; Mon, 19 Jan 2026 13:40:53 -0500
Received: from mout-p-201.mailbox.org ([80.241.56.171]:37612)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <juri@HIDDEN>)
 id 1vhuBF-00030c-VB; Mon, 19 Jan 2026 13:40:51 -0500
Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
 (No client certificate requested)
 by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4dvzmS204Rz9txp;
 Mon, 19 Jan 2026 19:40:40 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linkov.net; s=MBO0001; 
 t=1768848040;
 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:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=lMI1W1TCEm6mgzrmZKVnYtWs7T4CL/TUn0XHYJxE/B4=;
 b=pWSkcUtMmz5PrPwES0YSQExlD3SP0vYyQ75cx2nl6HGjSqcFpg8Fk0ZzhlbU6Lsl2jgOUQ
 iVn5gMR3yveRtb6YiKRmwpejPkr1mz9U9TCyi4WlV7L2TBOVvCehuuMtCsKKA7b54b0HWH
 d2DJMUJEiwloEpCmSsdiKczoIpFXU7n6aeIjGmJEh533sV80LokAf+f4fwz+cku/MQSjAa
 l+cs0j6aJgN72D62k5y77OzKh4ls+PKv/kRSb8fsSUy0Xg+6fCmvsF5f/UES6HbNovf5Yc
 cBOmfy+q959ZtvCSduF0R+DpYZ3siHcdfGzsw3V3JNFmaHUgY8IfaxLiVNgfyA==
From: Juri Linkov <juri@HIDDEN>
To: Spencer Baugh <sbaugh@HIDDEN>
Subject: Re: bug#80150: 30.1.90; No simple way to go to a line number from
 Lisp while respecting widen-automatically
In-Reply-To: <87fr86pwqe.fsf@HIDDEN>
Organization: LINKOV.NET
References: <ierv7hd8u4y.fsf@HIDDEN> <86ms2pcyja.fsf@HIDDEN>
 <iersech8qpp.fsf@HIDDEN> <86ikddcwne.fsf@HIDDEN>
 <ierms2p8ogf.fsf@HIDDEN> <87pl7d48vk.fsf@HIDDEN>
 <878qdyrcrf.fsf@HIDDEN> <ier3446pxvu.fsf@HIDDEN>
 <87fr86pwqe.fsf@HIDDEN>
Date: Mon, 19 Jan 2026 20:39:49 +0200
Message-ID: <87fr815tvu.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 80150
Cc: Eli Zaretskii <eliz@HIDDEN>, 80150 <at> debbugs.gnu.org
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 (-)

close 80150 31.0.50
thanks

>>> Even the docstring says twice "If called interactively",
>>> so here is the patch that allows non-interactive calls:
>>
>> This looks good to me.  Maybe we should have a NEWS entry too, though?
>
> Not sure about NEWS — this would encourage non-interactive use,
> whereas it looks like an exception: only when widening is required.

So now pushed without announcing in NEWS.




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

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


Received: (at 80150) by debbugs.gnu.org; 15 Jan 2026 18:19:46 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 15 13:19:46 2026
Received: from localhost ([127.0.0.1]:49735 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vgRwg-0000ek-88
	for submit <at> debbugs.gnu.org; Thu, 15 Jan 2026 13:19:46 -0500
Received: from mout-p-202.mailbox.org ([80.241.56.172]:46536)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <juri@HIDDEN>) id 1vgRwd-0000eV-KA
 for 80150 <at> debbugs.gnu.org; Thu, 15 Jan 2026 13:19:44 -0500
Received: from smtp1.mailbox.org (smtp1.mailbox.org
 [IPv6:2001:67c:2050:b231:465::1])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
 (No client certificate requested)
 by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4dsWTz75cdz9syn;
 Thu, 15 Jan 2026 19:19:35 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linkov.net; s=MBO0001; 
 t=1768501176;
 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:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=gQkYlykEPAtxc9G1ODBpDQ4g02BbwR8e/F/7AQJz13s=;
 b=mOfDAeuH2/U8cQrszFI0ef8tND7QYDIbPLDRA4/7nozO3wpbX37zOk0lw+GExNUp6ef4Li
 mBpMWpCfIlGep0cozI+yo41RzNHBND3a+ILANPTmeaqwF01y0PO6OYtaLkbOdZVgJE7+P/
 QJ18JkKOM70PEKhjNnbcN8oYLn4B02vPlDxvvXZB8MhrcYvUhrETikks+XEOant7Fd9A0u
 8phJ102R6f+V6iRo6zvVCX/6W37thvQtJitVnIDz/jFshAvc0wvFSwV+/pxxo+T7TVilxM
 3aBtg2Fg99v1SBGAl7gj6o3VZLsPf8BU+DaXKIYYUhXp/RkqLGiFUgK1kMovfQ==
Authentication-Results: outgoing_mbo_mout; dkim=none;
 spf=pass (outgoing_mbo_mout: domain of juri@HIDDEN designates
 2001:67c:2050:b231:465::1 as permitted sender) smtp.mailfrom=juri@HIDDEN
From: Juri Linkov <juri@HIDDEN>
To: Spencer Baugh <sbaugh@HIDDEN>
Subject: Re: bug#80150: 30.1.90; No simple way to go to a line number from
 Lisp while respecting widen-automatically
In-Reply-To: <ier3446pxvu.fsf@HIDDEN>
Organization: LINKOV.NET
References: <ierv7hd8u4y.fsf@HIDDEN> <86ms2pcyja.fsf@HIDDEN>
 <iersech8qpp.fsf@HIDDEN> <86ikddcwne.fsf@HIDDEN>
 <ierms2p8ogf.fsf@HIDDEN> <87pl7d48vk.fsf@HIDDEN>
 <878qdyrcrf.fsf@HIDDEN> <ier3446pxvu.fsf@HIDDEN>
Date: Thu, 15 Jan 2026 20:16:41 +0200
Message-ID: <87fr86pwqe.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Rspamd-Queue-Id: 4dsWTz75cdz9syn
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 80150
Cc: Eli Zaretskii <eliz@HIDDEN>, 80150 <at> debbugs.gnu.org
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 (-)

>> Even the docstring says twice "If called interactively",
>> so here is the patch that allows non-interactive calls:
>
> This looks good to me.  Maybe we should have a NEWS entry too, though?

Not sure about NEWS — this would encourage non-interactive use,
whereas it looks like an exception: only when widening is required.




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

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


Received: (at 80150) by debbugs.gnu.org; 15 Jan 2026 17:51:56 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 15 12:51:56 2026
Received: from localhost ([127.0.0.1]:49665 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vgRVk-0007dJ-62
	for submit <at> debbugs.gnu.org; Thu, 15 Jan 2026 12:51:56 -0500
Received: from mxout5.mail.janestreet.com ([64.215.233.18]:59445)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <sbaugh@HIDDEN>)
 id 1vgRVi-0007d6-EM
 for 80150 <at> debbugs.gnu.org; Thu, 15 Jan 2026 12:51:54 -0500
From: Spencer Baugh <sbaugh@HIDDEN>
To: Juri Linkov <juri@HIDDEN>
Subject: Re: bug#80150: 30.1.90; No simple way to go to a line number from
 Lisp while respecting widen-automatically
In-Reply-To: <878qdyrcrf.fsf@HIDDEN> (Juri Linkov's message of "Thu, 
 15 Jan 2026 19:45:08 +0200")
References: <ierv7hd8u4y.fsf@HIDDEN> <86ms2pcyja.fsf@HIDDEN>
 <iersech8qpp.fsf@HIDDEN> <86ikddcwne.fsf@HIDDEN>
 <ierms2p8ogf.fsf@HIDDEN> <87pl7d48vk.fsf@HIDDEN>
 <878qdyrcrf.fsf@HIDDEN>
Date: Thu, 15 Jan 2026 12:51:49 -0500
Message-ID: <ier3446pxvu.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com;
 s=waixah; t=1768499509;
 bh=43f5vH3ftEcGh4K/6MOBtn6RptUvadoYseQ3CXIrEV0=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date;
 b=p3gtZQ9HxBQ4jWiTstzu1bscpZgyYw3FXKddmF0ZmjYSLkdGc9jvDcqk3YsEZhH30
 NMk6aeGJGe9BRPYVwc9nTCOTtPiEBr0Qnrg3CZXX9xXdj4VVxFD6IzMvMp5vbCNKwe
 BOmAxgwDW+3VwwXrtcoRo3yNYywWkuktvsZcuMt1BKuxCIz6bt5xOtveLycc39+l0d
 96Lukqzq6cgjN1GVVclEd/AK1xzGSYDCweIKnqaufavcWRPVZcmTlrbau1tcNPzF8y
 wxkgLapi5hyAF5ATngIU+Ay11TNWk8UR6XzpS/wlUDPjO3U5BGokFEACfs0p5YjsF/
 21d6pJyzvOULQ==
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 80150
Cc: Eli Zaretskii <eliz@HIDDEN>, 80150 <at> debbugs.gnu.org
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 (---)

Juri Linkov <juri@HIDDEN> writes:

>>> If you look at goto-line, you'll see this is almost identical to some
>>> code in there.
>>
>> If you need to use 'goto-line' programmatically taking into account
>> narrowing, then we could add a new argument 'interactive'.
>>
>> I see only one line that should depend on this argument:
>>
>>   ;; Leave mark at previous position
>>   (or (region-active-p) (push-mark))
>>
>> All the rest of the function doesn't contain parts
>> that would require interactive-only.
>
> Even the docstring says twice "If called interactively",
> so here is the patch that allows non-interactive calls:

This looks good to me.  Maybe we should have a NEWS entry too, though?




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

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


Received: (at 80150) by debbugs.gnu.org; 15 Jan 2026 17:48:46 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 15 12:48:46 2026
Received: from localhost ([127.0.0.1]:49656 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vgRSg-0007Nj-AB
	for submit <at> debbugs.gnu.org; Thu, 15 Jan 2026 12:48:46 -0500
Received: from mout-p-103.mailbox.org ([80.241.56.161]:34608)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <juri@HIDDEN>) id 1vgRSd-0007ND-5w
 for 80150 <at> debbugs.gnu.org; Thu, 15 Jan 2026 12:48:43 -0500
Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
 (No client certificate requested)
 by mout-p-103.mailbox.org (Postfix) with ESMTPS id 4dsVp95gBmz9tkc;
 Thu, 15 Jan 2026 18:48:33 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linkov.net; s=MBO0001; 
 t=1768499313;
 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:references:references;
 bh=usfpQ3eibIYuhwl4g32YRaCpdaB3dVuY0zCYvdrzpX8=;
 b=v8DHcW0da8TI8MmtXIPHgmoEkWRbzi7klzIcgXFTc6HltrKvnh0/3LnaQUQZr950ae/KoV
 AHyw5yEZLqsz209ahSPfx+QTOWfKkbMalY04a6DjZwCDK52dMKfbMLbINi6wi09dFyUkO6
 77Z/UoUP6DAmER1rWa55ysbL2wSPmtSyh2AOu3OZ20N7AMbCHA78iO/jQ41X8v3AxStivI
 vQURNyfwpH2cxOhrrtARKTKEALsv/pOAhCjR1UMivvtIaNKd0oRnhD8IyoAKu2Pv8B02KX
 kRPXE2Dd8+JkfZMcxGdUvPY4ldEYPNlGwg5ZluZN/KoHCMOzM2FN9xl2QVes8g==
From: Juri Linkov <juri@HIDDEN>
To: Spencer Baugh <sbaugh@HIDDEN>
Subject: Re: bug#80150: 30.1.90; No simple way to go to a line number from
 Lisp while respecting widen-automatically
In-Reply-To: <87pl7d48vk.fsf@HIDDEN>
Organization: LINKOV.NET
References: <ierv7hd8u4y.fsf@HIDDEN> <86ms2pcyja.fsf@HIDDEN>
 <iersech8qpp.fsf@HIDDEN> <86ikddcwne.fsf@HIDDEN>
 <ierms2p8ogf.fsf@HIDDEN> <87pl7d48vk.fsf@HIDDEN>
Date: Thu, 15 Jan 2026 19:45:08 +0200
Message-ID: <878qdyrcrf.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 80150
Cc: Eli Zaretskii <eliz@HIDDEN>, 80150 <at> debbugs.gnu.org
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 (-)

--=-=-=
Content-Type: text/plain

>> If you look at goto-line, you'll see this is almost identical to some
>> code in there.
>
> If you need to use 'goto-line' programmatically taking into account
> narrowing, then we could add a new argument 'interactive'.
>
> I see only one line that should depend on this argument:
>
>   ;; Leave mark at previous position
>   (or (region-active-p) (push-mark))
>
> All the rest of the function doesn't contain parts
> that would require interactive-only.

Even the docstring says twice "If called interactively",
so here is the patch that allows non-interactive calls:


--=-=-=
Content-Type: text/x-diff
Content-Disposition: inline; filename=goto-line-interactive.patch

diff --git a/lisp/simple.el b/lisp/simple.el
index f06e473d383..ff06d6ac55e 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1638,7 +1638,7 @@ goto-line-read-args
                          'goto-line-history)
             buffer))))
 
-(defun goto-line (line &optional buffer relative)
+(defun goto-line (line &optional buffer relative interactive)
   "Go to LINE, counting from line 1 at beginning of buffer.
 If called interactively, a numeric prefix argument specifies
 LINE; without a numeric prefix argument, read LINE from the
@@ -1659,21 +1659,23 @@ goto-line
 activating it), unless Transient Mark mode is enabled and the
 mark is already active.
 
+A non-nil INTERACTIVE argument means to push the mark.
+
 This function is usually the wrong thing to use in a Lisp program.
 What you probably want instead is something like:
   (goto-char (point-min))
   (forward-line (1- N))
 If at all possible, an even better solution is to use char counts
 rather than line counts."
-  (declare (interactive-only forward-line))
-  (interactive (goto-line-read-args))
+  (interactive (append (goto-line-read-args) '(nil t)))
   ;; Switch to the desired buffer, one way or another.
   (if buffer
       (let ((window (get-buffer-window buffer)))
 	(if window (select-window window)
 	  (switch-to-buffer-other-window buffer))))
   ;; Leave mark at previous position
-  (or (region-active-p) (push-mark))
+  (when interactive
+    (or (region-active-p) (push-mark)))
   ;; Move to the specified line number in that buffer.
   (let ((pos (save-restriction
                (unless relative (widen))
@@ -1690,14 +1692,13 @@ goto-line
       (widen))
     (goto-char pos)))
 
-(defun goto-line-relative (line &optional buffer)
+(defun goto-line-relative (line &optional buffer interactive)
   "Go to LINE, counting from line at (point-min).
 The line number is relative to the accessible portion of the narrowed
-buffer.  The argument BUFFER is the same as in the function `goto-line'."
-  (declare (interactive-only forward-line))
-  (interactive (goto-line-read-args t))
-  (with-suppressed-warnings ((interactive-only goto-line))
-    (goto-line line buffer t)))
+buffer.  The argument BUFFER is the same as in the function `goto-line'.
+A non-nil INTERACTIVE argument means to push the mark."
+  (interactive (append (goto-line-read-args t) t))
+  (goto-line line buffer t interactive))
 
 (defun count-words-region (start end &optional arg)
   "Count the number of words in the region.

--=-=-=--




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

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


Received: (at 80150) by debbugs.gnu.org; 13 Jan 2026 19:24:18 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jan 13 14:24:18 2026
Received: from localhost ([127.0.0.1]:43948 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vfk01-00050Q-T0
	for submit <at> debbugs.gnu.org; Tue, 13 Jan 2026 14:24:18 -0500
Received: from mout-p-202.mailbox.org ([80.241.56.172]:51404)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <juri@HIDDEN>) id 1vfjzz-000508-JE
 for 80150 <at> debbugs.gnu.org; Tue, 13 Jan 2026 14:24:16 -0500
Received: from smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
 (No client certificate requested)
 by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4drK1M6x8nz9tQS;
 Tue, 13 Jan 2026 20:24:07 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linkov.net; s=MBO0001; 
 t=1768332248;
 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:references:references;
 bh=Gs+YqSINDMsWxWQer8bkFtD3mAKjmx8hhUZGu8KqM0w=;
 b=R4IAKHbPTQaFRDsVvdQOwT//uTlkIcP9dTUX7GCGJBq4dKYvIQ35X6uwc8T0zI2JVA6zzW
 w3HsZVbLC/+ayULLECPi4i9wlo06MfOIBwdObdwil5Gq07UtppC43QKJaPdUC2zKCQCzHy
 cKGr1bM0/+VRjz9vYAChDcHzWstRTxACfGroeQ/COeR4bbLYHa2XFllsgOSjSadKifmHgP
 D/YqNUK12/4qm08VcGriE6Je5HZJ3OeA/mwLQQJTFFBFgcRcK6X/xuvz440Tl4DBBUj7lz
 HZ2QpvBAM8amG00YqY8syRbHcP9/i+aBY989ITZHev+SgrPyv740diqSXyqaiA==
From: Juri Linkov <juri@HIDDEN>
To: Spencer Baugh <sbaugh@HIDDEN>
Subject: Re: bug#80150: 30.1.90; No simple way to go to a line number from
 Lisp while respecting widen-automatically
In-Reply-To: <ierms2p8ogf.fsf@HIDDEN>
Organization: LINKOV.NET
References: <ierv7hd8u4y.fsf@HIDDEN> <86ms2pcyja.fsf@HIDDEN>
 <iersech8qpp.fsf@HIDDEN> <86ikddcwne.fsf@HIDDEN>
 <ierms2p8ogf.fsf@HIDDEN>
Date: Tue, 13 Jan 2026 21:20:47 +0200
Message-ID: <87pl7d48vk.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 80150
Cc: Eli Zaretskii <eliz@HIDDEN>, 80150 <at> debbugs.gnu.org
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 (-)

> The real-world code to do this is more complex than that.
>
> Real-world code to do this looks like:
>
> (let ((pos (save-restriction
>              (widen)
>              (goto-char (point-min))
>              (forward-line (1- line))
>              (point))))
>   (when (and (buffer-narrowed-p)
>              widen-automatically
>              (or (> (point-min) pos) (> pos (point-max))))
>     (widen))
>   (goto-char pos))
>
> If you look at goto-line, you'll see this is almost identical to some
> code in there.

If you need to use 'goto-line' programmatically taking into account
narrowing, then we could add a new argument 'interactive'.

I see only one line that should depend on this argument:

  ;; Leave mark at previous position
  (or (region-active-p) (push-mark))

All the rest of the function doesn't contain parts
that would require interactive-only.




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

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


Received: (at 80150) by debbugs.gnu.org; 7 Jan 2026 14:52:40 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jan 07 09:52:40 2026
Received: from localhost ([127.0.0.1]:35445 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vdUts-0005K7-6L
	for submit <at> debbugs.gnu.org; Wed, 07 Jan 2026 09:52:40 -0500
Received: from mxout5.mail.janestreet.com ([64.215.233.18]:39819)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <sbaugh@HIDDEN>)
 id 1vdUtp-0005Jr-Om
 for 80150 <at> debbugs.gnu.org; Wed, 07 Jan 2026 09:52:38 -0500
From: Spencer Baugh <sbaugh@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#80150: 30.1.90; No simple way to go to a line number from
 Lisp while respecting widen-automatically
In-Reply-To: <86ikddcwne.fsf@HIDDEN> (Eli Zaretskii's message of "Wed, 07 Jan
 2026 16:41:57 +0200")
References: <ierv7hd8u4y.fsf@HIDDEN> <86ms2pcyja.fsf@HIDDEN>
 <iersech8qpp.fsf@HIDDEN> <86ikddcwne.fsf@HIDDEN>
Date: Wed, 07 Jan 2026 09:52:32 -0500
Message-ID: <ierms2p8ogf.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com;
 s=waixah; t=1767797552;
 bh=hr1TcOYECenA7LVsXzbkZwZErvRVubxrza9/OxwVVW4=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date;
 b=0f5A1fJa49N1gjckYEACzALs4KpN6aHa0T9N0BZlrpnS4xZPv1OjljP3aRI0tjzr5
 kunf7YnsLEQKV6yET+6aZxgL3NZi5HFP23BBgr7Y2xmrWZZjQnsNq56LwANg25YtKY
 fdCAxIEn/LHP/+UNa3j3zc/6y+FQqhCF5EKeuou+sj0VY6p06dFdQXFRHFI8LN2BGW
 KkPsgOeWITcCOoQv/qyv4a+QujTdI7K+AuGXIoTL0T7bXQLd1NBaNm6Nu9qOWOyUeX
 1KBdPjbNdUBwLVcFEUUPRypGfMJfPSgoFQJXT9LKQ/CWb1P8V9e22Kxi1QwfzYKffs
 AJp5F91LEPvXA==
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 80150
Cc: 80150 <at> debbugs.gnu.org
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 (---)

Eli Zaretskii <eliz@HIDDEN> writes:

>> From: Spencer Baugh <sbaugh@HIDDEN>
>> Cc: 80150 <at> debbugs.gnu.org
>> Date: Wed, 07 Jan 2026 09:03:46 -0500
>> 
>> Eli Zaretskii <eliz@HIDDEN> writes:
>> 
>> >> Date: Wed, 07 Jan 2026 07:49:49 -0500
>> >> From:  Spencer Baugh via "Bug reports for GNU Emacs,
>> >>  the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
>> >> 
>> >> 
>> >> There's no function to go to a line number from Lisp while respecting
>> >> widen-automatically: that is, if the buffer is narrowed, automatically
>> >> widen it.  goto-line does exactly this, but it's marked
>> >> interactive-only.  I think we should extract the relevant part of
>> >> goto-line into a separate function which can be used from Lisp.
>> >> 
>> >> I often need to do this because other programs produce file positions in
>> >> terms of line numbers, and I need to jump the user to these positions.
>> >
>> > The doc string of goto-line tells you what to do non-interactively.
>> > Why is doing that in your case a problem?
>> 
>> It doesn't respect widen-automatically.  That is, if the buffer is
>> narrowed, it doesn't automatically widen it if and only if it's
>> necesasry.
>
> "We have the technology."  What you need is something as simple as the
> below:
>
>    (save-restriction
>      (goto-char (point-min))
>      (forward-line (1- N))
>      (DO-SOMETHING))
> or
>    (widen)
>    (goto-char (point-min))
>    (forward-line (1- N))
>    (DO-SOMETHING)
>
> (depending on what you need to do in DO-SOMETHING).

The real-world code to do this is more complex than that.

Real-world code to do this looks like:

(let ((pos (save-restriction
             (widen)
             (goto-char (point-min))
             (forward-line (1- line))
             (point))))
  (when (and (buffer-narrowed-p)
             widen-automatically
             (or (> (point-min) pos) (> pos (point-max))))
    (widen))
  (goto-char pos))

If you look at goto-line, you'll see this is almost identical to some
code in there.

> I'm asking why do we need something else?

We don't need something else.  This code already exists in Emacs, it's
just inside an interactive-only function.

> and why does widening have to happen automatically?

Because widen-automatically is non-nil, which is the default.  See for
example xref--goto-char: xref (and eglot, which calls xref--goto-char)
will also automatically widen when jumping to a position.




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

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


Received: (at 80150) by debbugs.gnu.org; 7 Jan 2026 14:42:14 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jan 07 09:42:14 2026
Received: from localhost ([127.0.0.1]:35402 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vdUjm-00020Z-6x
	for submit <at> debbugs.gnu.org; Wed, 07 Jan 2026 09:42:14 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:45036)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1vdUjj-00020K-H6
 for 80150 <at> debbugs.gnu.org; Wed, 07 Jan 2026 09:42:12 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1vdUjd-0007eW-QZ; Wed, 07 Jan 2026 09:42:05 -0500
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=IPFibQasp24r8WN1zdAwl22dRLhhunuKSiXQf8TAUug=; b=ekcH2H2x9Nyn
 YQzch4wCZuFdWBfjpBgMCwLKIGUGIWna8UxMtb1WQF5TMVryH9KJ33nuKGvXkfqjplfg21fZbI4w9
 zsOmP2i2sc15+7Fq+OgK0nwuHZ3zJk7HMegiELu5n1v52XpSEtIoCtmS7qsBo9QdrWENbABukllZL
 cut3U7hIJzle0wxqRZWfaBw6fpki88DnaBTEHDz+nDjoxmv6+iLu78nDUHr9L4+4acFyoKeYcv+tR
 fXWM9vcODfnyoK34PPElL7MuTo++aKTPD+KDeQxZCIoitj1NnXclp57VuiMHp5rqfkJznEcCRM7KW
 sUU9RVPmPhK4G3YYoiFMpg==;
Date: Wed, 07 Jan 2026 16:41:57 +0200
Message-Id: <86ikddcwne.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Spencer Baugh <sbaugh@HIDDEN>
In-Reply-To: <iersech8qpp.fsf@HIDDEN> (message from Spencer Baugh on
 Wed, 07 Jan 2026 09:03:46 -0500)
Subject: Re: bug#80150: 30.1.90; No simple way to go to a line number from
 Lisp while respecting widen-automatically
References: <ierv7hd8u4y.fsf@HIDDEN> <86ms2pcyja.fsf@HIDDEN>
 <iersech8qpp.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 80150
Cc: 80150 <at> debbugs.gnu.org
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 (---)

> From: Spencer Baugh <sbaugh@HIDDEN>
> Cc: 80150 <at> debbugs.gnu.org
> Date: Wed, 07 Jan 2026 09:03:46 -0500
> 
> Eli Zaretskii <eliz@HIDDEN> writes:
> 
> >> Date: Wed, 07 Jan 2026 07:49:49 -0500
> >> From:  Spencer Baugh via "Bug reports for GNU Emacs,
> >>  the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
> >> 
> >> 
> >> There's no function to go to a line number from Lisp while respecting
> >> widen-automatically: that is, if the buffer is narrowed, automatically
> >> widen it.  goto-line does exactly this, but it's marked
> >> interactive-only.  I think we should extract the relevant part of
> >> goto-line into a separate function which can be used from Lisp.
> >> 
> >> I often need to do this because other programs produce file positions in
> >> terms of line numbers, and I need to jump the user to these positions.
> >
> > The doc string of goto-line tells you what to do non-interactively.
> > Why is doing that in your case a problem?
> 
> It doesn't respect widen-automatically.  That is, if the buffer is
> narrowed, it doesn't automatically widen it if and only if it's
> necesasry.

"We have the technology."  What you need is something as simple as the
below:

   (save-restriction
     (goto-char (point-min))
     (forward-line (1- N))
     (DO-SOMETHING))
or
   (widen)
   (goto-char (point-min))
   (forward-line (1- N))
   (DO-SOMETHING)

(depending on what you need to do in DO-SOMETHING).

I'm asking why do we need something else? and why does widening have
to happen automatically?




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

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


Received: (at 80150) by debbugs.gnu.org; 7 Jan 2026 14:03:55 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jan 07 09:03:55 2026
Received: from localhost ([127.0.0.1]:35191 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vdU8g-0008Hv-TR
	for submit <at> debbugs.gnu.org; Wed, 07 Jan 2026 09:03:55 -0500
Received: from mxout5.mail.janestreet.com ([64.215.233.18]:50723)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <sbaugh@HIDDEN>)
 id 1vdU8e-0008Hg-JU
 for 80150 <at> debbugs.gnu.org; Wed, 07 Jan 2026 09:03:53 -0500
From: Spencer Baugh <sbaugh@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#80150: 30.1.90; No simple way to go to a line number from
 Lisp while respecting widen-automatically
In-Reply-To: <86ms2pcyja.fsf@HIDDEN> (Eli Zaretskii's message of "Wed, 07 Jan
 2026 16:01:13 +0200")
References: <ierv7hd8u4y.fsf@HIDDEN> <86ms2pcyja.fsf@HIDDEN>
Date: Wed, 07 Jan 2026 09:03:46 -0500
Message-ID: <iersech8qpp.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com;
 s=waixah; t=1767794627;
 bh=ZZYa7zs9lEh88Zb1aHB613Pd6onpPjMyK6l/GI5kLFY=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date;
 b=e2UcJUDdJOELeQcrEoee7kwRGzbAMiaR2eo/PLbIFGDQYfG2A5ZzgHcVIe4qLoC3g
 IuN2ux/pl6CMVfOorDejoh5WL1Xy4WdU/Y6zMeSnvljomB8G4BAG9lKWElPWWMSsk2
 HoIqGfdFPWcuzg8tNXAlFfCRmgPCN7UFbTfFDxgLThK7CN2+j1KcriHE15htD2Jv0u
 zNO4yps1QGkzaxJNnC9yMrNz8lG0FcIq1T3n51zaWLS/fJnue511V5uSrl3VajbbNp
 1A5knuBG5xoIvgAlLKT0qzF1lAC9E0mq4F6rSTmNd16IvHOK1liyG2jFSp9ScutgS3
 Vd7esdzGhIOVA==
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 80150
Cc: 80150 <at> debbugs.gnu.org
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 (---)

Eli Zaretskii <eliz@HIDDEN> writes:

>> Date: Wed, 07 Jan 2026 07:49:49 -0500
>> From:  Spencer Baugh via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
>> 
>> 
>> There's no function to go to a line number from Lisp while respecting
>> widen-automatically: that is, if the buffer is narrowed, automatically
>> widen it.  goto-line does exactly this, but it's marked
>> interactive-only.  I think we should extract the relevant part of
>> goto-line into a separate function which can be used from Lisp.
>> 
>> I often need to do this because other programs produce file positions in
>> terms of line numbers, and I need to jump the user to these positions.
>
> The doc string of goto-line tells you what to do non-interactively.
> Why is doing that in your case a problem?

It doesn't respect widen-automatically.  That is, if the buffer is
narrowed, it doesn't automatically widen it if and only if it's
necesasry.




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

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


Received: (at 80150) by debbugs.gnu.org; 7 Jan 2026 14:01:40 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jan 07 09:01:40 2026
Received: from localhost ([127.0.0.1]:35176 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vdU6W-0008Do-6y
	for submit <at> debbugs.gnu.org; Wed, 07 Jan 2026 09:01:40 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:40862)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1vdU6S-0008Da-Ui
 for 80150 <at> debbugs.gnu.org; Wed, 07 Jan 2026 09:01:37 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1vdU6N-0006M0-Bv; Wed, 07 Jan 2026 09:01:31 -0500
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=yolwcJa2mZWPl3HKDd+Q5L6DYCZbhTQdQB7N0Witpsw=; b=cto5N688rFiq
 cM1mGKGIoSOOocf5XtgfXupHOMWsa/1Z9CM7592bOBJkDCQXvGvG6Ts6+sxNq4akc8lG0/Sd1O4b4
 Til+Pnah2aaQH7DHbAjZ0epGEK+2w8KMhAFcPaYqchYO3Lrv/AdC//JTE8JQRnQew3IfB6nlc/QOL
 ZA8TOp8CDA810Hgpg3V5GjW2hUIkwvZVjPc7479Y0wLDM8qYTHr3DpJJg1CkW8BNPKPMz09AtfMos
 N3Pr2/nOC/DEQ+ml5b+XLO2HRGamp3DyLJ4uBLnYhSPg6tsTgn2W8wZJRKg1mpHOY4gNav4hhQfQb
 UeHLYnzNU/Nrt+I9pZp9fA==;
Date: Wed, 07 Jan 2026 16:01:13 +0200
Message-Id: <86ms2pcyja.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Spencer Baugh <sbaugh@HIDDEN>
In-Reply-To: <ierv7hd8u4y.fsf@HIDDEN> (bug-gnu-emacs@HIDDEN)
Subject: Re: bug#80150: 30.1.90;
 No simple way to go to a line number from Lisp while respecting
 widen-automatically
References: <ierv7hd8u4y.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 80150
Cc: 80150 <at> debbugs.gnu.org
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 (---)

> Date: Wed, 07 Jan 2026 07:49:49 -0500
> From:  Spencer Baugh via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
> 
> 
> There's no function to go to a line number from Lisp while respecting
> widen-automatically: that is, if the buffer is narrowed, automatically
> widen it.  goto-line does exactly this, but it's marked
> interactive-only.  I think we should extract the relevant part of
> goto-line into a separate function which can be used from Lisp.
> 
> I often need to do this because other programs produce file positions in
> terms of line numbers, and I need to jump the user to these positions.

The doc string of goto-line tells you what to do non-interactively.
Why is doing that in your case a problem?




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

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


Received: (at submit) by debbugs.gnu.org; 7 Jan 2026 12:50:05 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jan 07 07:50:05 2026
Received: from localhost ([127.0.0.1]:34951 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vdSzF-0004er-5F
	for submit <at> debbugs.gnu.org; Wed, 07 Jan 2026 07:50:05 -0500
Received: from lists.gnu.org ([2001:470:142::17]:57218)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <sbaugh@HIDDEN>)
 id 1vdSzA-0004eB-HX
 for submit <at> debbugs.gnu.org; Wed, 07 Jan 2026 07:50:03 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <sbaugh@HIDDEN>)
 id 1vdSz3-00008n-21
 for bug-gnu-emacs@HIDDEN; Wed, 07 Jan 2026 07:49:53 -0500
Received: from mxout5.mail.janestreet.com ([64.215.233.18])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <sbaugh@HIDDEN>)
 id 1vdSz1-0004xb-98
 for bug-gnu-emacs@HIDDEN; Wed, 07 Jan 2026 07:49:52 -0500
From: Spencer Baugh <sbaugh@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 30.1.90; No simple way to go to a line number from Lisp while
 respecting widen-automatically
X-Debbugs-Cc: 
Date: Wed, 07 Jan 2026 07:49:49 -0500
Message-ID: <ierv7hd8u4y.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com;
 s=waixah; t=1767790189;
 bh=GlHzjk25xJ6rT9AdmygrSM5LOzjHkpu/6bThGxKwPak=;
 h=From:To:Subject:Date;
 b=RXFXAnFKNPkeOaPu6DTZVZ2r9P6W5QqJYb5YN24ver1UjRwXGifMiGDNrI6WLDGWO
 DKikixgNG5lQP28VjP7zJAqItoSGlu22e+yw64A8bLnMyv8byuFjIIWc/nVKRcoyaW
 hDjc2IQ41rXaAB5dAaDfv+5covKRiwqo8TEf3iBIiMlIiwzEdkspixrrdHjIoaJR3h
 qJ+Zxc+COFRBWBk/2CzDVKn4+bEZXr3+8cdGfWSrTlJrs2mHcQYux67NnXYp1oLXX8
 SfGSXfGx+npbOurOoQe5Za5ZOklW/gV+u7e/haoGoErLLoSXvuSGHHCDtIubLHxu6L
 SJe4t1esdBAxA==
Received-SPF: pass client-ip=64.215.233.18; envelope-from=sbaugh@HIDDEN;
 helo=mxout5.mail.janestreet.com
X-Spam_score_int: -43
X-Spam_score: -4.4
X-Spam_bar: ----
X-Spam_report: (-4.4 / 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_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001,
 RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001,
 SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.9 (/)
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: -0.1 (/)


There's no function to go to a line number from Lisp while respecting
widen-automatically: that is, if the buffer is narrowed, automatically
widen it.  goto-line does exactly this, but it's marked
interactive-only.  I think we should extract the relevant part of
goto-line into a separate function which can be used from Lisp.

I often need to do this because other programs produce file positions in
terms of line numbers, and I need to jump the user to these positions.


In GNU Emacs 30.1.90 (build 91, x86_64-pc-linux-gnu, X toolkit, cairo
 version 1.15.12, Xaw scroll bars) of 2025-12-29 built on
 igm-qws-u22796a
Repository revision: c4a0657b9713f73300ef01bbcac94e583832a7ea
Repository branch: emacs-30
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Rocky Linux 8.10 (Green Obsidian)

Configured using:
 'configure --with-x-toolkit=lucid --without-gpm --without-gconf
 --without-selinux --without-imagemagick --with-modules --with-gif=no
 --with-cairo --with-rsvg --without-compress-install --with-tree-sitter
 --with-native-compilation=aot
 PKG_CONFIG_PATH=/usr/local/home/garnish/libtree-sitter/0.22.6-1/lib/pkgconfig/'




Acknowledgement sent to Spencer Baugh <sbaugh@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#80150; 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, 19 Jan 2026 18:45:02 UTC

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