[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/compat dd436797d1 1/6: Add make-lock-file-name
From: |
ELPA Syncer |
Subject: |
[elpa] externals/compat dd436797d1 1/6: Add make-lock-file-name |
Date: |
Thu, 14 Apr 2022 06:57:28 -0400 (EDT) |
branch: externals/compat
commit dd436797d16eda951c871cac370a5dadf654ce73
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>
Add make-lock-file-name
---
MANUAL | 1 +
compat-28.el | 10 ++++++++++
compat-tests.el | 17 +++++++++++++++++
3 files changed, 28 insertions(+)
diff --git a/MANUAL b/MANUAL
index 5c202e9641..f7219f2cb1 100644
--- a/MANUAL
+++ b/MANUAL
@@ -395,6 +395,7 @@ provided by Compat by default:
- Function: file-modes-number-to-symbolic :: See [[info:elisp#Changing
Files][(elisp) Changing
Files]].
- Function: file-backup-file-names :: See [[info:elisp#Backup Names][(elisp)
Backup Names]].
+- Function: make-lock-file-name :: Defined in ~files.el~.
These functions are prefixed with ~compat~ prefix, and are only loaded
when ~compat-28~ is required:
diff --git a/compat-28.el b/compat-28.el
index 2d6a55bf4e..2f8c330355 100644
--- a/compat-28.el
+++ b/compat-28.el
@@ -675,6 +675,16 @@ recent files are first."
(push candidate files))))
(sort files #'file-newer-than-file-p)))
+(compat-defun make-lock-file-name (filename)
+ "Make a lock file name for FILENAME.
+This prepends \".#\" to the non-directory part of FILENAME, and
+doesn't respect `lock-file-name-transforms', as Emacs 28.1 and
+onwards does."
+ (expand-file-name
+ (concat
+ ".#" (file-name-nondirectory filename))
+ (file-name-directory filename)))
+
;;;; Defined in minibuffer.el
(compat-defun format-prompt (prompt default &rest format-args)
diff --git a/compat-tests.el b/compat-tests.el
index 6da09815c5..f59e33540b 100644
--- a/compat-tests.el
+++ b/compat-tests.el
@@ -1615,5 +1615,22 @@ being compared against."
(ought "/:a" "/:a")
(ought (concat "/ssh:" (system-name) ":/:a") "/ssh::a"))
+(compat-deftest make-lock-file-name
+ (ought (expand-file-name ".#") "")
+ (ought (expand-file-name ".#a") "a")
+ (ought (expand-file-name ".#foo") "foo")
+ (ought (expand-file-name ".#.") ".")
+ (ought (expand-file-name ".#.#") ".#")
+ (ought (expand-file-name ".#.a") ".a")
+ (ought (expand-file-name ".#.#") ".#")
+ (ought (expand-file-name "a/.#") "a/")
+ (ought (expand-file-name "a/.#b") "a/b")
+ (ought (expand-file-name "a/.#.#") "a/.#")
+ (ought (expand-file-name "a/.#.") "a/.")
+ (ought (expand-file-name "a/.#.b") "a/.b")
+ (ought (expand-file-name "a/.#foo") "a/foo")
+ (ought (expand-file-name "bar/.#b") "bar/b")
+ (ought (expand-file-name "bar/.#foo") "bar/foo"))
+
(provide 'compat-tests)
;;; compat-tests.el ends here
- [elpa] externals/compat updated (c42abd3474 -> 67316e83b2), ELPA Syncer, 2022/04/14
- [elpa] externals/compat f388ef2ba6 5/6: Add time-equal-p, ELPA Syncer, 2022/04/14
- [elpa] externals/compat dd436797d1 1/6: Add make-lock-file-name,
ELPA Syncer <=
- [elpa] externals/compat 21b6e6fb26 2/6: Add null-device, ELPA Syncer, 2022/04/14
- [elpa] externals/compat d77a66d79b 3/6: Remove superfluous quote disabling a test, ELPA Syncer, 2022/04/14
- [elpa] externals/compat ef10ac3968 4/6: Capitalise overlooked instances of "Compat" in the manual, ELPA Syncer, 2022/04/14
- [elpa] externals/compat 67316e83b2 6/6: Add date-days-in-month, ELPA Syncer, 2022/04/14