unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Konstantin Kharlamov <Hi-Angel@yandex.ru>
Cc: 65308@debbugs.gnu.org
Subject: bug#65308: (find-file) botches buffer-file-name in -batch mode
Date: Tue, 15 Aug 2023 15:03:15 +0300	[thread overview]
Message-ID: <83leeca4xo.fsf@gnu.org> (raw)
In-Reply-To: <5a188f33a3580e9046a28ba6bd527ff20d54366d.camel@yandex.ru> (message from Konstantin Kharlamov on Tue, 15 Aug 2023 14:25:16 +0300)

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.





  reply	other threads:[~2023-08-15 12:03 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 [this message]
2023-08-15 12:17   ` Konstantin Kharlamov
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=83leeca4xo.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=65308@debbugs.gnu.org \
    --cc=Hi-Angel@yandex.ru \
    /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).