From: Nicolas Martyanoff <nicolas@n16f.net>
To: emacs-devel@gnu.org
Subject: [PATCH] Update compat
Date: Wed, 25 Jan 2023 21:32:50 +0100 [thread overview]
Message-ID: <20230125203250.132801-1-nicolas@n16f.net> (raw)
In-Reply-To: <83ilgufsdb.fsf@gnu.org>
From: GNU ELPA Mirror Bot <emacs-devel@gnu.org>
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 @@ defvar json-null)
(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:
--
2.38.1
next prev parent reply other threads:[~2023-01-25 20:32 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-07 12:19 [PATCH] em-cmpl: fix completion of command paths Nicolas Martyanoff
2023-01-07 12:23 ` Nicolas Martyanoff
2023-01-13 10:59 ` Nicolas Martyanoff
2023-01-25 17:03 ` Stefan Monnier
2023-01-25 17:15 ` Eli Zaretskii
2023-01-25 20:32 ` Nicolas Martyanoff [this message]
[not found] ` <87bkmmwcwx.fsf@valhala.localdomain>
2023-01-26 6:02 ` Eli Zaretskii
2023-01-26 9:06 ` Eli Zaretskii
2023-01-26 12:21 ` Nicolas Martyanoff
2023-01-26 12:58 ` Eli Zaretskii
2023-01-28 0:11 ` Stefan Monnier
2023-01-28 8:27 ` Eli Zaretskii
2023-01-28 0:12 ` Stefan Monnier
2023-01-25 21:50 ` Jim Porter
2023-02-08 6:06 ` Jim Porter
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230125203250.132801-1-nicolas@n16f.net \
--to=nicolas@n16f.net \
--cc=emacs-devel@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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.