mirror of
https://github.com/org-roam/org-roam
synced 2025-08-21 13:53:31 -05:00
Merge pull request #27 from jethrokuan/fix/polyfill
Move polyfill into main file
This commit is contained in:
@@ -1,18 +1,2 @@
|
|||||||
;; 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)
|
(provide'org-roam-polyfill)
|
||||||
|
21
org-roam.el
21
org-roam.el
@@ -4,7 +4,6 @@
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
(require 'org-roam-polyfill)
|
|
||||||
(require 'org-element)
|
(require 'org-element)
|
||||||
(require 'async)
|
(require 'async)
|
||||||
(require 'subr-x)
|
(require 'subr-x)
|
||||||
@@ -61,6 +60,26 @@ Valid values are
|
|||||||
:type 'string
|
:type 'string
|
||||||
:group 'org-roam)
|
:group 'org-roam)
|
||||||
|
|
||||||
|
;;; Polyfills
|
||||||
|
;; These are for functions I use that are only available in newer Emacs
|
||||||
|
|
||||||
|
;; 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)))
|
||||||
|
|
||||||
;;; Dynamic variables
|
;;; Dynamic variables
|
||||||
(defvar org-roam-update-timer nil
|
(defvar org-roam-update-timer nil
|
||||||
"Variable containing the timer that periodically updates the buffer.")
|
"Variable containing the timer that periodically updates the buffer.")
|
||||||
|
Reference in New Issue
Block a user