Skip to content

Commit

Permalink
Update compat
Browse files Browse the repository at this point in the history
Timestamp: 2022-11-23 00:00:55
GNU ELPA commit: c1e7d260a3e9305188aea0b5a372f4ccd4dfb22c
Emacs commit: 057901f55ad12ebbc9cf092dd6ad0f02539849f9
  • Loading branch information
GNU ELPA Mirror Bot committed Nov 23, 2022
1 parent 9e05e93 commit 7ca7d30
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
11 changes: 11 additions & 0 deletions compat-27.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions compat.texi
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 7ca7d30

Please sign in to comment.