From: Konstantin Kharlamov <Hi-Angel@yandex.ru>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 65308@debbugs.gnu.org
Subject: bug#65308: (find-file) botches buffer-file-name in -batch mode
Date: Tue, 15 Aug 2023 15:17:00 +0300 [thread overview]
Message-ID: <b73e40b25662f6a6738f1a7159e848475cec0f20.camel@yandex.ru> (raw)
In-Reply-To: <83leeca4xo.fsf@gnu.org>
On Tue, 2023-08-15 at 15:03 +0300, Eli Zaretskii wrote:
> tags 65308 notabug
> thanks
>
> > From: Konstantin Kharlamov <Hi-Angel@yandex.ru>
> > Date: Tue, 15 Aug 2023 14:25:16 +0300
> >
> > $ mkdir dir && touch dir/1 dir/2
> > $ emacs -batch --eval '(progn (dolist (file command-line-
> > args-left) (find-file file) (print buffer-file-name))))' dir/1
> > dir/2
> >
> > "/tmp/dir/1"
> >
> > "/tmp/dir/dir/2"
> >
> > ## Expected
> >
> > Second print would say `/tmp/dir/2`
> >
> > ## Actual
> >
> > Second print refers to non-existing `/tmp/dir/dir/2`.
>
> IMO, this is the expected behavior: relative file names are
> interpreted relative to the current buffer's default-directory.
> After
> the first find-file, the current buffer visits the file "/tmp/dir/1",
> whose default-directory is "/tmp/dir/".
>
> There's no bug here. 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".
next prev parent reply other threads:[~2023-08-15 12:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-15 11:25 bug#65308: (find-file) botches buffer-file-name in -batch mode Konstantin Kharlamov
2023-08-15 12:03 ` Eli Zaretskii
2023-08-15 12:17 ` Konstantin Kharlamov [this message]
2023-08-15 12:26 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b73e40b25662f6a6738f1a7159e848475cec0f20.camel@yandex.ru \
--to=hi-angel@yandex.ru \
--cc=65308@debbugs.gnu.org \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).