bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#58360: 28.2; tramp-archive and file-directory-p


From: Michael Albinus
Subject: bug#58360: 28.2; tramp-archive and file-directory-p
Date: Sat, 08 Oct 2022 13:38:41 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Gustavo Barros <gusbrs.2016@gmail.com> writes:

> Hi All,

Hi Gustavo,

> The thing started with `counsel-find-file' which, instead of opening
> an ODT file as I wished to do, would auto mount a volume on the system
> and then navigate inside it as a directory.
>
> I went down the rabbit hole, and it turns out that `file-directory-p'
> returns `t' for an ODT file appended with a slash.  And the reason it
> does is that `tramp-archive' is enabled by default, and that
> OpenDocument format extensions are included in
> `tramp-archive-suffixes'.
>
> So, if you try:
>
>    (file-directory-p (expand-file-name "~/file.odt/"))
>
> provided that "~/file.odt" exists, will return `t' on an "emacs -Q"
> session.
>
> Is this really intended?  It was baffling to me (to the point that
> I've personally set `tramp-archive-enabled' to nil, as Tramp's manual
> taught me to), but perhaps there are use cases which I'm missing that
> may justify it.

This is intended. There is no need for packages like counsel to check

(file-directory-p (expand-file-name "~/file.odt/"))

It is a misuse to add a slash to an existing regular file and pray that
it works. There has been a similar error in ange-ftp, see bug#56078. It
has fixed. I recommend to contact the counsel author for a fix.

> A side comment on this.  Even assuming this is intended behavior, is
> it really the case to bundle up every file type extension supported by
> "libarchive" in `tramp-archive-suffixes'?  There may be people who
> wish to navigate into "tar", "iso", "rar" or "zip" files as
> directories.  But why should this be the default for OpenDocument
> formats, or for "exe", or "deb" files, for example, for which the
> desired behavior is likely something else?

There might be people who wish to navigate into "odt", "exe", or "deb"
files. It shall be possible. It happens only if you access
"/path/to/file.odt/" (the trailing slash is important), for which there
is no other desired behavior I could imagine.

> Furthermore, `tramp-archive-suffixes' is a defconst, not a
> defcustom. So users are stuck with "all or nothing", unable to select
> for which file types tramp-archive should be used or not.  (Of course,
> I know one can always change things regardless, but that's not the
> point.)

I doubt that people would change such a user option. What would be the
use case? There is still tramp-archive-enabled, and if a package really
really really wants to access "file.odt/" for another purpose than the
intended, the package shall let-bind this variable.

> Best regards,
> Gustavo.

Best regards, Michael.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]