emacs-diffs
[Top][All Lists]
Advanced

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

master 02c8030 2/2: Extend meaning of UNIQUIFY `auto-save-file-name-tran


From: Michael Albinus
Subject: master 02c8030 2/2: Extend meaning of UNIQUIFY `auto-save-file-name-transforms'. (Bug#47493)
Date: Mon, 10 May 2021 07:42:58 -0400 (EDT)

branch: master
commit 02c80307f13f7ffe3dc024aee72e47060b4a1996
Author: Michael Albinus <michael.albinus@gmx.de>
Commit: Michael Albinus <michael.albinus@gmx.de>

    Extend meaning of UNIQUIFY `auto-save-file-name-transforms'.  (Bug#47493)
    
    * doc/lispref/backups.texi (Auto-Saving): Explain UNIQUIFY being a
    secure hash in auto-save-file-name-transforms.
    
    * etc/NEWS: Mention change in `auto-save-file-name-transforms'.
    
    * lisp/files.el (auto-save-file-name-transforms): Adapt docstring.
    (make-auto-save-file-name): Care, if UNIQ is a secure hash symbol.
---
 doc/lispref/backups.texi |  6 ++++++
 etc/NEWS                 |  7 +++++++
 lisp/files.el            | 26 ++++++++++++++++++--------
 3 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/doc/lispref/backups.texi b/doc/lispref/backups.texi
index c0a4065..85a4f9e 100644
--- a/doc/lispref/backups.texi
+++ b/doc/lispref/backups.texi
@@ -481,6 +481,12 @@ all directory separators were changed to @samp{!} to 
prevent clashes.
 (This will not work correctly if your filesystem truncates the
 resulting name.)
 
+If @var{uniquify} is one of the members of
+@code{secure-hash-algorithms}, Emacs constructs the nondirectory part
+of the auto-save file name by applying that @code{secure-hash} to the
+buffer file name.  This avoids any risk of excessively long file
+names.
+
 All the transforms in the list are tried, in the order they are listed.
 When one transform applies, its result is final;
 no further transforms are tried.
diff --git a/etc/NEWS b/etc/NEWS
index e797d69..4870ca8 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -3083,6 +3083,13 @@ It is written as '(:success BODY...)' where BODY is 
executed
 whenever the protected form terminates without error, with the
 specified variable bound to the the value of the protected form.
 
++++
+** 'The 'uniquify' argument in 'auto-save-file-name-transforms' can be a 
symbol.
+If this symbol is one of the members of 'secure-hash-algorithms',
+Emacs constructs the nondirectory part of the auto-save file name by
+applying that 'secure-hash' to the buffer file name.  This avoids any
+risk of excessively long file names.
+
 
 * Changes in Emacs 28.1 on Non-Free Operating Systems
 
diff --git a/lisp/files.el b/lisp/files.el
index 7fb1320..47c5fc1 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -391,6 +391,10 @@ constructed by taking the directory part of the replaced 
file-name,
 concatenated with the buffer file name with all directory separators
 changed to `!' to prevent clashes.  This will not work
 correctly if your filesystem truncates the resulting name.
+If UNIQUIFY is one of the members of `secure-hash-algorithms',
+Emacs constructs the nondirectory part of the auto-save file name
+by applying that `secure-hash' to the buffer file name.  This
+avoids any risk of excessively long file names.
 
 All the transforms in the list are tried, in the order they are listed.
 When one transform applies, its result is final;
@@ -6647,14 +6651,20 @@ See also `auto-save-file-name-p'."
                        uniq (car (cddr (car list)))))
              (setq list (cdr list)))
            (if result
-               (if uniq
-                   (setq filename (concat
-                                   (file-name-directory result)
-                                   (subst-char-in-string
-                                    ?/ ?!
-                                    (replace-regexp-in-string "!" "!!"
-                                                              filename))))
-                 (setq filename result)))
+                (setq filename
+                      (cond
+                       ((memq uniq (secure-hash-algorithms))
+                        (concat
+                         (file-name-directory result)
+                         (secure-hash uniq filename)))
+                       (uniq
+                        (concat
+                        (file-name-directory result)
+                        (subst-char-in-string
+                         ?/ ?!
+                         (replace-regexp-in-string
+                           "!" "!!" filename))))
+                      (t result))))
            (setq result
                  (if (and (eq system-type 'ms-dos)
                           (not (msdos-long-file-names)))



reply via email to

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