unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Antero Mejr via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 61901@debbugs.gnu.org
Subject: bug#61901: 30.0.50; [PATCH v3] Add safe-local-variable-directories variable.
Date: Thu, 11 May 2023 20:11:16 +0000	[thread overview]
Message-ID: <878rdu39y3.fsf@mailbox.org> (raw)
In-Reply-To: <83v8gy4u1j.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 11 May 2023 21:11:52 +0300")

[-- Attachment #1: Type: text/plain, Size: 808 bytes --]

Eli Zaretskii <eliz@gnu.org> writes:

>> > This actually means that I misunderstood the code.  Now that I see the
>> > truth, why is it a good idea to compare directories case-sensitively
>> > when the filesystem is not?  That's not something users will expect.
>> 
>> To accurately assess if a directory name matches with possible
>> case-sensitivity, the process would be:
>> 1. check the case-sensitivity of the filesystem
>> 2. If case insensitive, check the case-sensitivity of each subdirectory
>> (using Windows queryCaseSensitiveInfo if applicable)
>> 3. map over the components of the directory name, checking each subdirectory
>> with the correct case-sensitivity setting
>
> We already have all that in file-equal-p.  We should just use is
> there.

Ok, patch is attached (tested on FAT32 disk).


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Handle-case-insensitivity-for-safe-local-variable-di.patch --]
[-- Type: text/x-patch, Size: 2067 bytes --]

From 338629b4dc6da17460c96a19178307e6db4bd5d8 Mon Sep 17 00:00:00 2001
From: Antero Mejr <antero@mailbox.org>
Date: Thu, 11 May 2023 19:22:49 +0000
Subject: [PATCH] Handle case-insensitivity for
 safe-local-variable-directories.

* lisp/emacs-lisp/files.el (hack-local-variables-filter): Use
file-equal-p when checking safe-local-variable-directories.
* doc/lispref/variables.texi (File Local Variables): Remove sentence
in safe-local-variable-directories description about unusual
case-sensitivity behavior.  (Bug#61901)
---
 doc/lispref/variables.texi | 4 +---
 lisp/files.el              | 4 +++-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi
index b3a8cd8110c..d8f0ad489bc 100644
--- a/doc/lispref/variables.texi
+++ b/doc/lispref/variables.texi
@@ -1984,9 +1984,7 @@ such as the variables in @file{.dir-locals.el}, will be enabled even
 if they are risky.  The directories in this list must be
 fully-expanded absolute file names that end in a directory separator
 character.  They may also be remote directories if the variable
-@code{enable-remote-dir-locals} is set non-@code{nil}.  Directories in
-this list are matched case-sensitively, even if the filesystem is
-case-sensitive.
+@code{enable-remote-dir-locals} is set non-@code{nil}.
 @end defvar
 
 @defun hack-local-variables &optional handle-mode
diff --git a/lisp/files.el b/lisp/files.el
index 35d794f6dcf..a3e7e2bd65d 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -3934,7 +3934,9 @@ DIR-NAME is the name of the associated directory.  Otherwise it is nil."
 		  (null unsafe-vars)
 		  (null risky-vars))
 	     (memq enable-local-variables '(:all :safe))
-             (member dir-name safe-local-variable-directories)
+             (delq nil (mapcar (lambda (dir)
+                                 (file-equal-p dir dir-name))
+                               safe-local-variable-directories))
 	     (hack-local-variables-confirm all-vars unsafe-vars
 					   risky-vars dir-name))
 	 (dolist (elt all-vars)
-- 
2.39.2


  reply	other threads:[~2023-05-11 20:11 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-01 22:20 bug#61901: 30.0.50; [PATCH] Add permanently-enabled-local-variable-dirs variable Antero Mejr via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-02  6:57 ` Eli Zaretskii
2023-03-02 17:09   ` Antero Mejr via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-02 18:04     ` Eli Zaretskii
2023-03-14 18:46       ` Antero Mejr via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-14 19:48         ` Eli Zaretskii
2023-04-25 16:40 ` bug#61901: 30.0.50; [PATCH v3] Add safe-local-variable-directories variable Antero Mejr via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-25 17:23   ` Eli Zaretskii
2023-05-09 21:29 ` Antero Mejr via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-11 13:55   ` Eli Zaretskii
     [not found]     ` <87ilcy3mdt.fsf@mailbox.org>
2023-05-11 16:10       ` Eli Zaretskii
2023-05-11 17:49         ` Antero Mejr via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-11 18:11           ` Eli Zaretskii
2023-05-11 20:11             ` Antero Mejr via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-05-11 21:38               ` Antero Mejr via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-12 11:09                 ` 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=878rdu39y3.fsf@mailbox.org \
    --to=bug-gnu-emacs@gnu.org \
    --cc=61901@debbugs.gnu.org \
    --cc=antero@mailbox.org \
    --cc=eliz@gnu.org \
    /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).