[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#65308: (find-file) botches buffer-file-name in -batch mode
From: |
Konstantin Kharlamov |
Subject: |
bug#65308: (find-file) botches buffer-file-name in -batch mode |
Date: |
Tue, 15 Aug 2023 15:17:00 +0300 |
User-agent: |
Evolution 3.48.4 |
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".