GNU bug report logs - #77666
Question/discussion about `trusted-content'

Previous Next

Package: emacs;

Reported by: Dominik Schrempf <dominik.schrempf <at> gmail.com>

Date: Wed, 9 Apr 2025 07:34:01 UTC

Severity: normal

Full log


Message #11 received at 77666 <at> debbugs.gnu.org (full text, mbox):

From: Dominik Schrempf <dominik.schrempf <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 77666 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#77666: Question/discussion about `trusted-content'
Date: Wed, 09 Apr 2025 16:22:58 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Dominik Schrempf <dominik.schrempf <at> gmail.com>
>> Date: Wed, 09 Apr 2025 09:33:41 +0200
>>
>> I have a remark/question with respect to the newly introduced
>> `trusted-content' customizable variable. The documentation states
>>
>>     - If it ends in "/", it is considered as a directory name and means that
>>       Emacs should trust all the files whose name has this directory as a prefix.
>>
>> And then,
>>
>>     Use abbreviated file names.  For example, an entry "~/mycode/" means
>>     that Emacs will trust all the files in your directory "mycode".
>>
>> Why is this second requirement in place?
>
> For speed, I believe.  (But Stefan will correct me if I'm wrong.)

Do you mean comparing "/home/user/mycode" is slower than comparing
"~/mycode/"? That doesn't make much sense to me, but I may miss relevant
information.

>
>> I tried trusting a directory using an absolute file name, e.g.,
>> "/home/user/trusted/dir/", and failed! I think this is because Emacs
>> uses the `buffer-file-truename' variable to check if the file is
>> trusted, and `buffer-file-truename' is "~/trusted/dir/basename".
>
> Exactly.
>
>> That is, I had to set `trusted-content' to a list containing
>> "~/trusted/dir/" which I want to avoid.
>
> Why do you want to avoid it?

I guess the reason is caution. I had situations where the tilde was not
expanded and a file was not found. I do not think this was in Emacs, but
that's how habits are formed.

>
>> Isn't it safer to trust absolute
>> directories instead of directories relative to the user home directory?
>
> HOME-relative file names are considered absolute file names in Emacs:
>
>   (file-name-absolute-p "~/.emacs.d/")
>    => t

Thank you, I didn't know that. Does this make sense? The file will be
different for two different users, which is not the case for absolute
file names in the classical sense.

>
>> On the side, isn't the name `buffer-file-truename' a misnomer? The
>> "true" ("real", see `realpath') filename should be the absolute one, or
>> not? What am I missing here?
>
> See above.
>
> Emacs always abbreviates HOME-relative file names, so adhering to that
> convention means we can compare file names as strings, instead of
> using file-truename (which hits the disk) and similar APIs to
> "normalize" the file names before comparing.

Thanks for your explanation.

I believe that by now, we are having a discussion about two different
but somewhat related concepts: "absolute" vs "relative" filenames and
the "true" vs "real" filenames.

I still wanted to state that the term "true filename" confused me and is
still confusing me. I think it should be "real", at least to me this
seems more of a Linux/Unix? standard.

Thanks!




This bug report was last modified 123 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.