mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
Add new user option lock-file-name-transforms
* doc/emacs/files.texi (Interlocking): Mention lock-file-name-transforms. * doc/lispref/files.texi (File Locks): Document lock-file-name-transforms. * doc/misc/efaq.texi (Not writing files to the current directory): Mention all the three variables needed to not having Emacs writing files to the current directory in one place. * lisp/files.el (lock-file-name-transforms): New user option (bug#49261). (make-auto-save-file-name): Factor out the main logic... (auto-save--transform-file-name): ... to this new function. (make-lock-file-name): New function that also calls the factored-out function. * src/filelock.c: Remove MAKE_LOCK_NAME and fill_in_lock_file_name. (make_lock_file_name): New utility function that calls out to Lisp to heed `lock-file-name-transforms'. (lock_file): Use it. Also remove likely buggy call to dostounix_filename. (unlock_file_body, Ffile_locked_p): Also use make_lock_file_name.
This commit is contained in:
parent
6d594848e0
commit
2ad34bcea4
7 changed files with 197 additions and 111 deletions
|
|
@ -949,6 +949,44 @@ unquoted file names."
|
|||
(make-auto-save-file-name)
|
||||
(kill-buffer)))))))
|
||||
|
||||
(ert-deftest files-test-auto-save-name-default ()
|
||||
(with-temp-buffer
|
||||
(let ((auto-save-file-name-transforms nil))
|
||||
(setq buffer-file-name "/tmp/foo.txt")
|
||||
(should (equal (make-auto-save-file-name) "/tmp/#foo.txt#")))))
|
||||
|
||||
(ert-deftest files-test-auto-save-name-transform ()
|
||||
(with-temp-buffer
|
||||
(setq buffer-file-name "/tmp/foo.txt")
|
||||
(let ((auto-save-file-name-transforms
|
||||
'(("\\`/.*/\\([^/]+\\)\\'" "/var/tmp/\\1" nil))))
|
||||
(should (equal (make-auto-save-file-name) "/var/tmp/#foo.txt#")))))
|
||||
|
||||
(ert-deftest files-test-auto-save-name-unique ()
|
||||
(with-temp-buffer
|
||||
(setq buffer-file-name "/tmp/foo.txt")
|
||||
(let ((auto-save-file-name-transforms
|
||||
'(("\\`/.*/\\([^/]+\\)\\'" "/var/tmp/\\1" t))))
|
||||
(should (equal (make-auto-save-file-name) "/var/tmp/#!tmp!foo.txt#")))
|
||||
(let ((auto-save-file-name-transforms
|
||||
'(("\\`/.*/\\([^/]+\\)\\'" "/var/tmp/\\1" sha1))))
|
||||
(should (equal (make-auto-save-file-name)
|
||||
"/var/tmp/#b57c5a04f429a83305859d3350ecdab8315a9037#")))))
|
||||
|
||||
(ert-deftest files-test-lock-name-default ()
|
||||
(let ((lock-file-name-transforms nil))
|
||||
(should (equal (make-lock-file-name "/tmp/foo.txt") "/tmp/.#foo.txt"))))
|
||||
|
||||
(ert-deftest files-test-lock-name-unique ()
|
||||
(let ((lock-file-name-transforms
|
||||
'(("\\`/.*/\\([^/]+\\)\\'" "/var/tmp/\\1" t))))
|
||||
(should (equal (make-lock-file-name "/tmp/foo.txt")
|
||||
"/var/tmp/.#!tmp!foo.txt")))
|
||||
(let ((lock-file-name-transforms
|
||||
'(("\\`/.*/\\([^/]+\\)\\'" "/var/tmp/\\1" sha1))))
|
||||
(should (equal (make-lock-file-name "/tmp/foo.txt")
|
||||
"/var/tmp/.#b57c5a04f429a83305859d3350ecdab8315a9037"))))
|
||||
|
||||
(ert-deftest files-tests-file-name-non-special-make-directory ()
|
||||
(files-tests--with-temp-non-special (tmpdir nospecial-dir t)
|
||||
(let ((default-directory nospecial-dir))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue