summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2025-01-23 06:42:10 +0200
committerThanos Apollo <[email protected]>2025-01-23 06:42:10 +0200
commitbf81cdd64a65b067bc98bdfa784c42a414cc5688 (patch)
tree4a00b310d07be4d861b5ca128d5eeec594bb83c4
parentc9c082950590d7dc4044043481632a9dec230a42 (diff)
Separate creation of filename & add custom timestring.
* Add org-gnosis--create-name function, separating the filename creation based on a customizable timestring.
-rw-r--r--org-gnosis.el27
1 files changed, 19 insertions, 8 deletions
diff --git a/org-gnosis.el b/org-gnosis.el
index 027cd4e..f7a0e55 100644
--- a/org-gnosis.el
+++ b/org-gnosis.el
@@ -72,6 +72,11 @@
:type 'boolean
:group 'org-gnosis)
+(defcustom org-gnosis-timestring "%Y%m%d%H%M%S"
+ "Timestring used for the creation of file."
+ :type 'string
+ :group 'org-gnosis)
+
(defcustom org-gnosis-completing-read-func #'org-completing-read
"Function to use for `completing-read'."
:type 'function
@@ -297,16 +302,22 @@ Removes all contents of FILE in database, adding them anew."
title)))
lst))
-(defun org-gnosis--create-file (title &optional file extras)
+(defun org-gnosis--create-name (title &optional timestring)
+ "Create filename for TITLE.
+
+TIMESTRING defaults to `org-gnosis-timestring'"
+ (let ((timestring (or timestring org-gnosis-timestring))
+ (filename (replace-regexp-in-string "#" ""
+ (replace-regexp-in-string " " "_" title))))
+ (format "%s--%s.org" (format-time-string timestring) filename)))
+
+(defun org-gnosis--create-file (title &optional directory extras)
"Create a node FILE for TITLE.
+
Insert initial Org metadata if the buffer is new or empty."
- (let* ((file-name (replace-regexp-in-string "#" ""
- (replace-regexp-in-string " " "_" title)))
- (file (or file (expand-file-name
- (format "%s--%s.org"
- (format-time-string "%Y%m%d%H%M%S")
- file-name)
- org-gnosis-dir)))
+ (let* ((file (expand-file-name
+ (org-gnosis--create-name title)
+ (or directory org-gnosis-dir)))
(buffer (find-file-noselect file)))
(with-current-buffer buffer
(unless (or (file-exists-p file)