mirror of
https://github.com/org-roam/org-roam
synced 2025-08-01 12:17:21 -05:00
Add polyfill for make-empty-file
make-empty-file was only introduced in Emacs 27, which some people are not yet running
This commit is contained in:
18
org-roam-polyfill.el
Normal file
18
org-roam-polyfill.el
Normal file
@ -0,0 +1,18 @@
|
||||
;; Introduced in Emacs 27.1
|
||||
(unless (fboundp 'make-empty-file)
|
||||
(defun make-empty-file (filename &optional parents)
|
||||
"Create an empty file FILENAME.
|
||||
Optional arg PARENTS, if non-nil then creates parent dirs as needed.
|
||||
|
||||
If called interactively, then PARENTS is non-nil."
|
||||
(interactive
|
||||
(let ((filename (read-file-name "Create empty file: ")))
|
||||
(list filename t)))
|
||||
(when (and (file-exists-p filename) (null parents))
|
||||
(signal 'file-already-exists `("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)))
|
||||
|
||||
(provide'org-roam-polyfill)
|
@ -5,6 +5,7 @@
|
||||
|
||||
;;; Code:
|
||||
(require 'deft)
|
||||
(require 'org-roam-polyfill)
|
||||
(require 'org-element)
|
||||
(require 'async)
|
||||
(require 'subr-x)
|
||||
|
Reference in New Issue
Block a user