From 7ca7d300d1d256f674f83932d2918d8e70cd28f6 Mon Sep 17 00:00:00 2001 From: GNU ELPA Mirror Bot Date: Wed, 23 Nov 2022 00:03:44 +0000 Subject: [PATCH] Update compat Timestamp: 2022-11-23 00:00:55 GNU ELPA commit: c1e7d260a3e9305188aea0b5a372f4ccd4dfb22c Emacs commit: 057901f55ad12ebbc9cf092dd6ad0f02539849f9 --- compat-27.el | 11 +++++++++++ compat.texi | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/compat-27.el b/compat-27.el index 04abe6e..714df89 100644 --- a/compat-27.el +++ b/compat-27.el @@ -662,6 +662,17 @@ REMOTE is non-nil, search on the remote host indicated by (when (stringp res) (compat--file-local-name res))) (executable-find command))) +;;*UNTESTED +(compat-defun make-empty-file (filename &optional parents) + "Create an empty file FILENAME. +Optional arg PARENTS, if non-nil then creates parent dirs as needed." + (when (and (file-exists-p filename) (null parents)) + (signal 'file-already-exists (list "File exists" filename))) + (let ((paren-dir (file-name-directory filename))) + (when (and paren-dir (not (file-exists-p paren-dir))) + (make-directory paren-dir parents))) + (write-region "" nil filename nil 0)) + ;; TODO provide advice for directory-files-recursively ;;;; Defined in format-spec.el diff --git a/compat.texi b/compat.texi index f19d27f..9953269 100644 --- a/compat.texi +++ b/compat.texi @@ -1482,6 +1482,14 @@ derived from any of the major modes given by the symbols @var{modes}. @xref{Derived Modes,,,elisp}. @end defun +@c based on lispref/files.texi +@defun make-empty-file filename &optional parents +This function creates an empty file named @var{filename}. As +@code{make-directory}, this function creates parent directories if +@var{parents} is non-@code{nil}. If @var{filename} already exists, this +function signals an error. +@end defun + @subsection Prefixed Definitions These functions are prefixed with @code{compat} prefix, and are only loaded when @code{compat-27} is required: