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

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

bug#35495: 27.0.50; Untarring an archive with a keyring.gpg inside


From: Federico Tedin
Subject: bug#35495: 27.0.50; Untarring an archive with a keyring.gpg inside
Date: Fri, 10 May 2019 23:20:44 -0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux)

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> I realize that in this case I'm hard-coding the specific
>> file name handlers that *can* be used.
>
> Exactly, it's no better.
>
>> I'm not sure how to express "only use these file handlers" without
>> explicitly mentioning them.
>
> Instead, you should state the property you want, and then let each
> file-name-handler decide how to handle that property.  E.g.:
>
>     (let ((write-region-provides-raw-file-contents t))
>       (write-region ...))
>
> Of course, the problem here is that by using dynamic scoping, this var
> will affect all write-regions that will take place during this call,
> which might lead to more problems.

I see, I hadn't realized that tar-mode still used dynamic scoping (I
imagine converting it to lexical is a lot of work).

> Maybe it would be better to have it as an argument to `write-region`, or
> to introduce a new function?
>
> Or maybe, not use `write-region` but `copy-file` instead (which already
> provides the expected semantics (i.e. it doesn't (un)compress or
> (en/de)crypt, IIUC).

It looks like `copy-file` only deals with files and not buffers, so we
would need to find a way to use it from tar-mode. Looking at the source
in fileio.c, it also seems like it uses `find-file-name-handler` for
`FILE` or `NEWNAME`, so it's possible it won't be useful for us.

If we added a new argument to `write-region` like you mentioned, say
`RAW`, could we then use symbol properties to decide whether the found
file name handler can be used or not? Like so:

(put 'jka-compr-handler 'provides-raw-file-contents nil)
(put 'epa-file-handler 'provides-raw-file-contents nil)

(put 'tramp-file-name-handler 'provides-raw-file-contents t)
(put 'tramp-completion-file-name-handler 'provides-raw-file-contents t)
(put 'file-name-non-special 'provides-raw-file-contents t)

The downside being that anyone adding a new file name handler must
remember to set the property to t if needed.





reply via email to

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