From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Konstantin Kharlamov Newsgroups: gmane.emacs.bugs Subject: bug#65308: (find-file) botches buffer-file-name in -batch mode Date: Tue, 15 Aug 2023 15:17:00 +0300 Message-ID: References: <5a188f33a3580e9046a28ba6bd527ff20d54366d.camel@yandex.ru> <83leeca4xo.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14887"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Evolution 3.48.4 Cc: 65308@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Aug 15 14:17:43 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 1qVszW-0003gG-Tb for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 15 Aug 2023 14:17:42 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qVsz9-0003Uf-Ir; Tue, 15 Aug 2023 08:17:24 -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 1qVsyt-0003UN-H4 for bug-gnu-emacs@gnu.org; Tue, 15 Aug 2023 08:17:04 -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 1qVsyt-0006k4-7B for bug-gnu-emacs@gnu.org; Tue, 15 Aug 2023 08:17:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qVsys-0003ly-Eu for bug-gnu-emacs@gnu.org; Tue, 15 Aug 2023 08:17:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Konstantin Kharlamov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 15 Aug 2023 12:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65308 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: notabug Original-Received: via spool by 65308-submit@debbugs.gnu.org id=B65308.169210179414461 (code B ref 65308); Tue, 15 Aug 2023 12:17:02 +0000 Original-Received: (at 65308) by debbugs.gnu.org; 15 Aug 2023 12:16:34 +0000 Original-Received: from localhost ([127.0.0.1]:35136 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qVsyQ-0003lA-9C for submit@debbugs.gnu.org; Tue, 15 Aug 2023 08:16:34 -0400 Original-Received: from forward502a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:d502]:48834) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qVsyL-0003kt-Nn for 65308@debbugs.gnu.org; Tue, 15 Aug 2023 08:16:32 -0400 Original-Received: from mail-nwsmtp-smtp-production-main-51.vla.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-51.vla.yp-c.yandex.net [IPv6:2a02:6b8:c1f:5e51:0:640:23ee:0]) by forward502a.mail.yandex.net (Yandex) with ESMTP id 7E1C95E772; Tue, 15 Aug 2023 15:16:23 +0300 (MSK) Original-Received: by mail-nwsmtp-smtp-production-main-51.vla.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id MGewmX9DXqM0-YfUGrDSd; Tue, 15 Aug 2023 15:16:23 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1692101783; bh=8DNU0W3LPcuJJjnwy90axtFkhJQK5+/kWXk9WbTEFwY=; h=References:Date:In-Reply-To:Cc:To:From:Subject:Message-ID; b=ugmpIES3+egfl/pqyyaX13FJSfGKp/dcWPOO9SufTwcQOhBYcmkzOT5fMOOy/cfiT rdC7azl11kcqnlayiePYSlJis8WqZHZGJC3o7e4bpmXKbUabvyFYXL9xiKj3R1hI1Z oO2EAzdWT8XCQBK7gXP4AU/iZA2m3gDyniY2sGuE= Authentication-Results: mail-nwsmtp-smtp-production-main-51.vla.yp-c.yandex.net; dkim=pass header.i=@yandex.ru In-Reply-To: <83leeca4xo.fsf@gnu.org> 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:267481 Archived-At: On Tue, 2023-08-15 at 15:03 +0300, Eli Zaretskii wrote: > tags 65308 notabug > thanks >=20 > > From: Konstantin Kharlamov > > Date: Tue, 15 Aug 2023 14:25:16 +0300 > >=20 > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0$ mkdir dir && touch di= r/1 dir/2 > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0$ emacs -batch --eval '= (progn (dolist (file command-line- > > args-left) (find-file file) (print buffer-file-name))))' dir/1 > > dir/2=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=20 > >=20 > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0"/tmp/dir/1" > >=20 > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0"/tmp/dir/dir/2" > >=20 > > ## Expected > >=20 > > Second print would say `/tmp/dir/2` > >=20 > > ## Actual > >=20 > > Second print refers to non-existing `/tmp/dir/dir/2`. >=20 > IMO, this is the expected behavior: relative file names are > interpreted relative to the current buffer's default-directory.=C2=A0 > After > the first find-file, the current buffer visits the file "/tmp/dir/1", > whose default-directory is "/tmp/dir/". >=20 > There's no bug here.=C2=A0 To get what you want, run the command-line > arguments through expand-file-name _before_ calling find-file. Oh, okay, thank you, I see. I settled with calling a `(kill-buffer)` after `(save-buffer)`, which I guess works because each time the buffer is killed we get back to the *scratch* buffer that has the original "current directory".