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#65877: 29.1; line-number-at-pos crashes with args-out-of-range when ran using emacsclient Date: Tue, 12 Sep 2023 14:28:59 +0300 Message-ID: <83o7i7pr44.fsf@gnu.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23667"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 65877@debbugs.gnu.org To: =?UTF-8?Q?Micha=C3=ABl?= Cadilhac Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Sep 12 13:30:10 2023 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 1qg1as-0005ur-DQ for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 12 Sep 2023 13:30:10 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qg1ah-0003aN-Ri; Tue, 12 Sep 2023 07:29:59 -0400 Original-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 ) id 1qg1ag-0003Zf-1U for bug-gnu-emacs@gnu.org; Tue, 12 Sep 2023 07:29:58 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qg1af-0008NL-QH for bug-gnu-emacs@gnu.org; Tue, 12 Sep 2023 07:29:57 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qg1ak-0004bB-45 for bug-gnu-emacs@gnu.org; Tue, 12 Sep 2023 07:30: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: Tue, 12 Sep 2023 11:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65877 X-GNU-PR-Package: emacs Original-Received: via spool by 65877-submit@debbugs.gnu.org id=B65877.169451816717587 (code B ref 65877); Tue, 12 Sep 2023 11:30:02 +0000 Original-Received: (at 65877) by debbugs.gnu.org; 12 Sep 2023 11:29:27 +0000 Original-Received: from localhost ([127.0.0.1]:56298 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qg1aA-0004Za-T3 for submit@debbugs.gnu.org; Tue, 12 Sep 2023 07:29:27 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44318) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qg1a8-0004ZK-VQ; Tue, 12 Sep 2023 07:29:25 -0400 Original-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 ) id 1qg1Zy-0008Fp-Eo; Tue, 12 Sep 2023 07:29:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=a91a41XjaYiQa62pDxgVtGmTX3zX6Eh8Uz6c64ApoUk=; b=lZUcAOWx/+7fMzH5FnOj gcCkYcr3v0kkMaPnszKkNr1kSLXe4uCkEZTDkaFORYjjsbYMp4RLGqffh1Gelw4Me1LFfBC1DsXeK FY6nYsNuTcWOUjcMbkHhp/L7RI3clIYEpKz2vxPn0SFm/BcXNENkN5zAB5qsks3cgxouVgoPd4EDg arwPYXzNWb3w5sNVjFtnGGXZPUrQVnQY/EbdiWjzwkxSm9JSjiRKLlTZWvZNmPVZLGRr1GRxjzd0x 2BY8vBkY0ovzNSU7/VG1H8fkqrc5NEIglJOXrMK/XdF7LamgE4iUf9hPT880pYX1h9MZ5j3Mnf4a7 K7N682trXuFRZg==; In-Reply-To: (message from =?UTF-8?Q?Micha=C3=ABl?= Cadilhac on Mon, 11 Sep 2023 16:07:42 -0500) 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:270155 Archived-At: tags 65877 notabug thanks > From: Michaël Cadilhac > Date: Mon, 11 Sep 2023 16:07:42 -0500 > > How to reproduce: start with > > $ emacs -Q > > M-x server-start > > Open a file with say 200 lines, scroll at the bottom, so that the > first line of the file is not at the top of the window. > > Then in a shell, run: > > $ emacsclient -e '(line-number-at-pos (window-start))' > *ERROR*: Args out of range: 146, 1, 1 This is a cockpit error, not a bug. The doc string of line-number-at-pos says: line-number-at-pos is a built-in function in ‘src/fns.c’. (line-number-at-pos &optional POSITION ABSOLUTE) Return the line number at POSITION in the current buffer. ^^^^^^^^^^^^^^^^^^^^^ So the correct form to evaluate is this: $ emacsclient -e "(with-current-buffer (window-buffer) (line-number-at-pos (window-start)))" IOW, you must make sure the buffer of the selected window is current when the server evaluates the expression. It is not guaranteed by default: $ emacsclient -e "(message \"%s\" (current-buffer))" " *server*"